From e379ae181430edd0711fd1caa99d2e5428430081 Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Thu, 29 Sep 2016 14:48:07 +0200 Subject: [PATCH] 8166850: No runtime error expected after calling NET_MapSocketOption Reviewed-by: chegar --- .../native/libnet/PlainDatagramSocketImpl.c | 18 ++++++------ .../unix/native/libnet/PlainSocketImpl.c | 16 +++++------ .../libnet/DualStackPlainDatagramSocketImpl.c | 28 +++++++++++-------- .../native/libnet/DualStackPlainSocketImpl.c | 21 ++++++-------- .../libnet/TwoStacksPlainDatagramSocketImpl.c | 20 ++++++------- .../native/libnet/TwoStacksPlainSocketImpl.c | 21 +++++++------- 6 files changed, 62 insertions(+), 62 deletions(-) diff --git a/jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c b/jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c index f141ad234c4..84737d20c03 100644 --- a/jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c +++ b/jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c @@ -1302,7 +1302,7 @@ static void mcast_set_loop_v6(JNIEnv *env, jobject this, int fd, jobject value) * Sets the multicast loopback mode. */ static void setMulticastLoopbackMode(JNIEnv *env, jobject this, int fd, - jint opt, jobject value) { + jint opt, jobject value) { #ifdef AF_INET6 #ifdef __linux__ mcast_set_loop_v4(env, this, fd, value); @@ -1330,10 +1330,9 @@ static void setMulticastLoopbackMode(JNIEnv *env, jobject this, int fd, * Signature: (ILjava/lang/Object;)V */ JNIEXPORT void JNICALL -Java_java_net_PlainDatagramSocketImpl_socketSetOption0(JNIEnv *env, - jobject this, - jint opt, - jobject value) { +Java_java_net_PlainDatagramSocketImpl_socketSetOption0 + (JNIEnv *env, jobject this, jint opt, jobject value) +{ int fd; int level, optname, optlen; int optval; @@ -1380,7 +1379,7 @@ Java_java_net_PlainDatagramSocketImpl_socketSetOption0(JNIEnv *env, * level and option name. */ if (NET_MapSocketOption(opt, &level, &optname)) { - JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Invalid option"); + JNU_ThrowByName(env, "java/net/SocketException", "Invalid option"); return; } @@ -1699,8 +1698,9 @@ jobject getMulticastInterface(JNIEnv *env, jobject this, int fd, jint opt) { * Signature: (I)Ljava/lang/Object; */ JNIEXPORT jobject JNICALL -Java_java_net_PlainDatagramSocketImpl_socketGetOption(JNIEnv *env, jobject this, - jint opt) { +Java_java_net_PlainDatagramSocketImpl_socketGetOption + (JNIEnv *env, jobject this, jint opt) +{ int fd; int level, optname, optlen; union { @@ -1751,7 +1751,7 @@ Java_java_net_PlainDatagramSocketImpl_socketGetOption(JNIEnv *env, jobject this, * level and option name. */ if (NET_MapSocketOption(opt, &level, &optname)) { - JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Invalid option"); + JNU_ThrowByName(env, "java/net/SocketException", "Invalid option"); return NULL; } diff --git a/jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c b/jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c index ba8e483c101..c7766751507 100644 --- a/jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c +++ b/jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c @@ -855,9 +855,9 @@ Java_java_net_PlainSocketImpl_socketShutdown(JNIEnv *env, jobject this, * Signature: (IZLjava/lang/Object;)V */ JNIEXPORT void JNICALL -Java_java_net_PlainSocketImpl_socketSetOption0(JNIEnv *env, jobject this, - jint cmd, jboolean on, - jobject value) { +Java_java_net_PlainSocketImpl_socketSetOption0 + (JNIEnv *env, jobject this, jint cmd, jboolean on, jobject value) +{ int fd; int level, optname, optlen; union { @@ -887,7 +887,7 @@ Java_java_net_PlainSocketImpl_socketSetOption0(JNIEnv *env, jobject this, * level and option name. */ if (NET_MapSocketOption(cmd, &level, &optname)) { - JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Invalid option"); + JNU_ThrowByName(env, "java/net/SocketException", "Invalid option"); return; } @@ -951,9 +951,9 @@ Java_java_net_PlainSocketImpl_socketSetOption0(JNIEnv *env, jobject this, * Signature: (I)I */ JNIEXPORT jint JNICALL -Java_java_net_PlainSocketImpl_socketGetOption(JNIEnv *env, jobject this, - jint cmd, jobject iaContainerObj) { - +Java_java_net_PlainSocketImpl_socketGetOption + (JNIEnv *env, jobject this, jint cmd, jobject iaContainerObj) +{ int fd; int level, optname, optlen; union { @@ -1004,7 +1004,7 @@ Java_java_net_PlainSocketImpl_socketGetOption(JNIEnv *env, jobject this, * level and option name. */ if (NET_MapSocketOption(cmd, &level, &optname)) { - JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Invalid option"); + JNU_ThrowByName(env, "java/net/SocketException", "Invalid option"); return -1; } diff --git a/jdk/src/java.base/windows/native/libnet/DualStackPlainDatagramSocketImpl.c b/jdk/src/java.base/windows/native/libnet/DualStackPlainDatagramSocketImpl.c index c1f1ae839fc..3ea2333fa08 100644 --- a/jdk/src/java.base/windows/native/libnet/DualStackPlainDatagramSocketImpl.c +++ b/jdk/src/java.base/windows/native/libnet/DualStackPlainDatagramSocketImpl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -475,13 +475,14 @@ JNIEXPORT void JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_socketSend * Method: socketSetIntOption * Signature: (III)V */ -JNIEXPORT void JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_socketSetIntOption - (JNIEnv *env, jclass clazz, jint fd , jint cmd, jint value) { +JNIEXPORT void JNICALL +Java_java_net_DualStackPlainDatagramSocketImpl_socketSetIntOption + (JNIEnv *env, jclass clazz, jint fd, jint cmd, jint value) +{ int level = 0, opt = 0; if (NET_MapSocketOption(cmd, &level, &opt) < 0) { - JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", - "Invalid option"); + JNU_ThrowByName(env, "java/net/SocketException", "Invalid option"); return; } @@ -495,14 +496,15 @@ JNIEXPORT void JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_socketSetI * Method: socketGetIntOption * Signature: (II)I */ -JNIEXPORT jint JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_socketGetIntOption - (JNIEnv *env, jclass clazz, jint fd, jint cmd) { - int level = 0, opt = 0, result=0; +JNIEXPORT jint JNICALL +Java_java_net_DualStackPlainDatagramSocketImpl_socketGetIntOption + (JNIEnv *env, jclass clazz, jint fd, jint cmd) +{ + int level = 0, opt = 0, result = 0; int result_len = sizeof(result); if (NET_MapSocketOption(cmd, &level, &opt) < 0) { - JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", - "Invalid option"); + JNU_ThrowByName(env, "java/net/SocketException", "Invalid option"); return -1; } @@ -519,8 +521,10 @@ JNIEXPORT jint JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_socketGetI * Method: dataAvailable * Signature: ()I */ -JNIEXPORT jint JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_dataAvailable -(JNIEnv *env, jobject this) { +JNIEXPORT jint JNICALL +Java_java_net_DualStackPlainDatagramSocketImpl_dataAvailable + (JNIEnv *env, jobject this) +{ SOCKET fd; int rv = -1; jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID); diff --git a/jdk/src/java.base/windows/native/libnet/DualStackPlainSocketImpl.c b/jdk/src/java.base/windows/native/libnet/DualStackPlainSocketImpl.c index eccf785b23f..0fa6d79be6a 100644 --- a/jdk/src/java.base/windows/native/libnet/DualStackPlainSocketImpl.c +++ b/jdk/src/java.base/windows/native/libnet/DualStackPlainSocketImpl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -369,18 +369,17 @@ JNIEXPORT void JNICALL Java_java_net_DualStackPlainSocketImpl_shutdown0 * Method: setIntOption * Signature: (III)V */ -JNIEXPORT void JNICALL Java_java_net_DualStackPlainSocketImpl_setIntOption - (JNIEnv *env, jclass clazz, jint fd, jint cmd, jint value) { - +JNIEXPORT void JNICALL +Java_java_net_DualStackPlainSocketImpl_setIntOption + (JNIEnv *env, jclass clazz, jint fd, jint cmd, jint value) +{ int level = 0, opt = 0; struct linger linger = {0, 0}; char *parg; int arglen; if (NET_MapSocketOption(cmd, &level, &opt) < 0) { - JNU_ThrowByNameWithLastError(env, - JNU_JAVANETPKG "SocketException", - "Invalid option"); + JNU_ThrowByName(env, "java/net/SocketException", "Invalid option"); return; } @@ -410,8 +409,8 @@ JNIEXPORT void JNICALL Java_java_net_DualStackPlainSocketImpl_setIntOption * Signature: (II)I */ JNIEXPORT jint JNICALL Java_java_net_DualStackPlainSocketImpl_getIntOption - (JNIEnv *env, jclass clazz, jint fd, jint cmd) { - + (JNIEnv *env, jclass clazz, jint fd, jint cmd) +{ int level = 0, opt = 0; int result=0; struct linger linger = {0, 0}; @@ -419,9 +418,7 @@ JNIEXPORT jint JNICALL Java_java_net_DualStackPlainSocketImpl_getIntOption int arglen; if (NET_MapSocketOption(cmd, &level, &opt) < 0) { - JNU_ThrowByNameWithLastError(env, - JNU_JAVANETPKG "SocketException", - "Unsupported socket option"); + JNU_ThrowByName(env, "java/net/SocketException", "Invalid option"); return -1; } diff --git a/jdk/src/java.base/windows/native/libnet/TwoStacksPlainDatagramSocketImpl.c b/jdk/src/java.base/windows/native/libnet/TwoStacksPlainDatagramSocketImpl.c index b37adf7e1d4..84fd4a59e89 100644 --- a/jdk/src/java.base/windows/native/libnet/TwoStacksPlainDatagramSocketImpl.c +++ b/jdk/src/java.base/windows/native/libnet/TwoStacksPlainDatagramSocketImpl.c @@ -1795,9 +1795,9 @@ static void setMulticastInterface(JNIEnv *env, jobject this, int fd, int fd1, * Signature: (ILjava/lang/Object;)V */ JNIEXPORT void JNICALL -Java_java_net_TwoStacksPlainDatagramSocketImpl_socketNativeSetOption(JNIEnv *env,jobject this, - jint opt,jobject value) { - +Java_java_net_TwoStacksPlainDatagramSocketImpl_socketNativeSetOption + (JNIEnv *env,jobject this, jint opt,jobject value) +{ int fd=-1, fd1=-1; int levelv4 = 0, levelv6 = 0, optnamev4 = 0, optnamev6 = 0, optlen = 0; union { @@ -1828,13 +1828,13 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_socketNativeSetOption(JNIEnv *env */ if (fd1 != -1) { if (NET_MapSocketOptionV6(opt, &levelv6, &optnamev6)) { - JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Invalid option"); + JNU_ThrowByName(env, "java/net/SocketException", "Invalid option"); return; } } if (fd != -1) { if (NET_MapSocketOption(opt, &levelv4, &optnamev4)) { - JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Invalid option"); + JNU_ThrowByName(env, "java/net/SocketException", "Invalid option"); return; } } @@ -2163,9 +2163,9 @@ jobject getMulticastInterface(JNIEnv *env, jobject this, int fd, int fd1, jint o * Signature: (I)Ljava/lang/Object; */ JNIEXPORT jobject JNICALL -Java_java_net_TwoStacksPlainDatagramSocketImpl_socketGetOption(JNIEnv *env, jobject this, - jint opt) { - +Java_java_net_TwoStacksPlainDatagramSocketImpl_socketGetOption + (JNIEnv *env, jobject this, jint opt) +{ int fd=-1, fd1=-1; int level, optname, optlen; union { @@ -2197,13 +2197,13 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_socketGetOption(JNIEnv *env, jobj * level and option name. */ if (NET_MapSocketOption(opt, &level, &optname)) { - JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Invalid option"); + JNU_ThrowByName(env, "java/net/SocketException", "Invalid option"); return NULL; } if (fd == -1) { if (NET_MapSocketOptionV6(opt, &level, &optname)) { - JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Invalid option"); + JNU_ThrowByName(env, "java/net/SocketException", "Invalid option"); return NULL; } fd = fd1; /* must be IPv6 only */ diff --git a/jdk/src/java.base/windows/native/libnet/TwoStacksPlainSocketImpl.c b/jdk/src/java.base/windows/native/libnet/TwoStacksPlainSocketImpl.c index 3d950d3d4ad..ace7b944bd5 100644 --- a/jdk/src/java.base/windows/native/libnet/TwoStacksPlainSocketImpl.c +++ b/jdk/src/java.base/windows/native/libnet/TwoStacksPlainSocketImpl.c @@ -838,10 +838,9 @@ Java_java_net_TwoStacksPlainSocketImpl_socketClose0(JNIEnv *env, jobject this, * Signature: (IZLjava/lang/Object;)V */ JNIEXPORT void JNICALL -Java_java_net_TwoStacksPlainSocketImpl_socketNativeSetOption(JNIEnv *env, - jobject this, - jint cmd, jboolean on, - jobject value) { +Java_java_net_TwoStacksPlainSocketImpl_socketNativeSetOption + (JNIEnv *env, jobject this, jint cmd, jboolean on, jobject value) +{ int fd, fd1; int level = 0, optname = 0, optlen = 0; union { @@ -923,11 +922,10 @@ Java_java_net_TwoStacksPlainSocketImpl_socketNativeSetOption(JNIEnv *env, /* * Map the Java level socket option to the platform specific - * level + * level and option name. */ if (NET_MapSocketOption(cmd, &level, &optname)) { - JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", - "Invalid option"); + JNU_ThrowByName(env, "java/net/SocketException", "Invalid option"); return; } @@ -1006,15 +1004,16 @@ Java_java_net_TwoStacksPlainSocketImpl_socketNativeSetOption(JNIEnv *env, * Signature: (I)I */ JNIEXPORT jint JNICALL -Java_java_net_TwoStacksPlainSocketImpl_socketGetOption(JNIEnv *env, jobject this, - jint opt, jobject iaContainerObj) { - +Java_java_net_TwoStacksPlainSocketImpl_socketGetOption + (JNIEnv *env, jobject this, jint opt, jobject iaContainerObj) +{ int fd, fd1; int level = 0, optname = 0, optlen = 0; union { int i; struct linger ling; } optval; + /* * Get SOCKET and check it hasn't been closed */ @@ -1073,7 +1072,7 @@ Java_java_net_TwoStacksPlainSocketImpl_socketGetOption(JNIEnv *env, jobject this * level and option name. */ if (NET_MapSocketOption(opt, &level, &optname)) { - JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Invalid option"); + JNU_ThrowByName(env, "java/net/SocketException", "Invalid option"); return -1; }