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 {
NET_EnableFastTcpLoopback;
NET_ThrowNew;
ipv6_available;
initInetAddressIDs;
local:
*;
...
...
src/share/native/java/net/Inet4Address.c
浏览文件 @
fbfea144
...
...
@@ -34,6 +34,8 @@
jclass
ia4_class
;
jmethodID
ia4_ctrID
;
static
int
ia4_initialized
=
0
;
/*
* Class: java_net_Inet4Address
* Method: init
...
...
@@ -41,9 +43,13 @@ jmethodID ia4_ctrID;
*/
JNIEXPORT
void
JNICALL
Java_java_net_Inet4Address_init
(
JNIEnv
*
env
,
jclass
cls
)
{
jclass
c
=
(
*
env
)
->
FindClass
(
env
,
"java/net/Inet4Address"
);
CHECK_NULL
(
c
);
ia4_class
=
(
*
env
)
->
NewGlobalRef
(
env
,
c
);
CHECK_NULL
(
ia4_class
);
ia4_ctrID
=
(
*
env
)
->
GetMethodID
(
env
,
ia4_class
,
"<init>"
,
"()V"
);
if
(
!
ia4_initialized
)
{
jclass
c
=
(
*
env
)
->
FindClass
(
env
,
"java/net/Inet4Address"
);
CHECK_NULL
(
c
);
ia4_class
=
(
*
env
)
->
NewGlobalRef
(
env
,
c
);
CHECK_NULL
(
ia4_class
);
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;
jfieldID
ia6_scopeifnameID
;
jmethodID
ia6_ctrID
;
static
int
ia6_initialized
=
0
;
/*
* Class: java_net_Inet6Address
* Method: init
...
...
@@ -49,24 +51,28 @@ jmethodID ia6_ctrID;
*/
JNIEXPORT
void
JNICALL
Java_java_net_Inet6Address_init
(
JNIEnv
*
env
,
jclass
cls
)
{
jclass
ia6h_class
;
jclass
c
=
(
*
env
)
->
FindClass
(
env
,
"java/net/Inet6Address"
);
CHECK_NULL
(
c
);
ia6_class
=
(
*
env
)
->
NewGlobalRef
(
env
,
c
);
CHECK_NULL
(
ia6_class
);
ia6h_class
=
(
*
env
)
->
FindClass
(
env
,
"java/net/Inet6Address$Inet6AddressHolder"
);
CHECK_NULL
(
ia6h_class
);
ia6_holder6ID
=
(
*
env
)
->
GetFieldID
(
env
,
ia6_class
,
"holder6"
,
"Ljava/net/Inet6Address$Inet6AddressHolder;"
);
CHECK_NULL
(
ia6_holder6ID
);
ia6_ipaddressID
=
(
*
env
)
->
GetFieldID
(
env
,
ia6h_class
,
"ipaddress"
,
"[B"
);
CHECK_NULL
(
ia6_ipaddressID
);
ia6_scopeidID
=
(
*
env
)
->
GetFieldID
(
env
,
ia6h_class
,
"scope_id"
,
"I"
);
CHECK_NULL
(
ia6_scopeidID
);
ia6_cachedscopeidID
=
(
*
env
)
->
GetFieldID
(
env
,
ia6_class
,
"cached_scope_id"
,
"I"
);
CHECK_NULL
(
ia6_cachedscopeidID
);
ia6_scopeidsetID
=
(
*
env
)
->
GetFieldID
(
env
,
ia6h_class
,
"scope_id_set"
,
"Z"
);
CHECK_NULL
(
ia6_scopeidsetID
);
ia6_scopeifnameID
=
(
*
env
)
->
GetFieldID
(
env
,
ia6h_class
,
"scope_ifname"
,
"Ljava/net/NetworkInterface;"
);
CHECK_NULL
(
ia6_scopeifnameID
);
ia6_ctrID
=
(
*
env
)
->
GetMethodID
(
env
,
ia6_class
,
"<init>"
,
"()V"
);
if
(
!
ia6_initialized
)
{
jclass
ia6h_class
;
jclass
c
=
(
*
env
)
->
FindClass
(
env
,
"java/net/Inet6Address"
);
CHECK_NULL
(
c
);
ia6_class
=
(
*
env
)
->
NewGlobalRef
(
env
,
c
);
CHECK_NULL
(
ia6_class
);
ia6h_class
=
(
*
env
)
->
FindClass
(
env
,
"java/net/Inet6Address$Inet6AddressHolder"
);
CHECK_NULL
(
ia6h_class
);
ia6_holder6ID
=
(
*
env
)
->
GetFieldID
(
env
,
ia6_class
,
"holder6"
,
"Ljava/net/Inet6Address$Inet6AddressHolder;"
);
CHECK_NULL
(
ia6_holder6ID
);
ia6_ipaddressID
=
(
*
env
)
->
GetFieldID
(
env
,
ia6h_class
,
"ipaddress"
,
"[B"
);
CHECK_NULL
(
ia6_ipaddressID
);
ia6_scopeidID
=
(
*
env
)
->
GetFieldID
(
env
,
ia6h_class
,
"scope_id"
,
"I"
);
CHECK_NULL
(
ia6_scopeidID
);
ia6_cachedscopeidID
=
(
*
env
)
->
GetFieldID
(
env
,
ia6_class
,
"cached_scope_id"
,
"I"
);
CHECK_NULL
(
ia6_cachedscopeidID
);
ia6_scopeidsetID
=
(
*
env
)
->
GetFieldID
(
env
,
ia6h_class
,
"scope_id_set"
,
"Z"
);
CHECK_NULL
(
ia6_scopeidsetID
);
ia6_scopeifnameID
=
(
*
env
)
->
GetFieldID
(
env
,
ia6h_class
,
"scope_ifname"
,
"Ljava/net/NetworkInterface;"
);
CHECK_NULL
(
ia6_scopeifnameID
);
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;
jfieldID
iac_origHostNameID
;
jfieldID
ia_preferIPv6AddressID
;
static
int
ia_initialized
=
0
;
/*
* Class: java_net_InetAddress
* Method: init
...
...
@@ -48,23 +50,27 @@ jfieldID ia_preferIPv6AddressID;
*/
JNIEXPORT
void
JNICALL
Java_java_net_InetAddress_init
(
JNIEnv
*
env
,
jclass
cls
)
{
jclass
c
=
(
*
env
)
->
FindClass
(
env
,
"java/net/InetAddress"
);
CHECK_NULL
(
c
);
ia_class
=
(
*
env
)
->
NewGlobalRef
(
env
,
c
);
CHECK_NULL
(
ia_class
);
c
=
(
*
env
)
->
FindClass
(
env
,
"java/net/InetAddress$InetAddressHolder"
);
CHECK_NULL
(
c
);
iac_class
=
(
*
env
)
->
NewGlobalRef
(
env
,
c
);
ia_holderID
=
(
*
env
)
->
GetFieldID
(
env
,
ia_class
,
"holder"
,
"Ljava/net/InetAddress$InetAddressHolder;"
);
CHECK_NULL
(
ia_holderID
);
ia_preferIPv6AddressID
=
(
*
env
)
->
GetStaticFieldID
(
env
,
ia_class
,
"preferIPv6Address"
,
"Z"
);
CHECK_NULL
(
ia_preferIPv6AddressID
);
if
(
!
ia_initialized
)
{
jclass
c
=
(
*
env
)
->
FindClass
(
env
,
"java/net/InetAddress"
);
CHECK_NULL
(
c
);
ia_class
=
(
*
env
)
->
NewGlobalRef
(
env
,
c
);
CHECK_NULL
(
ia_class
);
c
=
(
*
env
)
->
FindClass
(
env
,
"java/net/InetAddress$InetAddressHolder"
);
CHECK_NULL
(
c
);
iac_class
=
(
*
env
)
->
NewGlobalRef
(
env
,
c
);
ia_holderID
=
(
*
env
)
->
GetFieldID
(
env
,
ia_class
,
"holder"
,
"Ljava/net/InetAddress$InetAddressHolder;"
);
CHECK_NULL
(
ia_holderID
);
ia_preferIPv6AddressID
=
(
*
env
)
->
GetStaticFieldID
(
env
,
ia_class
,
"preferIPv6Address"
,
"Z"
);
CHECK_NULL
(
ia_preferIPv6AddressID
);
iac_addressID
=
(
*
env
)
->
GetFieldID
(
env
,
iac_class
,
"address"
,
"I"
);
CHECK_NULL
(
iac_addressID
);
iac_familyID
=
(
*
env
)
->
GetFieldID
(
env
,
iac_class
,
"family"
,
"I"
);
CHECK_NULL
(
iac_familyID
);
iac_hostNameID
=
(
*
env
)
->
GetFieldID
(
env
,
iac_class
,
"hostName"
,
"Ljava/lang/String;"
);
CHECK_NULL
(
iac_hostNameID
);
iac_origHostNameID
=
(
*
env
)
->
GetFieldID
(
env
,
iac_class
,
"originalHostName"
,
"Ljava/lang/String;"
);
iac_addressID
=
(
*
env
)
->
GetFieldID
(
env
,
iac_class
,
"address"
,
"I"
);
CHECK_NULL
(
iac_addressID
);
iac_familyID
=
(
*
env
)
->
GetFieldID
(
env
,
iac_class
,
"family"
,
"I"
);
CHECK_NULL
(
iac_familyID
);
iac_hostNameID
=
(
*
env
)
->
GetFieldID
(
env
,
iac_class
,
"hostName"
,
"Ljava/lang/String;"
);
CHECK_NULL
(
iac_hostNameID
);
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)
static
int
initialized
=
0
;
static
void
initInetAddr
s
(
JNIEnv
*
env
)
{
JNIEXPORT
void
JNICALL
initInetAddressID
s
(
JNIEnv
*
env
)
{
if
(
!
initialized
)
{
Java_java_net_InetAddress_init
(
env
,
0
);
JNU_CHECK_EXCEPTION
(
env
);
Java_java_net_Inet4Address_init
(
env
,
0
);
JNU_CHECK_EXCEPTION
(
env
);
Java_java_net_Inet6Address_init
(
env
,
0
);
JNU_CHECK_EXCEPTION
(
env
);
initialized
=
1
;
}
}
...
...
@@ -100,47 +103,32 @@ extern jfieldID iac_familyID;
* get_ methods that return objects return NULL on error.
*/
jobject
getInet6Address_scopeifname
(
JNIEnv
*
env
,
jobject
iaObj
)
{
jobject
holder
;
initInetAddrs
(
env
);
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia6_holder6ID
);
jobject
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia6_holder6ID
);
CHECK_NULL_RETURN
(
holder
,
NULL
);
return
(
*
env
)
->
GetObjectField
(
env
,
holder
,
ia6_scopeifnameID
);
}
int
setInet6Address_scopeifname
(
JNIEnv
*
env
,
jobject
iaObj
,
jobject
scopeifname
)
{
jobject
holder
;
initInetAddrs
(
env
);
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia6_holder6ID
);
jobject
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia6_holder6ID
);
CHECK_NULL_RETURN
(
holder
,
JNI_FALSE
);
(
*
env
)
->
SetObjectField
(
env
,
holder
,
ia6_scopeifnameID
,
scopeifname
);
return
JNI_TRUE
;
}
int
getInet6Address_scopeid_set
(
JNIEnv
*
env
,
jobject
iaObj
)
{
jobject
holder
;
initInetAddrs
(
env
);
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia6_holder6ID
);
jobject
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia6_holder6ID
);
CHECK_NULL_RETURN
(
holder
,
-
1
);
return
(
*
env
)
->
GetBooleanField
(
env
,
holder
,
ia6_scopeidsetID
);
}
int
getInet6Address_scopeid
(
JNIEnv
*
env
,
jobject
iaObj
)
{
jobject
holder
;
initInetAddrs
(
env
);
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia6_holder6ID
);
jobject
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia6_holder6ID
);
CHECK_NULL_RETURN
(
holder
,
-
1
);
return
(
*
env
)
->
GetIntField
(
env
,
holder
,
ia6_scopeidID
);
}
int
setInet6Address_scopeid
(
JNIEnv
*
env
,
jobject
iaObj
,
int
scopeid
)
{
jobject
holder
;
initInetAddrs
(
env
);
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia6_holder6ID
);
jobject
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia6_holder6ID
);
CHECK_NULL_RETURN
(
holder
,
JNI_FALSE
);
(
*
env
)
->
SetIntField
(
env
,
holder
,
ia6_scopeidID
,
scopeid
);
if
(
scopeid
>
0
)
{
...
...
@@ -154,7 +142,6 @@ int getInet6Address_ipaddress(JNIEnv *env, jobject iaObj, char *dest) {
jobject
holder
,
addr
;
jbyteArray
barr
;
initInetAddrs
(
env
);
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia6_holder6ID
);
CHECK_NULL_RETURN
(
holder
,
JNI_FALSE
);
addr
=
(
*
env
)
->
GetObjectField
(
env
,
holder
,
ia6_ipaddressID
);
...
...
@@ -167,7 +154,6 @@ int setInet6Address_ipaddress(JNIEnv *env, jobject iaObj, char *address) {
jobject
holder
;
jbyteArray
addr
;
initInetAddrs
(
env
);
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia6_holder6ID
);
CHECK_NULL_RETURN
(
holder
,
JNI_FALSE
);
addr
=
(
jbyteArray
)(
*
env
)
->
GetObjectField
(
env
,
holder
,
ia6_ipaddressID
);
...
...
@@ -181,53 +167,39 @@ int setInet6Address_ipaddress(JNIEnv *env, jobject iaObj, char *address) {
}
void
setInetAddress_addr
(
JNIEnv
*
env
,
jobject
iaObj
,
int
address
)
{
jobject
holder
;
initInetAddrs
(
env
);
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia_holderID
);
jobject
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia_holderID
);
(
*
env
)
->
SetIntField
(
env
,
holder
,
iac_addressID
,
address
);
}
void
setInetAddress_family
(
JNIEnv
*
env
,
jobject
iaObj
,
int
family
)
{
jobject
holder
;
initInetAddrs
(
env
);
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia_holderID
);
jobject
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia_holderID
);
(
*
env
)
->
SetIntField
(
env
,
holder
,
iac_familyID
,
family
);
}
void
setInetAddress_hostName
(
JNIEnv
*
env
,
jobject
iaObj
,
jobject
host
)
{
jobject
holder
;
initInetAddrs
(
env
);
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia_holderID
);
jobject
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia_holderID
);
(
*
env
)
->
SetObjectField
(
env
,
holder
,
iac_hostNameID
,
host
);
(
*
env
)
->
SetObjectField
(
env
,
holder
,
iac_origHostNameID
,
host
);
}
int
getInetAddress_addr
(
JNIEnv
*
env
,
jobject
iaObj
)
{
jobject
holder
;
initInetAddrs
(
env
);
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia_holderID
);
jobject
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia_holderID
);
return
(
*
env
)
->
GetIntField
(
env
,
holder
,
iac_addressID
);
}
int
getInetAddress_family
(
JNIEnv
*
env
,
jobject
iaObj
)
{
jobject
holder
;
initInetAddrs
(
env
);
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia_holderID
);
jobject
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia_holderID
);
return
(
*
env
)
->
GetIntField
(
env
,
holder
,
iac_familyID
);
}
jobject
getInetAddress_hostName
(
JNIEnv
*
env
,
jobject
iaObj
)
{
jobject
holder
;
initInetAddrs
(
env
);
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia_holderID
);
jobject
holder
=
(
*
env
)
->
GetObjectField
(
env
,
iaObj
,
ia_holderID
);
return
(
*
env
)
->
GetObjectField
(
env
,
holder
,
iac_hostNameID
);
}
JNIEXPORT
jobject
JNICALL
NET_SockaddrToInetAddress
(
JNIEnv
*
env
,
struct
sockaddr
*
him
,
int
*
port
)
{
jobject
iaObj
;
initInetAddrs
(
env
);
#ifdef AF_INET6
if
(
him
->
sa_family
==
AF_INET6
)
{
jbyteArray
ipaddress
;
...
...
@@ -239,31 +211,15 @@ NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port) {
jbyte
*
caddr
=
(
jbyte
*
)
&
(
him6
->
sin6_addr
);
if
(
NET_IsIPv4Mapped
(
caddr
))
{
int
address
;
static
jclass
inet4Cls
=
0
;
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
);
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ia4_class
,
ia4_ctrID
);
CHECK_NULL_RETURN
(
iaObj
,
NULL
);
address
=
NET_IPv4MappedToIPv4
(
caddr
);
setInetAddress_addr
(
env
,
iaObj
,
address
);
setInetAddress_family
(
env
,
iaObj
,
IPv4
);
}
else
{
static
jclass
inet6Cls
=
0
;
jint
scope
;
int
ret
;
if
(
inet6Cls
==
0
)
{
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
);
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ia6_class
,
ia6_ctrID
);
CHECK_NULL_RETURN
(
iaObj
,
NULL
);
ret
=
setInet6Address_ipaddress
(
env
,
iaObj
,
(
char
*
)
&
(
him6
->
sin6_addr
));
CHECK_NULL_RETURN
(
ret
,
NULL
);
...
...
@@ -276,16 +232,7 @@ NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port) {
#endif
/* AF_INET6 */
{
struct
sockaddr_in
*
him4
=
(
struct
sockaddr_in
*
)
him
;
static
jclass
inet4Cls
=
0
;
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
);
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ia4_class
,
ia4_ctrID
);
CHECK_NULL_RETURN
(
iaObj
,
NULL
);
setInetAddress_family
(
env
,
iaObj
,
IPv4
);
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;
extern
jfieldID
iac_origHostNameID
;
extern
jfieldID
ia_preferIPv6AddressID
;
JNIEXPORT
void
JNICALL
initInetAddressIDs
(
JNIEnv
*
env
);
/** (Inet6Address accessors)
* set_ methods return JNI_TRUE on success JNI_FALSE on error
* get_ methods that return int/boolean, return -1 on error
...
...
src/solaris/native/java/net/Inet4AddressImpl.c
浏览文件 @
fbfea144
...
...
@@ -51,29 +51,6 @@
#define HAS_GLIBC_GETHOSTBY_R 1
#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)
extern
jobjectArray
lookupIfLocalhost
(
JNIEnv
*
env
,
const
char
*
hostname
,
jboolean
includeV6
);
...
...
@@ -147,8 +124,8 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
int
getaddrinfo_error
=
0
;
struct
addrinfo
hints
,
*
res
,
*
resNew
=
NULL
;
i
f
(
!
initializeInetClasses
(
env
))
return
NULL
;
i
nitInetAddressIDs
(
env
);
JNU_CHECK_EXCEPTION_RETURN
(
env
,
NULL
)
;
if
(
IS_NULL
(
host
))
{
JNU_ThrowNullPointerException
(
env
,
"host is null"
);
...
...
@@ -242,7 +219,7 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
goto
cleanupAndReturn
;
}
ret
=
(
*
env
)
->
NewObjectArray
(
env
,
retLen
,
ni_iacl
s
,
NULL
);
ret
=
(
*
env
)
->
NewObjectArray
(
env
,
retLen
,
ia_clas
s
,
NULL
);
if
(
IS_NULL
(
ret
))
{
/* we may have memory to free at the end of this */
goto
cleanupAndReturn
;
...
...
@@ -252,7 +229,7 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
/* We need 4 bytes to store ipv4 address; */
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
))
{
/* we may have memory to free at the end of this */
ret
=
NULL
;
...
...
@@ -408,8 +385,8 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
int
error
=
0
;
struct
addrinfo
hints
,
*
res
,
*
resNew
=
NULL
;
i
f
(
!
initializeInetClasses
(
env
))
return
NULL
;
i
nitInetAddressIDs
(
env
);
JNU_CHECK_EXCEPTION_RETURN
(
env
,
NULL
)
;
if
(
IS_NULL
(
host
))
{
JNU_ThrowNullPointerException
(
env
,
"host is null"
);
...
...
@@ -487,7 +464,7 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
retLen
=
i
;
iterator
=
resNew
;
ret
=
(
*
env
)
->
NewObjectArray
(
env
,
retLen
,
ni_iacl
s
,
NULL
);
ret
=
(
*
env
)
->
NewObjectArray
(
env
,
retLen
,
ia_clas
s
,
NULL
);
if
(
IS_NULL
(
ret
))
{
/* we may have memory to free at the end of this */
...
...
@@ -496,7 +473,7 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
i
=
0
;
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
))
{
ret
=
NULL
;
goto
cleanupAndReturn
;
...
...
src/solaris/native/java/net/Inet6AddressImpl.c
浏览文件 @
fbfea144
...
...
@@ -117,44 +117,6 @@ Java_java_net_Inet6AddressImpl_getLocalHostName(JNIEnv *env, jobject this) {
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
/* also called from Inet4AddressImpl.c */
__private_extern__
jobjectArray
...
...
@@ -169,9 +131,8 @@ lookupIfLocalhost(JNIEnv *env, const char *hostname, jboolean includeV6)
jboolean
includeLoopback
=
JNI_FALSE
;
jobject
name
;
// Make sure static variables we need are set.
if
(
!
initializeInetClasses
(
env
))
return
NULL
;
initInetAddressIDs
(
env
);
JNU_CHECK_EXCEPTION_RETURN
(
env
,
NULL
);
/* If the requested name matches this host's hostname, return IP addresses
* from all attached interfaces. (#2844683 et al) This prevents undesired
...
...
@@ -234,10 +195,10 @@ lookupIfLocalhost(JNIEnv *env, const char *hostname, jboolean includeV6)
/* Create and fill the Java array. */
int
arraySize
=
addrs4
+
addrs6
-
(
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
(
preferIPv6Address
)
{
if
(
(
*
env
)
->
GetStaticBooleanField
(
env
,
ia_class
,
ia_preferIPv6AddressID
)
)
{
i
=
includeLoopback
?
addrs6
:
(
addrs6
-
numV6Loopbacks
);
j
=
0
;
}
else
{
...
...
@@ -301,8 +262,8 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
struct
addrinfo
hints
,
*
res
,
*
resNew
=
NULL
;
#endif
/* AF_INET6 */
i
f
(
!
initializeInetClasses
(
env
))
return
NULL
;
i
nitInetAddressIDs
(
env
);
JNU_CHECK_EXCEPTION_RETURN
(
env
,
NULL
)
;
if
(
IS_NULL
(
host
))
{
JNU_ThrowNullPointerException
(
env
,
"host is null"
);
...
...
@@ -429,14 +390,14 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
retLen
=
i
;
iterator
=
resNew
;
ret
=
(
*
env
)
->
NewObjectArray
(
env
,
retLen
,
ni_iacl
s
,
NULL
);
ret
=
(
*
env
)
->
NewObjectArray
(
env
,
retLen
,
ia_clas
s
,
NULL
);
if
(
IS_NULL
(
ret
))
{
/* we may have memory to free at the end of this */
goto
cleanupAndReturn
;
}
if
(
preferIPv6Address
)
{
if
(
(
*
env
)
->
GetStaticBooleanField
(
env
,
ia_class
,
ia_preferIPv6AddressID
)
)
{
/* AF_INET addresses will be offset by inet6Count */
inetIndex
=
inet6Count
;
inet6Index
=
0
;
...
...
@@ -449,7 +410,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
while
(
iterator
!=
NULL
)
{
int
ret1
;
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
))
{
ret
=
NULL
;
goto
cleanupAndReturn
;
...
...
@@ -461,7 +422,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
}
else
if
(
iterator
->
ai_family
==
AF_INET6
)
{
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
))
{
ret
=
NULL
;
goto
cleanupAndReturn
;
...
...
@@ -555,7 +516,7 @@ Java_java_net_Inet6AddressImpl_getHostByAddr(JNIEnv *env, jobject this,
if
(
!
error
)
{
ret
=
(
*
env
)
->
NewStringUTF
(
env
,
host
);
CHECK_NULL
(
ret
);
CHECK_NULL
_RETURN
(
ret
,
NULL
);
}
#endif
/* AF_INET6 */
...
...
src/solaris/native/java/net/NetworkInterface.c
浏览文件 @
fbfea144
...
...
@@ -133,12 +133,7 @@ jfieldID ni_parentID;
jfieldID
ni_defaultIndexID
;
jmethodID
ni_ctrID
;
static
jclass
ni_iacls
;
static
jclass
ni_ia4cls
;
static
jclass
ni_ia6cls
;
static
jclass
ni_ibcls
;
static
jmethodID
ni_ia4ctrID
;
static
jmethodID
ni_ia6ctrID
;
static
jmethodID
ni_ibctrID
;
static
jfieldID
ni_ibaddressID
;
static
jfieldID
ni_ib4broadcastID
;
...
...
@@ -215,26 +210,10 @@ JNIEXPORT void JNICALL Java_java_net_NetworkInterface_init
CHECK_NULL
(
ni_parentID
);
ni_ctrID
=
(
*
env
)
->
GetMethodID
(
env
,
ni_class
,
"<init>"
,
"()V"
);
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"
);
CHECK_NULL
(
ni_ibcls
);
ni_ibcls
=
(
*
env
)
->
NewGlobalRef
(
env
,
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"
);
CHECK_NULL
(
ni_ibctrID
);
ni_ibaddressID
=
(
*
env
)
->
GetFieldID
(
env
,
ni_ibcls
,
"address"
,
...
...
@@ -247,6 +226,9 @@ JNIEXPORT void JNICALL Java_java_net_NetworkInterface_init
CHECK_NULL
(
ni_ib4maskID
);
ni_defaultIndexID
=
(
*
env
)
->
GetStaticFieldID
(
env
,
ni_class
,
"defaultIndex"
,
"I"
);
CHECK_NULL
(
ni_defaultIndexID
);
initInetAddressIDs
(
env
);
}
/*
...
...
@@ -700,7 +682,7 @@ static jobject createNetworkInterface(JNIEnv *env, netif *ifs) {
}
// 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
)
{
return
NULL
;
}
...
...
@@ -717,7 +699,7 @@ static jobject createNetworkInterface(JNIEnv *env, netif *ifs) {
jobject
ibObj
=
NULL
;
if
(
addrP
->
family
==
AF_INET
)
{
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ni_ia4cls
,
ni_ia4
ctrID
);
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ia4_class
,
ia4_
ctrID
);
if
(
iaObj
)
{
setInetAddress_addr
(
env
,
iaObj
,
htonl
(
((
struct
sockaddr_in
*
)
addrP
->
addr
)
->
sin_addr
.
s_addr
));
...
...
@@ -729,7 +711,7 @@ static jobject createNetworkInterface(JNIEnv *env, netif *ifs) {
(
*
env
)
->
SetObjectField
(
env
,
ibObj
,
ni_ibaddressID
,
iaObj
);
if
(
addrP
->
brdcast
)
{
jobject
ia2Obj
=
NULL
;
ia2Obj
=
(
*
env
)
->
NewObject
(
env
,
ni_ia4cls
,
ni_ia4
ctrID
);
ia2Obj
=
(
*
env
)
->
NewObject
(
env
,
ia4_class
,
ia4_
ctrID
);
if
(
ia2Obj
)
{
setInetAddress_addr
(
env
,
ia2Obj
,
htonl
(
((
struct
sockaddr_in
*
)
addrP
->
brdcast
)
->
sin_addr
.
s_addr
));
...
...
@@ -747,7 +729,7 @@ static jobject createNetworkInterface(JNIEnv *env, netif *ifs) {
#if defined(AF_INET6)
if
(
addrP
->
family
==
AF_INET6
)
{
int
scope
=
0
;
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ni_ia6cls
,
ni_ia6
ctrID
);
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ia6_class
,
ia6_
ctrID
);
if
(
iaObj
)
{
jboolean
ret
=
setInet6Address_ipaddress
(
env
,
iaObj
,
(
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) {
IO_fd_fdID
=
NET_GetFileDescriptorID
(
env
);
CHECK_NULL
(
IO_fd_fdID
);
Java_java_net_InetAddress_init
(
env
,
0
);
Java_java_net_Inet4Address_init
(
env
,
0
);
Java_java_net_Inet6Address_init
(
env
,
0
);
initInetAddressIDs
(
env
);
JNU_CHECK_EXCEPTION
(
env
);
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) {
IO_fd_fdID
=
NET_GetFileDescriptorID
(
env
);
CHECK_NULL
(
IO_fd_fdID
);
initInetAddressIDs
(
env
);
JNU_CHECK_EXCEPTION
(
env
);
/* Create the marker fd used for dup2 */
marker_fd
=
getMarkerFD
();
}
...
...
src/solaris/native/sun/nio/ch/IOUtil.c
浏览文件 @
fbfea144
...
...
@@ -35,6 +35,7 @@
#include "java_lang_Integer.h"
#include "nio.h"
#include "nio_util.h"
#include "net_util.h"
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)
{
CHECK_NULL
(
clazz
=
(
*
env
)
->
FindClass
(
env
,
"java/io/FileDescriptor"
));
CHECK_NULL
(
fd_fdID
=
(
*
env
)
->
GetFieldID
(
env
,
clazz
,
"fd"
,
"I"
));
initInetAddressIDs
(
env
);
}
JNIEXPORT
jboolean
JNICALL
...
...
src/solaris/native/sun/nio/ch/sctp/SctpNet.c
浏览文件 @
fbfea144
...
...
@@ -157,6 +157,7 @@ Java_sun_nio_ch_sctp_SctpNet_init
}
preCloseFD
=
sp
[
0
];
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) {
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
* code only works for addresses of type INET. The translation
...
...
@@ -143,19 +138,8 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
jobjectArray
ret
=
NULL
;
if
(
!
initialized
)
{
ni_iacls
=
(
*
env
)
->
FindClass
(
env
,
"java/net/InetAddress"
);
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
;
}
initInetAddressIDs
(
env
);
JNU_CHECK_EXCEPTION_RETURN
(
env
,
NULL
);
if
(
IS_NULL
(
host
))
{
JNU_ThrowNullPointerException
(
env
,
"host argument"
);
...
...
@@ -199,13 +183,13 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
address
|=
(
addr
[
1
]
<<
8
)
&
0xff00
;
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
))
{
goto
cleanupAndReturn
;
}
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ni_ia4cls
,
ni_ia4
ctrID
);
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ia4_class
,
ia4_
ctrID
);
if
(
IS_NULL
(
iaObj
))
{
ret
=
NULL
;
goto
cleanupAndReturn
;
...
...
@@ -229,7 +213,7 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
addrp
++
;
}
ret
=
(
*
env
)
->
NewObjectArray
(
env
,
i
,
ni_iacl
s
,
NULL
);
ret
=
(
*
env
)
->
NewObjectArray
(
env
,
i
,
ia_clas
s
,
NULL
);
if
(
IS_NULL
(
ret
))
{
goto
cleanupAndReturn
;
...
...
@@ -238,7 +222,7 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
addrp
=
(
struct
in_addr
**
)
hp
->
h_addr_list
;
i
=
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
))
{
ret
=
NULL
;
goto
cleanupAndReturn
;
...
...
src/windows/native/java/net/Inet6AddressImpl.c
浏览文件 @
fbfea144
...
...
@@ -74,13 +74,6 @@ Java_java_net_Inet6AddressImpl_getLocalHostName (JNIEnv *env, jobject this) {
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
Java_java_net_Inet6AddressImpl_lookupAllHostAddr
(
JNIEnv
*
env
,
jobject
this
,
jstring
host
)
{
...
...
@@ -88,30 +81,13 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
jobjectArray
ret
=
0
;
int
retLen
=
0
;
jboolean
preferIPv6Address
;
static
jfieldID
ia_preferIPv6AddressID
;
int
error
=
0
;
struct
addrinfo
hints
,
*
res
,
*
resNew
=
NULL
;
if
(
!
initialized
)
{
ni_iacls
=
(
*
env
)
->
FindClass
(
env
,
"java/net/InetAddress"
);
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
;
}
initInetAddressIDs
(
env
);
JNU_CHECK_EXCEPTION_RETURN
(
env
,
NULL
);
if
(
IS_NULL
(
host
))
{
JNU_ThrowNullPointerException
(
env
,
"host is null"
);
return
0
;
...
...
@@ -119,17 +95,6 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
hostname
=
JNU_GetStringPlatformChars
(
env
,
host
,
JNI_FALSE
);
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 */
preferIPv6Address
=
(
*
env
)
->
GetStaticBooleanField
(
env
,
ia_class
,
ia_preferIPv6AddressID
);
...
...
@@ -231,7 +196,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
retLen
=
i
;
iterator
=
resNew
;
i
=
0
;
ret
=
(
*
env
)
->
NewObjectArray
(
env
,
retLen
,
ni_iacl
s
,
NULL
);
ret
=
(
*
env
)
->
NewObjectArray
(
env
,
retLen
,
ia_clas
s
,
NULL
);
if
(
IS_NULL
(
ret
))
{
/* we may have memory to free at the end of this */
...
...
@@ -248,7 +213,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
while
(
iterator
!=
NULL
)
{
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
))
{
ret
=
NULL
;
goto
cleanupAndReturn
;
...
...
@@ -259,7 +224,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
inetIndex
++
;
}
else
if
(
iterator
->
ai_family
==
AF_INET6
)
{
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
))
{
ret
=
NULL
;
goto
cleanupAndReturn
;
...
...
@@ -349,7 +314,7 @@ Java_java_net_Inet6AddressImpl_getHostByAddr(JNIEnv *env, jobject this,
if
(
!
error
)
{
ret
=
(
*
env
)
->
NewStringUTF
(
env
,
host
);
CHECK_NULL
(
ret
);
CHECK_NULL
_RETURN
(
ret
,
NULL
);
}
if
(
ret
==
NULL
)
{
...
...
src/windows/native/java/net/NetworkInterface.c
浏览文件 @
fbfea144
...
...
@@ -65,13 +65,6 @@ jfieldID ni_bindsID; /* NetworkInterface.bindings */
jfieldID
ni_nameID
;
/* NetworkInterface.name */
jfieldID
ni_displayNameID
;
/* NetworkInterface.displayName */
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 */
jmethodID
ni_ibctrID
;
/* InterfaceAddress() */
...
...
@@ -515,26 +508,6 @@ Java_java_net_NetworkInterface_init(JNIEnv *env, jclass cls)
CHECK_NULL
(
ni_childsID
);
ni_ctor
=
(
*
env
)
->
GetMethodID
(
env
,
ni_class
,
"<init>"
,
"()V"
);
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"
);
CHECK_NULL
(
ni_ibcls
);
ni_ibcls
=
(
*
env
)
->
NewGlobalRef
(
env
,
ni_ibcls
);
...
...
@@ -546,6 +519,9 @@ Java_java_net_NetworkInterface_init(JNIEnv *env, jclass cls)
ni_ibbroadcastID
=
(
*
env
)
->
GetFieldID
(
env
,
ni_ibcls
,
"broadcast"
,
"Ljava/net/Inet4Address;"
);
CHECK_NULL
(
ni_ibbroadcastID
);
ni_ibmaskID
=
(
*
env
)
->
GetFieldID
(
env
,
ni_ibcls
,
"maskLength"
,
"S"
);
CHECK_NULL
(
ni_ibmaskID
);
initInetAddressIDs
(
env
);
}
/*
...
...
@@ -591,7 +567,7 @@ jobject createNetworkInterface
return
NULL
;
}
}
addrArr
=
(
*
env
)
->
NewObjectArray
(
env
,
netaddrCount
,
ni_iacl
s
,
NULL
);
addrArr
=
(
*
env
)
->
NewObjectArray
(
env
,
netaddrCount
,
ia_clas
s
,
NULL
);
if
(
addrArr
==
NULL
)
{
free_netaddr
(
netaddrP
);
return
NULL
;
...
...
@@ -609,7 +585,7 @@ jobject createNetworkInterface
jobject
iaObj
,
ia2Obj
;
jobject
ibObj
=
NULL
;
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
)
{
free_netaddr
(
netaddrP
);
return
NULL
;
...
...
@@ -624,7 +600,7 @@ jobject createNetworkInterface
return
NULL
;
}
(
*
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
)
{
free_netaddr
(
netaddrP
);
return
NULL
;
...
...
@@ -636,7 +612,7 @@ jobject createNetworkInterface
}
}
else
/* AF_INET6 */
{
int
scope
;
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ni_ia6cls
,
ni_ia6
ctrID
);
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ia6_class
,
ia6_
ctrID
);
if
(
iaObj
)
{
int
ret
=
setInet6Address_ipaddress
(
env
,
iaObj
,
(
jbyte
*
)
&
(
addrs
->
addr
.
him6
.
sin6_addr
.
s6_addr
));
if
(
ret
==
JNI_FALSE
)
{
...
...
src/windows/native/java/net/NetworkInterface.h
浏览文件 @
fbfea144
...
...
@@ -70,16 +70,6 @@ extern jfieldID ni_nameID; /* NetworkInterface.name */
extern
jfieldID
ni_displayNameID
;
/* NetworkInterface.displayName */
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
jmethodID
ni_ibctrID
;
/* InterfaceAddress() */
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)
}
}
addrArr
=
(
*
env
)
->
NewObjectArray
(
env
,
netaddrCount
,
ni_iacl
s
,
NULL
);
addrArr
=
(
*
env
)
->
NewObjectArray
(
env
,
netaddrCount
,
ia_clas
s
,
NULL
);
if
(
addrArr
==
NULL
)
{
return
NULL
;
}
...
...
@@ -531,7 +531,7 @@ static jobject createNetworkInterfaceXP(JNIEnv *env, netif *ifs)
jobject
iaObj
,
ia2Obj
;
jobject
ibObj
=
NULL
;
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
)
{
return
NULL
;
}
...
...
@@ -545,7 +545,7 @@ static jobject createNetworkInterfaceXP(JNIEnv *env, netif *ifs)
return
NULL
;
}
(
*
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
)
{
free_netaddr
(
netaddrP
);
return
NULL
;
...
...
@@ -556,7 +556,7 @@ static jobject createNetworkInterfaceXP(JNIEnv *env, netif *ifs)
(
*
env
)
->
SetObjectArrayElement
(
env
,
bindsArr
,
bind_index
++
,
ibObj
);
}
else
/* AF_INET6 */
{
int
scope
;
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ni_ia6cls
,
ni_ia6
ctrID
);
iaObj
=
(
*
env
)
->
NewObject
(
env
,
ia6_class
,
ia6_
ctrID
);
if
(
iaObj
)
{
int
ret
=
setInet6Address_ipaddress
(
env
,
iaObj
,
(
jbyte
*
)
&
(
addrs
->
addr
.
him6
.
sin6_addr
.
s6_addr
));
if
(
ret
==
JNI_FALSE
)
{
...
...
src/windows/native/sun/nio/ch/IOUtil.c
浏览文件 @
fbfea144
...
...
@@ -33,6 +33,7 @@
#include "nio.h"
#include "nio_util.h"
#include "net_util.h"
#include "sun_nio_ch_IOUtil.h"
/* 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)
CHECK_NULL
(
clazz
=
(
*
env
)
->
FindClass
(
env
,
"java/io/FileDescriptor"
));
CHECK_NULL
(
fd_fdID
=
(
*
env
)
->
GetFieldID
(
env
,
clazz
,
"fd"
,
"I"
));
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录