JavaNativeMethodImpl_OpenJDK6.st
branchdevelopment
changeset 2657 d7adb8d06c1c
parent 2656 415a8ada238c
child 2658 dd506d4837a4
--- a/JavaNativeMethodImpl_OpenJDK6.st	Thu Aug 15 23:32:16 2013 +0100
+++ b/JavaNativeMethodImpl_OpenJDK6.st	Fri Aug 16 09:59:11 2013 +0100
@@ -12595,76 +12595,37 @@
     "Modified: / 30-01-2013 / 17:50:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-_java_net_PlainSocketImpl_socketConnect: this _:a1 _: a2 _: a3
+_java_net_PlainSocketImpl_socketConnect: this _:jaddr _: port _: a3
 
     <javanative: 'java/net/PlainSocketImpl' name: 'socketConnect(Ljava/net/InetAddress;II)V'>
 
-    |jsock jaddr port sock addr hostName ok|
-
-    jsock := this.
-    jaddr := a1.
-    port := a2.
-
-    hostName := jaddr instVarNamed:'hostName'.
-    hostName notNil ifTrue:[
-        hostName := Java as_ST_String:hostName
-    ] ifFalse:[
-        addr := jaddr instVarNamed:'address'.
-        addr notNil ifTrue:[
-            hostName := ByteArray new:4.
-            hostName at:4 put:(addr bitAnd:16rFF).
-            addr := addr bitShift:-8.
-            hostName at:3 put:(addr bitAnd:16rFF).
-            addr := addr bitShift:-8.
-            hostName at:2 put:(addr bitAnd:16rFF).
-            addr := addr bitShift:-8.
-            hostName at:1 put:(addr bitAnd:16rFF).
-        ].
-    ].
-    hostName isNil ifTrue:[
-        self halt.
-    ].
-
-    sock := self validateFile:jsock.
-    sock notNil ifTrue:[
-        FileIOTrace ifTrue:[
-            Logger log: ('socket connect to ' , hostName printString , ' port ' , port printString) severity: #trace facility: #JVM.
-        ].
-        SocketConnectConfirmation ifTrue:[
-            (PermittedHostConnects isNil
-            or:[(PermittedHostConnects includes:hostName) not]) ifTrue:[
-                (self confirm:'connect to host: ' , hostName printString , ' - ok ?')
-                ifFalse:[
-                    JavaVM throwIOExceptionWithMessage:'connect permission denied'.
-                ].
-
-                (self confirm:('JAVA Security check\\Always permit connects to this host (''' , hostName printString , ''') ?') withCRs)
-                ifTrue:[
-                    PermittedHostConnects isNil ifTrue:[
-                        PermittedHostConnects := Set new
-                    ].
-                    PermittedHostConnects add:hostName.
-                ]
-            ]
-        ].
-
-        [
-            ok := sock connectTo:hostName port:port.
-            ok ifFalse:[
-                JavaVM throwExceptionClassName:'java.net.ConnectException' withMessage:'connect failed'.
-            ].
-            jsock instVarNamed: #localport put: sock port.
-            jsock instVarNamed: #address put: jaddr.
-        ] on: Error do:[:ex|
-            JavaVM throwExceptionClassName:'java.net.ConnectException' withMessage:'connect failed: ' , ex description
-        ].
-
+    | sock sockaddr ok|
+
+    jaddr isNil ifTrue:[
+        JavaVM throwNullPointerException: 'address parameter is nil'.
+        ^ nil.
+    ].
+
+    sockaddr := IPSocketAddress new.
+    sockaddr hostAddress: (jaddr perform: #'getAddress()[B').    
+    sockaddr port: port.           
+
+    sock := self validateFile:this.
+
+    [
+        ok := sock connectTo:sockaddr port:port.
+        ok ifFalse:[
+            JavaVM throwExceptionClassName:'java.net.ConnectException' withMessage:'connect failed'.
+        ].
+        this instVarNamed: #localport put: sock port.
+        this instVarNamed: #address put: jaddr.
+    ] on: Error do:[:ex|
+        JavaVM throwExceptionClassName:'java.net.ConnectException' withMessage:'connect failed: ' , ex description
     ].
 
     "Created: / 25-01-1998 / 20:02:27 / cg"
     "Modified: / 30-12-1998 / 20:10:28 / cg"
-    "Modified: / 13-11-2011 / 23:16:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified (format): / 15-08-2013 / 23:11:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 16-08-2013 / 09:56:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_net_PlainSocketImpl_socketCreate: this _:a1