JavaNativeMethodImpl_OpenJDK6.st
branchdevelopment
changeset 2658 dd506d4837a4
parent 2657 d7adb8d06c1c
child 2659 d64692c5d7e8
--- a/JavaNativeMethodImpl_OpenJDK6.st	Fri Aug 16 09:59:11 2013 +0100
+++ b/JavaNativeMethodImpl_OpenJDK6.st	Sat Aug 17 09:57:56 2013 +0100
@@ -12543,47 +12543,38 @@
     "Modified: / 30.12.1998 / 20:10:08 / cg"
 !
 
-_java_net_PlainSocketImpl_socketBind: this _:a1 _: a2
+_java_net_PlainSocketImpl_socketBind: this _: addr _:  port
 
     <javanative: 'java/net/PlainSocketImpl' name: 'socketBind(Ljava/net/InetAddress;I)V'>
 
-    |jsock jaddr port sock hostName ok err|
-
-    jsock := this.
-    jaddr := a1.
-    port := a2.
-
-    hostName := jaddr instVarNamed:'hostName'.
-    hostName isNil ifTrue:[
-        self halt.
-    ] ifFalse:[
-        hostName := Java as_ST_String:hostName
-    ].
-
-    sock := self validateFile:jsock.
+    |sock sockaddr ok err|
+
+    sockaddr := IPSocketAddress new.
+    sockaddr hostAddress: (addr perform: #'getAddress()[B').    
+    sockaddr port: port.    
+
+    sock := self validateFile:this.
     sock notNil ifTrue:[
         FileIOTrace ifTrue:[
-            ('JAVA: socket bind to ' , hostName printString, ' port ' , port printString) infoPrintCR
+            ('JAVA: socket bind to ' , sockaddr printString, ' port ' , port printString) infoPrintCR
         ].
 
         [
-            ok := sock bindTo:port address:nil "hostName".
+            ok := sock bindTo:port address: sockaddr
         ] on: Error do: [:ex|
-            JavaVM throwExceptionClassName:'java.net.BindException'
-    withMessage:'bind failed: ' , ex description.
+            JavaVM throwExceptionClassName:'java.net.BindException' withMessage:'bind failed: ' , ex description.
         ].
         ok ifFalse:[
             err := OperatingSystem lastErrorString.
-            JavaVM throwExceptionClassName:'java.net.BindException'
-    withMessage:'bind failed: ' , err.
-        ].
-       jsock instVarNamed: #localport put: sock port.
-       jsock instVarNamed: #address put: jaddr.
+            JavaVM throwExceptionClassName:'java.net.BindException' withMessage:'bind failed: ' , err.
+        ].
+       this instVarNamed: #localport put: sock port.
+       this instVarNamed: #address put: addr.
     ].
 
     "Created: / 04-02-1998 / 15:06:20 / cg"
     "Modified: / 30-12-1998 / 20:10:16 / cg"
-    "Modified: / 19-11-2011 / 00:43:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 17-08-2013 / 09:54:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_net_PlainSocketImpl_socketClose0: this _:a1
@@ -12886,46 +12877,39 @@
     "Modified: / 09-11-2011 / 22:27:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-_java_net_SocketInputStream_socketRead0: this _:a1 _: a2 _: a3 _: a4 _: a5
+_java_net_SocketInputStream_socketRead0: this _:fdObj _: data _: off _: len _: timeout
 
     <javanative: 'java/net/SocketInputStream' name: 'socketRead0(Ljava/io/FileDescriptor;[BIII)I'>
 
-    | fdObj data off len timeout sock nread |
-    fdObj   := a1.
-    data    := a2.
-    off     := a3.
-    len     := a4.
-    timeout := a5.
+    | sock nread timeoutOrNil |
 
     fdObj isNil ifTrue:[
-        JavaVM
-    throwSocketException:'Socket closed (null fdObj passed to socketRead0)'.
+        JavaVM throwSocketException:'Socket closed (null fdObj passed to socketRead0)'.
         ^ -1.
     ].
 
+    timeoutOrNil := nil.
     sock := self validateFile: fdObj.
-
     timeout ~~ 0 ifTrue:[
-        [
-            (sock readWaitWithTimeout: timeout) ifTrue:[
-                JavaVM throwExceptionClassName:'java.net.SocketTimeoutException'
-    withMessage:'Read timed out'.
-                ^ -1.
-            ].
-        ] on: Error do:[:ex|
-            JavaVM throwSocketException:'Error when reading: ' , ex description.
-        ]
+        timeoutOrNil := timeout.
+        Transcript show: ' -- timeout '; showCR: timeout printString.
     ].
 
     [
-        nread := sock nextAvailableBytes: len into: data startingAt: off + 1
+        (sock readWaitWithTimeoutMs: timeoutOrNil) ifTrue:[
+            JavaVM throwExceptionClassName:'java.net.SocketTimeoutException' withMessage:'Read timed out'.
+            ^ -1.
+        ].
+        nread := sock nextAvailableBytes: len into: data startingAt: off + 1.
+        Transcript show: '<   '; showCR: nread printString.
+        Transcript show: '<-- '; showCR: (data copyFrom: off + 1 to: off + nread ) asString.
     ] on: Error do:[:ex|
         JavaVM throwSocketException:'Error when reading: ' , ex description.
     ].
 
     ^nread
 
-    "Modified: / 04-12-2011 / 20:24:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (format): / 17-08-2013 / 09:44:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_net_SocketOutputStream_init: this
@@ -12949,8 +12933,7 @@
 
 
     fdObj isNil ifTrue:[
-        JavaVM
-    throwSocketException:'Socket closed (null fdObj passed to socketRead0)'.
+        JavaVM throwSocketException:'Socket closed (null fdObj passed to socketRead0)'.
         ^ -1.
     ].
 
@@ -12958,12 +12941,12 @@
 
     [
         sock nextPutBytes: len from: data startingAt: off + 1.
+        Transcript show: '--> '; showCR: (data copyFrom: off + 1 to: off + len ) asString.
     ] on: Error do:[:ex|
-        JavaVM
-    throwIOExceptionWithMessage:'Error when writing: ' , ex description.
-    ].
-
-    "Modified: / 13-11-2011 / 23:53:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+        JavaVM throwIOExceptionWithMessage:'Error when writing: ' , ex description.
+    ].
+
+    "Modified: / 17-08-2013 / 09:24:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - java.nio'!
@@ -18913,9 +18896,9 @@
     ].
 
     process := Processor activeProcess.
-    self park: process timeout: tout.
-
-    "Modified: / 16-08-2012 / 21:52:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    JavaVM park: process timeout: tout.
+
+    "Modified: / 17-08-2013 / 09:49:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _sun_misc_Unsafe_putAddress: this _: a1 _: a2 _: a3