Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
fbfea144
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
fbfea144
编写于
2月 04, 2014
作者:
C
chegar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8025306: Inet[4|6]Address class and fieldID initialization in networking native code
Reviewed-by: alanb, michaelm
上级
094bb042
变更
19
显示空白变更内容
内联
并排
Showing
19 changed file
with
142 addition
and
332 deletion
+142
-332
make/mapfiles/libnet/mapfile-vers
make/mapfiles/libnet/mapfile-vers
+1
-0
src/share/native/java/net/Inet4Address.c
src/share/native/java/net/Inet4Address.c
+11
-5
src/share/native/java/net/Inet6Address.c
src/share/native/java/net/Inet6Address.c
+26
-20
src/share/native/java/net/InetAddress.c
src/share/native/java/net/InetAddress.c
+24
-18
src/share/native/java/net/net_util.c
src/share/native/java/net/net_util.c
+18
-71
src/share/native/java/net/net_util.h
src/share/native/java/net/net_util.h
+2
-0
src/solaris/native/java/net/Inet4AddressImpl.c
src/solaris/native/java/net/Inet4AddressImpl.c
+8
-31
src/solaris/native/java/net/Inet6AddressImpl.c
src/solaris/native/java/net/Inet6AddressImpl.c
+11
-50
src/solaris/native/java/net/NetworkInterface.c
src/solaris/native/java/net/NetworkInterface.c
+7
-25
src/solaris/native/java/net/PlainDatagramSocketImpl.c
src/solaris/native/java/net/PlainDatagramSocketImpl.c
+2
-3
src/solaris/native/java/net/PlainSocketImpl.c
src/solaris/native/java/net/PlainSocketImpl.c
+3
-0
src/solaris/native/sun/nio/ch/IOUtil.c
src/solaris/native/sun/nio/ch/IOUtil.c
+2
-0
src/solaris/native/sun/nio/ch/sctp/SctpNet.c
src/solaris/native/sun/nio/ch/sctp/SctpNet.c
+1
-0
src/windows/native/java/net/Inet4AddressImpl.c
src/windows/native/java/net/Inet4AddressImpl.c
+6
-22
src/windows/native/java/net/Inet6AddressImpl.c
src/windows/native/java/net/Inet6AddressImpl.c
+7
-42
src/windows/native/java/net/NetworkInterface.c
src/windows/native/java/net/NetworkInterface.c
+7
-31
src/windows/native/java/net/NetworkInterface.h
src/windows/native/java/net/NetworkInterface.h
+0
-10
src/windows/native/java/net/NetworkInterface_winXP.c
src/windows/native/java/net/NetworkInterface_winXP.c
+4
-4
src/windows/native/sun/nio/ch/IOUtil.c
src/windows/native/sun/nio/ch/IOUtil.c
+2
-0
未找到文件。
make/mapfiles/libnet/mapfile-vers
浏览文件 @
fbfea144
...
@@ -112,6 +112,7 @@ SUNWprivate_1.1 {
...
@@ -112,6 +112,7 @@ SUNWprivate_1.1 {
NET_EnableFastTcpLoopback;
NET_EnableFastTcpLoopback;
NET_ThrowNew;
NET_ThrowNew;
ipv6_available;
ipv6_available;
initInetAddressIDs;
local:
local:
*;
*;
...
...
src/share/native/java/net/Inet4Address.c
浏览文件 @
fbfea144
...
@@ -34,6 +34,8 @@
...
@@ -34,6 +34,8 @@
jclass
ia4_class
;
jclass
ia4_class
;
jmethodID
ia4_ctrID
;
jmethodID
ia4_ctrID
;
static
int
ia4_initialized
=
0
;
/*
/*
* Class: java_net_Inet4Address
* Class: java_net_Inet4Address
* Method: init
* Method: init
...
@@ -41,9 +43,13 @@ jmethodID ia4_ctrID;
...
@@ -41,9 +43,13 @@ jmethodID ia4_ctrID;
*/
*/
JNIEXPORT
void
JNICALL
JNIEXPORT
void
JNICALL
Java_java_net_Inet4Address_init
(
JNIEnv
*
env
,
jclass
cls
)
{
Java_java_net_Inet4Address_init
(
JNIEnv
*
env
,
jclass
cls
)
{
if
(
!
ia4_initialized
)
{
jclass
c
=
(
*
env
)
->
FindClass
(
env
,
"java/net/Inet4Address"
);
jclass
c
=
(
*
env
)
->
FindClass
(
env
,
"java/net/Inet4Address"
);
CHECK_NULL
(
c
);
CHECK_NULL
(
c
);
ia4_class
=
(
*
env
)
->
NewGlobalRef
(
env
,
c
);
ia4_class
=
(
*
env
)
->
NewGlobalRef
(
env
,
c
);
CHECK_NULL
(
ia4_class
);
CHECK_NULL
(
ia4_class
);
ia4_ctrID
=
(
*
env
)
->
GetMethodID
(
env
,
ia4_class
,
"<init>"
,
"()V"
);
ia4_ctrID
=
(
*
env
)
->
GetMethodID
(
env
,
ia4_class
,
"<init>"
,
"()V"
);
CHECK_NULL
(
ia4_ctrID
);
ia4_initialized
=
1
;
}
}
}
src/share/native/java/net/Inet6Address.c
浏览文件 @
fbfea144
...
@@ -42,6 +42,8 @@ jfieldID ia6_scopeidsetID;
...
@@ -42,6 +42,8 @@ jfieldID ia6_scopeidsetID;
jfieldID
ia6_scopeifnameID
;
jfieldID
ia6_scopeifnameID
;
jmethodID
ia6_ctrID
;
jmethodID
ia6_ctrID
;
static
int
ia6_initialized
=
0
;
/*
/*
* Class: java_net_Inet6Address
* Class: java_net_Inet6Address
* Method: init
* Method: init
...
@@ -49,6 +51,7 @@ jmethodID ia6_ctrID;
...
@@ -49,6 +51,7 @@ jmethodID ia6_ctrID;
*/
*/
JNIEXPORT
void
JNICALL
JNIEXPORT
void
JNICALL
Java_java_net_Inet6Address_init
(
JNIEnv
*
env
,
jclass
cls
)
{
Java_java_net_Inet6Address_init
(
JNIEnv
*
env
,
jclass
cls
)
{
if
(
!
ia6_initialized
)
{
jclass
ia6h_class
;
jclass
ia6h_class
;
jclass
c
=
(
*
env
)
->
FindClass
(
env
,
"java/net/Inet6Address"
);
jclass
c
=
(
*
env
)
->
FindClass
(
env
,
"java/net/Inet6Address"
);
CHECK_NULL
(
c
);
CHECK_NULL
(
c
);
...
@@ -69,4 +72,7 @@ Java_java_net_Inet6Address_init(JNIEnv *env, jclass cls) {
...
@@ -69,4 +72,7 @@ Java_java_net_Inet6Address_init(JNIEnv *env, jclass cls) {
ia6_scopeifnameID
=
(
*
env
)
->
GetFieldID
(
env
,
ia6h_class
,
"scope_ifname"
,
"Ljava/net/NetworkInterface;"
);
ia6_scopeifnameID
=
(
*
env
)
->
GetFieldID
(
env
,
ia6h_class
,
"scope_ifname"
,
"Ljava/net/NetworkInterface;"
);
CHECK_NULL
(
ia6_scopeifnameID
);
CHECK_NULL
(
ia6_scopeifnameID
);
ia6_ctrID
=
(
*
env
)
->
GetMethodID
(
env
,
ia6_class
,
"<init>"
,
"()V"
);
ia6_ctrID
=
(
*
env
)
->
GetMethodID
(
env
,
ia6_class
,
"<init>"
,
"()V"
);
CHECK_NULL
(
ia6_ctrID
);
ia6_initialized
=
1
;
}
}
}
src/share/native/java/net/InetAddress.c
浏览文件 @
fbfea144
...
@@ -41,6 +41,8 @@ jfieldID iac_hostNameID;
...
@@ -41,6 +41,8 @@ jfieldID iac_hostNameID;
jfieldID
iac_origHostNameID
;
jfieldID
iac_origHostNameID
;
jfieldID
ia_preferIPv6AddressID
;
jfieldID
ia_preferIPv6AddressID
;
static
int
ia_initialized
=
0
;
/*
/*
* Class: java_net_InetAddress
* Class: java_net_InetAddress
* Method: init
* Method: init
...
@@ -48,6 +50,7 @@ jfieldID ia_preferIPv6AddressID;
...
@@ -48,6 +50,7 @@ jfieldID ia_preferIPv6AddressID;
*/
*/
JNIEXPORT
void
JNICALL
JNIEXPORT
void
JNICALL
Java_java_net_InetAddress_init
(
JNIEnv
*
env
,
jclass
cls
)
{
Java_java_net_InetAddress_init
(
JNIEnv
*
env
,
jclass
cls
)
{
if
(
!
ia_initialized
)
{
jclass
c
=
(
*
env
)
->
FindClass
(
env
,
"java/net/InetAddress"
);
jclass
c
=
(
*
env
)
->
FindClass
(
env
,
"java/net/InetAddress"
);
CHECK_NULL
(
c
);
CHECK_NULL
(
c
);
ia_class
=
(
*
env
)
->
NewGlobalRef
(
env
,
c
);
ia_class
=
(
*
env
)
->
NewGlobalRef
(
env
,
c
);
...
@@ -67,4 +70,7 @@ Java_java_net_InetAddress_init(JNIEnv *env, jclass cls) {
...
@@ -67,4 +70,7 @@ Java_java_net_InetAddress_init(JNIEnv *env, jclass cls) {
iac_hostNameID
=
(
*
env
)
->
GetFieldID
(
env
,
iac_class
,
"hostName"
,
"Ljava/lang/String;"
);
iac_hostNameID
=
(
*
env
)
->
GetFieldID
(
env
,
iac_class
,
"hostName"
,
"Ljava/lang/String;"
);
CHECK_NULL
(
iac_hostNameID
);
CHECK_NULL
(
iac_hostNameID
);
iac_origHostNameID
=
(
*
env
)
->
GetFieldID
(
env
,
iac_class
,
"originalHostName"
,
"Ljava/lang/String;"
);
iac_origHostNameID
=
(
*
env
)
->
GetFieldID
(
env
,
iac_class
,
"originalHostName"
,
"Ljava/lang/String;"
);
CHECK_NULL
(
iac_origHostNameID
);
ia_initialized
=
1
;
}
}
}
src/share/native/java/net/net_util.c
浏览文件 @
fbfea144
...
@@ -75,11 +75,14 @@ JNI_OnLoad(JavaVM *vm, void *reserved)
...
@@ -75,11 +75,14 @@ JNI_OnLoad(JavaVM *vm, void *reserved)
static
int
initialized
=
0
;
static
int
initialized
=
0
;
static
void
initInetAddr
s
(
JNIEnv
*
env
)
{
JNIEXPORT
void
JNICALL
initInetAddressID
s
(
JNIEnv
*
env
)
{
if
(
!
initialized
)
{
if
(
!
initialized
)
{
Java_java_net_InetAddress_init
(
env
,
0
);
Java_java_net_InetAddress_init
(
env
,
0
);
JNU_CHECK_EXCEPTION
(
env
);
Java_java_net_Inet4Address_init
(
env
,
0
);
Java_java_net_Inet4Address_init
(
env
,
0
);
JNU_CHECK_EXCEPTION
(
env
);
Java_java_net_Inet6Address_init
(
env
,
0
);
Java_java_net_Inet6Address_init
(
env
,
0
);
JNU_CHECK_EXCEPTION
(
env
);
initialized
=
1
;
initialized
=
1
;
}
}
}
}
...
@@ -100,47 +103,32 @@ extern jfieldID iac_familyID;
...
@@ -100,47 +103,32 @@ extern jfieldID iac_familyID;
* get_ methods that return objects return NULL on error.
* get_ methods that return objects return NULL on error.
*/
*/
jobject
getInet6Address_scopeifname
(
JNIEnv
*
env
,
jobject
iaObj
)
{
jobject
getInet6Address_scopeifname
(
JNIEnv
*
env
,
jobject
iaObj
)
{
jobject
holder
;
jobject
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia6_holder6ID
);
initInetAddrs
(
env
);
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia6_holder6ID
);
CHECK_NULL_RETURN
(
holder
,
NULL
);
CHECK_NULL_RETURN
(
holder
,
NULL
);
return
(
*
env
)
->
GetObjectField
(
env
,
holder
,
ia6_scopeifnameID
);
return
(
*
env
)
->
GetObjectField
(
env
,
holder
,
ia6_scopeifnameID
);
}
}
int
setInet6Address_scopeifname
(
JNIEnv
*
env
,
jobject
iaObj
,
jobject
scopeifname
)
{
int
setInet6Address_scopeifname
(
JNIEnv
*
env
,
jobject
iaObj
,
jobject
scopeifname
)
{
jobject
holder
;
jobject
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia6_holder6ID
);
initInetAddrs
(
env
);
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia6_holder6ID
);
CHECK_NULL_RETURN
(
holder
,
JNI_FALSE
);
CHECK_NULL_RETURN
(
holder
,
JNI_FALSE
);
(
*
env
)
->
SetObjectField
(
env
,
holder
,
ia6_scopeifnameID
,
scopeifname
);
(
*
env
)
->
SetObjectField
(
env
,
holder
,
ia6_scopeifnameID
,
scopeifname
);
return
JNI_TRUE
;
return
JNI_TRUE
;
}
}
int
getInet6Address_scopeid_set
(
JNIEnv
*
env
,
jobject
iaObj
)
{
int
getInet6Address_scopeid_set
(
JNIEnv
*
env
,
jobject
iaObj
)
{
jobject
holder
;
jobject
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia6_holder6ID
);
initInetAddrs
(
env
);
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia6_holder6ID
);
CHECK_NULL_RETURN
(
holder
,
-
1
);
CHECK_NULL_RETURN
(
holder
,
-
1
);
return
(
*
env
)
->
GetBooleanField
(
env
,
holder
,
ia6_scopeidsetID
);
return
(
*
env
)
->
GetBooleanField
(
env
,
holder
,
ia6_scopeidsetID
);
}
}
int
getInet6Address_scopeid
(
JNIEnv
*
env
,
jobject
iaObj
)
{
int
getInet6Address_scopeid
(
JNIEnv
*
env
,
jobject
iaObj
)
{
jobject
holder
;
jobject
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia6_holder6ID
);
initInetAddrs
(
env
);
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia6_holder6ID
);
CHECK_NULL_RETURN
(
holder
,
-
1
);
CHECK_NULL_RETURN
(
holder
,
-
1
);
return
(
*
env
)
->
GetIntField
(
env
,
holder
,
ia6_scopeidID
);
return
(
*
env
)
->
GetIntField
(
env
,
holder
,
ia6_scopeidID
);
}
}
int
setInet6Address_scopeid
(
JNIEnv
*
env
,
jobject
iaObj
,
int
scopeid
)
{
int
setInet6Address_scopeid
(
JNIEnv
*
env
,
jobject
iaObj
,
int
scopeid
)
{
jobject
holder
;
jobject
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia6_holder6ID
);
initInetAddrs
(
env
);
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia6_holder6ID
);
CHECK_NULL_RETURN
(
holder
,
JNI_FALSE
);
CHECK_NULL_RETURN
(
holder
,
JNI_FALSE
);
(
*
env
)
->
SetIntField
(
env
,
holder
,
ia6_scopeidID
,
scopeid
);
(
*
env
)
->
SetIntField
(
env
,
holder
,
ia6_scopeidID
,
scopeid
);
if
(
scopeid
>
0
)
{
if
(
scopeid
>
0
)
{
...
@@ -154,7 +142,6 @@ int getInet6Address_ipaddress(JNIEnv *env, jobject iaObj, char *dest) {
...
@@ -154,7 +142,6 @@ int getInet6Address_ipaddress(JNIEnv *env, jobject iaObj, char *dest) {
jobject
holder
,
addr
;
jobject
holder
,
addr
;
jbyteArray
barr
;
jbyteArray
barr
;
initInetAddrs
(
env
);
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia6_holder6ID
);
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia6_holder6ID
);
CHECK_NULL_RETURN
(
holder
,
JNI_FALSE
);
CHECK_NULL_RETURN
(
holder
,
JNI_FALSE
);
addr
=
(
*
env
)
->
GetObjectField
(
env
,
holder
,
ia6_ipaddressID
);
addr
=
(
*
env
)
->
GetObjectField
(
env
,
holder
,
ia6_ipaddressID
);
...
@@ -167,7 +154,6 @@ int setInet6Address_ipaddress(JNIEnv *env, jobject iaObj, char *address) {
...
@@ -167,7 +154,6 @@ int setInet6Address_ipaddress(JNIEnv *env, jobject iaObj, char *address) {
jobject
holder
;
jobject
holder
;
jbyteArray
addr
;
jbyteArray
addr
;
initInetAddrs
(
env
);
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia6_holder6ID
);
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia6_holder6ID
);
CHECK_NULL_RETURN
(
holder
,
JNI_FALSE
);
CHECK_NULL_RETURN
(
holder
,
JNI_FALSE
);
addr
=
(
jbyteArray
)(
*
env
)
->
GetObjectField
(
env
,
holder
,
ia6_ipaddressID
);
addr
=
(
jbyteArray
)(
*
env
)
->
GetObjectField
(
env
,
holder
,
ia6_ipaddressID
);
...
@@ -181,53 +167,39 @@ int setInet6Address_ipaddress(JNIEnv *env, jobject iaObj, char *address) {
...
@@ -181,53 +167,39 @@ int setInet6Address_ipaddress(JNIEnv *env, jobject iaObj, char *address) {
}
}
void
setInetAddress_addr
(
JNIEnv
*
env
,
jobject
iaObj
,
int
address
)
{
void
setInetAddress_addr
(
JNIEnv
*
env
,
jobject
iaObj
,
int
address
)
{
jobject
holder
;
jobject
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia_holderID
);
initInetAddrs
(
env
);
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia_holderID
);
(
*
env
)
->
SetIntField
(
env
,
holder
,
iac_addressID
,
address
);
(
*
env
)
->
SetIntField
(
env
,
holder
,
iac_addressID
,
address
);
}
}
void
setInetAddress_family
(
JNIEnv
*
env
,
jobject
iaObj
,
int
family
)
{
void
setInetAddress_family
(
JNIEnv
*
env
,
jobject
iaObj
,
int
family
)
{
jobject
holder
;
jobject
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia_holderID
);
initInetAddrs
(
env
);
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia_holderID
);
(
*
env
)
->
SetIntField
(
env
,
holder
,
iac_familyID
,
family
);
(
*
env
)
->
SetIntField
(
env
,
holder
,
iac_familyID
,
family
);
}
}
void
setInetAddress_hostName
(
JNIEnv
*
env
,
jobject
iaObj
,
jobject
host
)
{
void
setInetAddress_hostName
(
JNIEnv
*
env
,
jobject
iaObj
,
jobject
host
)
{
jobject
holder
;
jobject
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia_holderID
);
initInetAddrs
(
env
);
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia_holderID
);
(
*
env
)
->
SetObjectField
(
env
,
holder
,
iac_hostNameID
,
host
);
(
*
env
)
->
SetObjectField
(
env
,
holder
,
iac_hostNameID
,
host
);
(
*
env
)
->
SetObjectField
(
env
,
holder
,
iac_origHostNameID
,
host
);
(
*
env
)
->
SetObjectField
(
env
,
holder
,
iac_origHostNameID
,
host
);
}
}
int
getInetAddress_addr
(
JNIEnv
*
env
,
jobject
iaObj
)
{
int
getInetAddress_addr
(
JNIEnv
*
env
,
jobject
iaObj
)
{
jobject
holder
;
jobject
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia_holderID
);
initInetAddrs
(
env
);
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia_holderID
);
return
(
*
env
)
->
GetIntField
(
env
,
holder
,
iac_addressID
);
return
(
*
env
)
->
GetIntField
(
env
,
holder
,
iac_addressID
);
}
}
int
getInetAddress_family
(
JNIEnv
*
env
,
jobject
iaObj
)
{
int
getInetAddress_family
(
JNIEnv
*
env
,
jobject
iaObj
)
{
jobject
holder
;
jobject
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia_holderID
);
initInetAddrs
(
env
);
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia_holderID
);
return
(
*
env
)
->
GetIntField
(
env
,
holder
,
iac_familyID
);
return
(
*
env
)
->
GetIntField
(
env
,
holder
,
iac_familyID
);
}
}
jobject
getInetAddress_hostName
(
JNIEnv
*
env
,
jobject
iaObj
)
{
jobject
getInetAddress_hostName
(
JNIEnv
*
env
,
jobject
iaObj
)
{
jobject
holder
;
jobject
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia_holderID
);
initInetAddrs
(
env
);
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia_holderID
);
return
(
*
env
)
->
GetObjectField
(
env
,
holder
,
iac_hostNameID
);
return
(
*
env
)
->
GetObjectField
(
env
,
holder
,
iac_hostNameID
);
}
}
JNIEXPORT
jobject
JNICALL
JNIEXPORT
jobject
JNICALL
NET_SockaddrToInetAddress
(
JNIEnv
*
env
,
struct
sockaddr
*
him
,
int
*
port
)
{
NET_SockaddrToInetAddress
(
JNIEnv
*
env
,
struct
sockaddr
*
him
,
int
*
port
)
{
jobject
iaObj
;
jobject
iaObj
;
initInetAddrs
(
env
);
#ifdef AF_INET6
#ifdef AF_INET6
if
(
him
->
sa_family
==
AF_INET6
)
{
if
(
him
->
sa_family
==
AF_INET6
)
{
jbyteArray
ipaddress
;
jbyteArray
ipaddress
;
...
@@ -239,31 +211,15 @@ NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port) {
...
@@ -239,31 +211,15 @@ NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port) {
jbyte
*
caddr
=
(
jbyte
*
)
&
(
him6
->
sin6_addr
);
jbyte
*
caddr
=
(
jbyte
*
)
&
(
him6
->
sin6_addr
);
if
(
NET_IsIPv4Mapped
(
caddr
))
{
if
(
NET_IsIPv4Mapped
(
caddr
))
{
int
address
;
int
address
;
static
jclass
inet4Cls
=
0
;
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ia4_class
,
ia4_ctrID
);
if
(
inet4Cls
==
0
)
{
jclass
c
=
(
*
env
)
->
FindClass
(
env
,
"java/net/Inet4Address"
);
CHECK_NULL_RETURN
(
c
,
NULL
);
inet4Cls
=
(
*
env
)
->
NewGlobalRef
(
env
,
c
);
CHECK_NULL_RETURN
(
inet4Cls
,
NULL
);
(
*
env
)
->
DeleteLocalRef
(
env
,
c
);
}
iaObj
=
(
*
env
)
->
NewObject
(
env
,
inet4Cls
,
ia4_ctrID
);
CHECK_NULL_RETURN
(
iaObj
,
NULL
);
CHECK_NULL_RETURN
(
iaObj
,
NULL
);
address
=
NET_IPv4MappedToIPv4
(
caddr
);
address
=
NET_IPv4MappedToIPv4
(
caddr
);
setInetAddress_addr
(
env
,
iaObj
,
address
);
setInetAddress_addr
(
env
,
iaObj
,
address
);
setInetAddress_family
(
env
,
iaObj
,
IPv4
);
setInetAddress_family
(
env
,
iaObj
,
IPv4
);
}
else
{
}
else
{
static
jclass
inet6Cls
=
0
;
jint
scope
;
jint
scope
;
int
ret
;
int
ret
;
if
(
inet6Cls
==
0
)
{
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ia6_class
,
ia6_ctrID
);
jclass
c
=
(
*
env
)
->
FindClass
(
env
,
"java/net/Inet6Address"
);
CHECK_NULL_RETURN
(
c
,
NULL
);
inet6Cls
=
(
*
env
)
->
NewGlobalRef
(
env
,
c
);
CHECK_NULL_RETURN
(
inet6Cls
,
NULL
);
(
*
env
)
->
DeleteLocalRef
(
env
,
c
);
}
iaObj
=
(
*
env
)
->
NewObject
(
env
,
inet6Cls
,
ia6_ctrID
);
CHECK_NULL_RETURN
(
iaObj
,
NULL
);
CHECK_NULL_RETURN
(
iaObj
,
NULL
);
ret
=
setInet6Address_ipaddress
(
env
,
iaObj
,
(
char
*
)
&
(
him6
->
sin6_addr
));
ret
=
setInet6Address_ipaddress
(
env
,
iaObj
,
(
char
*
)
&
(
him6
->
sin6_addr
));
CHECK_NULL_RETURN
(
ret
,
NULL
);
CHECK_NULL_RETURN
(
ret
,
NULL
);
...
@@ -276,16 +232,7 @@ NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port) {
...
@@ -276,16 +232,7 @@ NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port) {
#endif
/* AF_INET6 */
#endif
/* AF_INET6 */
{
{
struct
sockaddr_in
*
him4
=
(
struct
sockaddr_in
*
)
him
;
struct
sockaddr_in
*
him4
=
(
struct
sockaddr_in
*
)
him
;
static
jclass
inet4Cls
=
0
;
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ia4_class
,
ia4_ctrID
);
if
(
inet4Cls
==
0
)
{
jclass
c
=
(
*
env
)
->
FindClass
(
env
,
"java/net/Inet4Address"
);
CHECK_NULL_RETURN
(
c
,
NULL
);
inet4Cls
=
(
*
env
)
->
NewGlobalRef
(
env
,
c
);
CHECK_NULL_RETURN
(
inet4Cls
,
NULL
);
(
*
env
)
->
DeleteLocalRef
(
env
,
c
);
}
iaObj
=
(
*
env
)
->
NewObject
(
env
,
inet4Cls
,
ia4_ctrID
);
CHECK_NULL_RETURN
(
iaObj
,
NULL
);
CHECK_NULL_RETURN
(
iaObj
,
NULL
);
setInetAddress_family
(
env
,
iaObj
,
IPv4
);
setInetAddress_family
(
env
,
iaObj
,
IPv4
);
setInetAddress_addr
(
env
,
iaObj
,
ntohl
(
him4
->
sin_addr
.
s_addr
));
setInetAddress_addr
(
env
,
iaObj
,
ntohl
(
him4
->
sin_addr
.
s_addr
));
...
...
src/share/native/java/net/net_util.h
浏览文件 @
fbfea144
...
@@ -56,6 +56,8 @@ extern jfieldID iac_hostNameID;
...
@@ -56,6 +56,8 @@ extern jfieldID iac_hostNameID;
extern
jfieldID
iac_origHostNameID
;
extern
jfieldID
iac_origHostNameID
;
extern
jfieldID
ia_preferIPv6AddressID
;
extern
jfieldID
ia_preferIPv6AddressID
;
JNIEXPORT
void
JNICALL
initInetAddressIDs
(
JNIEnv
*
env
);
/** (Inet6Address accessors)
/** (Inet6Address accessors)
* set_ methods return JNI_TRUE on success JNI_FALSE on error
* set_ methods return JNI_TRUE on success JNI_FALSE on error
* get_ methods that return int/boolean, return -1 on error
* get_ methods that return int/boolean, return -1 on error
...
...
src/solaris/native/java/net/Inet4AddressImpl.c
浏览文件 @
fbfea144
...
@@ -51,29 +51,6 @@
...
@@ -51,29 +51,6 @@
#define HAS_GLIBC_GETHOSTBY_R 1
#define HAS_GLIBC_GETHOSTBY_R 1
#endif
#endif
static
jclass
ni_iacls
;
static
jclass
ni_ia4cls
;
static
jmethodID
ni_ia4ctrID
;
static
jboolean
initializeInetClasses
(
JNIEnv
*
env
)
{
static
int
initialized
=
0
;
if
(
!
initialized
)
{
ni_iacls
=
(
*
env
)
->
FindClass
(
env
,
"java/net/InetAddress"
);
CHECK_NULL_RETURN
(
ni_iacls
,
JNI_FALSE
);
ni_iacls
=
(
*
env
)
->
NewGlobalRef
(
env
,
ni_iacls
);
CHECK_NULL_RETURN
(
ni_iacls
,
JNI_FALSE
);
ni_ia4cls
=
(
*
env
)
->
FindClass
(
env
,
"java/net/Inet4Address"
);
CHECK_NULL_RETURN
(
ni_ia4cls
,
JNI_FALSE
);
ni_ia4cls
=
(
*
env
)
->
NewGlobalRef
(
env
,
ni_ia4cls
);
CHECK_NULL_RETURN
(
ni_ia4cls
,
JNI_FALSE
);
ni_ia4ctrID
=
(
*
env
)
->
GetMethodID
(
env
,
ni_ia4cls
,
"<init>"
,
"()V"
);
CHECK_NULL_RETURN
(
ni_ia4ctrID
,
JNI_FALSE
);
initialized
=
1
;
}
return
JNI_TRUE
;
}
#if defined(_ALLBSD_SOURCE) && !defined(HAS_GLIBC_GETHOSTBY_R)
#if defined(_ALLBSD_SOURCE) && !defined(HAS_GLIBC_GETHOSTBY_R)
extern
jobjectArray
lookupIfLocalhost
(
JNIEnv
*
env
,
const
char
*
hostname
,
jboolean
includeV6
);
extern
jobjectArray
lookupIfLocalhost
(
JNIEnv
*
env
,
const
char
*
hostname
,
jboolean
includeV6
);
...
@@ -147,8 +124,8 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
...
@@ -147,8 +124,8 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
int
getaddrinfo_error
=
0
;
int
getaddrinfo_error
=
0
;
struct
addrinfo
hints
,
*
res
,
*
resNew
=
NULL
;
struct
addrinfo
hints
,
*
res
,
*
resNew
=
NULL
;
i
f
(
!
initializeInetClasses
(
env
))
i
nitInetAddressIDs
(
env
);
return
NULL
;
JNU_CHECK_EXCEPTION_RETURN
(
env
,
NULL
)
;
if
(
IS_NULL
(
host
))
{
if
(
IS_NULL
(
host
))
{
JNU_ThrowNullPointerException
(
env
,
"host is null"
);
JNU_ThrowNullPointerException
(
env
,
"host is null"
);
...
@@ -242,7 +219,7 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
...
@@ -242,7 +219,7 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
goto
cleanupAndReturn
;
goto
cleanupAndReturn
;
}
}
ret
=
(
*
env
)
->
NewObjectArray
(
env
,
retLen
,
ni_iacl
s
,
NULL
);
ret
=
(
*
env
)
->
NewObjectArray
(
env
,
retLen
,
ia_clas
s
,
NULL
);
if
(
IS_NULL
(
ret
))
{
if
(
IS_NULL
(
ret
))
{
/* we may have memory to free at the end of this */
/* we may have memory to free at the end of this */
goto
cleanupAndReturn
;
goto
cleanupAndReturn
;
...
@@ -252,7 +229,7 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
...
@@ -252,7 +229,7 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
/* We need 4 bytes to store ipv4 address; */
/* We need 4 bytes to store ipv4 address; */
int
len
=
4
;
int
len
=
4
;
jobject
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ni_ia4cls
,
ni_ia4
ctrID
);
jobject
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ia4_class
,
ia4_
ctrID
);
if
(
IS_NULL
(
iaObj
))
{
if
(
IS_NULL
(
iaObj
))
{
/* we may have memory to free at the end of this */
/* we may have memory to free at the end of this */
ret
=
NULL
;
ret
=
NULL
;
...
@@ -408,8 +385,8 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
...
@@ -408,8 +385,8 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
int
error
=
0
;
int
error
=
0
;
struct
addrinfo
hints
,
*
res
,
*
resNew
=
NULL
;
struct
addrinfo
hints
,
*
res
,
*
resNew
=
NULL
;
i
f
(
!
initializeInetClasses
(
env
))
i
nitInetAddressIDs
(
env
);
return
NULL
;
JNU_CHECK_EXCEPTION_RETURN
(
env
,
NULL
)
;
if
(
IS_NULL
(
host
))
{
if
(
IS_NULL
(
host
))
{
JNU_ThrowNullPointerException
(
env
,
"host is null"
);
JNU_ThrowNullPointerException
(
env
,
"host is null"
);
...
@@ -487,7 +464,7 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
...
@@ -487,7 +464,7 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
retLen
=
i
;
retLen
=
i
;
iterator
=
resNew
;
iterator
=
resNew
;
ret
=
(
*
env
)
->
NewObjectArray
(
env
,
retLen
,
ni_iacl
s
,
NULL
);
ret
=
(
*
env
)
->
NewObjectArray
(
env
,
retLen
,
ia_clas
s
,
NULL
);
if
(
IS_NULL
(
ret
))
{
if
(
IS_NULL
(
ret
))
{
/* we may have memory to free at the end of this */
/* we may have memory to free at the end of this */
...
@@ -496,7 +473,7 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
...
@@ -496,7 +473,7 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
i
=
0
;
i
=
0
;
while
(
iterator
!=
NULL
)
{
while
(
iterator
!=
NULL
)
{
jobject
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ni_ia4cls
,
ni_ia4
ctrID
);
jobject
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ia4_class
,
ia4_
ctrID
);
if
(
IS_NULL
(
iaObj
))
{
if
(
IS_NULL
(
iaObj
))
{
ret
=
NULL
;
ret
=
NULL
;
goto
cleanupAndReturn
;
goto
cleanupAndReturn
;
...
...
src/solaris/native/java/net/Inet6AddressImpl.c
浏览文件 @
fbfea144
...
@@ -117,44 +117,6 @@ Java_java_net_Inet6AddressImpl_getLocalHostName(JNIEnv *env, jobject this) {
...
@@ -117,44 +117,6 @@ Java_java_net_Inet6AddressImpl_getLocalHostName(JNIEnv *env, jobject this) {
return
(
*
env
)
->
NewStringUTF
(
env
,
hostname
);
return
(
*
env
)
->
NewStringUTF
(
env
,
hostname
);
}
}
static
jclass
ni_iacls
;
static
jclass
ni_ia4cls
;
static
jclass
ni_ia6cls
;
static
jmethodID
ni_ia4ctrID
;
static
jmethodID
ni_ia6ctrID
;
static
jboolean
preferIPv6Address
;
static
jboolean
initializeInetClasses
(
JNIEnv
*
env
)
{
jfieldID
ni_preferIPv6AddressID
;
static
int
initialized
=
0
;
if
(
!
initialized
)
{
ni_iacls
=
(
*
env
)
->
FindClass
(
env
,
"java/net/InetAddress"
);
CHECK_NULL_RETURN
(
ni_iacls
,
JNI_FALSE
);
ni_iacls
=
(
*
env
)
->
NewGlobalRef
(
env
,
ni_iacls
);
CHECK_NULL_RETURN
(
ni_iacls
,
JNI_FALSE
);
ni_ia4cls
=
(
*
env
)
->
FindClass
(
env
,
"java/net/Inet4Address"
);
CHECK_NULL_RETURN
(
ni_ia4cls
,
JNI_FALSE
);
ni_ia4cls
=
(
*
env
)
->
NewGlobalRef
(
env
,
ni_ia4cls
);
CHECK_NULL_RETURN
(
ni_ia4cls
,
JNI_FALSE
);
ni_ia6cls
=
(
*
env
)
->
FindClass
(
env
,
"java/net/Inet6Address"
);
CHECK_NULL_RETURN
(
ni_ia6cls
,
JNI_FALSE
);
ni_ia6cls
=
(
*
env
)
->
NewGlobalRef
(
env
,
ni_ia6cls
);
CHECK_NULL_RETURN
(
ni_ia6cls
,
JNI_FALSE
);
ni_ia4ctrID
=
(
*
env
)
->
GetMethodID
(
env
,
ni_ia4cls
,
"<init>"
,
"()V"
);
CHECK_NULL_RETURN
(
ni_ia4ctrID
,
JNI_FALSE
);
ni_ia6ctrID
=
(
*
env
)
->
GetMethodID
(
env
,
ni_ia6cls
,
"<init>"
,
"()V"
);
CHECK_NULL_RETURN
(
ni_ia6ctrID
,
JNI_FALSE
);
ni_preferIPv6AddressID
=
(
*
env
)
->
GetStaticFieldID
(
env
,
ni_iacls
,
"preferIPv6Address"
,
"Z"
);
CHECK_NULL_RETURN
(
ni_preferIPv6AddressID
,
JNI_FALSE
);
preferIPv6Address
=
(
*
env
)
->
GetStaticBooleanField
(
env
,
ia_class
,
ia_preferIPv6AddressID
);
initialized
=
1
;
}
return
JNI_TRUE
;
}
#ifdef MACOSX
#ifdef MACOSX
/* also called from Inet4AddressImpl.c */
/* also called from Inet4AddressImpl.c */
__private_extern__
jobjectArray
__private_extern__
jobjectArray
...
@@ -169,9 +131,8 @@ lookupIfLocalhost(JNIEnv *env, const char *hostname, jboolean includeV6)
...
@@ -169,9 +131,8 @@ lookupIfLocalhost(JNIEnv *env, const char *hostname, jboolean includeV6)
jboolean
includeLoopback
=
JNI_FALSE
;
jboolean
includeLoopback
=
JNI_FALSE
;
jobject
name
;
jobject
name
;
// Make sure static variables we need are set.
initInetAddressIDs
(
env
);
if
(
!
initializeInetClasses
(
env
))
JNU_CHECK_EXCEPTION_RETURN
(
env
,
NULL
);
return
NULL
;
/* If the requested name matches this host's hostname, return IP addresses
/* If the requested name matches this host's hostname, return IP addresses
* from all attached interfaces. (#2844683 et al) This prevents undesired
* from all attached interfaces. (#2844683 et al) This prevents undesired
...
@@ -234,10 +195,10 @@ lookupIfLocalhost(JNIEnv *env, const char *hostname, jboolean includeV6)
...
@@ -234,10 +195,10 @@ lookupIfLocalhost(JNIEnv *env, const char *hostname, jboolean includeV6)
/* Create and fill the Java array. */
/* Create and fill the Java array. */
int
arraySize
=
addrs4
+
addrs6
-
int
arraySize
=
addrs4
+
addrs6
-
(
includeLoopback
?
0
:
(
numV4Loopbacks
+
numV6Loopbacks
));
(
includeLoopback
?
0
:
(
numV4Loopbacks
+
numV6Loopbacks
));
result
=
(
*
env
)
->
NewObjectArray
(
env
,
arraySize
,
ni_iacl
s
,
NULL
);
result
=
(
*
env
)
->
NewObjectArray
(
env
,
arraySize
,
ia_clas
s
,
NULL
);
if
(
!
result
)
goto
done
;
if
(
!
result
)
goto
done
;
if
(
preferIPv6Address
)
{
if
(
(
*
env
)
->
GetStaticBooleanField
(
env
,
ia_class
,
ia_preferIPv6AddressID
)
)
{
i
=
includeLoopback
?
addrs6
:
(
addrs6
-
numV6Loopbacks
);
i
=
includeLoopback
?
addrs6
:
(
addrs6
-
numV6Loopbacks
);
j
=
0
;
j
=
0
;
}
else
{
}
else
{
...
@@ -301,8 +262,8 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
...
@@ -301,8 +262,8 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
struct
addrinfo
hints
,
*
res
,
*
resNew
=
NULL
;
struct
addrinfo
hints
,
*
res
,
*
resNew
=
NULL
;
#endif
/* AF_INET6 */
#endif
/* AF_INET6 */
i
f
(
!
initializeInetClasses
(
env
))
i
nitInetAddressIDs
(
env
);
return
NULL
;
JNU_CHECK_EXCEPTION_RETURN
(
env
,
NULL
)
;
if
(
IS_NULL
(
host
))
{
if
(
IS_NULL
(
host
))
{
JNU_ThrowNullPointerException
(
env
,
"host is null"
);
JNU_ThrowNullPointerException
(
env
,
"host is null"
);
...
@@ -429,14 +390,14 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
...
@@ -429,14 +390,14 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
retLen
=
i
;
retLen
=
i
;
iterator
=
resNew
;
iterator
=
resNew
;
ret
=
(
*
env
)
->
NewObjectArray
(
env
,
retLen
,
ni_iacl
s
,
NULL
);
ret
=
(
*
env
)
->
NewObjectArray
(
env
,
retLen
,
ia_clas
s
,
NULL
);
if
(
IS_NULL
(
ret
))
{
if
(
IS_NULL
(
ret
))
{
/* we may have memory to free at the end of this */
/* we may have memory to free at the end of this */
goto
cleanupAndReturn
;
goto
cleanupAndReturn
;
}
}
if
(
preferIPv6Address
)
{
if
(
(
*
env
)
->
GetStaticBooleanField
(
env
,
ia_class
,
ia_preferIPv6AddressID
)
)
{
/* AF_INET addresses will be offset by inet6Count */
/* AF_INET addresses will be offset by inet6Count */
inetIndex
=
inet6Count
;
inetIndex
=
inet6Count
;
inet6Index
=
0
;
inet6Index
=
0
;
...
@@ -449,7 +410,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
...
@@ -449,7 +410,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
while
(
iterator
!=
NULL
)
{
while
(
iterator
!=
NULL
)
{
int
ret1
;
int
ret1
;
if
(
iterator
->
ai_family
==
AF_INET
)
{
if
(
iterator
->
ai_family
==
AF_INET
)
{
jobject
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ni_ia4cls
,
ni_ia4
ctrID
);
jobject
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ia4_class
,
ia4_
ctrID
);
if
(
IS_NULL
(
iaObj
))
{
if
(
IS_NULL
(
iaObj
))
{
ret
=
NULL
;
ret
=
NULL
;
goto
cleanupAndReturn
;
goto
cleanupAndReturn
;
...
@@ -461,7 +422,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
...
@@ -461,7 +422,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
}
else
if
(
iterator
->
ai_family
==
AF_INET6
)
{
}
else
if
(
iterator
->
ai_family
==
AF_INET6
)
{
jint
scope
=
0
;
jint
scope
=
0
;
jobject
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ni_ia6cls
,
ni_ia6
ctrID
);
jobject
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ia6_class
,
ia6_
ctrID
);
if
(
IS_NULL
(
iaObj
))
{
if
(
IS_NULL
(
iaObj
))
{
ret
=
NULL
;
ret
=
NULL
;
goto
cleanupAndReturn
;
goto
cleanupAndReturn
;
...
@@ -555,7 +516,7 @@ Java_java_net_Inet6AddressImpl_getHostByAddr(JNIEnv *env, jobject this,
...
@@ -555,7 +516,7 @@ Java_java_net_Inet6AddressImpl_getHostByAddr(JNIEnv *env, jobject this,
if
(
!
error
)
{
if
(
!
error
)
{
ret
=
(
*
env
)
->
NewStringUTF
(
env
,
host
);
ret
=
(
*
env
)
->
NewStringUTF
(
env
,
host
);
CHECK_NULL
(
ret
);
CHECK_NULL
_RETURN
(
ret
,
NULL
);
}
}
#endif
/* AF_INET6 */
#endif
/* AF_INET6 */
...
...
src/solaris/native/java/net/NetworkInterface.c
浏览文件 @
fbfea144
...
@@ -133,12 +133,7 @@ jfieldID ni_parentID;
...
@@ -133,12 +133,7 @@ jfieldID ni_parentID;
jfieldID
ni_defaultIndexID
;
jfieldID
ni_defaultIndexID
;
jmethodID
ni_ctrID
;
jmethodID
ni_ctrID
;
static
jclass
ni_iacls
;
static
jclass
ni_ia4cls
;
static
jclass
ni_ia6cls
;
static
jclass
ni_ibcls
;
static
jclass
ni_ibcls
;
static
jmethodID
ni_ia4ctrID
;
static
jmethodID
ni_ia6ctrID
;
static
jmethodID
ni_ibctrID
;
static
jmethodID
ni_ibctrID
;
static
jfieldID
ni_ibaddressID
;
static
jfieldID
ni_ibaddressID
;
static
jfieldID
ni_ib4broadcastID
;
static
jfieldID
ni_ib4broadcastID
;
...
@@ -215,26 +210,10 @@ JNIEXPORT void JNICALL Java_java_net_NetworkInterface_init
...
@@ -215,26 +210,10 @@ JNIEXPORT void JNICALL Java_java_net_NetworkInterface_init
CHECK_NULL
(
ni_parentID
);
CHECK_NULL
(
ni_parentID
);
ni_ctrID
=
(
*
env
)
->
GetMethodID
(
env
,
ni_class
,
"<init>"
,
"()V"
);
ni_ctrID
=
(
*
env
)
->
GetMethodID
(
env
,
ni_class
,
"<init>"
,
"()V"
);
CHECK_NULL
(
ni_ctrID
);
CHECK_NULL
(
ni_ctrID
);
ni_iacls
=
(
*
env
)
->
FindClass
(
env
,
"java/net/InetAddress"
);
CHECK_NULL
(
ni_iacls
);
ni_iacls
=
(
*
env
)
->
NewGlobalRef
(
env
,
ni_iacls
);
CHECK_NULL
(
ni_iacls
);
ni_ia4cls
=
(
*
env
)
->
FindClass
(
env
,
"java/net/Inet4Address"
);
CHECK_NULL
(
ni_ia4cls
);
ni_ia4cls
=
(
*
env
)
->
NewGlobalRef
(
env
,
ni_ia4cls
);
CHECK_NULL
(
ni_ia4cls
);
ni_ia6cls
=
(
*
env
)
->
FindClass
(
env
,
"java/net/Inet6Address"
);
CHECK_NULL
(
ni_ia6cls
);
ni_ia6cls
=
(
*
env
)
->
NewGlobalRef
(
env
,
ni_ia6cls
);
CHECK_NULL
(
ni_ia6cls
);
ni_ibcls
=
(
*
env
)
->
FindClass
(
env
,
"java/net/InterfaceAddress"
);
ni_ibcls
=
(
*
env
)
->
FindClass
(
env
,
"java/net/InterfaceAddress"
);
CHECK_NULL
(
ni_ibcls
);
CHECK_NULL
(
ni_ibcls
);
ni_ibcls
=
(
*
env
)
->
NewGlobalRef
(
env
,
ni_ibcls
);
ni_ibcls
=
(
*
env
)
->
NewGlobalRef
(
env
,
ni_ibcls
);
CHECK_NULL
(
ni_ibcls
);
CHECK_NULL
(
ni_ibcls
);
ni_ia4ctrID
=
(
*
env
)
->
GetMethodID
(
env
,
ni_ia4cls
,
"<init>"
,
"()V"
);
CHECK_NULL
(
ni_ia4ctrID
);
ni_ia6ctrID
=
(
*
env
)
->
GetMethodID
(
env
,
ni_ia6cls
,
"<init>"
,
"()V"
);
CHECK_NULL
(
ni_ia6ctrID
);
ni_ibctrID
=
(
*
env
)
->
GetMethodID
(
env
,
ni_ibcls
,
"<init>"
,
"()V"
);
ni_ibctrID
=
(
*
env
)
->
GetMethodID
(
env
,
ni_ibcls
,
"<init>"
,
"()V"
);
CHECK_NULL
(
ni_ibctrID
);
CHECK_NULL
(
ni_ibctrID
);
ni_ibaddressID
=
(
*
env
)
->
GetFieldID
(
env
,
ni_ibcls
,
"address"
,
ni_ibaddressID
=
(
*
env
)
->
GetFieldID
(
env
,
ni_ibcls
,
"address"
,
...
@@ -247,6 +226,9 @@ JNIEXPORT void JNICALL Java_java_net_NetworkInterface_init
...
@@ -247,6 +226,9 @@ JNIEXPORT void JNICALL Java_java_net_NetworkInterface_init
CHECK_NULL
(
ni_ib4maskID
);
CHECK_NULL
(
ni_ib4maskID
);
ni_defaultIndexID
=
(
*
env
)
->
GetStaticFieldID
(
env
,
ni_class
,
"defaultIndex"
,
ni_defaultIndexID
=
(
*
env
)
->
GetStaticFieldID
(
env
,
ni_class
,
"defaultIndex"
,
"I"
);
"I"
);
CHECK_NULL
(
ni_defaultIndexID
);
initInetAddressIDs
(
env
);
}
}
/*
/*
...
@@ -700,7 +682,7 @@ static jobject createNetworkInterface(JNIEnv *env, netif *ifs) {
...
@@ -700,7 +682,7 @@ static jobject createNetworkInterface(JNIEnv *env, netif *ifs) {
}
}
// create the array of InetAddresses
// create the array of InetAddresses
addrArr
=
(
*
env
)
->
NewObjectArray
(
env
,
addr_count
,
ni_iacl
s
,
NULL
);
addrArr
=
(
*
env
)
->
NewObjectArray
(
env
,
addr_count
,
ia_clas
s
,
NULL
);
if
(
addrArr
==
NULL
)
{
if
(
addrArr
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
...
@@ -717,7 +699,7 @@ static jobject createNetworkInterface(JNIEnv *env, netif *ifs) {
...
@@ -717,7 +699,7 @@ static jobject createNetworkInterface(JNIEnv *env, netif *ifs) {
jobject
ibObj
=
NULL
;
jobject
ibObj
=
NULL
;
if
(
addrP
->
family
==
AF_INET
)
{
if
(
addrP
->
family
==
AF_INET
)
{
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ni_ia4cls
,
ni_ia4
ctrID
);
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ia4_class
,
ia4_
ctrID
);
if
(
iaObj
)
{
if
(
iaObj
)
{
setInetAddress_addr
(
env
,
iaObj
,
htonl
(
setInetAddress_addr
(
env
,
iaObj
,
htonl
(
((
struct
sockaddr_in
*
)
addrP
->
addr
)
->
sin_addr
.
s_addr
));
((
struct
sockaddr_in
*
)
addrP
->
addr
)
->
sin_addr
.
s_addr
));
...
@@ -729,7 +711,7 @@ static jobject createNetworkInterface(JNIEnv *env, netif *ifs) {
...
@@ -729,7 +711,7 @@ static jobject createNetworkInterface(JNIEnv *env, netif *ifs) {
(
*
env
)
->
SetObjectField
(
env
,
ibObj
,
ni_ibaddressID
,
iaObj
);
(
*
env
)
->
SetObjectField
(
env
,
ibObj
,
ni_ibaddressID
,
iaObj
);
if
(
addrP
->
brdcast
)
{
if
(
addrP
->
brdcast
)
{
jobject
ia2Obj
=
NULL
;
jobject
ia2Obj
=
NULL
;
ia2Obj
=
(
*
env
)
->
NewObject
(
env
,
ni_ia4cls
,
ni_ia4
ctrID
);
ia2Obj
=
(
*
env
)
->
NewObject
(
env
,
ia4_class
,
ia4_
ctrID
);
if
(
ia2Obj
)
{
if
(
ia2Obj
)
{
setInetAddress_addr
(
env
,
ia2Obj
,
htonl
(
setInetAddress_addr
(
env
,
ia2Obj
,
htonl
(
((
struct
sockaddr_in
*
)
addrP
->
brdcast
)
->
sin_addr
.
s_addr
));
((
struct
sockaddr_in
*
)
addrP
->
brdcast
)
->
sin_addr
.
s_addr
));
...
@@ -747,7 +729,7 @@ static jobject createNetworkInterface(JNIEnv *env, netif *ifs) {
...
@@ -747,7 +729,7 @@ static jobject createNetworkInterface(JNIEnv *env, netif *ifs) {
#if defined(AF_INET6)
#if defined(AF_INET6)
if
(
addrP
->
family
==
AF_INET6
)
{
if
(
addrP
->
family
==
AF_INET6
)
{
int
scope
=
0
;
int
scope
=
0
;
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ni_ia6cls
,
ni_ia6
ctrID
);
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ia6_class
,
ia6_
ctrID
);
if
(
iaObj
)
{
if
(
iaObj
)
{
jboolean
ret
=
setInet6Address_ipaddress
(
env
,
iaObj
,
jboolean
ret
=
setInet6Address_ipaddress
(
env
,
iaObj
,
(
char
*
)
&
(((
struct
sockaddr_in6
*
)
addrP
->
addr
)
->
sin6_addr
));
(
char
*
)
&
(((
struct
sockaddr_in6
*
)
addrP
->
addr
)
->
sin6_addr
));
...
...
src/solaris/native/java/net/PlainDatagramSocketImpl.c
浏览文件 @
fbfea144
...
@@ -174,9 +174,8 @@ Java_java_net_PlainDatagramSocketImpl_init(JNIEnv *env, jclass cls) {
...
@@ -174,9 +174,8 @@ Java_java_net_PlainDatagramSocketImpl_init(JNIEnv *env, jclass cls) {
IO_fd_fdID
=
NET_GetFileDescriptorID
(
env
);
IO_fd_fdID
=
NET_GetFileDescriptorID
(
env
);
CHECK_NULL
(
IO_fd_fdID
);
CHECK_NULL
(
IO_fd_fdID
);
Java_java_net_InetAddress_init
(
env
,
0
);
initInetAddressIDs
(
env
);
Java_java_net_Inet4Address_init
(
env
,
0
);
JNU_CHECK_EXCEPTION
(
env
);
Java_java_net_Inet6Address_init
(
env
,
0
);
Java_java_net_NetworkInterface_init
(
env
,
0
);
Java_java_net_NetworkInterface_init
(
env
,
0
);
}
}
...
...
src/solaris/native/java/net/PlainSocketImpl.c
浏览文件 @
fbfea144
...
@@ -162,6 +162,9 @@ Java_java_net_PlainSocketImpl_initProto(JNIEnv *env, jclass cls) {
...
@@ -162,6 +162,9 @@ Java_java_net_PlainSocketImpl_initProto(JNIEnv *env, jclass cls) {
IO_fd_fdID
=
NET_GetFileDescriptorID
(
env
);
IO_fd_fdID
=
NET_GetFileDescriptorID
(
env
);
CHECK_NULL
(
IO_fd_fdID
);
CHECK_NULL
(
IO_fd_fdID
);
initInetAddressIDs
(
env
);
JNU_CHECK_EXCEPTION
(
env
);
/* Create the marker fd used for dup2 */
/* Create the marker fd used for dup2 */
marker_fd
=
getMarkerFD
();
marker_fd
=
getMarkerFD
();
}
}
...
...
src/solaris/native/sun/nio/ch/IOUtil.c
浏览文件 @
fbfea144
...
@@ -35,6 +35,7 @@
...
@@ -35,6 +35,7 @@
#include "java_lang_Integer.h"
#include "java_lang_Integer.h"
#include "nio.h"
#include "nio.h"
#include "nio_util.h"
#include "nio_util.h"
#include "net_util.h"
static
jfieldID
fd_fdID
;
/* for jint 'fd' in java.io.FileDescriptor */
static
jfieldID
fd_fdID
;
/* for jint 'fd' in java.io.FileDescriptor */
...
@@ -44,6 +45,7 @@ Java_sun_nio_ch_IOUtil_initIDs(JNIEnv *env, jclass clazz)
...
@@ -44,6 +45,7 @@ Java_sun_nio_ch_IOUtil_initIDs(JNIEnv *env, jclass clazz)
{
{
CHECK_NULL
(
clazz
=
(
*
env
)
->
FindClass
(
env
,
"java/io/FileDescriptor"
));
CHECK_NULL
(
clazz
=
(
*
env
)
->
FindClass
(
env
,
"java/io/FileDescriptor"
));
CHECK_NULL
(
fd_fdID
=
(
*
env
)
->
GetFieldID
(
env
,
clazz
,
"fd"
,
"I"
));
CHECK_NULL
(
fd_fdID
=
(
*
env
)
->
GetFieldID
(
env
,
clazz
,
"fd"
,
"I"
));
initInetAddressIDs
(
env
);
}
}
JNIEXPORT
jboolean
JNICALL
JNIEXPORT
jboolean
JNICALL
...
...
src/solaris/native/sun/nio/ch/sctp/SctpNet.c
浏览文件 @
fbfea144
...
@@ -157,6 +157,7 @@ Java_sun_nio_ch_sctp_SctpNet_init
...
@@ -157,6 +157,7 @@ Java_sun_nio_ch_sctp_SctpNet_init
}
}
preCloseFD
=
sp
[
0
];
preCloseFD
=
sp
[
0
];
close
(
sp
[
1
]);
close
(
sp
[
1
]);
initInetAddressIDs
(
env
);
}
}
/*
/*
...
...
src/windows/native/java/net/Inet4AddressImpl.c
浏览文件 @
fbfea144
...
@@ -114,11 +114,6 @@ Java_java_net_Inet4AddressImpl_getLocalHostName (JNIEnv *env, jobject this) {
...
@@ -114,11 +114,6 @@ Java_java_net_Inet4AddressImpl_getLocalHostName (JNIEnv *env, jobject this) {
return
JNU_NewStringPlatform
(
env
,
hostname
);
return
JNU_NewStringPlatform
(
env
,
hostname
);
}
}
static
jclass
ni_iacls
;
static
jclass
ni_ia4cls
;
static
jmethodID
ni_ia4ctrID
;
static
int
initialized
=
0
;
/*
/*
* Find an internet address for a given hostname. Not this this
* Find an internet address for a given hostname. Not this this
* code only works for addresses of type INET. The translation
* code only works for addresses of type INET. The translation
...
@@ -143,19 +138,8 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
...
@@ -143,19 +138,8 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
jobjectArray
ret
=
NULL
;
jobjectArray
ret
=
NULL
;
if
(
!
initialized
)
{
initInetAddressIDs
(
env
);
ni_iacls
=
(
*
env
)
->
FindClass
(
env
,
"java/net/InetAddress"
);
JNU_CHECK_EXCEPTION_RETURN
(
env
,
NULL
);
CHECK_NULL_RETURN
(
ni_iacls
,
NULL
);
ni_iacls
=
(
*
env
)
->
NewGlobalRef
(
env
,
ni_iacls
);
CHECK_NULL_RETURN
(
ni_iacls
,
NULL
);
ni_ia4cls
=
(
*
env
)
->
FindClass
(
env
,
"java/net/Inet4Address"
);
CHECK_NULL_RETURN
(
ni_ia4cls
,
NULL
);
ni_ia4cls
=
(
*
env
)
->
NewGlobalRef
(
env
,
ni_ia4cls
);
CHECK_NULL_RETURN
(
ni_ia4cls
,
NULL
);
ni_ia4ctrID
=
(
*
env
)
->
GetMethodID
(
env
,
ni_ia4cls
,
"<init>"
,
"()V"
);
CHECK_NULL_RETURN
(
ni_ia4ctrID
,
NULL
);
initialized
=
1
;
}
if
(
IS_NULL
(
host
))
{
if
(
IS_NULL
(
host
))
{
JNU_ThrowNullPointerException
(
env
,
"host argument"
);
JNU_ThrowNullPointerException
(
env
,
"host argument"
);
...
@@ -199,13 +183,13 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
...
@@ -199,13 +183,13 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
address
|=
(
addr
[
1
]
<<
8
)
&
0xff00
;
address
|=
(
addr
[
1
]
<<
8
)
&
0xff00
;
address
|=
addr
[
0
];
address
|=
addr
[
0
];
ret
=
(
*
env
)
->
NewObjectArray
(
env
,
1
,
ni_iacl
s
,
NULL
);
ret
=
(
*
env
)
->
NewObjectArray
(
env
,
1
,
ia_clas
s
,
NULL
);
if
(
IS_NULL
(
ret
))
{
if
(
IS_NULL
(
ret
))
{
goto
cleanupAndReturn
;
goto
cleanupAndReturn
;
}
}
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ni_ia4cls
,
ni_ia4
ctrID
);
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ia4_class
,
ia4_
ctrID
);
if
(
IS_NULL
(
iaObj
))
{
if
(
IS_NULL
(
iaObj
))
{
ret
=
NULL
;
ret
=
NULL
;
goto
cleanupAndReturn
;
goto
cleanupAndReturn
;
...
@@ -229,7 +213,7 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
...
@@ -229,7 +213,7 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
addrp
++
;
addrp
++
;
}
}
ret
=
(
*
env
)
->
NewObjectArray
(
env
,
i
,
ni_iacl
s
,
NULL
);
ret
=
(
*
env
)
->
NewObjectArray
(
env
,
i
,
ia_clas
s
,
NULL
);
if
(
IS_NULL
(
ret
))
{
if
(
IS_NULL
(
ret
))
{
goto
cleanupAndReturn
;
goto
cleanupAndReturn
;
...
@@ -238,7 +222,7 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
...
@@ -238,7 +222,7 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
addrp
=
(
struct
in_addr
**
)
hp
->
h_addr_list
;
addrp
=
(
struct
in_addr
**
)
hp
->
h_addr_list
;
i
=
0
;
i
=
0
;
while
(
*
addrp
!=
(
struct
in_addr
*
)
0
)
{
while
(
*
addrp
!=
(
struct
in_addr
*
)
0
)
{
jobject
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ni_ia4cls
,
ni_ia4
ctrID
);
jobject
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ia4_class
,
ia4_
ctrID
);
if
(
IS_NULL
(
iaObj
))
{
if
(
IS_NULL
(
iaObj
))
{
ret
=
NULL
;
ret
=
NULL
;
goto
cleanupAndReturn
;
goto
cleanupAndReturn
;
...
...
src/windows/native/java/net/Inet6AddressImpl.c
浏览文件 @
fbfea144
...
@@ -74,13 +74,6 @@ Java_java_net_Inet6AddressImpl_getLocalHostName (JNIEnv *env, jobject this) {
...
@@ -74,13 +74,6 @@ Java_java_net_Inet6AddressImpl_getLocalHostName (JNIEnv *env, jobject this) {
return
JNU_NewStringPlatform
(
env
,
hostname
);
return
JNU_NewStringPlatform
(
env
,
hostname
);
}
}
static
jclass
ni_iacls
;
static
jclass
ni_ia4cls
;
static
jclass
ni_ia6cls
;
static
jmethodID
ni_ia4ctrID
;
static
jmethodID
ni_ia6ctrID
;
static
int
initialized
=
0
;
JNIEXPORT
jobjectArray
JNICALL
JNIEXPORT
jobjectArray
JNICALL
Java_java_net_Inet6AddressImpl_lookupAllHostAddr
(
JNIEnv
*
env
,
jobject
this
,
Java_java_net_Inet6AddressImpl_lookupAllHostAddr
(
JNIEnv
*
env
,
jobject
this
,
jstring
host
)
{
jstring
host
)
{
...
@@ -88,30 +81,13 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
...
@@ -88,30 +81,13 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
jobjectArray
ret
=
0
;
jobjectArray
ret
=
0
;
int
retLen
=
0
;
int
retLen
=
0
;
jboolean
preferIPv6Address
;
jboolean
preferIPv6Address
;
static
jfieldID
ia_preferIPv6AddressID
;
int
error
=
0
;
int
error
=
0
;
struct
addrinfo
hints
,
*
res
,
*
resNew
=
NULL
;
struct
addrinfo
hints
,
*
res
,
*
resNew
=
NULL
;
if
(
!
initialized
)
{
initInetAddressIDs
(
env
);
ni_iacls
=
(
*
env
)
->
FindClass
(
env
,
"java/net/InetAddress"
);
JNU_CHECK_EXCEPTION_RETURN
(
env
,
NULL
);
CHECK_NULL_RETURN
(
ni_iacls
,
NULL
);
ni_iacls
=
(
*
env
)
->
NewGlobalRef
(
env
,
ni_iacls
);
CHECK_NULL_RETURN
(
ni_iacls
,
NULL
);
ni_ia4cls
=
(
*
env
)
->
FindClass
(
env
,
"java/net/Inet4Address"
);
CHECK_NULL_RETURN
(
ni_ia4cls
,
NULL
);
ni_ia4cls
=
(
*
env
)
->
NewGlobalRef
(
env
,
ni_ia4cls
);
CHECK_NULL_RETURN
(
ni_ia4cls
,
NULL
);
ni_ia6cls
=
(
*
env
)
->
FindClass
(
env
,
"java/net/Inet6Address"
);
CHECK_NULL_RETURN
(
ni_ia6cls
,
NULL
);
ni_ia6cls
=
(
*
env
)
->
NewGlobalRef
(
env
,
ni_ia6cls
);
CHECK_NULL_RETURN
(
ni_ia6cls
,
NULL
);
ni_ia4ctrID
=
(
*
env
)
->
GetMethodID
(
env
,
ni_ia4cls
,
"<init>"
,
"()V"
);
CHECK_NULL_RETURN
(
ni_ia4ctrID
,
NULL
);
ni_ia6ctrID
=
(
*
env
)
->
GetMethodID
(
env
,
ni_ia6cls
,
"<init>"
,
"()V"
);
CHECK_NULL_RETURN
(
ni_ia6ctrID
,
NULL
);
initialized
=
1
;
}
if
(
IS_NULL
(
host
))
{
if
(
IS_NULL
(
host
))
{
JNU_ThrowNullPointerException
(
env
,
"host is null"
);
JNU_ThrowNullPointerException
(
env
,
"host is null"
);
return
0
;
return
0
;
...
@@ -119,17 +95,6 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
...
@@ -119,17 +95,6 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
hostname
=
JNU_GetStringPlatformChars
(
env
,
host
,
JNI_FALSE
);
hostname
=
JNU_GetStringPlatformChars
(
env
,
host
,
JNI_FALSE
);
CHECK_NULL_RETURN
(
hostname
,
NULL
);
CHECK_NULL_RETURN
(
hostname
,
NULL
);
if
(
ia_preferIPv6AddressID
==
NULL
)
{
jclass
c
=
(
*
env
)
->
FindClass
(
env
,
"java/net/InetAddress"
);
if
(
c
)
{
ia_preferIPv6AddressID
=
(
*
env
)
->
GetStaticFieldID
(
env
,
c
,
"preferIPv6Address"
,
"Z"
);
}
if
(
ia_preferIPv6AddressID
==
NULL
)
{
JNU_ReleaseStringPlatformChars
(
env
,
host
,
hostname
);
return
NULL
;
}
}
/* get the address preference */
/* get the address preference */
preferIPv6Address
preferIPv6Address
=
(
*
env
)
->
GetStaticBooleanField
(
env
,
ia_class
,
ia_preferIPv6AddressID
);
=
(
*
env
)
->
GetStaticBooleanField
(
env
,
ia_class
,
ia_preferIPv6AddressID
);
...
@@ -231,7 +196,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
...
@@ -231,7 +196,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
retLen
=
i
;
retLen
=
i
;
iterator
=
resNew
;
iterator
=
resNew
;
i
=
0
;
i
=
0
;
ret
=
(
*
env
)
->
NewObjectArray
(
env
,
retLen
,
ni_iacl
s
,
NULL
);
ret
=
(
*
env
)
->
NewObjectArray
(
env
,
retLen
,
ia_clas
s
,
NULL
);
if
(
IS_NULL
(
ret
))
{
if
(
IS_NULL
(
ret
))
{
/* we may have memory to free at the end of this */
/* we may have memory to free at the end of this */
...
@@ -248,7 +213,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
...
@@ -248,7 +213,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
while
(
iterator
!=
NULL
)
{
while
(
iterator
!=
NULL
)
{
if
(
iterator
->
ai_family
==
AF_INET
)
{
if
(
iterator
->
ai_family
==
AF_INET
)
{
jobject
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ni_ia4cls
,
ni_ia4
ctrID
);
jobject
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ia4_class
,
ia4_
ctrID
);
if
(
IS_NULL
(
iaObj
))
{
if
(
IS_NULL
(
iaObj
))
{
ret
=
NULL
;
ret
=
NULL
;
goto
cleanupAndReturn
;
goto
cleanupAndReturn
;
...
@@ -259,7 +224,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
...
@@ -259,7 +224,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
inetIndex
++
;
inetIndex
++
;
}
else
if
(
iterator
->
ai_family
==
AF_INET6
)
{
}
else
if
(
iterator
->
ai_family
==
AF_INET6
)
{
jint
scope
=
0
,
ret1
;
jint
scope
=
0
,
ret1
;
jobject
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ni_ia6cls
,
ni_ia6
ctrID
);
jobject
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ia6_class
,
ia6_
ctrID
);
if
(
IS_NULL
(
iaObj
))
{
if
(
IS_NULL
(
iaObj
))
{
ret
=
NULL
;
ret
=
NULL
;
goto
cleanupAndReturn
;
goto
cleanupAndReturn
;
...
@@ -349,7 +314,7 @@ Java_java_net_Inet6AddressImpl_getHostByAddr(JNIEnv *env, jobject this,
...
@@ -349,7 +314,7 @@ Java_java_net_Inet6AddressImpl_getHostByAddr(JNIEnv *env, jobject this,
if
(
!
error
)
{
if
(
!
error
)
{
ret
=
(
*
env
)
->
NewStringUTF
(
env
,
host
);
ret
=
(
*
env
)
->
NewStringUTF
(
env
,
host
);
CHECK_NULL
(
ret
);
CHECK_NULL
_RETURN
(
ret
,
NULL
);
}
}
if
(
ret
==
NULL
)
{
if
(
ret
==
NULL
)
{
...
...
src/windows/native/java/net/NetworkInterface.c
浏览文件 @
fbfea144
...
@@ -65,13 +65,6 @@ jfieldID ni_bindsID; /* NetworkInterface.bindings */
...
@@ -65,13 +65,6 @@ jfieldID ni_bindsID; /* NetworkInterface.bindings */
jfieldID
ni_nameID
;
/* NetworkInterface.name */
jfieldID
ni_nameID
;
/* NetworkInterface.name */
jfieldID
ni_displayNameID
;
/* NetworkInterface.displayName */
jfieldID
ni_displayNameID
;
/* NetworkInterface.displayName */
jfieldID
ni_childsID
;
/* NetworkInterface.childs */
jfieldID
ni_childsID
;
/* NetworkInterface.childs */
jclass
ni_iacls
;
/* InetAddress */
jclass
ni_ia4cls
;
/* Inet4Address */
jmethodID
ni_ia4Ctor
;
/* Inet4Address() */
jclass
ni_ia6cls
;
/* Inet6Address */
jmethodID
ni_ia6ctrID
;
/* Inet6Address() */
jclass
ni_ibcls
;
/* InterfaceAddress */
jclass
ni_ibcls
;
/* InterfaceAddress */
jmethodID
ni_ibctrID
;
/* InterfaceAddress() */
jmethodID
ni_ibctrID
;
/* InterfaceAddress() */
...
@@ -515,26 +508,6 @@ Java_java_net_NetworkInterface_init(JNIEnv *env, jclass cls)
...
@@ -515,26 +508,6 @@ Java_java_net_NetworkInterface_init(JNIEnv *env, jclass cls)
CHECK_NULL
(
ni_childsID
);
CHECK_NULL
(
ni_childsID
);
ni_ctor
=
(
*
env
)
->
GetMethodID
(
env
,
ni_class
,
"<init>"
,
"()V"
);
ni_ctor
=
(
*
env
)
->
GetMethodID
(
env
,
ni_class
,
"<init>"
,
"()V"
);
CHECK_NULL
(
ni_ctor
);
CHECK_NULL
(
ni_ctor
);
ni_iacls
=
(
*
env
)
->
FindClass
(
env
,
"java/net/InetAddress"
);
CHECK_NULL
(
ni_iacls
);
ni_iacls
=
(
*
env
)
->
NewGlobalRef
(
env
,
ni_iacls
);
CHECK_NULL
(
ni_iacls
);
ni_ia4cls
=
(
*
env
)
->
FindClass
(
env
,
"java/net/Inet4Address"
);
CHECK_NULL
(
ni_ia4cls
);
ni_ia4cls
=
(
*
env
)
->
NewGlobalRef
(
env
,
ni_ia4cls
);
CHECK_NULL
(
ni_ia4cls
);
ni_ia4Ctor
=
(
*
env
)
->
GetMethodID
(
env
,
ni_ia4cls
,
"<init>"
,
"()V"
);
CHECK_NULL
(
ni_ia4Ctor
);
ni_ia6cls
=
(
*
env
)
->
FindClass
(
env
,
"java/net/Inet6Address"
);
CHECK_NULL
(
ni_ia6cls
);
ni_ia6cls
=
(
*
env
)
->
NewGlobalRef
(
env
,
ni_ia6cls
);
CHECK_NULL
(
ni_ia6cls
);
ni_ia6ctrID
=
(
*
env
)
->
GetMethodID
(
env
,
ni_ia6cls
,
"<init>"
,
"()V"
);
CHECK_NULL
(
ni_ia6ctrID
);
ni_ibcls
=
(
*
env
)
->
FindClass
(
env
,
"java/net/InterfaceAddress"
);
ni_ibcls
=
(
*
env
)
->
FindClass
(
env
,
"java/net/InterfaceAddress"
);
CHECK_NULL
(
ni_ibcls
);
CHECK_NULL
(
ni_ibcls
);
ni_ibcls
=
(
*
env
)
->
NewGlobalRef
(
env
,
ni_ibcls
);
ni_ibcls
=
(
*
env
)
->
NewGlobalRef
(
env
,
ni_ibcls
);
...
@@ -546,6 +519,9 @@ Java_java_net_NetworkInterface_init(JNIEnv *env, jclass cls)
...
@@ -546,6 +519,9 @@ Java_java_net_NetworkInterface_init(JNIEnv *env, jclass cls)
ni_ibbroadcastID
=
(
*
env
)
->
GetFieldID
(
env
,
ni_ibcls
,
"broadcast"
,
"Ljava/net/Inet4Address;"
);
ni_ibbroadcastID
=
(
*
env
)
->
GetFieldID
(
env
,
ni_ibcls
,
"broadcast"
,
"Ljava/net/Inet4Address;"
);
CHECK_NULL
(
ni_ibbroadcastID
);
CHECK_NULL
(
ni_ibbroadcastID
);
ni_ibmaskID
=
(
*
env
)
->
GetFieldID
(
env
,
ni_ibcls
,
"maskLength"
,
"S"
);
ni_ibmaskID
=
(
*
env
)
->
GetFieldID
(
env
,
ni_ibcls
,
"maskLength"
,
"S"
);
CHECK_NULL
(
ni_ibmaskID
);
initInetAddressIDs
(
env
);
}
}
/*
/*
...
@@ -591,7 +567,7 @@ jobject createNetworkInterface
...
@@ -591,7 +567,7 @@ jobject createNetworkInterface
return
NULL
;
return
NULL
;
}
}
}
}
addrArr
=
(
*
env
)
->
NewObjectArray
(
env
,
netaddrCount
,
ni_iacl
s
,
NULL
);
addrArr
=
(
*
env
)
->
NewObjectArray
(
env
,
netaddrCount
,
ia_clas
s
,
NULL
);
if
(
addrArr
==
NULL
)
{
if
(
addrArr
==
NULL
)
{
free_netaddr
(
netaddrP
);
free_netaddr
(
netaddrP
);
return
NULL
;
return
NULL
;
...
@@ -609,7 +585,7 @@ jobject createNetworkInterface
...
@@ -609,7 +585,7 @@ jobject createNetworkInterface
jobject
iaObj
,
ia2Obj
;
jobject
iaObj
,
ia2Obj
;
jobject
ibObj
=
NULL
;
jobject
ibObj
=
NULL
;
if
(
addrs
->
addr
.
him
.
sa_family
==
AF_INET
)
{
if
(
addrs
->
addr
.
him
.
sa_family
==
AF_INET
)
{
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ni_ia4cls
,
ni_ia4Ctor
);
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ia4_class
,
ia4_ctrID
);
if
(
iaObj
==
NULL
)
{
if
(
iaObj
==
NULL
)
{
free_netaddr
(
netaddrP
);
free_netaddr
(
netaddrP
);
return
NULL
;
return
NULL
;
...
@@ -624,7 +600,7 @@ jobject createNetworkInterface
...
@@ -624,7 +600,7 @@ jobject createNetworkInterface
return
NULL
;
return
NULL
;
}
}
(
*
env
)
->
SetObjectField
(
env
,
ibObj
,
ni_ibaddressID
,
iaObj
);
(
*
env
)
->
SetObjectField
(
env
,
ibObj
,
ni_ibaddressID
,
iaObj
);
ia2Obj
=
(
*
env
)
->
NewObject
(
env
,
ni_ia4cls
,
ni_ia4Ctor
);
ia2Obj
=
(
*
env
)
->
NewObject
(
env
,
ia4_class
,
ia4_ctrID
);
if
(
ia2Obj
==
NULL
)
{
if
(
ia2Obj
==
NULL
)
{
free_netaddr
(
netaddrP
);
free_netaddr
(
netaddrP
);
return
NULL
;
return
NULL
;
...
@@ -636,7 +612,7 @@ jobject createNetworkInterface
...
@@ -636,7 +612,7 @@ jobject createNetworkInterface
}
}
}
else
/* AF_INET6 */
{
}
else
/* AF_INET6 */
{
int
scope
;
int
scope
;
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ni_ia6cls
,
ni_ia6
ctrID
);
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ia6_class
,
ia6_
ctrID
);
if
(
iaObj
)
{
if
(
iaObj
)
{
int
ret
=
setInet6Address_ipaddress
(
env
,
iaObj
,
(
jbyte
*
)
&
(
addrs
->
addr
.
him6
.
sin6_addr
.
s6_addr
));
int
ret
=
setInet6Address_ipaddress
(
env
,
iaObj
,
(
jbyte
*
)
&
(
addrs
->
addr
.
him6
.
sin6_addr
.
s6_addr
));
if
(
ret
==
JNI_FALSE
)
{
if
(
ret
==
JNI_FALSE
)
{
...
...
src/windows/native/java/net/NetworkInterface.h
浏览文件 @
fbfea144
...
@@ -70,16 +70,6 @@ extern jfieldID ni_nameID; /* NetworkInterface.name */
...
@@ -70,16 +70,6 @@ extern jfieldID ni_nameID; /* NetworkInterface.name */
extern
jfieldID
ni_displayNameID
;
/* NetworkInterface.displayName */
extern
jfieldID
ni_displayNameID
;
/* NetworkInterface.displayName */
extern
jfieldID
ni_childsID
;
/* NetworkInterface.childs */
extern
jfieldID
ni_childsID
;
/* NetworkInterface.childs */
extern
jclass
ni_iacls
;
/* InetAddress */
extern
jclass
ni_ia4cls
;
/* Inet4Address */
extern
jmethodID
ni_ia4Ctor
;
/* Inet4Address() */
extern
jclass
ni_ia6cls
;
/* Inet6Address */
extern
jmethodID
ni_ia6ctrID
;
/* Inet6Address() */
extern
jfieldID
ni_ia6ipaddressID
;
extern
jfieldID
ni_ia6ipaddressID
;
extern
jclass
ni_ibcls
;
/* InterfaceAddress */
extern
jclass
ni_ibcls
;
/* InterfaceAddress */
extern
jmethodID
ni_ibctrID
;
/* InterfaceAddress() */
extern
jmethodID
ni_ibctrID
;
/* InterfaceAddress() */
extern
jfieldID
ni_ibaddressID
;
/* InterfaceAddress.address */
extern
jfieldID
ni_ibaddressID
;
/* InterfaceAddress.address */
...
...
src/windows/native/java/net/NetworkInterface_winXP.c
浏览文件 @
fbfea144
...
@@ -513,7 +513,7 @@ static jobject createNetworkInterfaceXP(JNIEnv *env, netif *ifs)
...
@@ -513,7 +513,7 @@ static jobject createNetworkInterfaceXP(JNIEnv *env, netif *ifs)
}
}
}
}
addrArr
=
(
*
env
)
->
NewObjectArray
(
env
,
netaddrCount
,
ni_iacl
s
,
NULL
);
addrArr
=
(
*
env
)
->
NewObjectArray
(
env
,
netaddrCount
,
ia_clas
s
,
NULL
);
if
(
addrArr
==
NULL
)
{
if
(
addrArr
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
...
@@ -531,7 +531,7 @@ static jobject createNetworkInterfaceXP(JNIEnv *env, netif *ifs)
...
@@ -531,7 +531,7 @@ static jobject createNetworkInterfaceXP(JNIEnv *env, netif *ifs)
jobject
iaObj
,
ia2Obj
;
jobject
iaObj
,
ia2Obj
;
jobject
ibObj
=
NULL
;
jobject
ibObj
=
NULL
;
if
(
addrs
->
addr
.
him
.
sa_family
==
AF_INET
)
{
if
(
addrs
->
addr
.
him
.
sa_family
==
AF_INET
)
{
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ni_ia4cls
,
ni_ia4Ctor
);
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ia4_class
,
ia4_ctrID
);
if
(
iaObj
==
NULL
)
{
if
(
iaObj
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
...
@@ -545,7 +545,7 @@ static jobject createNetworkInterfaceXP(JNIEnv *env, netif *ifs)
...
@@ -545,7 +545,7 @@ static jobject createNetworkInterfaceXP(JNIEnv *env, netif *ifs)
return
NULL
;
return
NULL
;
}
}
(
*
env
)
->
SetObjectField
(
env
,
ibObj
,
ni_ibaddressID
,
iaObj
);
(
*
env
)
->
SetObjectField
(
env
,
ibObj
,
ni_ibaddressID
,
iaObj
);
ia2Obj
=
(
*
env
)
->
NewObject
(
env
,
ni_ia4cls
,
ni_ia4Ctor
);
ia2Obj
=
(
*
env
)
->
NewObject
(
env
,
ia4_class
,
ia4_ctrID
);
if
(
ia2Obj
==
NULL
)
{
if
(
ia2Obj
==
NULL
)
{
free_netaddr
(
netaddrP
);
free_netaddr
(
netaddrP
);
return
NULL
;
return
NULL
;
...
@@ -556,7 +556,7 @@ static jobject createNetworkInterfaceXP(JNIEnv *env, netif *ifs)
...
@@ -556,7 +556,7 @@ static jobject createNetworkInterfaceXP(JNIEnv *env, netif *ifs)
(
*
env
)
->
SetObjectArrayElement
(
env
,
bindsArr
,
bind_index
++
,
ibObj
);
(
*
env
)
->
SetObjectArrayElement
(
env
,
bindsArr
,
bind_index
++
,
ibObj
);
}
else
/* AF_INET6 */
{
}
else
/* AF_INET6 */
{
int
scope
;
int
scope
;
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ni_ia6cls
,
ni_ia6
ctrID
);
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ia6_class
,
ia6_
ctrID
);
if
(
iaObj
)
{
if
(
iaObj
)
{
int
ret
=
setInet6Address_ipaddress
(
env
,
iaObj
,
(
jbyte
*
)
&
(
addrs
->
addr
.
him6
.
sin6_addr
.
s6_addr
));
int
ret
=
setInet6Address_ipaddress
(
env
,
iaObj
,
(
jbyte
*
)
&
(
addrs
->
addr
.
him6
.
sin6_addr
.
s6_addr
));
if
(
ret
==
JNI_FALSE
)
{
if
(
ret
==
JNI_FALSE
)
{
...
...
src/windows/native/sun/nio/ch/IOUtil.c
浏览文件 @
fbfea144
...
@@ -33,6 +33,7 @@
...
@@ -33,6 +33,7 @@
#include "nio.h"
#include "nio.h"
#include "nio_util.h"
#include "nio_util.h"
#include "net_util.h"
#include "sun_nio_ch_IOUtil.h"
#include "sun_nio_ch_IOUtil.h"
/* field id for jlong 'handle' in java.io.FileDescriptor used for file fds */
/* field id for jlong 'handle' in java.io.FileDescriptor used for file fds */
...
@@ -55,6 +56,7 @@ Java_sun_nio_ch_IOUtil_initIDs(JNIEnv *env, jclass clazz)
...
@@ -55,6 +56,7 @@ Java_sun_nio_ch_IOUtil_initIDs(JNIEnv *env, jclass clazz)
CHECK_NULL
(
clazz
=
(
*
env
)
->
FindClass
(
env
,
"java/io/FileDescriptor"
));
CHECK_NULL
(
clazz
=
(
*
env
)
->
FindClass
(
env
,
"java/io/FileDescriptor"
));
CHECK_NULL
(
fd_fdID
=
(
*
env
)
->
GetFieldID
(
env
,
clazz
,
"fd"
,
"I"
));
CHECK_NULL
(
fd_fdID
=
(
*
env
)
->
GetFieldID
(
env
,
clazz
,
"fd"
,
"I"
));
CHECK_NULL
(
handle_fdID
=
(
*
env
)
->
GetFieldID
(
env
,
clazz
,
"handle"
,
"J"
));
CHECK_NULL
(
handle_fdID
=
(
*
env
)
->
GetFieldID
(
env
,
clazz
,
"handle"
,
"J"
));
initInetAddressIDs
(
env
);
}
}
/**************************************************************
/**************************************************************
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录