thread>>name mauve test passes jk_new_structure
authorhlopkmar
Tue, 29 Nov 2011 11:15:52 +0000
branchjk_new_structure
changeset 1173 5eefc8f414bd
parent 1172 7795b5618017
child 1174 5ea95cf8f73d
thread>>name mauve test passes
src/JavaVM.st
--- a/src/JavaVM.st	Tue Nov 29 10:22:50 2011 +0000
+++ b/src/JavaVM.st	Tue Nov 29 11:15:52 2011 +0000
@@ -2952,7 +2952,6 @@
 
 newThread: name 
     | thread  threadClass  i |
-
     threadClass := JavaVM classForName: 'java.lang.Thread'.
     thread := threadClass basicNew.
     thread instVarNamed: 'name' put: (Java as_String: name).
@@ -2962,7 +2961,8 @@
     thread instVarNamed: 'daemon' put: 0.
     thread instVarNamed: 'stillborn' put: 0.
     thread instVarNamed: 'target' put: nil.
-    thread instVarNamed: 'blockerLock' put: (JavaVM classForName:'java.lang.Object') basicNew.
+    thread instVarNamed: 'blockerLock'
+        put: (JavaVM classForName: 'java.lang.Object') basicNew.
     
     "/
     "/ that on was only temporarily present in JDK1.1.3 (sigh)
@@ -2972,11 +2972,14 @@
         thread instVarAt: i put: 0.
     ].
     thread instVarNamed: 'group' put: (self standardThreadGroup).
+    threadClass classLoader isNil ifTrue: [thread instVarNamed:'contextClassLoader' put: self systemClassLoader] ifFalse: [thread instVarNamed: 'contextClassLoader' put: threadClass classLoader].
+    self breakPoint:#mh.
     ^ thread
 
     "Created: / 03-01-1998 / 01:47:30 / cg"
     "Modified: / 27-01-1998 / 00:54:33 / cg"
     "Modified: / 21-11-2011 / 09:48:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 29-11-2011 / 12:15:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 !
 
 stProcessForJavaThread:jThread
@@ -6443,94 +6446,76 @@
     ^ Java intern:jString
 !
 
-_java_lang_System_arraycopy: nativeContext
-
+_java_lang_System_arraycopy: nativeContext 
     <javanative: 'java/lang/System' name: 'arraycopy'>
-
-    |srcArray srcIdx dstArray dstIdx srcArrayCC dstArrayCC count dstEndIdx|
-
-    srcArray := nativeContext argAt:1.
-    srcArray isNil ifTrue:[
-        ^ self throwNullPointerException
-    ].
-    srcArray isJavaArray ifFalse:[
-        ^ self throwArrayStoreException:srcArray
-    ].
-    srcIdx := nativeContext argAt:2.
-    dstArray := nativeContext argAt:3.
-    dstArray isNil ifTrue:[
-        ^ self throwNullPointerException
-    ].
-    dstArray isJavaArray ifFalse:[
-        ^ self throwArrayStoreException:dstArray
-    ].
-
+    | srcArray  srcIdx  dstArray  dstIdx  srcArrayCC  dstArrayCC  count  dstEndIdx |
+    srcArray := nativeContext argAt: 1.
+    srcArray isNil ifTrue: [ ^ self throwNullPointerException ].     
+    srcArray isJavaArray ifFalse: [ "mh 29.11.11 dirty ugly hack, pretend that java string is char array"
+    (self canCast:srcArray class to: (self classNamed:'java/lang/String')) ifTrue: [srcArray := srcArray instVarNamed: #value] ifFalse: [
+    ^ self throwArrayStoreException: srcArray] ].
+    srcIdx := nativeContext argAt: 2.
+    dstArray := nativeContext argAt: 3.
+    dstArray isNil ifTrue: [ ^ self throwNullPointerException ].
+    dstArray isJavaArray ifFalse: [ ^ self throwArrayStoreException: dstArray ].
     srcArrayCC := srcArray class javaComponentClass.
     dstArrayCC := dstArray class javaComponentClass.
-
-    srcArrayCC isJavaPrimitiveType == dstArrayCC isJavaPrimitiveType 
-        ifTrue:
-            [srcArrayCC isJavaPrimitiveType
-                ifTrue:
-                    [srcArrayCC ~~ dstArrayCC ifTrue:
-                        [^ self throwArrayStoreException:dstArray]].
-            ]
-        ifFalse:
-            [^ self throwArrayStoreException:dstArray].
-
-    dstIdx := nativeContext argAt:4.
-    count := nativeContext argAt:5.
-
-    count < 0 ifTrue:[
-        ^ self throwArrayIndexOutOfBoundsException:(srcIdx + count - 1)        
-    ].
-
-    ((srcIdx < 0) or:[srcIdx + count > srcArray size]) ifTrue:[
-        srcArray size == 0 ifTrue:[
-            srcArray isVariable ifFalse:[
-                ^ self throwArrayStoreException:srcArray
+    srcArrayCC isJavaPrimitiveType == dstArrayCC isJavaPrimitiveType ifTrue: [
+        srcArrayCC isJavaPrimitiveType ifTrue: [
+            srcArrayCC ~~ dstArrayCC ifTrue: [ ^ self throwArrayStoreException: dstArray ]
+        ].
+    ] ifFalse: [ ^ self throwArrayStoreException: dstArray ].
+    dstIdx := nativeContext argAt: 4.
+    count := nativeContext argAt: 5.
+    count < 0 ifTrue: [
+        ^ self throwArrayIndexOutOfBoundsException: (srcIdx + count - 1)
+    ].
+    ((srcIdx < 0) or: [ srcIdx + count > srcArray size ]) ifTrue: [
+        srcArray size == 0 ifTrue: [
+            srcArray isVariable ifFalse: [ ^ self throwArrayStoreException: srcArray ]
+        ].
+        ^ self throwArrayIndexOutOfBoundsException: (srcIdx + count - 1)
+    ].
+    ((dstIdx < 0) or: [ dstIdx + count > dstArray size ]) ifTrue: [
+        dstArray size == 0 ifTrue: [
+            dstArray isVariable ifFalse: [ ^ self throwArrayStoreException: dstArray ]
+        ].
+        ^ self throwArrayIndexOutOfBoundsException: (dstIdx + count - 1)
+    ].
+    dstEndIdx := dstIdx + count.
+    dstIdx := dstIdx + 1.
+    srcIdx := srcIdx + 1.
+    (srcArray class isBytes and: [ dstArray class isBytes ]) ifTrue: [
+        dstArray 
+            replaceBytesFrom: dstIdx
+            to: dstEndIdx
+            with: srcArray
+            startingAt: srcIdx.
+    ] ifFalse: [
+        dstArrayCC isJavaPrimitiveType ifFalse: [
+            "Copy from array iff src=dst to avoid overwriting a data when copying"
+            srcArray == dstArray ifTrue: [ srcArray := srcArray copy ].
+            1 to: count do: [
+                :i | 
+                | obj |
+                obj := srcArray at: srcIdx + i - 1.
+                (obj notNil and: [ (self canCast: obj class to: dstArrayCC) not ]) ifTrue: [
+                    ^ self throwArrayStoreException: dstArray
+                ].
+                dstArray at: dstIdx + i - 1 put: (srcArray at: srcIdx + i - 1)
             ]
-        ].
-        ^ self throwArrayIndexOutOfBoundsException:(srcIdx + count - 1)
-    ].
-    ((dstIdx < 0) or:[dstIdx + count > dstArray size]) ifTrue:[
-        dstArray size == 0 ifTrue:[
-            dstArray isVariable ifFalse:[
-                ^ self throwArrayStoreException:dstArray
-            ]
-        ].
-        ^ self throwArrayIndexOutOfBoundsException:(dstIdx + count - 1)
-    ].
-
-    dstEndIdx := dstIdx + count.
-    dstIdx := dstIdx + 1.       "/ ST uses 1-based indexing
-    srcIdx := srcIdx + 1.       "/ ST uses 1-based indexing
-
-
-
-    (srcArray class isBytes and:[dstArray class isBytes]) ifTrue:[
-        dstArray replaceBytesFrom:dstIdx to:dstEndIdx with:srcArray startingAt:srcIdx.
-    ] ifFalse:[
-        dstArrayCC isJavaPrimitiveType ifFalse:[
-            "Copy from array iff src=dst to avoid overwriting a data when copying"
-            srcArray == dstArray ifTrue:[srcArray := srcArray copy].
-            1 to: count do:[:i|
-                | obj |
-
-                obj := srcArray at:srcIdx + i - 1.
-
-                (obj notNil and:[(self canCast: obj class to: dstArrayCC) not]) ifTrue:[
-                    ^ self throwArrayStoreException:dstArray
-                ].
-                dstArray at: dstIdx + i - 1 put: (srcArray at:srcIdx + i - 1)
-            ]
-        ] ifTrue:[
-            dstArray replaceFrom:dstIdx to:dstEndIdx with:srcArray startingAt:srcIdx.
+        ] ifTrue: [
+            dstArray 
+                replaceFrom: dstIdx
+                to: dstEndIdx
+                with: srcArray
+                startingAt: srcIdx.
         ]
     ].
     ^ nil.
 
     "Modified: / 08-09-2011 / 15:25:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 29-11-2011 / 12:17:17 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 !
 
 _java_lang_System_currentTimeMillis: nativeContext