harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r389887 [1/2] - in /incubator/harmony/enhanced/classlib/trunk: modules/luni/src/main/java/java/net/ native-src/linux.IA32/luni/ native-src/shared/luni/ native-src/win.IA32/luni/
Date Wed, 29 Mar 2006 20:58:56 GMT
Author: tellison
Date: Wed Mar 29 12:58:53 2006
New Revision: 389887

URL: http://svn.apache.org/viewcvs?rev=389887&view=rev
Log:
Apply patch HARMONY-272 (Redudant native codes should be removed from LUNI component)

Removed:
    incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/luni/pdsimpl.c
    incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/fileis.c
    incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/fileos.c
    incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/pmsimpl.c
    incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/pmsimpl.h
    incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/psimpl2.c
    incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/psimpl2.h
    incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/pssimpl.c
    incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/pssimpl.h
    incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/rafile.c
    incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/simpl.c
    incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/luni/pdsimpl.c
Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/DatagramSocket.java
    incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/luni/OSNetworkSystem.c
    incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/luni/libhyluni.exp
    incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/luni/makefile
    incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/nethelp.c
    incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/nethelp.h
    incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/socket.c
    incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/luni/OSNetworkSystem.c
    incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/luni/hyluni.def
    incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/luni/makefile

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/DatagramSocket.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/DatagramSocket.java?rev=389887&r1=389886&r2=389887&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/DatagramSocket.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/DatagramSocket.java Wed Mar 29 12:58:53 2006
@@ -17,10 +17,10 @@
 
 
 import java.io.IOException;
-import java.security.AccessController;
+
+import org.apache.harmony.luni.net.SocketImplProvider;
 
 import com.ibm.oti.util.Msg;
-import com.ibm.oti.util.PriviAction;
 
 /**
  * This class models a socket for sending & receiving datagram packets.
@@ -173,7 +173,7 @@
 	synchronized void createSocket(int aPort, InetAddress addr)
 			throws SocketException {
 		impl = factory != null ? factory.createDatagramSocketImpl()
-				: createSocketImpl();
+				: SocketImplProvider.getDatagramSocketImpl();
 		impl.create();
 		try {
 			impl.bind(aPort, addr);
@@ -184,31 +184,6 @@
 		}
 	}
 
-	/**
-	 * Answer a concrete instance of DatagramSocketImpl, either as declared in
-	 * the system properties or the default, PlainDatagramSocketImpl. The latter
-	 * does not support security checks.
-	 * 
-	 * @return DatagramSocketImpl the concrete instance
-	 * 
-	 * @exception SocketException
-	 *                if an error occurs during the instantiation of a type
-	 *                declared in the system properties
-	 */
-	DatagramSocketImpl createSocketImpl() throws SocketException {
-		Object socketImpl = null;
-		String prefix;
-		prefix = (String) AccessController.doPrivileged(new PriviAction(
-				"impl.prefix", "Plain"));
-		try {
-			Class aClass = Class.forName("java.net." + prefix
-					+ "DatagramSocketImpl");
-			socketImpl = aClass.newInstance();
-		} catch (Exception e) {
-			throw new SocketException(Msg.getString("K0033"));
-		}
-		return (DatagramSocketImpl) socketImpl;
-	}
 
 	/**
 	 * Returns an {@link InetAddress} instance representing the address this
@@ -551,7 +526,7 @@
 			checkListen(((InetSocketAddress) localAddr).getPort());
 		}
 		impl = factory != null ? factory.createDatagramSocketImpl()
-				: createSocketImpl();
+				: SocketImplProvider.getDatagramSocketImpl();
 		impl.create();
 		if (localAddr != null) {
 			try {

Modified: incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/luni/OSNetworkSystem.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/luni/OSNetworkSystem.c?rev=389887&r1=389886&r2=389887&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/luni/OSNetworkSystem.c (original)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/luni/OSNetworkSystem.c Wed Mar 29 12:58:53 2006
@@ -23,9 +23,157 @@
 #include "jclglob.h"
 
 
+void setSocketImplPort (JNIEnv * env, jobject socketImpl, U_16 hPort);
+void setSocketImplAddress (JNIEnv * env, jobject socketImpl,
+	 jobject anInetAddress);
+void updateSocket (JNIEnv * env, hysockaddr_t sockaddrP, hysocket_t socketNew,
+       jobject socketImpl, jobject fileDescriptorSocketImpl);
 void * getConnectContext(JNIEnv	*env,jobject longclass);
 void setConnectContext(JNIEnv *env,jobject longclass,U_8 * context);
 
+void setDatagramPacketAddress (JNIEnv *	env, jobject datagramPacket,
+	     jobject anInetAddress);
+void setDatagramPacketPort (JNIEnv * env, jobject datagramPacket, U_16 hPort);
+void updateAddress (JNIEnv * env, hysockaddr_t sockaddrP,
+	jobject	senderAddress);	
+void updatePacket (JNIEnv * env, hysockaddr_t sockaddrP,
+       jobject datagramPacket, I_32 bytesRead);	
+void setDatagramPacketLength (JNIEnv * env, jobject datagramPacket,
+	    I_32 length);
+int 
+selectRead (JNIEnv * env,hysocket_t hysocketP, I_32 uSecTime, BOOLEAN accept);
+
+/**
+ * A helper method, to set the remote address into the DatagramPacket.
+ *
+ * @param env		pointer	to the JNI library
+ * @param datagramPacket  pointer to the java DatagramPacket object to update
+ * @param anInetAddress	  pointer to the java InetAddress to update the	packet with
+ *
+ */
+
+void
+setDatagramPacketAddress (JNIEnv * env,	jobject	datagramPacket,	
+	jobject	anInetAddress)
+{
+  /*----------------------former cache get/set ----------------------------
+  //jfieldID fid = JCL_CACHE_GET (env, FID_java_net_DatagramPacket_address);
+  */
+  jfieldID fid = getJavaNetDatagramPacketAddress(env);
+  (*env)->SetObjectField (env, datagramPacket, fid, anInetAddress);
+}
+
+/**
+ * A helper method, to set the remote port into	the java DatagramPacket.
+ *
+ * @param env		pointer	to the JNI library
+ * @param datagramPacket  pointer to the java DatagramPacket object to update
+ * @param hPort		the port value to update the packet with, in host order	
+ */
+
+void
+setDatagramPacketPort (JNIEnv *	env, jobject datagramPacket, U_16 hPort)
+{
+  /*----------------------former cache get/set ----------------------------
+  //jfieldID fid = JCL_CACHE_GET (env, FID_java_net_DatagramPacket_port);
+  */
+  jfieldID fid = getJavaNetDatagramPacketPort(env);
+  (*env)->SetIntField (env, datagramPacket, fid, hPort);
+}
+
+/**
+ * A helper method, to set the data length into	a java DatagramPacket.
+ *
+ * @param env		pointer	to the JNI library
+ * @param datagramPacket  pointer to the java DatagramPacket object to update
+ * @param length	  the length value to update the packet	with
+ */
+
+void
+setDatagramPacketLength	(JNIEnv	* env, jobject datagramPacket, I_32 length)
+{
+  /*----------------------former cache get/set ----------------------------
+  //jfieldID fid = JCL_CACHE_GET (env, FID_java_net_DatagramPacket_length);
+  */
+  jfieldID fid = getJavaNetDatagramPacketLength(env);
+  (*env)->SetIntField (env, datagramPacket, fid, length);
+}
+
+/**
+ * A helper method, to update the java DatagramPacket argument.	 Used after receiving a	datagram packet, 
+ * to update the DatagramPacket	with the network address and port of the sending machine.
+ *
+ * @param env		pointer	to the JNI library
+ * @param sockaddrP	pointer	to the hysockaddr struct with the sending host address & port
+ * @param datagramPacket  pointer to the java DatagramPacket object to update
+ * @param bytesRead	the bytes read value to	update the packet with
+ */
+
+void
+updatePacket (JNIEnv * env, hysockaddr_t sockaddrP, jobject datagramPacket,
+	I_32 bytesRead)	
+{
+  PORT_ACCESS_FROM_ENV (env);
+  jobject anInetAddress;
+  U_16 nPort;
+  U_32 length;
+  U_32 scope_id	= 0;
+  jbyte	byte_array[HYSOCK_INADDR6_LEN];	
+  hysock_sockaddr_address6 (sockaddrP, (U_8 *) byte_array, &length,
+	  &scope_id);
+
+  nPort	= hysock_sockaddr_port (sockaddrP);
+  anInetAddress	=
+    newJavaNetInetAddressGenericB (env,	byte_array, length, scope_id);
+
+  setDatagramPacketAddress (env, datagramPacket, anInetAddress);
+  setDatagramPacketPort	(env, datagramPacket, hysock_ntohs (nPort));
+  setDatagramPacketLength (env,	datagramPacket,	bytesRead);
+}
+
+/**
+ * A helper method, to set address of the java InetAddress argument.
+ *
+ * @param env		pointer	to the JNI library
+ * @param sockaddrP	pointer	to the hysockaddr struct containing the	network	address	
+ * @param senderAddress	pointer	to the java InetAddress	object to update
+ */
+
+void
+updateAddress (JNIEnv *	env, hysockaddr_t sockaddrP, jobject senderAddress)
+{
+  PORT_ACCESS_FROM_ENV (env);
+  jbyte	ipv4Addr[16];
+  U_32 length;
+  U_32 scope_id	= 0;
+  hysock_sockaddr_address6 (sockaddrP, (U_8 *) ipv4Addr, &length, &scope_id);
+  /*-------------- Here is the cache get/set,remain for next change  ---------------
+  
+  //(*env)->SetObjectField (env, senderAddress,	
+  //	  JCL_CACHE_GET	(env,
+  //	     FID_java_net_InetAddress_address),	
+  //	  newJavaByteArray (env, ipv4Addr, length));
+  */
+  (*env)->SetObjectField (env, senderAddress,
+	getJavaNetInetAddressIpaddress(env),
+	newJavaByteArray (env, ipv4Addr, length));
+  if (jcl_supports_ipv6	(env) && (scope_id != 0))
+    {
+      jclass tempClass = getJavaNetInetAddressClass(env);
+      jfieldID fid = NULL;
+
+      fid = (*env)->GetFieldID (env, tempClass,	"scope_id", "I");
+      if ((*env)->ExceptionCheck (env))	
+	{
+	  (*env)->ExceptionClear (env);	
+	}
+      else
+	{
+	  (*env)->SetIntField (env, senderAddress, fid,	scope_id);
+	}
+    }
+}
+
 /**
  * A helper method, to set the connect context to a Long object.
  *
@@ -38,7 +186,7 @@
   jfieldID descriptorFID;
   descriptorCLS	= (*env)->FindClass (env, "java/lang/Long");
   descriptorFID	= (*env)->GetFieldID (env, descriptorCLS, "value","J");	
-  (*env)->SetLongField(env,longclass,descriptorFID,(jlong)context);
+  (*env)->SetLongField(env,  longclass,	descriptorFID,(jlong)context);
 };
 
 /**
@@ -51,13 +199,83 @@
 getConnectContext(JNIEnv *env,jobject longclass){
   jclass descriptorCLS;	
   jfieldID descriptorFID;
-  void * retConnectContext;
   descriptorCLS	= (*env)->FindClass (env, "java/lang/Long");
   descriptorFID	= (*env)->GetFieldID (env, descriptorCLS, "value", "J");
-  retConnectContext = (void *) ((*env)->GetLongField (env, longclass, descriptorFID));
-  return retConnectContext;
+  return  (void	*) ((*env)->GetLongField (env, longclass, descriptorFID));
+};
+
+/**
+ * A helper method, to set the remote address into the socketImpl.
+ *
+ * @param env		pointer	to the JNI library
+ * @param socketImpl	  pointer to the java SocketImpl object	to update
+ * @param anInetAddress	  pointer to the java InetAddress to update the	socket with
+ */
+
+void
+setSocketImplAddress (JNIEnv * env, jobject socketImpl,	jobject	anInetAddress)
+{
+  /*-------------- Here is the cache get/set,remain for next change  ---------------
+  //jfieldID fid = JCL_CACHE_GET (env, FID_java_net_SocketImpl_address);
+  */
+  jfieldID fid = getJavaNetSocketImplAddress(env);
+  (*env)->SetObjectField (env, socketImpl, fid,	anInetAddress);	
 }
 
+/**
+ * A helper method, to set the remote port into	the socketImpl.	
+ *
+ * @param env	      pointer to the JNI library
+ * @param socketImpl	pointer	to the java SocketImpl object to update	
+ * @param hPort	      the port number, in host order, to update	the socket with	
+ */
+
+void
+setSocketImplPort (JNIEnv * env, jobject socketImpl, U_16 hPort)
+{
+  /*----------------------former cache get/set ---------------
+  //jfieldID fid = JCL_CACHE_GET (env, FID_java_net_SocketImpl_port);
+  */
+  jfieldID fid = getJavaNetSocketImplPort( env);
+  (*env)->SetIntField (env, socketImpl,	fid, hPort);
+}
+
+/**
+ * A helper method, to update the java SocketImpl argument.  Used after	connecting, to 'link' the 
+ * system socket with the java socketImpl and update the address/port fields with the values
+ * corresponding to the	remote machine.	
+ *
+ * @param env			pointer	to the JNI library
+ * @param sockaddrP		pointer	to the hysockaddr struct with the remote host address &	port
+ * @param socketNew		pointer	to the new hysocket
+ * @param socketImpl		  pointer to the new java (connected) socket
+ * @param fileDescriptorSocketImpl    pointer to the java file descriptor of the socketImpl
+ */
+
+void
+updateSocket (JNIEnv * env,
+	hysockaddr_t sockaddrP,	hysocket_t socketNew,
+	jobject	socketImpl, jobject fileDescriptorSocketImpl)
+{
+  PORT_ACCESS_FROM_ENV (env);
+  U_8 nipAddress[HYSOCK_INADDR6_LEN];
+  U_32 length;
+  jobject anInetAddress;
+  U_16 nPort;
+  U_32 scope_id	= 0;
+
+  hysock_sockaddr_address6 (sockaddrP, nipAddress, &length, &scope_id);	
+  nPort	= hysock_sockaddr_port (sockaddrP);
+  anInetAddress	=
+    newJavaNetInetAddressGenericB (env,	nipAddress, length, scope_id);
+
+  setJavaIoFileDescriptorContents (env,	fileDescriptorSocketImpl,
+	      socketNew);
+  setSocketImplAddress (env, socketImpl, anInetAddress);
+  setSocketImplPort (env, socketImpl, hysock_ntohs (nPort));
+}
+
+
 /*----------------------former cache get/set ------------------------------------
 /*
  * Class:     org_apache_harmony_luni_platform_OSNetworkSystem
@@ -175,7 +393,7 @@
 #define	INTERNAL_RECEIVE_BUFFER_MAX 2048
   U_8 internalBuffer[INTERNAL_RECEIVE_BUFFER_MAX];
 
-  hysocketP =getJavaIoFileDescriptorContentsAsPointer (env, fileDescriptor);
+  hysocketP =getJavaIoFileDescriptorContentsAsAPointer (env, fileDescriptor);
 
   /*----------------the older form,nearly the same with below------------
   //result = pollSelectRead (env, fileDescriptor, timeout, TRUE);
@@ -272,7 +490,7 @@
   while	(sent <	count)
     {
       socketP =	
-	getJavaIoFileDescriptorContentsAsPointer (env,	fileDescriptor);
+	getJavaIoFileDescriptorContentsAsAPointer (env,	fileDescriptor);
       if (!hysock_socketIsValid	(socketP))
 	{
 	  if (((U_8 *)message) != internalBuffer)
@@ -326,7 +544,7 @@
 	PORT_ACCESS_FROM_ENV (env);
 	hysocket_t socketP;
 	int result;		
-	socketP	=getJavaIoFileDescriptorContentsAsPointer (env, afd);
+	socketP	=getJavaIoFileDescriptorContentsAsAPointer (env, afd);
 	if (!hysock_socketIsValid (socketP))
     	{
       		//throwJavaNetSocketException (env,	HYPORT_ERROR_SOCKET_BADSOCKET);	
@@ -362,7 +580,7 @@
   hysockaddr_struct sockaddrP;
   U_32 scope_id	= 0;
 
-  socketP = getJavaIoFileDescriptorContentsAsPointer (env, fileDescriptor);
+  socketP = getJavaIoFileDescriptorContentsAsAPointer (env, fileDescriptor);
   if (!hysock_socketIsValid (socketP))
     {
       throwJavaNetSocketException (env,	HYPORT_ERROR_SOCKET_BADSOCKET);	
@@ -425,7 +643,7 @@
   U_8 *	context	= NULL;	
   context = getConnectContext(env,passContext);	
   
-  socketP = getJavaIoFileDescriptorContentsAsPointer (env, fileDescriptor);
+  socketP = getJavaIoFileDescriptorContentsAsAPointer (env, fileDescriptor);
 
   if (!hysock_socketIsValid (socketP))
     {
@@ -509,7 +727,7 @@
   hysockaddr_struct sockaddrP;
   U_32 scope_id	= 0;
 
-  socketP = getJavaIoFileDescriptorContentsAsPointer (env, fileDescriptor);
+  socketP = getJavaIoFileDescriptorContentsAsAPointer (env, fileDescriptor);
   if (!hysock_socketIsValid (socketP))
     {
       throwJavaNetSocketException (env,	HYPORT_ERROR_SOCKET_BADSOCKET);	
@@ -557,7 +775,7 @@
   hysocket_t socketP;
   I_32 result;
 
-  socketP = getJavaIoFileDescriptorContentsAsPointer (env, fileDescriptor);
+  socketP = getJavaIoFileDescriptorContentsAsAPointer (env, fileDescriptor);
   if (!hysock_socketIsValid (socketP))
     {
       throwJavaNetSocketException (env,	HYPORT_ERROR_SOCKET_BADSOCKET);	
@@ -587,7 +805,7 @@
 
   I_32 result, flags = 0;
 
-  hysocketP = getJavaIoFileDescriptorContentsAsPointer	(env, fileDescriptor);
+  hysocketP = getJavaIoFileDescriptorContentsAsAPointer	(env, fileDescriptor);
   if (!hysock_socketIsValid (hysocketP))
     {
       throwJavaNetSocketException (env,	HYPORT_ERROR_SOCKET_BADSOCKET);	
@@ -649,7 +867,7 @@
     return;
 
   socketS =
-    getJavaIoFileDescriptorContentsAsPointer (env, fileDescriptorServer);
+    getJavaIoFileDescriptorContentsAsAPointer (env, fileDescriptorServer);
   if (!hysock_socketIsValid (socketS))
     {
       throwJavaNetSocketException (env,	HYPORT_ERROR_SOCKET_BADSOCKET);	
@@ -684,7 +902,7 @@
   I_32 flags = 0;
   I_32 result;
 
-  socketP = getJavaIoFileDescriptorContentsAsPointer (env, fileDescriptor);
+  socketP = getJavaIoFileDescriptorContentsAsAPointer (env, fileDescriptor);
   if (!hysock_socketIsValid (socketP))
     {
       return FALSE;
@@ -707,7 +925,7 @@
   I_32 flags = 0;
   I_32 result =	0;
 
-  socketP = getJavaIoFileDescriptorContentsAsPointer (env, fileDescriptor);
+  socketP = getJavaIoFileDescriptorContentsAsAPointer (env, fileDescriptor);
   if (!hysock_socketIsValid (socketP))
     {
       throwJavaNetSocketException (env,	HYPORT_ERROR_SOCKET_BADSOCKET);	
@@ -750,7 +968,7 @@
   hysockaddr_struct sockaddrP;
   U_32 scope_id	= 0;
 
-  socketP = getJavaIoFileDescriptorContentsAsPointer (env, fileDescriptor);
+  socketP = getJavaIoFileDescriptorContentsAsAPointer (env, fileDescriptor);
   if (!hysock_socketIsValid (socketP))
     {
       throwJavaNetSocketException (env,	HYPORT_ERROR_SOCKET_BADSOCKET);	
@@ -799,7 +1017,7 @@
   hysocket_t socketP;
   hysockaddr_struct sockaddrP;
 
-  socketP = getJavaIoFileDescriptorContentsAsPointer (env, fileDescriptor);
+  socketP = getJavaIoFileDescriptorContentsAsAPointer (env, fileDescriptor);
   if (!hysock_socketIsValid (socketP))
     {
       throwJavaNetSocketException (env,	HYPORT_ERROR_SOCKET_BADSOCKET);	
@@ -845,7 +1063,7 @@
   hysockaddr_struct sockaddrP;
   U_32 scope_id = 0;
 
-  socketP = getJavaIoFileDescriptorContentsAsPointer (env, fileDescriptor);
+  socketP = getJavaIoFileDescriptorContentsAsAPointer (env, fileDescriptor);
   if (!hysock_socketIsValid (socketP))
     {
       throwJavaNetSocketException (env, HYPORT_ERROR_SOCKET_BADSOCKET);
@@ -906,7 +1124,7 @@
   if (0	> result)
     return (jint) 0;
 
-  hysocketP = getJavaIoFileDescriptorContentsAsPointer	(env, fileDescriptor);
+  hysocketP = getJavaIoFileDescriptorContentsAsAPointer	(env, fileDescriptor);
   if (!hysock_socketIsValid (hysocketP))
     {
       throwJavaNetSocketException (env,	HYPORT_ERROR_SOCKET_BADSOCKET);	
@@ -965,7 +1183,7 @@
   I_32 flags = HYSOCK_NOFLAGS;
   jbyte	nlocalAddrBytes[HYSOCK_INADDR6_LEN];
 
-  hysocketP = getJavaIoFileDescriptorContentsAsPointer	(env, fileDescriptor);
+  hysocketP = getJavaIoFileDescriptorContentsAsAPointer	(env, fileDescriptor);
   result = pollSelectRead (env,	fileDescriptor,	timeout, TRUE);	
   //result = selectRead (env,hysocketP, timeout, FALSE);
   if (0	> result)
@@ -1050,7 +1268,7 @@
     }
 
   /* get the handle to the socket */
-  hysocketP = getJavaIoFileDescriptorContentsAsPointer	(env, fileDescriptor);
+  hysocketP = getJavaIoFileDescriptorContentsAsAPointer	(env, fileDescriptor);
   if (!hysock_socketIsValid (hysocketP))
     {
       throwJavaNetSocketException (env,	HYPORT_ERROR_SOCKET_BADSOCKET);	
@@ -1144,7 +1362,7 @@
   netGetJavaNetInetAddressValue	(env, inetAddress, nhostAddrBytes, &length);
   nPort	= hysock_htons ((U_16) targetPort);
 
-  socketP = getJavaIoFileDescriptorContentsAsPointer (env, fileDescriptor);
+  socketP = getJavaIoFileDescriptorContentsAsAPointer (env, fileDescriptor);
   if (length ==	HYSOCK_INADDR6_LEN)
     {
       netGetJavaNetInetAddressScopeId (env, inetAddress, &scope_id);
@@ -1172,7 +1390,7 @@
   do
     {
       socketP =	
-	getJavaIoFileDescriptorContentsAsPointer (env,	fileDescriptor);
+	getJavaIoFileDescriptorContentsAsAPointer (env,	fileDescriptor);
       if (!hysock_socketIsValid	(socketP))
 	{
 	  hymem_free_memory ( message);	
@@ -1242,7 +1460,7 @@
     {
       /* make sure the socket is still valid */	
       socketP =	
-	(hysocket_t) getJavaIoFileDescriptorContentsAsPointer (env,
+	(hysocket_t) getJavaIoFileDescriptorContentsAsAPointer (env,
 	fileDescriptor);
       if (!hysock_socketIsValid	(socketP))
 	{
@@ -1326,7 +1544,7 @@
   hysocket_t socketP;
   createSocket (env, thisObjFD,	HYSOCK_STREAM, preferIPv4Stack);
   socketP =
-    (hysocket_t) getJavaIoFileDescriptorContentsAsPointer (env, thisObjFD);
+    (hysocket_t) getJavaIoFileDescriptorContentsAsAPointer (env, thisObjFD);
   setDefaultServerSocketOptions	(env, socketP);	
 }
 
@@ -1349,7 +1567,7 @@
   hysocket_t socketP;
   createSocket (env, thisObjFD,	HYSOCK_DGRAM, preferIPv4Stack);	
   socketP =
-    (hysocket_t) getJavaIoFileDescriptorContentsAsPointer (env, thisObjFD);
+    (hysocket_t) getJavaIoFileDescriptorContentsAsAPointer (env, thisObjFD);
 
   hysock_setopt_bool (socketP, HY_SOL_SOCKET, HY_SO_REUSEPORT, &value);	
   hysock_setopt_bool (socketP, HY_SOL_SOCKET, HY_SO_REUSEADDR, &value);	
@@ -1390,7 +1608,7 @@
       finishTime = hytime_msec_clock ()	+ (UDATA) timeout;
     }
 
-  socketP = getJavaIoFileDescriptorContentsAsPointer (env, fileDescriptor);
+  socketP = getJavaIoFileDescriptorContentsAsAPointer (env, fileDescriptor);
   if (!hysock_socketIsValid (socketP))
     {
       throwJavaNetSocketException (env,	HYPORT_ERROR_SOCKET_BADSOCKET);	
@@ -1464,7 +1682,7 @@
 	  /* now check if the socket is	still connected.  Do it	here as	some platforms seem to think they 
 	   * are connected if the socket is closed on them. */
 	  socketP =
-	    getJavaIoFileDescriptorContentsAsPointer (env, fileDescriptor);
+	    getJavaIoFileDescriptorContentsAsAPointer (env, fileDescriptor);
 	  if (!hysock_socketIsValid (socketP))
 	    {
 	      hysock_connect_with_timeout (socketP, &sockaddrP,	0,
@@ -1560,7 +1778,7 @@
 	&length);
 
       socketP =	
-	(hysocket_t) getJavaIoFileDescriptorContentsAsPointer (env,
+	(hysocket_t) getJavaIoFileDescriptorContentsAsAPointer (env,
 	fileDescriptor);
       nPort = hysock_htons ((U_16) targetPort);	
       if (length == HYSOCK_INADDR_LEN)
@@ -1588,7 +1806,7 @@
   while	(sent <	msgLength)
     {
       socketP =	
-	(hysocket_t) getJavaIoFileDescriptorContentsAsPointer (env,
+	(hysocket_t) getJavaIoFileDescriptorContentsAsAPointer (env,
 	fileDescriptor);
       if (!hysock_socketIsValid	(socketP))
 	{
@@ -1640,7 +1858,7 @@
   if (0	> result)
     return (jint) 0;
 
-  hysocketP = getJavaIoFileDescriptorContentsAsPointer	(env, fileDescriptor);
+  hysocketP = getJavaIoFileDescriptorContentsAsAPointer	(env, fileDescriptor);
   if (!hysock_socketIsValid (hysocketP))
     {
       throwJavaNetSocketException (env,	HYPORT_ERROR_SOCKET_BADSOCKET);	
@@ -1722,7 +1940,7 @@
   while	(sent <	count)
     {
       socketP =	
-	getJavaIoFileDescriptorContentsAsPointer (env,	fileDescriptor);
+	getJavaIoFileDescriptorContentsAsAPointer (env,	fileDescriptor);
       if (!hysock_socketIsValid	(socketP))
 	{
 	  if (((U_8 *)message) != internalBuffer)
@@ -1777,7 +1995,7 @@
   hysocket_t socketP;
 
   socketP =
-    (hysocket_t) getJavaIoFileDescriptorContentsAsPointer (env,
+    (hysocket_t) getJavaIoFileDescriptorContentsAsAPointer (env,
 		 fileDescriptor);
   if (!hysock_socketIsValid (socketP))
     {
@@ -1805,7 +2023,7 @@
   hysocket_t socketP;
 
   socketP =
-    (hysocket_t) getJavaIoFileDescriptorContentsAsPointer (env,
+    (hysocket_t) getJavaIoFileDescriptorContentsAsAPointer (env,
 		 fileDescriptor);
   if (!hysock_socketIsValid (socketP))
     {
@@ -1843,7 +2061,7 @@
     return;
 
   socketS =
-    getJavaIoFileDescriptorContentsAsPointer (env, fileDescriptorServer);
+    getJavaIoFileDescriptorContentsAsAPointer (env, fileDescriptorServer);
   if (!hysock_socketIsValid (socketS))
     {
       throwJavaNetSocketException (env,	HYPORT_ERROR_SOCKET_BADSOCKET);	
@@ -1878,7 +2096,7 @@
   hysocket_t socketP;
   createSocket (env, thisObjFD,	HYSOCK_STREAM, preferIPv4Stack);
   socketP =
-    (hysocket_t) getJavaIoFileDescriptorContentsAsPointer (env, thisObjFD);
+    (hysocket_t) getJavaIoFileDescriptorContentsAsAPointer (env, thisObjFD);
   setPlatformBindOptions (env, socketP);
 }
 
@@ -1910,7 +2128,7 @@
   FD_ZERO (&fdset_write->handle);
   for (val = 0; val<countReadC; val++){
 	  gotFD	= (*env)->GetObjectArrayElement(env,readFDArray,val);
-	  hysocketP = getJavaIoFileDescriptorContentsAsPointer	(env, gotFD);
+	  hysocketP = getJavaIoFileDescriptorContentsAsAPointer	(env, gotFD);
 	  /*No difference between ipv4 and ipv6 as in windows*/
 		FD_SET (hysocketP->sock, &fdset_read->handle);
 		if (0 >	(size -	hysocketP->sock))
@@ -1918,7 +2136,7 @@
 	}
   for (val = 0; val<countWriteC; val++){
 	  gotFD	= (*env)->GetObjectArrayElement(env,writeFDArray,val);
-	  hysocketP = getJavaIoFileDescriptorContentsAsPointer	(env, gotFD);
+	  hysocketP = getJavaIoFileDescriptorContentsAsAPointer	(env, gotFD);
 	  /*No difference between ipv4 and ipv6 as in windows*/
 	  FD_SET (hysocketP->sock, &fdset_write->handle);	
 		if (0 >	(size -	hysocketP->sock))
@@ -1948,7 +2166,7 @@
 	  flagArray = (*env)->GetIntArrayElements(env,outFlags,	&isCopy);
 	  for (val=0;val<countReadC;val++){
 		gotFD =	(*env)->GetObjectArrayElement(env,readFDArray,val);
-		hysocketP = getJavaIoFileDescriptorContentsAsPointer (env, gotFD);
+		hysocketP = getJavaIoFileDescriptorContentsAsAPointer (env, gotFD);
 		if (FD_ISSET(hysocketP->sock,&fdset_read->handle))
 			flagArray[val] = SOCKET_OP_READ;
 		else
@@ -1958,7 +2176,7 @@
 		
 	  for (val=0;val<countWriteC;val++){
 		gotFD =	(*env)->GetObjectArrayElement(env,writeFDArray,val);
-		hysocketP = getJavaIoFileDescriptorContentsAsPointer (env, gotFD);
+		hysocketP = getJavaIoFileDescriptorContentsAsAPointer (env, gotFD);
 		if (FD_ISSET(hysocketP->sock,&fdset_write->handle))
 			flagArray[val+countReadC] = SOCKET_OP_WRITE;
 		else
@@ -2048,7 +2266,7 @@
   PORT_ACCESS_FROM_ENV (env);
   hysocket_t hysocketP;	
 
-  hysocketP = getJavaIoFileDescriptorContentsAsPointer	(env, aFileDescriptor);
+  hysocketP = getJavaIoFileDescriptorContentsAsAPointer	(env, aFileDescriptor);
   if (!hysock_socketIsValid (hysocketP))
     {
       throwJavaNetSocketException (env,	HYPORT_ERROR_SOCKET_BADSOCKET);	
@@ -2109,7 +2327,7 @@
   PORT_ACCESS_FROM_ENV (env);
   hysocket_t hysocketP;	
 
-  hysocketP = getJavaIoFileDescriptorContentsAsPointer	(env, aFileDescriptor);
+  hysocketP = getJavaIoFileDescriptorContentsAsAPointer	(env, aFileDescriptor);
   if (!hysock_socketIsValid (hysocketP))
     {
       throwJavaNetSocketException (env,	HYPORT_ERROR_SOCKET_BADSOCKET);	
@@ -2219,7 +2437,7 @@
   hysocket_t socketP;
   I_32 result =	0;
 
-  socketP = getJavaIoFileDescriptorContentsAsPointer (env, fileDescriptor);
+  socketP = getJavaIoFileDescriptorContentsAsAPointer (env, fileDescriptor);
   if (hysock_socketIsValid (socketP))
     {
       /* Set the file descriptor before	closing	so the select polling loop will	terminate. */

Modified: incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/luni/libhyluni.exp
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/luni/libhyluni.exp?rev=389887&r1=389886&r2=389887&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/luni/libhyluni.exp (original)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/luni/libhyluni.exp Wed Mar 29 12:58:53 2006
@@ -84,17 +84,6 @@
 		Java_java_io_ObjectStreamClass_getMethodSignature;
 		Java_java_io_ObjectStreamClass_hasClinit;
 		Java_java_io_ObjectStreamClass_oneTimeInitialization;
-		Java_java_io_RandomAccessFile_closeImpl;
-		Java_java_io_RandomAccessFile_getFilePointer;
-		Java_java_io_RandomAccessFile_length;
-		Java_java_io_RandomAccessFile_oneTimeInitialization;
-		Java_java_io_RandomAccessFile_openImpl;
-		Java_java_io_RandomAccessFile_readByteImpl;
-		Java_java_io_RandomAccessFile_readImpl;
-		Java_java_io_RandomAccessFile_seek;
-		Java_java_io_RandomAccessFile_setLengthImpl;
-		Java_java_io_RandomAccessFile_writeByteImpl;
-		Java_java_io_RandomAccessFile_writeImpl;
 		Java_java_lang_Double_doubleToLongBits;
 		Java_java_lang_Double_doubleToRawLongBits;
 		Java_java_lang_Double_longBitsToDouble;
@@ -140,42 +129,6 @@
 		Java_java_net_InetAddress_inetNtoaImpl;
 		Java_java_net_InetAddress_oneTimeInitialization;
 		Java_java_net_NetworkInterface_getNetworkInterfacesImpl;
-		Java_java_net_PlainDatagramSocketImpl_connectDatagramImpl2;
-		Java_java_net_PlainDatagramSocketImpl_createDatagramSocketImpl;
-		Java_java_net_PlainDatagramSocketImpl_disconnectDatagramImpl;
-		Java_java_net_PlainDatagramSocketImpl_oneTimeInitialization;
-		Java_java_net_PlainDatagramSocketImpl_peekDatagramImpl;
-		Java_java_net_PlainDatagramSocketImpl_receiveDatagramImpl2;
-		Java_java_net_PlainDatagramSocketImpl_recvConnectedDatagramImpl;
-		Java_java_net_PlainDatagramSocketImpl_sendConnectedDatagramImpl;
-		Java_java_net_PlainDatagramSocketImpl_sendDatagramImpl2;
-		Java_java_net_PlainDatagramSocketImpl_socketBindImpl2;
-		Java_java_net_PlainMulticastSocketImpl_createMulticastSocketImpl;
-		Java_java_net_PlainServerSocketImpl_createServerStreamSocketImpl;
-		Java_java_net_PlainSocketImpl2_connectStreamSocketImpl2;
-		Java_java_net_PlainSocketImpl2_connectStreamWithTimeoutSocketImpl2;
-		Java_java_net_PlainSocketImpl2_createStreamSocketImpl2;
-		Java_java_net_PlainSocketImpl2_sendDatagramImpl2;
-		Java_java_net_PlainSocketImpl2_socketBindImpl2;
-		Java_java_net_Socket_getSocketFlags;
-		Java_java_net_Socket_getSocketLocalAddressImpl;
-		Java_java_net_Socket_getSocketLocalPortImpl;
-		Java_java_net_Socket_getSocketOptionImpl;
-		Java_java_net_Socket_oneTimeInitialization;
-		Java_java_net_Socket_setSocketOptionImpl;
-		Java_java_net_Socket_socketCloseImpl;
-		Java_java_net_SocketImpl_acceptStreamSocketImpl;
-		Java_java_net_SocketImpl_availableStreamImpl;
-		Java_java_net_SocketImpl_createDatagramSocketImpl;
-		Java_java_net_SocketImpl_createStreamSocketImpl;
-		Java_java_net_SocketImpl_listenStreamSocketImpl;
-		Java_java_net_SocketImpl_oneTimeInitialization;
-		Java_java_net_SocketImpl_receiveStreamImpl;
-		Java_java_net_SocketImpl_sendStreamImpl;
-		Java_java_net_SocketImpl_sendUrgentDataImpl;
-		Java_java_net_SocketImpl_shutdownInputImpl;
-		Java_java_net_SocketImpl_shutdownOutputImpl;
-		Java_java_net_SocketImpl_supportsUrgentDataImpl;
 		Java_java_util_TimeZone_getCustomTimeZone;
 		JNI_OnLoad;
 		JNI_OnUnload;
@@ -262,5 +215,6 @@
 		Java_org_apache_harmony_luni_platform_OSNetworkSystem_getHostByAddrImpl;
 		Java_org_apache_harmony_luni_platform_OSNetworkSystem_getHostByNameImpl;
 		Java_org_apache_harmony_luni_platform_OSNetworkSystem_setInetAddressImpl;
+        Java_org_apache_harmony_luni_platform_OSNetworkSystem_isReachableByPing;
 	local : *;
 };

Modified: incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/luni/makefile
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/luni/makefile?rev=389887&r1=389886&r2=389887&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/luni/makefile (original)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/luni/makefile Wed Mar 29 12:58:53 2006
@@ -22,15 +22,15 @@
 
 BUILDFILES = \
 	$(SHAREDSUB)luni_copyright.o $(SHAREDSUB)file.o procimpl.o \
-	$(SHAREDSUB)oos.o $(SHAREDSUB)fileis.o \
-	$(SHAREDSUB)simpl.o $(SHAREDSUB)psimpl2.o $(SHAREDSUB)nethelp.o \
-	$(SHAREDSUB)floatbits.o $(SHAREDSUB)rafile.o $(SHAREDSUB)ois.o \
+	$(SHAREDSUB)oos.o \
+	$(SHAREDSUB)nethelp.o \
+	$(SHAREDSUB)floatbits.o $(SHAREDSUB)ois.o \
 	helpers.o $(SHAREDSUB)math.o $(SHAREDSUB)luniglob.o $(SHAREDSUB)proxy.o \
 	$(SHAREDSUB)netif.o $(SHAREDSUB)process.o $(SHAREDSUB)bigint.o \
 	$(SHAREDSUB)osc.o $(SHAREDSUB)socket.o $(SHAREDSUB)inetadds.o \
-	$(SHAREDSUB)pssimpl.o $(SHAREDSUB)filedesc.o \
-	$(SHAREDSUB)timezone.o $(SHAREDSUB)pmsimpl.o pdsimpl.o \
-	$(SHAREDSUB)fileos.o $(SHAREDSUB)OSFileSystem.o OSFileSystemLinux32.o \
+	$(SHAREDSUB)filedesc.o \
+	$(SHAREDSUB)timezone.o \
+	$(SHAREDSUB)OSFileSystem.o OSFileSystemLinux32.o \
 	OSMemory.o OSMemoryLinux32.o OSNetworkSystem.o OSNetworkSystemLinux.o
 
 MDLLIBFILES = \

Modified: incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/nethelp.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/nethelp.c?rev=389887&r1=389886&r2=389887&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/nethelp.c (original)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/nethelp.c Wed Mar 29 12:58:53 2006
@@ -1,4 +1,4 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,51 +14,251 @@
  */
 
 #include "nethelp.h"
-#include "jclglob.h"
 #include "portsock.h"
 #include "hyport.h"
+#include "jclglob.h"
+
+/**
+ * Set up JNI ID Caches.
+ *
+ * @param env           pointer to the JNI library
+ *
+ */
+
+void
+netInitializeIDCaches (JNIEnv * env, jboolean ipv6_support)
+{
+  jclass lookupClass;
+  jmethodID mid;
+  jfieldID fid;
+  jobject globalRef;
+
+  /* Set the JCL cache to use IPv6 address support */
+  JCL_CACHE_SET (env, jcl_supports_ipv6, ipv6_support);
+
+  /* java/lang/Boolean class, constructors, and fids */
+  lookupClass = (*env)->FindClass (env, "java/lang/Boolean");
+  if (!lookupClass)
+    return;
+  globalRef = (*env)->NewWeakGlobalRef (env, lookupClass);
+  if (!globalRef)
+    return;
+  mid = (*env)->GetMethodID (env, lookupClass, "<init>", "(Z)V");
+  if (!mid)
+    return;
+  fid = (*env)->GetFieldID (env, lookupClass, "value", "Z");
+  if (!fid)
+    return;
+  JCL_CACHE_SET (env, CLS_java_lang_Boolean, globalRef);
+  JCL_CACHE_SET (env, MID_java_lang_Boolean_init, mid);
+  JCL_CACHE_SET (env, FID_java_lang_Boolean_value, fid);
+
+  /* java/lang/Byte class, constructors, and fids */
+  lookupClass = (*env)->FindClass (env, "java/lang/Byte");
+  if (!lookupClass)
+    return;
+  globalRef = (*env)->NewWeakGlobalRef (env, lookupClass);
+  if (!globalRef)
+    return;
+  mid = (*env)->GetMethodID (env, lookupClass, "<init>", "(B)V");
+  if (!mid)
+    return;
+  fid = (*env)->GetFieldID (env, lookupClass, "value", "B");
+  if (!fid)
+    return;
+  JCL_CACHE_SET (env, CLS_java_lang_Byte, globalRef);
+  JCL_CACHE_SET (env, MID_java_lang_Byte_init, mid);
+  JCL_CACHE_SET (env, FID_java_lang_Byte_value, fid);
+
+  /* java/lang/Integer class, constructors, and fids */
+  lookupClass = (*env)->FindClass (env, "java/lang/Integer");
+  if (!lookupClass)
+    return;
+  globalRef = (*env)->NewWeakGlobalRef (env, lookupClass);
+  if (!globalRef)
+    return;
+  mid = (*env)->GetMethodID (env, lookupClass, "<init>", "(I)V");
+  if (!mid)
+    return;
+  fid = (*env)->GetFieldID (env, lookupClass, "value", "I");
+  if (!fid)
+    return;
+  JCL_CACHE_SET (env, CLS_java_lang_Integer, globalRef);
+  JCL_CACHE_SET (env, MID_java_lang_Integer_init, mid);
+  JCL_CACHE_SET (env, FID_java_lang_Integer_value, fid);
+
+  /* InetAddress cache setup */
+  lookupClass = (*env)->FindClass (env, "java/net/InetAddress");
+  if (!lookupClass)
+    return;
+  globalRef = (*env)->NewWeakGlobalRef (env, lookupClass);
+  if (!globalRef)
+    return;
+  fid = (*env)->GetFieldID (env, lookupClass, "ipaddress", "[B");
+
+  if (!fid)
+    return;
+  JCL_CACHE_SET (env, CLS_java_net_InetAddress, globalRef);
+  JCL_CACHE_SET (env, FID_java_net_InetAddress_address, fid);
+
+  mid = NULL;
+  mid =
+    (*env)->GetStaticMethodID (env, lookupClass, "preferIPv6Addresses",
+             "()Z");
+  if (!mid)
+    return;
+  JCL_CACHE_SET (env, MID_java_net_InetAddress_preferIPv6Addresses, mid);
+
+  if (ipv6_support)
+    {
+      /* static InetAddress getByAddress( String name, byte[] address ) */
+      mid =
+        (*env)->GetStaticMethodID (env, lookupClass, "getByAddress",
+        "(Ljava/lang/String;[B)Ljava/net/InetAddress;");
+      if (!mid)
+        return;
+      JCL_CACHE_SET (env,
+        MID_java_net_InetAddress_getByAddress_Ljava_lang_String_byteArray,
+        mid);
+
+      /* static InetAddress getByAddress( byte[] address ) */
+      mid =
+        (*env)->GetStaticMethodID (env, lookupClass, "getByAddress",
+        "([B)Ljava/net/InetAddress;");
+      if (!mid)
+        return;
+      JCL_CACHE_SET (env, MID_java_net_InetAddress_getByAddress_byteArray,
+        mid);
+    }
+  else
+    {
+      /* InetAddress( byte[] addr ) */
+      mid = (*env)->GetMethodID (env, lookupClass, "<init>", "([B)V");
+      if (!mid)
+        return;
+      JCL_CACHE_SET (env, MID_java_net_InetAddress_init_byteArray, mid);
+
+      /* InetAddress( byte[] addr, String address ) */
+      mid =
+        (*env)->GetMethodID (env, lookupClass, "<init>",
+        "([BLjava/lang/String;)V");
+      if (!mid)
+        return;
+      JCL_CACHE_SET (env,
+        MID_java_net_InetAddress_init_byteArrayLjava_lang_String,
+        mid);
+    }
+
+  /* cache Socket class CLS and preferIPv4Socket method */
+  lookupClass = (*env)->FindClass (env, "java/net/Socket");
+  if (!lookupClass)
+    return;
+  globalRef = (*env)->NewWeakGlobalRef (env, lookupClass);
+  if (!globalRef)
+    return;
+  mid =
+    (*env)->GetStaticMethodID (env, lookupClass, "preferIPv4Stack", "()Z");
+  if (!mid)
+    return;
+  JCL_CACHE_SET (env, CLS_java_net_Socket, globalRef);
+  JCL_CACHE_SET (env, MID_java_net_Socket_preferIPv4Stack, mid);
+
+  lookupClass = (*env)->FindClass (env, "java/lang/Thread");
+  if (!lookupClass)
+    return;
+  globalRef = (*env)->NewWeakGlobalRef (env, lookupClass);
+  if (!globalRef)
+    return;
+  mid = (*env)->GetStaticMethodID (env, lookupClass, "yield", "()V");
+  if (!mid)
+    return;
+  JCL_CACHE_SET (env, CLS_java_lang_Thread, globalRef);
+  JCL_CACHE_SET (env, MID_java_lang_Thread_yield, mid);
+
+}
+
+
+/*--------------------------------------
+//reflect function
+----------------------------------------*/
+jclass 
+getJavaLangBooleanClass(JNIEnv * env);
+
+jmethodID
+getJavaLangBooleanInit(JNIEnv * env);
+
+jfieldID
+getJavaLangBooleanValue(JNIEnv * env);
+
+jclass
+getJavaLangByteClass(JNIEnv * env);
+
+jmethodID
+getJavaLangByteInit(JNIEnv * env);
+
+jfieldID
+getJavaLangByteValue(JNIEnv * env);
+
+jclass
+getJavaLangIntegerClass(JNIEnv * env);
+
+jmethodID
+getJavaLangIntegerInit(JNIEnv * env);
+
+jfieldID
+getJavaLangIntegerValue(JNIEnv * env);
+
+jclass
+getJavaNetInetAddressClass(JNIEnv * env);
+
+jfieldID
+getJavaNetInetAddressIpaddress(JNIEnv * env);
+
+jmethodID
+getJavaNetInetAddressPreferIPv6Addresses(JNIEnv * env);
+
+jmethodID
+getJavaNetInetAddressGetByAddressStringByte(JNIEnv * env);
+
+jmethodID
+getJavaNetInetAddressGetByAddressByteArray(JNIEnv * env);
+jmethodID
+getJavaNetInetAddressInitByteArray(JNIEnv * env);
+
+jmethodID
+getJavaNetInetAddressInitByteString(JNIEnv * env);
+
+jclass
+getJavaNetSocketClass(JNIEnv * env);
+
+jmethodID
+getJavaNetSocketPreferIPv4Stack(JNIEnv * env);
+
+jclass
+getJavaLangThreadClass(JNIEnv * env);
+
+jmethodID
+getJavaLangThreadYield(JNIEnv * env);
+
+jclass
+getJavaNetDatagramPacketClass(JNIEnv * env);
+
+jfieldID
+getJavaNetDatagramPacketAddress(JNIEnv * env);
+
+jfieldID
+getJavaNetDatagramPacketLength(JNIEnv * env);
+
+jfieldID
+getJavaNetDatagramPacketPort(JNIEnv * env);
+
+jfieldID
+getJavaNetSocketImplAddress(JNIEnv * env);
+
+jfieldID
+getJavaNetSocketImplPort(JNIEnv * env);
+
 
-void throwJavaNetBindException (JNIEnv * env, I_32 errorNumber);
-jobject newJavaNetInetAddressGenericBS (JNIEnv * env, jbyte * address,
-          U_32 length, char *hostName,
-          U_32 scope_id);
-void throwJavaNetUnknownHostException (JNIEnv * env, I_32 errorNumber);
-jobject newJavaNetInetAddressGenericB (JNIEnv * env, jbyte * address,
-               U_32 length, U_32 scope_id);
-jobject newJavaLangByte (JNIEnv * env, U_8 aByte);
-U_8 byteValue (JNIEnv * env, jobject aByte);
-I_32 intValue (JNIEnv * env, jobject anInteger);
-void throwJavaNetPortUnreachableException (JNIEnv * env, I_32 errorNumber);
-jobject newJavaByteArray (JNIEnv * env, jbyte * bytes, jint length);
-jobjectArray createAliasArrayFromAddrinfo (JNIEnv * env,
-             hyaddrinfo_t addresses,
-             char *hName);
-BOOLEAN booleanValue (JNIEnv * env, jobject aBoolean);
-BOOLEAN jcl_supports_ipv6 (JNIEnv * env);
-jobject newJavaLangInteger (JNIEnv * env, I_32 anInt);
-BOOLEAN preferIPv4Stack (JNIEnv * env);
-char *netLookupErrorString (JNIEnv * env, I_32 anErrorNum);
-void netInitializeIDCaches (JNIEnv * env, jboolean ipv6_support);
-jobject newJavaLangBoolean (JNIEnv * env, BOOLEAN aBool);
-void throwJavaLangIllegalArgumentException (JNIEnv * env, I_32 errorNumber);
-void netGetJavaNetInetAddressValue (JNIEnv * env, jobject anInetAddress,
-            U_8 * buffer, U_32 * length);
-void throwJavaIoInterruptedIOException (JNIEnv * env, I_32 errorNumber);
-void throwJavaNetSocketTimeoutException (JNIEnv * env, I_32 errorNumber);
-void callThreadYield (JNIEnv * env);
-void throwJavaNetConnectException (JNIEnv * env, I_32 errorNumber);
-void netGetJavaNetInetAddressScopeId (JNIEnv * env, jobject anInetAddress,
-              U_32 * scope_id);
-BOOLEAN preferIPv6Addresses (JNIEnv * env);
-jobjectArray createAliasArray (JNIEnv * env, jbyte ** addresses,
-             I_32 * family, U_32 count, char *hName,
-             U_32 * scope_id_array);
-void throwJavaNetSocketException (JNIEnv * env, I_32 errorNumber);
-I_32 netGetSockAddr (JNIEnv * env, jobject fileDescriptor,
-         hysockaddr_t sockaddrP, jboolean preferIPv6Addresses);
-jfieldID getJavaNetInetAddressIpaddress(JNIEnv * env);
-void setJavaIoFileDescriptorContents (JNIEnv * env, jobject fd, void *value);
-jfieldID getJavaIoFileDescriptorDescriptorFID (JNIEnv * env);
 
 /**
  * Set the exception state of the VM with a new java.lang.IllegalArgumentException.
@@ -233,8 +433,10 @@
   jclass tempClass;
   jmethodID tempMethod;
 
-  tempClass = JCL_CACHE_GET (env, CLS_java_lang_Boolean);
-  tempMethod = JCL_CACHE_GET (env, MID_java_lang_Boolean_init);
+  /*former: tempClass = JCL_CACHE_GET (env, CLS_java_lang_Boolean);*/
+  tempClass = getJavaLangBooleanClass(env);
+  /*fromer: tempMethod = JCL_CACHE_GET (env, MID_java_lang_Boolean_init);*/
+  tempMethod = getJavaLangBooleanInit(env);
   return (*env)->NewObject (env, tempClass, tempMethod, (jboolean) aBool);
 }
 
@@ -253,8 +455,10 @@
   jclass tempClass;
   jmethodID tempMethod;
 
-  tempClass = JCL_CACHE_GET (env, CLS_java_lang_Byte);
-  tempMethod = JCL_CACHE_GET (env, MID_java_lang_Byte_init);
+  /*tempClass = JCL_CACHE_GET (env, CLS_java_lang_Byte);*/
+  tempClass = getJavaLangByteClass(env);
+  tempMethod = getJavaLangByteInit(env);
+  /*tempMethod = JCL_CACHE_GET (env, MID_java_lang_Byte_init);*/
   return (*env)->NewObject (env, tempClass, tempMethod, (jbyte) aByte);
 }
 
@@ -273,8 +477,10 @@
   jclass tempClass;
   jmethodID tempMethod;
 
-  tempClass = JCL_CACHE_GET (env, CLS_java_lang_Integer);
-  tempMethod = JCL_CACHE_GET (env, MID_java_lang_Integer_init);
+  /*tempClass = JCL_CACHE_GET (env, CLS_java_lang_Integer);
+  //tempMethod = JCL_CACHE_GET (env, MID_java_lang_Integer_init);*/
+  tempClass = getJavaLangIntegerClass(env);
+  tempMethod = getJavaLangIntegerInit(env);
   return (*env)->NewObject (env, tempClass, tempMethod, (jint) anInt);
 }
 
@@ -301,7 +507,7 @@
   U_8 ipAddr[HYSOCK_INADDR6_LEN];
   memset (ipAddr, 0, HYSOCK_INADDR6_LEN);
 
-  socketP = getJavaIoFileDescriptorContentsAsPointer (env, fileDescriptor);
+  socketP = getJavaIoFileDescriptorContentsAsAPointer (env, fileDescriptor);
   if (!hysock_socketIsValid (socketP))
     {
       return HYPORT_ERROR_SOCKET_UNKNOWNSOCKET;
@@ -336,10 +542,13 @@
 BOOLEAN
 booleanValue (JNIEnv * env, jobject aBoolean)
 {
+  /*return (BOOLEAN) ((*env)->
+  //      GetBooleanField (env, aBoolean,
+  //           JCL_CACHE_GET (env,
+  //              FID_java_lang_Boolean_value)));*/
   return (BOOLEAN) ((*env)->
         GetBooleanField (env, aBoolean,
-             JCL_CACHE_GET (env,
-                FID_java_lang_Boolean_value)));
+             getJavaLangBooleanValue(env)));
 }
 
 /**
@@ -354,9 +563,12 @@
 U_8
 byteValue (JNIEnv * env, jobject aByte)
 {
+  /*return (U_8) ((*env)->
+  //  GetByteField (env, aByte,
+  //          JCL_CACHE_GET (env, FID_java_lang_Byte_value)));*/
   return (U_8) ((*env)->
     GetByteField (env, aByte,
-            JCL_CACHE_GET (env, FID_java_lang_Byte_value)));
+            getJavaLangByteValue(env)));
 }
 
 /**
@@ -371,10 +583,14 @@
 I_32
 intValue (JNIEnv * env, jobject anInteger)
 {
+  /*return (I_32) ((*env)->
+  //   GetIntField (env, anInteger,
+  //          JCL_CACHE_GET (env,
+  //             FID_java_lang_Integer_value)));
+  */
   return (I_32) ((*env)->
      GetIntField (env, anInteger,
-            JCL_CACHE_GET (env,
-               FID_java_lang_Integer_value)));
+            getJavaLangIntegerValue(env)));
 }
 
 /**
@@ -489,175 +705,17 @@
       return "Unable to allocate the linger structure";
     case HYPORT_ERROR_SOCKET_IPMREQALLOCFAIL:
       return "Unable to allocate the ipmreq structure";
-    case HYPORT_ERROR_SOCKET_FDSETALLOCFAIL:
-      return "Unable to allocate the fdset structure";
-    case HYPORT_ERROR_SOCKET_CONNECTION_REFUSED:
-      return "Connection refused";
-
-    default:
-      return (char *) hysock_error_message ();
-    }
-}
-
-/**
- * Set up JNI ID Caches.
- *
- * @param env           pointer to the JNI library
- *
- */
-
-void
-netInitializeIDCaches (JNIEnv * env, jboolean ipv6_support)
-{
-  jclass lookupClass;
-  jmethodID mid;
-  jfieldID fid;
-  jobject globalRef;
-
-  /* Set the JCL cache to use IPv6 address support */
-  JCL_CACHE_SET (env, jcl_supports_ipv6, ipv6_support);
-
-  /* java/lang/Boolean class, constructors, and fids */
-  lookupClass = (*env)->FindClass (env, "java/lang/Boolean");
-  if (!lookupClass)
-    return;
-  globalRef = (*env)->NewWeakGlobalRef (env, lookupClass);
-  if (!globalRef)
-    return;
-  mid = (*env)->GetMethodID (env, lookupClass, "<init>", "(Z)V");
-  if (!mid)
-    return;
-  fid = (*env)->GetFieldID (env, lookupClass, "value", "Z");
-  if (!fid)
-    return;
-  JCL_CACHE_SET (env, CLS_java_lang_Boolean, globalRef);
-  JCL_CACHE_SET (env, MID_java_lang_Boolean_init, mid);
-  JCL_CACHE_SET (env, FID_java_lang_Boolean_value, fid);
-
-  /* java/lang/Byte class, constructors, and fids */
-  lookupClass = (*env)->FindClass (env, "java/lang/Byte");
-  if (!lookupClass)
-    return;
-  globalRef = (*env)->NewWeakGlobalRef (env, lookupClass);
-  if (!globalRef)
-    return;
-  mid = (*env)->GetMethodID (env, lookupClass, "<init>", "(B)V");
-  if (!mid)
-    return;
-  fid = (*env)->GetFieldID (env, lookupClass, "value", "B");
-  if (!fid)
-    return;
-  JCL_CACHE_SET (env, CLS_java_lang_Byte, globalRef);
-  JCL_CACHE_SET (env, MID_java_lang_Byte_init, mid);
-  JCL_CACHE_SET (env, FID_java_lang_Byte_value, fid);
-
-  /* java/lang/Integer class, constructors, and fids */
-  lookupClass = (*env)->FindClass (env, "java/lang/Integer");
-  if (!lookupClass)
-    return;
-  globalRef = (*env)->NewWeakGlobalRef (env, lookupClass);
-  if (!globalRef)
-    return;
-  mid = (*env)->GetMethodID (env, lookupClass, "<init>", "(I)V");
-  if (!mid)
-    return;
-  fid = (*env)->GetFieldID (env, lookupClass, "value", "I");
-  if (!fid)
-    return;
-  JCL_CACHE_SET (env, CLS_java_lang_Integer, globalRef);
-  JCL_CACHE_SET (env, MID_java_lang_Integer_init, mid);
-  JCL_CACHE_SET (env, FID_java_lang_Integer_value, fid);
-
-  /* InetAddress cache setup */
-  lookupClass = (*env)->FindClass (env, "java/net/InetAddress");
-  if (!lookupClass)
-    return;
-  globalRef = (*env)->NewWeakGlobalRef (env, lookupClass);
-  if (!globalRef)
-    return;
-  fid = (*env)->GetFieldID (env, lookupClass, "ipaddress", "[B");
-
-  if (!fid)
-    return;
-  JCL_CACHE_SET (env, CLS_java_net_InetAddress, globalRef);
-  JCL_CACHE_SET (env, FID_java_net_InetAddress_address, fid);
-
-  mid = NULL;
-  mid =
-    (*env)->GetStaticMethodID (env, lookupClass, "preferIPv6Addresses",
-             "()Z");
-  if (!mid)
-    return;
-  JCL_CACHE_SET (env, MID_java_net_InetAddress_preferIPv6Addresses, mid);
-
-  if (ipv6_support)
-    {
-      /* static InetAddress getByAddress( String name, byte[] address ) */
-      mid =
-        (*env)->GetStaticMethodID (env, lookupClass, "getByAddress",
-        "(Ljava/lang/String;[B)Ljava/net/InetAddress;");
-      if (!mid)
-        return;
-      JCL_CACHE_SET (env,
-        MID_java_net_InetAddress_getByAddress_Ljava_lang_String_byteArray,
-        mid);
-
-      /* static InetAddress getByAddress( byte[] address ) */
-      mid =
-        (*env)->GetStaticMethodID (env, lookupClass, "getByAddress",
-        "([B)Ljava/net/InetAddress;");
-      if (!mid)
-        return;
-      JCL_CACHE_SET (env, MID_java_net_InetAddress_getByAddress_byteArray,
-        mid);
-    }
-  else
-    {
-      /* InetAddress( byte[] addr ) */
-      mid = (*env)->GetMethodID (env, lookupClass, "<init>", "([B)V");
-      if (!mid)
-        return;
-      JCL_CACHE_SET (env, MID_java_net_InetAddress_init_byteArray, mid);
-
-      /* InetAddress( byte[] addr, String address ) */
-      mid =
-        (*env)->GetMethodID (env, lookupClass, "<init>",
-        "([BLjava/lang/String;)V");
-      if (!mid)
-        return;
-      JCL_CACHE_SET (env,
-        MID_java_net_InetAddress_init_byteArrayLjava_lang_String,
-        mid);
-    }
-
-  /* cache Socket class CLS and preferIPv4Socket method */
-  lookupClass = (*env)->FindClass (env, "java/net/Socket");
-  if (!lookupClass)
-    return;
-  globalRef = (*env)->NewWeakGlobalRef (env, lookupClass);
-  if (!globalRef)
-    return;
-  mid =
-    (*env)->GetStaticMethodID (env, lookupClass, "preferIPv4Stack", "()Z");
-  if (!mid)
-    return;
-  JCL_CACHE_SET (env, CLS_java_net_Socket, globalRef);
-  JCL_CACHE_SET (env, MID_java_net_Socket_preferIPv4Stack, mid);
-
-  lookupClass = (*env)->FindClass (env, "java/lang/Thread");
-  if (!lookupClass)
-    return;
-  globalRef = (*env)->NewWeakGlobalRef (env, lookupClass);
-  if (!globalRef)
-    return;
-  mid = (*env)->GetStaticMethodID (env, lookupClass, "yield", "()V");
-  if (!mid)
-    return;
-  JCL_CACHE_SET (env, CLS_java_lang_Thread, globalRef);
-  JCL_CACHE_SET (env, MID_java_lang_Thread_yield, mid);
+    case HYPORT_ERROR_SOCKET_FDSETALLOCFAIL:
+      return "Unable to allocate the fdset structure";
+    case HYPORT_ERROR_SOCKET_CONNECTION_REFUSED:
+      return "Connection refused";
 
+    default:
+      return (char *) hysock_error_message ();
+    }
 }
 
+
 /**
  * Answer the 'address' field value from a java.net.InetAddress
  *
@@ -671,10 +729,14 @@
 netGetJavaNetInetAddressValue (JNIEnv * env, jobject anInetAddress,
              U_8 * buffer, U_32 * length)
 {
+  /*jbyteArray byte_array =
+  //  (jbyteArray) ((*env)->GetObjectField (env, anInetAddress,
+  //          JCL_CACHE_GET (env,
+  //             FID_java_net_InetAddress_address)));
+  */
   jbyteArray byte_array =
     (jbyteArray) ((*env)->GetObjectField (env, anInetAddress,
-            JCL_CACHE_GET (env,
-               FID_java_net_InetAddress_address)));
+            getJavaNetInetAddressIpaddress(env)));
   *length = (*env)->GetArrayLength (env, byte_array);
   (*env)->GetByteArrayRegion (env, byte_array, 0, *length, buffer);
 }
@@ -693,8 +755,11 @@
   jclass tempClass;
   jobject globalRef;
 
-  tempClass = JCL_CACHE_GET (env, CLS_java_lang_Thread);
-  tempMethod = JCL_CACHE_GET (env, MID_java_lang_Thread_yield);
+  /*tempClass = JCL_CACHE_GET (env, CLS_java_lang_Thread);
+  //tempMethod = JCL_CACHE_GET (env, MID_java_lang_Thread_yield);
+  */
+  tempClass = getJavaLangThreadClass(env);
+  tempMethod = getJavaLangThreadYield(env);
   if (tempClass == 0)
     {
       tempClass = (*env)->FindClass (env, "java/lang/Thread");
@@ -706,8 +771,9 @@
       tempMethod = (*env)->GetStaticMethodID (env, tempClass, "yield", "()V");
       if (!tempMethod)
         return;
-      JCL_CACHE_SET (env, CLS_java_lang_Thread, globalRef);
-      JCL_CACHE_SET (env, MID_java_lang_Thread_yield, tempMethod);
+      /*JCL_CACHE_SET (env, CLS_java_lang_Thread, globalRef);
+      //JCL_CACHE_SET (env, MID_java_lang_Thread_yield, tempMethod);
+      */
     }
   (*env)->CallStaticVoidMethod (env, tempClass, tempMethod);
 }
@@ -804,9 +870,9 @@
 
   /* The array needs to be big enough to hold an aliases and an address for each entry */
   mem_size = length * sizeof (jbyte *);
-  aliasList = jclmem_allocate_memory (env, mem_size);
-  family = jclmem_allocate_memory (env, length * sizeof (I_32));
-  scope_id_array = jclmem_allocate_memory (env, length * sizeof (U_32));
+  aliasList = hymem_allocate_memory (mem_size);
+  family = hymem_allocate_memory (length * sizeof (I_32));
+  scope_id_array = hymem_allocate_memory (length * sizeof (U_32));
   memset (aliasList, 0, mem_size);
 
   for (i = 0; i < (U_32) length; i++)
@@ -827,7 +893,7 @@
       if (!contains)
         {
           aliasList[count] =
-            (U_8 *) jclmem_allocate_memory (env, HYSOCK_INADDR6_LEN);
+            (U_8 *) hymem_allocate_memory (HYSOCK_INADDR6_LEN);
           hysock_getaddrinfo_family (addresses, &family[count], i);
           scope_id_array[count] = scope_id;
           memcpy (aliasList[count++], temp_address, HYSOCK_INADDR6_LEN);
@@ -838,11 +904,11 @@
 
   for (i = 0; i < count; i++)
     {
-      jclmem_free_memory (env, aliasList[i]);
+      hymem_free_memory ( aliasList[i]);
     }
-  jclmem_free_memory (env, family);
-  jclmem_free_memory (env, scope_id_array);
-  jclmem_free_memory (env, aliasList);
+  hymem_free_memory (family);
+  hymem_free_memory (scope_id_array);
+  hymem_free_memory (aliasList);
 
   return inetAddressArray;
 }
@@ -857,7 +923,11 @@
 BOOLEAN
 jcl_supports_ipv6 (JNIEnv * env)
 {
-  return (BOOLEAN) JCL_CACHE_GET (env, jcl_supports_ipv6);
+  static int support = 1;
+  /*return (BOOLEAN) JCL_CACHE_GET (env, jcl_supports_ipv6);
+  //TODO check support
+  */
+  return (BOOLEAN) support;
 }
 
 /**
@@ -963,10 +1033,16 @@
       tempMethodWithScope = NULL;
       if (scope_id != 0)
         {
+          /*tempMethodWithScope =
+          //  (*env)->GetStaticMethodID (env,
+          //  JCL_CACHE_GET (env,
+          //  CLS_java_net_InetAddress),
+          //  "getByAddress",
+          //  "([BI)Ljava/net/InetAddress;");
+          */
           tempMethodWithScope =
             (*env)->GetStaticMethodID (env,
-            JCL_CACHE_GET (env,
-            CLS_java_net_InetAddress),
+            getJavaNetInetAddressClass(env),
             "getByAddress",
             "([BI)Ljava/net/InetAddress;");
           if ((*env)->ExceptionCheck (env))
@@ -979,26 +1055,33 @@
       if (tempMethodWithScope != NULL)
         {
           /* create using the scope id */
-          tempClass = JCL_CACHE_GET (env, CLS_java_net_InetAddress);
+          /*tempClass = JCL_CACHE_GET (env, CLS_java_net_InetAddress);*/
+          tempClass = getJavaNetInetAddressClass(env);
           return (*env)->CallStaticObjectMethod (env, tempClass,
             tempMethodWithScope,
             byte_array, scope_id);
         }
       else
         {
-          tempClass = JCL_CACHE_GET (env, CLS_java_net_InetAddress);
-          tempMethod =
-            JCL_CACHE_GET (env,
-            MID_java_net_InetAddress_getByAddress_byteArray);
+          /*tempClass = JCL_CACHE_GET (env, CLS_java_net_InetAddress);*/
+          tempClass = getJavaNetInetAddressClass(env);
+          /*tempMethod =
+          //  JCL_CACHE_GET (env,
+          //  MID_java_net_InetAddress_getByAddress_byteArray);
+          */
+          tempMethod = getJavaNetInetAddressGetByAddressByteArray(env);
           return (*env)->CallStaticObjectMethod (env, tempClass, tempMethod,
             byte_array);
         }
     }
   else
     {
-      tempClass = JCL_CACHE_GET (env, CLS_java_net_InetAddress);
-      tempMethod =
-        JCL_CACHE_GET (env, MID_java_net_InetAddress_init_byteArray);
+      /*tempClass = JCL_CACHE_GET (env, CLS_java_net_InetAddress);
+      //tempMethod =
+      //  JCL_CACHE_GET (env, MID_java_net_InetAddress_init_byteArray);
+      */
+      tempClass = getJavaNetInetAddressClass(env);
+      tempMethod = getJavaNetInetAddressInitByteArray(env);
       return (*env)->NewObject (env, tempClass, tempMethod, byte_array);
     }
 }
@@ -1033,11 +1116,8 @@
 
   aString = (*env)->NewStringUTF (env, hostName);
 
-  /**
-    * check if the address being returned is the any address.  
-    * If so we need to check the prefer flags to see how it should be returned
-    * (either as IPv4 Any or IPv6 ANY) 
-    */
+  /* check if the address being returned is the any address.  If so we need to check the prefer flags to see how it should be returned
+     (either as IPv4 Any or IPv6 ANY) */
 
   if (jcl_supports_ipv6 (env))
     {
@@ -1091,12 +1171,18 @@
       tempMethodWithScope = NULL;
       if (scope_id != 0)
         {
-          tempMethodWithScope =
+          /* tempMethodWithScope =
             (*env)->GetStaticMethodID (env,
             JCL_CACHE_GET (env,
             CLS_java_net_InetAddress),
             "getByAddress",
             "(Ljava/lang/String;[BI)Ljava/net/InetAddress;");
+          */
+          tempMethodWithScope =
+            (*env)->GetStaticMethodID (env,
+            getJavaNetInetAddressClass(env),
+            "getByAddress",
+            "(Ljava/lang/String;[BI)Ljava/net/InetAddress;");
           if ((*env)->ExceptionCheck (env))
             {
               (*env)->ExceptionClear (env);
@@ -1107,27 +1193,34 @@
       if (tempMethodWithScope != NULL)
         {
           /* create using the scope id */
-          tempClass = JCL_CACHE_GET (env, CLS_java_net_InetAddress);
+          /*tempClass = JCL_CACHE_GET (env, CLS_java_net_InetAddress);*/
+          tempClass = getJavaNetInetAddressClass(env);
           return (*env)->CallStaticObjectMethod (env, tempClass,
             tempMethodWithScope, aString,
             byte_array, scope_id);
         }
       else
         {
-          tempClass = JCL_CACHE_GET (env, CLS_java_net_InetAddress);
+          /*tempClass = JCL_CACHE_GET (env, CLS_java_net_InetAddress);
           tempMethod =
             JCL_CACHE_GET (env,
             MID_java_net_InetAddress_getByAddress_Ljava_lang_String_byteArray);
+          */
+          tempClass = getJavaNetInetAddressClass(env);
+          tempMethod = getJavaNetInetAddressGetByAddressStringByte(env);
           return (*env)->CallStaticObjectMethod (env, tempClass, tempMethod,
             aString, byte_array);
         }
       }
     else
       {
-        tempClass = JCL_CACHE_GET (env, CLS_java_net_InetAddress);
+        /*tempClass = JCL_CACHE_GET (env, CLS_java_net_InetAddress);
         tempMethod =
           JCL_CACHE_GET (env,
           MID_java_net_InetAddress_init_byteArrayLjava_lang_String);
+        */
+        tempClass = getJavaNetInetAddressClass(env);
+        tempMethod = getJavaNetInetAddressInitByteString(env);        
         return (*env)->NewObject (env, tempClass, tempMethod, byte_array,
           aString);
     }
@@ -1200,11 +1293,16 @@
       return TRUE;
     }
 
-  result =
+  /*result =
     (*env)->CallStaticBooleanMethod (env,
              JCL_CACHE_GET (env, CLS_java_net_Socket),
              JCL_CACHE_GET (env,
                 MID_java_net_Socket_preferIPv4Stack));
+  */
+  result =
+    (*env)->CallStaticBooleanMethod (env,
+             getJavaNetSocketClass(env),
+             getJavaNetSocketPreferIPv4Stack(env));
   if ((*env)->ExceptionCheck (env))
     {
       /* older JCLs do not have the right code for security checks so this may fail with an exception
@@ -1237,12 +1335,17 @@
       return FALSE;
     }
 
-  result =
+  /*result =
     (*env)->CallStaticBooleanMethod (env,
              JCL_CACHE_GET (env,
                 CLS_java_net_InetAddress),
              JCL_CACHE_GET (env,
                 MID_java_net_InetAddress_preferIPv6Addresses));
+  */
+  result =
+    (*env)->CallStaticBooleanMethod (env,
+             getJavaNetInetAddressClass(env),
+             getJavaNetInetAddressPreferIPv6Addresses(env)); 
   if ((*env)->ExceptionCheck (env))
     {
       /* older JCLs do not have the right code for security checks so this may fail with an exception
@@ -1296,6 +1399,146 @@
 
 }
 
+jclass 
+getJavaLangBooleanClass(JNIEnv * env){
+  jclass lookupClass = (*env)->FindClass (env, "java/lang/Boolean");
+  if (!lookupClass)
+    return NULL;
+  return lookupClass;
+}
+
+jmethodID
+getJavaLangBooleanInit(JNIEnv * env){
+  jmethodID mid;
+  jclass lookupClass = (*env)->FindClass (env, "java/lang/Boolean");
+  if (!lookupClass)
+    return NULL;
+  mid = (*env)->GetMethodID (env, lookupClass, "<init>", "(Z)V");
+  if (!mid)
+    return NULL;
+  return mid;
+}
+
+jfieldID
+getJavaLangBooleanValue(JNIEnv * env){
+  jmethodID mid;
+  jfieldID fid;
+  jclass lookupClass = (*env)->FindClass (env, "java/lang/Boolean");
+  if (!lookupClass)
+    return NULL;
+  mid = (*env)->GetMethodID (env, lookupClass, "<init>", "(Z)V");
+  if (!mid)
+    return NULL;
+  fid = (*env)->GetFieldID (env, lookupClass, "value", "Z");
+  if (!fid)
+    return NULL;
+  return fid;
+}
+
+jclass
+getJavaLangByteClass(JNIEnv * env){
+  jclass lookupClass = (*env)->FindClass (env, "java/lang/Byte");
+  if (!lookupClass)
+    return NULL;
+  return lookupClass;
+}
+
+jmethodID
+getJavaLangByteInit(JNIEnv * env){
+  jmethodID mid;
+  jclass lookupClass = (*env)->FindClass (env, "java/lang/Byte");
+  if (!lookupClass)
+    return NULL;
+  mid = (*env)->GetMethodID (env, lookupClass, "<init>", "(B)V");
+  if (!mid)
+    return NULL;
+  return mid;
+}
+
+jfieldID
+getJavaLangByteValue(JNIEnv * env){
+  jmethodID mid;
+  jfieldID fid;
+  jclass lookupClass = (*env)->FindClass (env, "java/lang/Byte");
+  if (!lookupClass)
+    return NULL;
+  mid = (*env)->GetMethodID (env, lookupClass, "<init>", "(B)V");
+  if (!mid)
+    return NULL;
+  fid = (*env)->GetFieldID (env, lookupClass, "value", "B");
+  if (!fid)
+    return NULL;
+  return fid;
+}
+
+jclass
+getJavaLangIntegerClass(JNIEnv * env){
+  jclass lookupClass = (*env)->FindClass (env, "java/lang/Integer");
+  if (!lookupClass)
+    return NULL;
+  return lookupClass;
+}
+
+jmethodID
+getJavaLangIntegerInit(JNIEnv * env){
+  jmethodID mid;
+  jclass lookupClass = (*env)->FindClass (env, "java/lang/Integer");
+  if (!lookupClass)
+    return NULL;
+  mid =  (*env)->GetMethodID (env, lookupClass, "<init>", "(I)V");
+  return mid;
+}
+
+jfieldID
+getJavaLangIntegerValue(JNIEnv * env){
+  jfieldID fid;
+  jclass lookupClass = (*env)->FindClass (env, "java/lang/Integer");
+  if (!lookupClass)
+    return NULL;
+  fid =  (*env)->GetFieldID (env, lookupClass, "value", "I");
+  if (!fid)
+    return NULL;
+  return fid;
+}
+
+/* already impl
+jmethodID
+getJavaLangByteInit(JNIEnv * env){
+  jmethodID mid;
+  jclass lookupClass = (*env)->FindClass (env, "java/lang/Integer");
+  if (!lookupClass)
+    return NULL;
+  mid = (*env)->GetMethodID (env, lookupClass, "<init>", "(I)V");
+  if (!mid)
+    return NULL;
+  return mid;
+}
+
+jfieldID
+getJavaLangByteValue(JNIEnv * env){
+  jmethodID mid;
+  jfieldID fid;
+  jclass lookupClass = (*env)->FindClass (env, "java/lang/Integer");
+  if (!lookupClass)
+    return NULL;
+  mid = (*env)->GetMethodID (env, lookupClass, "<init>", "(I)V");
+  if (!mid)
+    return NULL;
+  fid = (*env)->GetFieldID (env, lookupClass, "value", "I");
+  if (!fid)
+    return NULL;
+  return fid;
+}
+*/
+
+jclass
+getJavaNetInetAddressClass(JNIEnv * env){
+  jclass lookupClass = (*env)->FindClass (env, "java/net/InetAddress");
+  if (!lookupClass)
+    return NULL;
+  return lookupClass;
+}
+
 jfieldID
 getJavaNetInetAddressIpaddress(JNIEnv * env){
   jfieldID fid;
@@ -1308,11 +1551,220 @@
   return fid;
 }
 
-void setJavaIoFileDescriptorContents (JNIEnv * env, jobject fd, void *value)
+jmethodID
+getJavaNetInetAddressPreferIPv6Addresses(JNIEnv * env){
+  jmethodID mid;
+  jclass lookupClass = (*env)->FindClass (env, "java/net/InetAddress");
+  if (!lookupClass)
+    return NULL;
+  mid = (*env)->GetStaticMethodID (env, lookupClass, "preferIPv6Addresses",
+             "()Z");
+  if (!mid)
+    return NULL;
+  return mid;
+}
+
+jmethodID
+getJavaNetInetAddressGetByAddressStringByte(JNIEnv * env){
+  jmethodID mid;
+  jclass lookupClass = (*env)->FindClass (env, "java/net/InetAddress");
+  if (!lookupClass)
+    return NULL;
+  mid =
+        (*env)->GetStaticMethodID (env, lookupClass, "getByAddress",
+        "(Ljava/lang/String;[B)Ljava/net/InetAddress;");
+  if (!mid)
+        return NULL;
+  return mid;
+}
+
+jmethodID
+getJavaNetInetAddressGetByAddressByteArray(JNIEnv * env){
+  jmethodID mid;
+  jclass lookupClass = (*env)->FindClass (env, "java/net/InetAddress");
+  if (!lookupClass)
+    return NULL;
+  mid =
+        (*env)->GetStaticMethodID (env, lookupClass, "getByAddress",
+        "([B)Ljava/net/InetAddress;");
+  if (!mid)
+        return NULL;
+  return mid;
+}
+jmethodID
+getJavaNetInetAddressInitByteArray(JNIEnv * env){
+  jmethodID mid;
+  jclass lookupClass = (*env)->FindClass (env, "java/net/InetAddress");
+  if (!lookupClass)
+    return NULL;
+  mid = (*env)->GetMethodID (env, lookupClass, "<init>", "([B)V");
+  if (!mid)
+        return NULL;
+  return mid;
+}
+
+jmethodID
+getJavaNetInetAddressInitByteString(JNIEnv * env){
+  jmethodID mid;
+  jclass lookupClass = (*env)->FindClass (env, "java/net/InetAddress");
+  if (!lookupClass)
+    return NULL;
+  mid = (*env)->GetMethodID (env, lookupClass, "<init>",
+        "([BLjava/lang/String;)V");
+  if (!mid)
+        return NULL;
+  return mid;
+}
+
+jclass
+getJavaNetSocketClass(JNIEnv * env){
+  jclass lookupClass = (*env)->FindClass (env, "java/net/Socket");
+  if (!lookupClass)
+    return NULL;
+  return lookupClass;
+}
+
+jmethodID
+getJavaNetSocketPreferIPv4Stack(JNIEnv * env){
+  jmethodID mid;
+  jclass lookupClass = (*env)->FindClass (env, "java/net/Socket");
+  if (!lookupClass)
+    return NULL;
+  mid = (*env)->GetStaticMethodID (env, lookupClass, "preferIPv4Stack", "()Z");
+  if (!mid)
+    return NULL;
+  return mid;
+}
+
+jclass
+getJavaLangThreadClass(JNIEnv * env){
+  jclass lookupClass = (*env)->FindClass (env, "java/lang/Thread");
+  if (!lookupClass)
+    return NULL;
+  return lookupClass;
+}
+
+jmethodID
+getJavaLangThreadYield(JNIEnv * env){
+  jmethodID mid;
+  jclass lookupClass = (*env)->FindClass (env, "java/lang/Thread");
+  if (!lookupClass)
+    return NULL;
+  mid = (*env)->GetStaticMethodID (env, lookupClass, "yield", "()V");
+  if (!mid)
+    return NULL;
+  return mid;
+}
+
+jclass
+getJavaNetDatagramPacketClass(JNIEnv * env){
+  jclass lookupClass = (*env)->FindClass (env, "java/net/DatagramPacket");
+  if (!lookupClass)
+    return NULL;
+  return lookupClass;
+}
+
+jfieldID
+getJavaNetDatagramPacketAddress(JNIEnv * env){
+  jfieldID fid;
+  jclass lookupClass = (*env)->FindClass (env, "java/net/DatagramPacket");
+  if (!lookupClass)
+    return NULL;
+  fid =
+    (*env)->GetFieldID (env, lookupClass, "address",
+      "Ljava/net/InetAddress;");
+  if (!fid)
+    return NULL;
+  return fid;
+}
+
+jfieldID
+getJavaNetDatagramPacketLength(JNIEnv * env){
+  jfieldID fid;
+  jclass lookupClass = (*env)->FindClass (env, "java/net/DatagramPacket");
+  if (!lookupClass)
+    return NULL;
+  fid = (*env)->GetFieldID (env, lookupClass, "length", "I");
+  if (!fid)
+    return NULL;
+  return fid;
+}
+
+jfieldID
+getJavaNetDatagramPacketPort(JNIEnv * env){
+  jfieldID fid;
+  jclass lookupClass = (*env)->FindClass (env, "java/net/DatagramPacket");
+  if (!lookupClass)
+    return NULL;
+  fid = (*env)->GetFieldID (env, lookupClass, "port", "I");
+  if (!fid)
+    return NULL;
+  return fid;
+}
+
+jfieldID
+getJavaNetSocketImplAddress(JNIEnv * env){
+  jfieldID fid;
+  jclass lookupClass = (*env)->FindClass (env, "java/net/SocketImpl");
+  if (!lookupClass)
+    return NULL;
+  fid = (*env)->GetFieldID (env, lookupClass, "address", "Ljava/net/InetAddress;");
+  if (!fid)
+    return NULL;
+  return fid;
+}
+jfieldID
+getJavaNetSocketImplPort(JNIEnv * env){
+  jfieldID fid;
+  jclass lookupClass = (*env)->FindClass (env, "java/net/SocketImpl");
+  if (!lookupClass)
+    return NULL;
+  fid = (*env)->GetFieldID (env, lookupClass, "port", "I");
+  if (!fid)
+    return NULL;
+  return fid;
+}
+
+jfieldID
+getJavaIoFileDescriptorDescriptor (JNIEnv * env)
+{
+  jclass descriptorCLS;
+  jfieldID descriptorFID;
+
+  descriptorCLS = (*env)->FindClass (env, "java/io/FileDescriptor");
+  if (NULL == descriptorCLS)
+    {
+      return NULL;
+    }
+
+  descriptorFID = (*env)->GetFieldID (env, descriptorCLS, "descriptor", "J");
+  if (NULL == descriptorFID)
+    {
+      return NULL;
+    }
+
+  return descriptorFID;
+}
+
+void
+setJavaIoFileDescriptorContents (JNIEnv * env, jobject fd,
+                                          void *value)
 {
-  jfieldID fid = getJavaIoFileDescriptorDescriptorFID (env);
+  jfieldID fid = getJavaIoFileDescriptorDescriptor (env);
   if (NULL != fid)
     {
       (*env)->SetLongField (env, fd, fid, (jlong) value);
     }
 }
+
+void *
+getJavaIoFileDescriptorContentsAsAPointer (JNIEnv * env, jobject fd)
+{
+  jfieldID descriptorFID = getJavaIoFileDescriptorDescriptor (env);
+  if (NULL == descriptorFID)
+    {
+      return (void *) -1;
+    }
+  return (void *) ((*env)->GetLongField (env, fd, descriptorFID));
+}
+

Modified: incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/nethelp.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/nethelp.h?rev=389887&r1=389886&r2=389887&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/nethelp.h (original)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/nethelp.h Wed Mar 29 12:58:53 2006
@@ -37,4 +37,127 @@
 #define JAVASOCKOPT_IP_MULTICAST_IF2 31
 #define JAVASOCKOPT_SO_OOBINLINE  4099
 #define JAVASOCKOPT_REUSEADDR_AND_REUSEPORT  10001
+
+
+void *
+getJavaIoFileDescriptorContentsAsAPointer (JNIEnv * env, jobject fd);
+void throwJavaNetBindException (JNIEnv * env, I_32 errorNumber);
+jobject newJavaNetInetAddressGenericBS (JNIEnv * env, jbyte * address,
+          U_32 length, char *hostName,
+          U_32 scope_id);
+void throwJavaNetUnknownHostException (JNIEnv * env, I_32 errorNumber);
+jobject newJavaNetInetAddressGenericB (JNIEnv * env, jbyte * address,
+               U_32 length, U_32 scope_id);
+jobject newJavaLangByte (JNIEnv * env, U_8 aByte);
+U_8 byteValue (JNIEnv * env, jobject aByte);
+I_32 intValue (JNIEnv * env, jobject anInteger);
+void throwJavaNetPortUnreachableException (JNIEnv * env, I_32 errorNumber);
+jobject newJavaByteArray (JNIEnv * env, jbyte * bytes, jint length);
+jobjectArray createAliasArrayFromAddrinfo (JNIEnv * env,
+             hyaddrinfo_t addresses,
+             char *hName);
+BOOLEAN booleanValue (JNIEnv * env, jobject aBoolean);
+BOOLEAN jcl_supports_ipv6 (JNIEnv * env);
+jobject newJavaLangInteger (JNIEnv * env, I_32 anInt);
+BOOLEAN preferIPv4Stack (JNIEnv * env);
+char *netLookupErrorString (JNIEnv * env, I_32 anErrorNum);
+void netInitializeIDCaches (JNIEnv * env, jboolean ipv6_support);
+jobject newJavaLangBoolean (JNIEnv * env, BOOLEAN aBool);
+void throwJavaLangIllegalArgumentException (JNIEnv * env, I_32 errorNumber);
+void netGetJavaNetInetAddressValue (JNIEnv * env, jobject anInetAddress,
+            U_8 * buffer, U_32 * length);
+void throwJavaIoInterruptedIOException (JNIEnv * env, I_32 errorNumber);
+void throwJavaNetSocketTimeoutException (JNIEnv * env, I_32 errorNumber);
+void callThreadYield (JNIEnv * env);
+void throwJavaNetConnectException (JNIEnv * env, I_32 errorNumber);
+void netGetJavaNetInetAddressScopeId (JNIEnv * env, jobject anInetAddress,
+              U_32 * scope_id);
+BOOLEAN preferIPv6Addresses (JNIEnv * env);
+jobjectArray createAliasArray (JNIEnv * env, jbyte ** addresses,
+             I_32 * family, U_32 count, char *hName,
+             U_32 * scope_id_array);
+void throwJavaNetSocketException (JNIEnv * env, I_32 errorNumber);
+I_32 netGetSockAddr (JNIEnv * env, jobject fileDescriptor,
+         hysockaddr_t sockaddrP, jboolean preferIPv6Addresses);
+         
+         jclass 
+getJavaLangBooleanClass(JNIEnv * env);
+
+jmethodID
+getJavaLangBooleanInit(JNIEnv * env);
+
+jfieldID
+getJavaLangBooleanValue(JNIEnv * env);
+
+jclass
+getJavaLangByteClass(JNIEnv * env);
+
+jmethodID
+getJavaLangByteInit(JNIEnv * env);
+
+jfieldID
+getJavaLangByteValue(JNIEnv * env);
+
+jclass
+getJavaLangIntegerClass(JNIEnv * env);
+
+jmethodID
+getJavaLangIntegerInit(JNIEnv * env);
+
+jfieldID
+getJavaLangIntegerValue(JNIEnv * env);
+
+jclass
+getJavaNetInetAddressClass(JNIEnv * env);
+
+jfieldID
+getJavaNetInetAddressIpaddress(JNIEnv * env);
+
+jmethodID
+getJavaNetInetAddressPreferIPv6Addresses(JNIEnv * env);
+
+jmethodID
+getJavaNetInetAddressGetByAddressStringByte(JNIEnv * env);
+
+jmethodID
+getJavaNetInetAddressGetByAddressByteArray(JNIEnv * env);
+jmethodID
+getJavaNetInetAddressInitByteArray(JNIEnv * env);
+
+jmethodID
+getJavaNetInetAddressInitByteString(JNIEnv * env);
+
+jclass
+getJavaNetSocketClass(JNIEnv * env);
+
+jmethodID
+getJavaNetSocketPreferIPv4Stack(JNIEnv * env);
+
+jclass
+getJavaLangThreadClass(JNIEnv * env);
+
+jmethodID
+getJavaLangThreadYield(JNIEnv * env);
+
+jclass
+getJavaNetDatagramPacketClass(JNIEnv * env);
+
+jfieldID
+getJavaNetDatagramPacketAddress(JNIEnv * env);
+
+jfieldID
+getJavaNetDatagramPacketLength(JNIEnv * env);
+
+jfieldID
+getJavaNetDatagramPacketPort(JNIEnv * env);
+
+jfieldID
+getJavaNetSocketImplAddress(JNIEnv * env);
+
+jfieldID
+getJavaNetSocketImplPort(JNIEnv * env);
+
+void
+setJavaIoFileDescriptorContents (JNIEnv * env, jobject fd,
+                                          void *value);
 #endif /* nethelp_h */

Modified: incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/socket.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/socket.c?rev=389887&r1=389886&r2=389887&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/socket.c (original)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/socket.c Wed Mar 29 12:58:53 2006
@@ -769,287 +769,6 @@
     }
 }
 
-/**
- * Answer the local host address to which the socket argument is bound.
- *
- * @param	env					pointer to the JNI library
- * @param	thisClz				pointer to the class of the receiver (of the java message)
- * @param	fileDescriptor 	pointer to the file descriptor of the socket to query
- * @param preferIPv6Addresses on V4/V6 nodes, a preference as to which address to return for the node
- *
- * @return	the InetAddress, representing the local host address to which the socket is bound
- */
-
-jobject JNICALL
-Java_java_net_Socket_getSocketLocalAddressImpl (JNIEnv * env, jclass thisClz,
-                                                jobject fileDescriptor,
-                                                jboolean preferIPv6Addresses)
-{
-  PORT_ACCESS_FROM_ENV (env);
-  I_32 result;
-  hysockaddr_struct sockaddrP;
-  jbyte byte_array[HYSOCK_INADDR6_LEN];
-  U_32 length;
-  U_32 scope_id = 0;
-  memset (byte_array, 0, HYSOCK_INADDR6_LEN);
-
-  result =
-    netGetSockAddr (env, fileDescriptor, &sockaddrP, preferIPv6Addresses);
-  if (0 != result)
-    {
-      return newJavaNetInetAddressGenericB (env, byte_array,
-                                            HYSOCK_INADDR_LEN, 0);
-      /*The Java spec allows no exception on this call */
-    }
-  else
-    {
-      hysock_sockaddr_address6 (&sockaddrP, byte_array, &length, &scope_id);
-      /* Cannot call gethostbyaddr since it is not reentrant on some OS's */
-      return newJavaNetInetAddressGenericB (env, byte_array, length,
-                                            scope_id);
-    }
-}
-
-/**
- * Answer the local port to which the socket argument is bound.
- *
- * @param	env					pointer to the JNI library
- * @param	thisClz				pointer to the class of the receiver (of the java message)
- * @param	fileDescriptor 	pointer to the file descriptor of the socket to query
- * @param preferIPv6Addresses on V4/V6 nodes, a preference as to which address to return for the node
- *
- * @return	the local host port to which the socket is bound
- */
-
-jint JNICALL
-Java_java_net_Socket_getSocketLocalPortImpl (JNIEnv * env, jclass thisClz,
-                                             jobject fileDescriptor,
-                                             jboolean preferIPv6Addresses)
-{
-  PORT_ACCESS_FROM_ENV (env);
-  I_32 result;
-  hysockaddr_struct sockaddrP;
-  U_16 nPort, hPort;
-
-  result =
-    netGetSockAddr (env, fileDescriptor, &sockaddrP, preferIPv6Addresses);
-  if (0 != result)
-    {
-      return (jint) 0;          /* The java spec does not indicate any exceptions on this call */
-    }
-  else
-    {
-      nPort = hysock_sockaddr_port (&sockaddrP);
-      hPort = hysock_ntohs (nPort);
-      return (jint) hPort;
-    }
-}
-
-/**
- * Answer the value of the socket option for the socket argument.  Refer to the file nethelp.h
- * for the declarations which map the java option constants to portLib constants.
- *
- * @param	env					pointer to the JNI library
- * @param	thisClz				pointer to the class of the receiver (of the java message)
- * @param	fileDescriptor 	pointer to the file descriptor of the socket to query
- * @param	anOption			a constant, representing the option type to query
- *
- * @return	the java Object, represent the option value
- * @exception SocketException	if an error occurs during the call
- */
-
-jobject JNICALL
-Java_java_net_Socket_getSocketOptionImpl (JNIEnv * env, jclass thisClz,
-                                          jobject aFileDescriptor,
-                                          jint anOption)
-{
-  PORT_ACCESS_FROM_ENV (env);
-  hysocket_t hysocketP;
-
-  hysocketP = getJavaIoFileDescriptorContentsAsPointer (env, aFileDescriptor);
-  if (!hysock_socketIsValid (hysocketP))
-    {
-      throwJavaNetSocketException (env, HYPORT_ERROR_SOCKET_BADSOCKET);
-      return NULL;
-    }
-  switch ((I_32) anOption & 0xffff)
-    {
-    case JAVASOCKOPT_SO_LINGER:
-      return getLingerOption (env, hysocketP);
-    case JAVASOCKOPT_TCP_NODELAY:
-      if ((anOption >> 16) & BROKEN_TCP_NODELAY)
-        return NULL;
-      return getBooleanValue (env, hysocketP, HY_IPPROTO_TCP, HY_TCP_NODELAY);
-    case JAVASOCKOPT_MCAST_TTL:
-      if ((anOption >> 16) & BROKEN_MULTICAST_TTL)
-        return newJavaLangByte (env, 0);
-      return getByteSocketOption (env, hysocketP, HY_MCAST_TTL);
-    case JAVASOCKOPT_MCAST_INTERFACE:
-      if ((anOption >> 16) & BROKEN_MULTICAST_IF)
-        return NULL;
-      return getMcastInterface (env, hysocketP);
-    case JAVASOCKOPT_IP_MULTICAST_IF2:
-      return getIPV6McastInterface (env, hysocketP);
-    case JAVASOCKOPT_SO_SNDBUF:
-      return getSendBufferSize (env, hysocketP);
-    case JAVASOCKOPT_SO_RCVBUF:
-      return getReceiveBufferSize (env, hysocketP);
-    case JAVASOCKOPT_SO_BROADCAST:
-      return getBooleanValue (env, hysocketP, HY_SOL_SOCKET, HY_SO_BROADCAST);
-    case JAVASOCKOPT_SO_REUSEADDR:
-      return getBooleanValue (env, hysocketP, HY_SOL_SOCKET, HY_SO_REUSEADDR);
-    case JAVASOCKOPT_SO_REUSEPORT:
-      return getBooleanValue (env, hysocketP, HY_SOL_SOCKET, HY_SO_REUSEPORT);
-    case JAVASOCKOPT_SO_KEEPALIVE:
-      return getBooleanValue (env, hysocketP, HY_SOL_SOCKET, HY_SO_KEEPALIVE);
-    case JAVASOCKOPT_SO_OOBINLINE:
-      return getBooleanValue (env, hysocketP, HY_SOL_SOCKET, HY_SO_OOBINLINE);
-    case JAVASOCKOPT_IP_MULTICAST_LOOP:
-      return getBooleanValue (env, hysocketP, HY_IPPROTO_IP,
-                              HY_IP_MULTICAST_LOOP);
-    case JAVASOCKOPT_IP_TOS:
-      return getIntegerValue (env, hysocketP, HY_IPPROTO_IP, HY_IP_TOS);
-
-    default:
-      throwJavaNetSocketException (env, HYPORT_ERROR_SOCKET_OPTUNSUPP);
-      return NULL;
-    }
-}
-
-/**
- * Set the value of the socket option to the nominated value.  Refer to the file nethelp.h
- * for the declarations which map the java option constants to portLib constants.
- *
- * @param	env					pointer to the JNI library
- * @param	thisClz				pointer to the class of the receiver (of the java message)
- * @param	fileDescriptor 	pointer to the file descriptor of the socket to set the option on
- * @param	anOption			a constant, representing the option type to set
- * @param	aValue				the option value to set
- *
- * @exception SocketException	if an error occurs during the call
- */
-void JNICALL
-Java_java_net_Socket_setSocketOptionImpl (JNIEnv * env, jclass thisClz,
-                                          jobject aFileDescriptor,
-                                          jint anOption, jobject aValue)
-{
-  PORT_ACCESS_FROM_ENV (env);
-  hysocket_t hysocketP;
-
-  hysocketP = getJavaIoFileDescriptorContentsAsPointer (env, aFileDescriptor);
-  if (!hysock_socketIsValid (hysocketP))
-    {
-      throwJavaNetSocketException (env, HYPORT_ERROR_SOCKET_BADSOCKET);
-      return;
-    }
-  switch ((I_32) anOption & 0xffff)
-    {
-    case JAVASOCKOPT_SO_LINGER:
-      setLingerOption (env, hysocketP, aValue);
-      break;
-    case JAVASOCKOPT_TCP_NODELAY:
-      if ((anOption >> 16) & BROKEN_TCP_NODELAY)
-        return;
-      setBoolSocketOption (env, hysocketP, HY_IPPROTO_TCP, HY_TCP_NODELAY,
-                           aValue);
-      break;
-    case JAVASOCKOPT_MCAST_TTL:
-      if ((anOption >> 16) & BROKEN_MULTICAST_TTL)
-        return;
-      setByteSocketOption (env, hysocketP, HY_MCAST_TTL, aValue);
-      break;
-    case JAVASOCKOPT_MCAST_ADD_MEMBERSHIP:
-      mcastAddMembership (env, hysocketP, aValue,
-                          (anOption >> 16) & BROKEN_MULTICAST_IF);
-      break;
-    case JAVASOCKOPT_MCAST_DROP_MEMBERSHIP:
-      mcastDropMembership (env, hysocketP, aValue,
-                           (anOption >> 16) & BROKEN_MULTICAST_IF);
-      break;
-    case JAVASOCKOPT_MCAST_INTERFACE:
-      if ((anOption >> 16) & BROKEN_MULTICAST_IF)
-        return;
-      setMcastInterface (env, hysocketP, aValue);
-      break;
-    case JAVASOCKOPT_IP_MULTICAST_IF2:
-      setIPV6McastInterface (env, hysocketP, aValue);
-      break;
-    case JAVASOCKOPT_SO_SNDBUF:
-      setSendBufferSize (env, hysocketP, aValue);
-      break;
-    case JAVASOCKOPT_SO_RCVBUF:
-      setReceiveBufferSize (env, hysocketP, aValue);
-      break;
-    case JAVASOCKOPT_SO_BROADCAST:
-      setBoolSocketOption (env, hysocketP, HY_SOL_SOCKET, HY_SO_BROADCAST,
-                           aValue);
-      break;
-    case JAVASOCKOPT_SO_REUSEADDR:
-      setBoolSocketOption (env, hysocketP, HY_SOL_SOCKET, HY_SO_REUSEADDR,
-                           aValue);
-      break;
-    case JAVASOCKOPT_SO_REUSEPORT:
-      setBoolSocketOption (env, hysocketP, HY_SOL_SOCKET, HY_SO_REUSEPORT,
-                           aValue);
-      break;
-    case JAVASOCKOPT_SO_KEEPALIVE:
-      setBoolSocketOption (env, hysocketP, HY_SOL_SOCKET, HY_SO_KEEPALIVE,
-                           aValue);
-      break;
-    case JAVASOCKOPT_SO_OOBINLINE:
-      setBoolSocketOption (env, hysocketP, HY_SOL_SOCKET, HY_SO_OOBINLINE,
-                           aValue);
-      break;
-    case JAVASOCKOPT_IP_MULTICAST_LOOP:
-      setBoolSocketOption (env, hysocketP, HY_IPPROTO_IP,
-                           HY_IP_MULTICAST_LOOP, aValue);
-      break;
-    case JAVASOCKOPT_IP_TOS:
-      setIntegerSocketOption (env, hysocketP, HY_IPPROTO_IP, HY_IP_TOS,
-                              aValue);
-      break;
-    case JAVASOCKOPT_REUSEADDR_AND_REUSEPORT:
-      setReuseAddrAndReusePort (env, hysocketP, aValue);
-      break;
-
-    default:
-      throwJavaNetSocketException (env, HYPORT_ERROR_SOCKET_OPTUNSUPP);
-    }
-}
-
-/**
- * Close the socket.  The behavior of this call is influenced by the set linger option.
- * The Java method calling this native, by specification, does not return completion status 
- * and thus currently this function does return completion status.
- *
- * @param	env					pointer to the JNI library
- * @param	thisClz				pointer to the class of the receiver (of the java message)
- * @param	fileDescriptor 	pointer to the file descriptor of the socket to close
- */
-void JNICALL
-Java_java_net_Socket_socketCloseImpl (JNIEnv * env, jclass thisClz,
-                                      jobject fileDescriptor)
-{
-  PORT_ACCESS_FROM_ENV (env);
-  hysocket_t socketP;
-
-  socketP = getJavaIoFileDescriptorContentsAsPointer (env, fileDescriptor);
-  if (hysock_socketIsValid (socketP))
-    {
-      /* Set the file descriptor before closing so the select polling loop will terminate. */
-      /* Some platforms wait in the socket close. */
-      setJavaIoFileDescriptorContentsAsPointer (env, fileDescriptor,
-                                                (void *) -1);
-      hysock_close (&socketP);
-    }
-}
-
-void JNICALL
-Java_java_net_Socket_oneTimeInitialization (JNIEnv * env, jclass clazz,
-                                            jboolean jcl_supports_ipv6)
-{
-  netInitializeIDCaches (env, jcl_supports_ipv6);
-}
 
 /**
  * Set a boolean socket option.
@@ -1219,18 +938,6 @@
   return newJavaLangBoolean (env, optval);
 }
 
-jint JNICALL
-Java_java_net_Socket_getSocketFlags (JNIEnv * env, jclass thisClz)
-{
-  /* Return the flags indicating the socket state to save in the class library. */
-  /* 1 - Multicast interface */
-  /* 2 - Multicast TTL */
-  /* 4 - Socket TCP_NODELAY */
-  /* 8 - Calling shutdown output before close when SO_LINGER is set */
-
-  return 0;
-
-}
 
 /**
  * Answer the byte value of the specified option for the socket argument,



Mime
View raw message