8166850: No runtime error expected after calling NET_MapSocketOption

Reviewed-by: chegar
This commit is contained in:
Christoph Langer 2016-09-29 14:48:07 +02:00
parent c34cee90d8
commit e379ae1814
6 changed files with 62 additions and 62 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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 */

View File

@ -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;
}