changeset 15723:153b4781adcc

8166850: No runtime error expected after calling NET_MapSocketOption Reviewed-by: chegar
author clanger
date Thu, 29 Sep 2016 14:48:07 +0200
parents 3ad485a9cf57
children 91a5353ecbbb
files src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c src/java.base/unix/native/libnet/PlainSocketImpl.c src/java.base/windows/native/libnet/DualStackPlainDatagramSocketImpl.c src/java.base/windows/native/libnet/DualStackPlainSocketImpl.c src/java.base/windows/native/libnet/TwoStacksPlainDatagramSocketImpl.c src/java.base/windows/native/libnet/TwoStacksPlainSocketImpl.c
diffstat 6 files changed, 62 insertions(+), 62 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c	Thu Sep 29 17:36:26 2016 +0900
+++ b/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c	Thu Sep 29 14:48:07 2016 +0200
@@ -1302,7 +1302,7 @@
  * 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 @@
  * 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 @@
      * 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 @@
  * 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 @@
      * 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;
     }
 
--- a/src/java.base/unix/native/libnet/PlainSocketImpl.c	Thu Sep 29 17:36:26 2016 +0900
+++ b/src/java.base/unix/native/libnet/PlainSocketImpl.c	Thu Sep 29 14:48:07 2016 +0200
@@ -855,9 +855,9 @@
  * 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 @@
      * 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 @@
  * 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 @@
      * 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;
     }
 
--- a/src/java.base/windows/native/libnet/DualStackPlainDatagramSocketImpl.c	Thu Sep 29 17:36:26 2016 +0900
+++ b/src/java.base/windows/native/libnet/DualStackPlainDatagramSocketImpl.c	Thu Sep 29 14:48:07 2016 +0200
@@ -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 @@
  * 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 @@
  * 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 @@
  * 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);
--- a/src/java.base/windows/native/libnet/DualStackPlainSocketImpl.c	Thu Sep 29 17:36:26 2016 +0900
+++ b/src/java.base/windows/native/libnet/DualStackPlainSocketImpl.c	Thu Sep 29 14:48:07 2016 +0200
@@ -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 @@
  * 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 @@
  * 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 @@
     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;
     }
 
--- a/src/java.base/windows/native/libnet/TwoStacksPlainDatagramSocketImpl.c	Thu Sep 29 17:36:26 2016 +0900
+++ b/src/java.base/windows/native/libnet/TwoStacksPlainDatagramSocketImpl.c	Thu Sep 29 14:48:07 2016 +0200
@@ -1795,9 +1795,9 @@
  * 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 @@
      */
     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 @@
  * 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 @@
      * 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 */
--- a/src/java.base/windows/native/libnet/TwoStacksPlainSocketImpl.c	Thu Sep 29 17:36:26 2016 +0900
+++ b/src/java.base/windows/native/libnet/TwoStacksPlainSocketImpl.c	Thu Sep 29 14:48:07 2016 +0200
@@ -838,10 +838,9 @@
  * 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 @@
 
     /*
      * 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 @@
  * 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 @@
      * 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;
     }