src/JavaVM.st
branchjk_new_structure
changeset 885 5934b58e7507
parent 883 b0eecab8d572
child 886 cccfdbf664a7
--- a/src/JavaVM.st	Sun Aug 07 18:33:00 2011 +0000
+++ b/src/JavaVM.st	Sun Aug 07 21:41:38 2011 +0000
@@ -4109,11 +4109,38 @@
     "Modified (comment): / 05-08-2011 / 18:37:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+_java_lang_ClassLoader_findBootstrapClass: nativeContext
+
+    <javanative: 'java/lang/ClassLoader' name: 'findBootstrapClass'>
+
+    | nm class |
+    nm := Java as_ST_String: (nativeContext argAt:1).
+    class := JavaClassReader loadClassLazy: nm.
+    ^class notNil ifTrue:[
+        self reflection javaClassObjectForClass:class
+    ] ifFalse:[
+        self throwClassNotFoundException: nm
+    ]
+
+    "Modified: / 07-08-2011 / 21:37:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 _java_lang_ClassLoader_findLoadedClass0: nativeContext
 
     <javanative: 'java/lang/ClassLoader' name: 'findLoadedClass0'>
 
-    ^ UnimplementedNativeMethodSignal raise
+    "
+    The <tt>Class</tt> object, or <tt>null</tt> if the class has not been loaded
+    "        
+    |  class |
+    class := Java at: (Java as_ST_String: (nativeContext argAt:1)).
+    ^class notNil ifTrue:[
+        self reflection javaClassObjectForClass:class
+    ] ifFalse:[
+        nil
+    ]
+
+    "Modified: / 07-08-2011 / 21:19:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_lang_ClassLoader_registerNatives: aJavaContext
@@ -4610,15 +4637,16 @@
      * @since 1.3
      */
     "
-    | f |
+    | f b |
     f := aJavaContext argAt:1.
     (f =  0.0) ifTrue:[^0].
     (f = -0.0) ifTrue:[^(1 bitShift: 63)].
 
-    self error:'Not yet implemented since I''m lazy'.
+    b := ByteArray streamContents:[:s|Float storeBinaryIEEEDouble:f on:s].
+    ^ LargeInteger digitBytes: b MSB: UninterpretedBytes isBigEndian not.
 
     "Created: / 10-11-2010 / 14:48:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 31-05-2011 / 10:13:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 07-08-2011 / 21:43:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_lang_Double_longBitsToDouble: nativeContext
@@ -4696,15 +4724,16 @@
      * @since 1.3
      */
     "
-    | f exponent mantissa |
+    | f b |
     f := aJavaContext argAt:1.
     (f =  0.0) ifTrue:[^0].
     (f = -0.0) ifTrue:[^(1 bitShift: 31) ].
 
-    self error: 'Not yet implemented since I''m bit lazy'.
+    b := ByteArray streamContents:[:s|ShortFloat storeBinaryIEEESingle:f on:s].
+    ^ (LargeInteger digitBytes: b MSB: UninterpretedBytes isBigEndian not) compressed
 
     "Created: / 09-11-2010 / 20:59:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 31-05-2011 / 10:13:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 07-08-2011 / 21:45:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_lang_Object_clone: nativeContext
@@ -5081,6 +5110,15 @@
     "Modified: / 01-04-2011 / 18:14:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+_java_lang_System_nanoTime: nativeContext
+
+    <javanative: 'java/lang/System' name: 'nanoTime'>
+
+    ^ OperatingSystem getMicrosecondTime * 1000
+
+    "Modified: / 07-08-2011 / 21:47:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 _java_lang_System_registerNatives: aJavaContext
 
     <javanative: 'java/lang/System' name: 'registerNatives'>
@@ -5567,7 +5605,11 @@
 
     <javanative: 'java/util/concurrent/atomic/AtomicLong' name: 'VMSupportsCS8'>
 
-    ^ UnimplementedNativeMethodSignal raise
+    "Should be safe - say we don't support lockless updates"        
+
+    ^ 0
+
+    "Modified: / 07-08-2011 / 20:53:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !JavaVM class methodsFor:'native - java.util.jar'!
@@ -13390,6 +13432,25 @@
 
     <javanative: 'sun/misc/Unsafe' name: 'compareAndSwapInt'>
 
+    ^self _sun_misc_Unsafe_compareAndSwapObject: aJavaContext
+
+    "Created: / 22-11-2010 / 18:40:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 07-08-2011 / 21:50:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_compareAndSwapLong: aJavaContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'compareAndSwapInt'>
+
+    ^self _sun_misc_Unsafe_compareAndSwapObject: aJavaContext
+
+    "Modified: / 07-08-2011 / 21:50:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_compareAndSwapObject: aJavaContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'compareAndSwapInt'>
+
         "
     /**
      * Atomically update Java variable to <tt>x</tt> if it is currently
@@ -13410,20 +13471,12 @@
     OperatingSystem blockInterrupts.
     real := o instVarAt: offset.
     (real == expected)
-            ifTrue:[o instVarAt: offset put: new. ok := true]
-            ifFalse:[ok := false].
+            ifTrue:[o instVarAt: offset put: new. ok := 1]
+            ifFalse:[ok := 1].
     OperatingSystem unblockInterrupts.
     ^ok
 
-    "Created: / 22-11-2010 / 18:40:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 06-02-2011 / 12:10:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-_sun_misc_Unsafe_compareAndSwapObject: nativeContext
-
-    <javanative: 'sun/misc/Unsafe' name: 'compareAndSwapObject'>
-
-    ^ UnimplementedNativeMethodSignal raise
+    "Modified: / 07-08-2011 / 21:53:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _sun_misc_Unsafe_defineClass: nativeContext