Make rest of native methods not using nativeContext parameter. refactoring-vmdata
authorJan Vrany <jan.vrany@fit.cvut.cz>
Wed, 30 Jan 2013 14:24:21 +0000
branchrefactoring-vmdata
changeset 2009 d904ed10c6b7
parent 2008 c348b894fbfe
child 2010 9bacff8c53de
Make rest of native methods not using nativeContext parameter.
JavaNativeMethodImpl_OpenJDK6.st
--- a/JavaNativeMethodImpl_OpenJDK6.st	Wed Jan 30 13:27:16 2013 +0000
+++ b/JavaNativeMethodImpl_OpenJDK6.st	Wed Jan 30 14:24:21 2013 +0000
@@ -71,6 +71,27 @@
 "
 ! !
 
+!JavaNativeMethodImpl_OpenJDK6 class methodsFor:'helpers'!
+
+nativeContext
+    "Return a context (JavaContext) of the native method
+     being executed. Should be used only by certain methods
+     like getCallingClassLoader or so"
+
+    | ctx |
+
+    ctx := thisContext sender.
+    [ ctx isJavaContext ] whileFalse:[
+        ctx := ctx sender.
+    ].
+    self assert: ctx method notNil.
+    self assert: ctx method isJavaMethod.
+    self assert: ctx method isNative.
+    ^ctx.
+
+    "Created: / 30-01-2013 / 14:11:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !JavaNativeMethodImpl_OpenJDK6 class methodsFor:'helpers - awt'!
 
 commonReshapeComponent: nativeContext
@@ -931,7 +952,7 @@
     ].
 
     "Lookup the method here - hack, because of those stupid package private methods"
-    method isStatic not ifTrue:[
+    method isStatic ifFalse:[
         method := JavaLookup instance
                     lookupMethodForSelector: method selector
                                  directedTo: obj class
@@ -972,7 +993,7 @@
     ^retval.
 
     "Created: / 05-07-2012 / 23:48:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 16-01-2013 / 22:03:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 30-01-2013 / 14:00:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - UNPORTED'!
@@ -7000,9 +7021,9 @@
 
     <javanative: 'java/io/FileInputStream' name: 'close0()V'>
 
-    ^self commonClose: nativeContext
-
-    "Modified: / 10-08-2011 / 14:03:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    ^self commonClose: self nativeContext
+
+    "Modified: / 30-01-2013 / 14:13:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_io_FileInputStream_initIDs: this _context: nativeContext
@@ -7105,10 +7126,10 @@
 
     <javanative: 'java/io/FileInputStream' name: 'readBytes([BII)I'>
 
-    ^ self anyStream_readBytes: nativeContext
+    ^ self anyStream_readBytes: self nativeContext
 
     "Modified: / 04-02-1998 / 15:23:08 / cg"
-    "Modified (format): / 10-08-2011 / 21:32:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 30-01-2013 / 14:13:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_io_FileInputStream_skip: this _:a1 _: a2 _context: nativeContext
@@ -7142,9 +7163,9 @@
 
     <javanative: 'java/io/FileOutputStream' name: 'close0()V'>
 
-    ^self commonClose: nativeContext
-
-    "Modified: / 10-08-2011 / 14:03:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    ^self commonClose: self nativeContext
+
+    "Modified: / 30-01-2013 / 14:13:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_io_FileOutputStream_initIDs: this _context: nativeContext
@@ -7160,20 +7181,20 @@
 
     <javanative: 'java/io/FileOutputStream' name: 'open(Ljava/lang/String;)V'>
 
-    ^ self commonOpen: nativeContext forAppend:false
+    ^ self commonOpen: self nativeContext forAppend:false
 
     "Modified: / 07-04-1998 / 19:14:31 / cg"
-    "Modified (format): / 10-08-2011 / 14:25:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 30-01-2013 / 14:13:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_io_FileOutputStream_openAppend: this _:a1 _context: nativeContext
 
     <javanative: 'java/io/FileOutputStream' name: 'openAppend(Ljava/lang/String;)V'>
 
-    ^ self commonOpen: nativeContext forAppend:true
+    ^ self commonOpen: self nativeContext forAppend:true
 
     "Modified: / 07-04-1998 / 19:13:42 / cg"
-    "Modified (format): / 10-08-2011 / 23:48:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 30-01-2013 / 14:13:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_io_FileOutputStream_write: this _:a1 _context: nativeContext
@@ -7210,9 +7231,10 @@
 
     <javanative: 'java/io/FileOutputStream' name: 'writeBytes([BII)V'>
 
-        ^ self anyStream_writeBytes: nativeContext
-
-    "Modified: / 4.2.1998 / 15:24:20 / cg"
+        ^ self anyStream_writeBytes: self nativeContext
+
+    "Modified: / 04-02-1998 / 15:24:20 / cg"
+    "Modified: / 30-01-2013 / 14:13:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_io_FileSystem_getFileSystem: this _context: nativeContext
@@ -7250,7 +7272,7 @@
     "
 
     | ctx cl |
-    ctx := nativeContext.
+    ctx := self nativeContext.
     [ ctx notNil ] whileTrue:[
         ctx receiver isJavaObject ifTrue:[
             (cl := ctx receiver class classLoader) notNil ifTrue:[
@@ -7263,7 +7285,7 @@
     ].
     ^nil
 
-    "Modified: / 30-08-2011 / 16:00:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 30-01-2013 / 14:13:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_io_ObjectStreamClass_hasStaticInitializer: this _:a1 _context: nativeContext
@@ -7296,9 +7318,9 @@
 
     <javanative: 'java/io/RandomAccessFile' name: 'close0()V'>
 
-    ^ self commonClose: nativeContext
-
-    "Modified: / 06-07-2012 / 00:09:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    ^ self commonClose: self nativeContext
+
+    "Modified: / 30-01-2013 / 14:17:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_io_RandomAccessFile_getFilePointer: this _context: nativeContext
@@ -7468,10 +7490,10 @@
 
     <javanative: 'java/io/RandomAccessFile' name: 'readBytes([BII)I'>
 
-    ^ self anyStream_readBytes: nativeContext
+    ^ self anyStream_readBytes: self nativeContext
 
     "Modified: / 04-02-1998 / 15:23:27 / cg"
-    "Modified (format): / 06-07-2012 / 00:08:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 30-01-2013 / 14:14:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_io_RandomAccessFile_seek: this _:a1 _: a2 _context: nativeContext
@@ -7497,10 +7519,10 @@
 
     <javanative: 'java/io/RandomAccessFile' name: 'writeBytes([BII)V'>
 
-        ^ self anyStream_writeBytes: nativeContext
-
-    "Modified: / 4.2.1998 / 15:24:20 / cg"
-    "Created: / 4.2.1998 / 15:24:35 / cg"
+        ^ self anyStream_writeBytes: self nativeContext
+
+    "Created: / 04-02-1998 / 15:24:35 / cg"
+    "Modified: / 30-01-2013 / 14:14:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_io_UnixFileSystem_canonicalize0: this _:a1 _context: nativeContext
@@ -7869,9 +7891,10 @@
 
     <javanative: 'java/io/WinNTFileSystem' name: 'createFileExclusively(Ljava/lang/String;)Z'>
 
-    ^ self _java_io_UnixFileSystem_createFileExclusively: nativeContext
+    ^ self _java_io_UnixFileSystem_createFileExclusively: this _:a1 _context: nil
 
     "Modified: / 18-08-2011 / 17:26:11 / jv"
+    "Modified: / 30-01-2013 / 14:17:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_io_WinNTFileSystem_delete0: this _:a1 _context: nativeContext
@@ -7885,36 +7908,40 @@
 
     <javanative: 'java/io/WinNTFileSystem' name: 'getBooleanAttributes(Ljava/io/File;)I'>
 
-    ^ self _java_io_UnixFileSystem_getBooleanAttributes0: nativeContext
+    ^ self _java_io_UnixFileSystem_getBooleanAttributes0: this _:a1 _context: nil
 
     "Created: / 01-04-2011 / 18:10:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 30-01-2013 / 14:17:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_io_WinNTFileSystem_getLastModifiedTime: this _:a1 _context: nativeContext
 
     <javanative: 'java/io/WinNTFileSystem' name: 'getLastModifiedTime(Ljava/io/File;)J'>
 
-    ^ self _java_io_UnixFileSystem_getLastModifiedTime: nativeContext
+    ^ self _java_io_UnixFileSystem_getLastModifiedTime: this _:a1 _context: nil
 
     "Modified: / 18-08-2011 / 14:12:07 / jv"
+    "Modified: / 30-01-2013 / 14:17:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_io_WinNTFileSystem_getLength: this _:a1 _context: nativeContext
 
     <javanative: 'java/io/WinNTFileSystem' name: 'getLength(Ljava/io/File;)J'>
 
-    ^ self _java_io_UnixFileSystem_getLength: nativeContext
+    ^ self _java_io_UnixFileSystem_getLength: this _:a1 _context: nil
 
     "Modified: / 18-08-2011 / 14:15:36 / jv"
+    "Modified: / 30-01-2013 / 14:17:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_io_WinNTFileSystem_list: this _:a1 _context: nativeContext
 
     <javanative: 'java/io/WinNTFileSystem' name: 'list(Ljava/io/File;)[Ljava/lang/String;'>
 
-    ^ self _java_io_UnixFileSystem_list: nativeContext
+    ^ self _java_io_UnixFileSystem_list: this _:a1 _context: nil
 
     "Modified: / 01-09-2011 / 21:46:37 / jv"
+    "Modified: / 30-01-2013 / 14:17:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - java.lang'!
@@ -8266,10 +8293,10 @@
 
 _java_lang_Class_getDeclaredFields0: this _:a1 _context: nativeContext
     <javanative: 'java/lang/Class' name: 'getDeclaredFields0(Z)[Ljava/lang/reflect/Field;'>
-    |javaClassObject class fields publicOnly|
+    |class fields publicOnly|
 
     class := Reflection
-                classForJavaClassObject:(javaClassObject := nativeContext argAt:0).
+                classForJavaClassObject:(this).
     (class isJavaPrimitiveType or:[class isJavaArrayClass]) ifTrue:[
         ^(JavaVM classForName:'java.lang.reflect.Field') javaArrayClass new:0.
     ].
@@ -8280,7 +8307,7 @@
 
     "Created: / 10-11-2010 / 16:22:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 28-01-2011 / 15:19:06 / Marcel Hlopko <hlopik@gmail.com>"
-    "Modified: / 22-08-2012 / 12:16:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 30-01-2013 / 14:15:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_lang_Class_getDeclaredMethods0: this _:a1 _context: nativeContext
@@ -9537,14 +9564,14 @@
 
 _java_lang_Thread_currentThread: this _context: nativeContext
     <javanative: 'java/lang/Thread' name: 'currentThread()Ljava/lang/Thread;'>
-    | t  p |
+    | t  p nctx |
     p := Processor activeProcess.
     t := JavaVM javaThreadForSTProcess: p.
-    nativeContext sender receiver class name
+    (nctx := self nativeContext) sender receiver class name
         = 'java/util/concurrent/locks/ReentrantLock$NonfairSync'
             ifTrue: [
                 | owner |
-                owner := (nativeContext sender receiver
+                owner := (nctx sender receiver
                             perform: #'getExclusiveOwnerThread()Ljava/lang/Thread;').
                 (owner notNil and: [ owner ~= t ]) ifTrue: [ self breakPoint: #mh. ]
             ].
@@ -9555,7 +9582,7 @@
     ^ t
 
     "Modified: / 09-12-2011 / 12:52:39 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-    "Modified: / 16-01-2013 / 19:48:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 30-01-2013 / 14:17:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_lang_Thread_holdsLock: this _:a1 _context: nativeContext
@@ -9711,9 +9738,10 @@
     <javanative: 'java/lang/Thread' name: 'start0()V'>
 
 
-    ^JavaVM threadStart: nativeContext
+    ^JavaVM threadStart: self nativeContext
 
     "Created: / 19-01-2013 / 23:44:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 30-01-2013 / 14:16:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_lang_Thread_stop0: this _:a1 _context: nativeContext
@@ -10012,14 +10040,13 @@
     "Modified: / 22-11-2011 / 09:13:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-_java_lang_reflect_Array_set: this _:a1 _: a2 _: a3 _context: nativeContext
+_java_lang_reflect_Array_set: this _: array _: index0 _: value _context: nativeContext
 
     <javanative: 'java/lang/reflect/Array' name: 'set(Ljava/lang/Object;ILjava/lang/Object;)V'>
 
-    | array index value |
-    array :=  nativeContext at:1.
-    index := (nativeContext at:2) + 1.
-    value :=  nativeContext at:3.
+    | index  |
+
+    index := index0 + 1.
 
     array isJavaArray ifFalse:[
         Reflection throwIllegalArgumentException:'passed object is not an array'.
@@ -10043,7 +10070,7 @@
     ].
     array at: index put: value.
 
-    "Modified: / 16-01-2013 / 19:49:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 30-01-2013 / 13:45:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_lang_reflect_Proxy_defineClass0: this _:a1 _: a2 _: a3 _: a4 _: a5 _context: nativeContext
@@ -10492,9 +10519,9 @@
 
     <javanative: 'java/net/PlainSocketImpl' name: 'socketClose0(Z)V'>
 
-    ^self commonClose: nativeContext
-
-    "Modified: / 07-11-2011 / 23:21:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    ^self commonClose: self nativeContext
+
+    "Modified: / 30-01-2013 / 14:16:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_net_PlainSocketImpl_socketConnect: this _:a1 _: a2 _: a3 _context: nativeContext
@@ -10977,12 +11004,12 @@
 
     <javanative: 'java/sql/DriverManager' name: 'getCallerClassLoader()Ljava/lang/ClassLoader;'>
 
-    ^nativeContext
+    ^self nativeContext
         sender sender
         receiver class theNonMetaclass
         classLoader
 
-    "Modified: / 05-12-2011 / 11:34:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 30-01-2013 / 14:16:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - java.text'!
@@ -11379,18 +11406,13 @@
     "Modified: / 03-11-2011 / 22:22:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-_java_util_zip_ZipFile_freeEntry: this _:a1 _: a2 _: a3 _: a4 _context: nativeContext
+_java_util_zip_ZipFile_freeEntry: this _: jzfile _: dummy1 _: jzentry _: dummy2 _context: nativeContext
 
     <javanative: 'java/util/zip/ZipFile' name: 'freeEntry(JJ)V'>
 
-    | zipArchiveIndex  zipEntryIndex |
-
-
-    zipArchiveIndex := nativeContext at: 1.
-    zipEntryIndex := nativeContext at: 3.
-    zipEntryIndex = 0 ifFalse: [ ZipEntryCache at: zipEntryIndex put: nil ].
-
-    "Modified: / 01-05-2011 / 13:33:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    jzentry = 0 ifFalse: [ ZipEntryCache at: jzentry put: nil ].
+
+    "Modified: / 30-01-2013 / 13:47:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_util_zip_ZipFile_getCSize: this _:a1 _: a2 _context: nativeContext
@@ -11445,14 +11467,13 @@
     "Created: / 30-04-2011 / 21:53:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-_java_util_zip_ZipFile_getNextEntry: this _:a1 _: a2 _: a3 _context: nativeContext
+_java_util_zip_ZipFile_getNextEntry: this _:jzfile _: dummy1 _: index _context: nativeContext
 
     <javanative: 'java/util/zip/ZipFile' name: 'getNextEntry(JI)J'>
 
-    | zipArchive  index i |
-
-    zipArchive := ZipCache at: (nativeContext at: 1).
-    index := nativeContext at: 3.
+    | zipArchive i |
+
+    zipArchive := ZipCache at: jzfile.
     i := 0.
     zipArchive zipMembersDo:[:member |
         index == i ifTrue:[
@@ -11465,7 +11486,7 @@
     ].
     ^0
 
-    "Modified: / 05-12-2011 / 11:19:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 30-01-2013 / 13:48:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_util_zip_ZipFile_getSize: this _:a1 _: a2 _context: nativeContext
@@ -11509,10 +11530,10 @@
 
     | path  mode  lastModTime  result |
 
-    path := Java as_ST_String: (nativeContext at: 1).
+    path := Java as_ST_String: a1.
     "/(path endsWith:'.jar') ifFalse:[self breakPoint: #jv].
-    mode := nativeContext at: 2.
-    lastModTime := nativeContext at: 3.
+    mode := a2.
+    lastModTime := a3.
     result := path asFilename.
     result ifNil: [ JavaVM throwZipException ].
     ^[
@@ -11531,7 +11552,7 @@
     ]
 
     "Modified: / 01-04-2011 / 15:35:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-    "Modified: / 20-07-2012 / 21:48:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 30-01-2013 / 13:55:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_util_zip_ZipFile_read: this _:a1 _: a2 _: a3 _: a4 _: a5 _: a6 _: a7 _: a8 _: a9 _context: nativeContext
@@ -11977,10 +11998,10 @@
 
     <javanative: 'sun/misc/Unsafe' name: 'compareAndSwapInt(Ljava/lang/Object;JII)Z'>
 
-    ^self _sun_misc_Unsafe_compareAndSwapObject: this _:a1 _: a2 _: a3 _: a4 _: a5 _context: nativeContext
+    ^self _sun_misc_Unsafe_compareAndSwapObject: this _:a1 _: a2 _: a3 _: a4 _: a5 _context: nil
 
     "Created: / 22-11-2010 / 18:40:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 21-01-2013 / 09:16:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 30-01-2013 / 13:56:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _sun_misc_Unsafe_compareAndSwapLong: this _:a1 _: a2 _: a3 _: a4 _: a5 _: a6 _: a7 _context: nativeContext
@@ -12315,9 +12336,9 @@
     public native Object getObjectVolatile(Object o, long offset);
     "
 
-    ^self _sun_misc_Unsafe_getObject: nativeContext
-
-    "Modified: / 03-09-2012 / 19:00:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    ^self _sun_misc_Unsafe_getObject: this _:a1 _: a2 _: a3 _context: nil
+
+    "Modified: / 30-01-2013 / 13:56:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _sun_misc_Unsafe_getShort: this _:a1 _: a2 _: a3 _context: nativeContext
@@ -12427,25 +12448,13 @@
     <javanative: 'sun/misc/Unsafe' name: 'putByte(Ljava/lang/Object;JB)V'>
     <javanative: 'sun/misc/Unsafe' name: 'putByte(JB)V'>
 
-    nativeContext selector == #'putByte(JB)V' ifTrue:[
-        | address value |
-        address := a1.
-        value := a3.
-        SimulatedNativeMemory byteAt: address put: (value bitAnd: 16rFF).
-        ^nil.
-    ].
-
-    nativeContext selector = #'putByte(Ljava/lang/Object;JB)V' ifTrue:[
-        | o offset x |
-        o := a1.
-        offset := a2.
-        x := a4.
-        ^o instVarAt: offset put: x.
-    ].
-
-    self shouldNotImplement
-
-    "Modified: / 31-07-2012 / 11:47:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    | o offset x |
+    o := a1.
+    offset := a2.
+    x := a4.
+    ^o instVarAt: offset put: x.
+
+    "Modified: / 30-01-2013 / 13:57:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _sun_misc_Unsafe_putChar: this _:a1 _: a2 _: a3 _: a4 _context: nativeContext
@@ -12469,24 +12478,13 @@
 
     | o offset x |
 
-    nativeContext numArgs == 5 ifTrue:[
-        "putDouble(Ljava/lang/Object;JD)V"
-        o := a1.
-        offset := a2.
-        x := a4.
-        o instVarAt: offset put: x.
-        ^nil
-    ].
-    nativeContext numArgs == 4 ifTrue:[
-        "putDouble(JD)V"
-        o := a1.
-        x := a3.
-        SimulatedNativeMemory doubleAt: o put: x.
-        ^nil
-    ].
-    self internalError:'Unknown variant of putDouble() native!!'
-
-    "Modified: / 30-08-2011 / 15:58:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    o := a1.
+    offset := a2.
+    x := a4.
+    o instVarAt: offset put: x.
+    ^nil
+
+    "Modified: / 30-01-2013 / 13:57:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _sun_misc_Unsafe_putFloat: this _:a1 _: a2 _: a3 _: a4 _context: nativeContext
@@ -12607,9 +12605,9 @@
 
     <javanative: 'sun/misc/Unsafe' name: 'putObjectVolatile(Ljava/lang/Object;JLjava/lang/Object;)V'>
 
-    ^self _sun_misc_Unsafe_putObject: nativeContext
-
-    "Modified: / 03-09-2012 / 18:59:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    ^self _sun_misc_Unsafe_putObject: this _:a1 _: a2 _: a3 _: a4 _context: nil
+
+    "Modified: / 30-01-2013 / 14:16:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _sun_misc_Unsafe_putOrderedObject: this _:a1 _: a2 _: a3 _: a4 _context: nativeContext
@@ -12626,9 +12624,9 @@
      */
     "
 
-    ^ self _sun_misc_Unsafe_putObject: nativeContext
-
-    "Modified (comment): / 03-09-2012 / 18:56:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    ^ self _sun_misc_Unsafe_putObject: this _:a1 _: a2 _: a3 _: a4 _context: nil
+
+    "Modified: / 30-01-2013 / 14:16:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _sun_misc_Unsafe_putShort: this _:a1 _: a2 _: a3 _: a4 _context: nativeContext
@@ -12951,15 +12949,14 @@
         | cpool  index  double |
 
     cpool := Reflection constantPoolFor:this.
-    index := nativeContext at:3.
-     "TODO: why 3?"
+    index := a2.
     double := cpool at:index.
     self assert:double isFloat description:'Not a float constant!!'.
     ^ double
 
-    "Modified: / 25-02-2011 / 18:40:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Created: / 28-02-2011 / 17:24:17 / Marcel Hlopko <hlopik@gmail.com>"
     "Modified: / 02-11-2011 / 11:24:35 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 30-01-2013 / 13:58:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _sun_reflect_ConstantPool_getIntAt0: this _:a1 _: a2 _context: nativeContext
@@ -12969,14 +12966,13 @@
         | cpool  index  int |
 
     cpool := Reflection constantPoolFor:this.
-    index := nativeContext at:3.
-     "TODO: why 3?"
+    index := a2.
     int := cpool at:index.
     self assert:int isInteger description:'Not an integer constant!!'.
     ^ int
 
-    "Modified: / 25-02-2011 / 18:40:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Created: / 28-02-2011 / 17:28:10 / Marcel Hlopko <hlopik@gmail.com>"
+    "Modified: / 30-01-2013 / 13:58:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _sun_reflect_ConstantPool_getLongAt0: this _:a1 _: a2 _context: nativeContext
@@ -12986,14 +12982,13 @@
         | cpool  index  long |
 
     cpool := Reflection constantPoolFor:this.
-    index := nativeContext at:3.
-     "TODO: why 3?"
+    index := a2.
     long := cpool at:index.
     self assert:long isInteger description:'Not a float constant!!'.
     ^ long
 
     "Modified: / 28-02-2011 / 17:40:02 / Marcel Hlopko <hlopik@gmail.com>"
-    "Modified: / 28-02-2011 / 18:54:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 30-01-2013 / 13:59:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _sun_reflect_ConstantPool_getUTF8At0: this _:a1 _: a2 _context: nativeContext
@@ -13003,14 +12998,14 @@
 
     | cpool index string |
     cpool := Reflection constantPoolFor: this.
-    index := nativeContext at: 3.
-    "TODO: why 3?"
+    index := a2.
 
     string := cpool at: index.
     self assert: string isString description: 'Not an UTF8 constant!!'.
     ^Java as_String: string
 
     "Created: / 06-02-2011 / 12:56:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 30-01-2013 / 13:59:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _sun_reflect_NativeConstructorAccessorImpl_newInstance0: this _:a1 _: a2 _context: nativeContext
@@ -13025,12 +13020,12 @@
     method := Reflection methodForJavaConstructorObject: ctor.
 
     instance := class new.
-    self invoke: ctor receiver: instance arguments: args context: nativeContext constructor: true.
+    self invoke: ctor receiver: instance arguments: args context: self nativeContext constructor: true.
     ^instance
 
     "Created: / 26-11-2010 / 11:41:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 09-02-2011 / 01:12:10 / Marcel Hlopko <hlopik@gmail.com>"
-    "Modified: / 22-08-2012 / 12:25:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 30-01-2013 / 14:16:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _sun_reflect_NativeMethodAccessorImpl_invoke0: this _:a1 _: a2 _: a3 _context: nativeContext
@@ -13045,12 +13040,12 @@
     args := a3.
     method := Reflection methodForJavaMethodObject: m.
 
-    ^ self invoke: m receiver: obj arguments: args context: nativeContext constructor: false.
+    ^ self invoke: m receiver: obj arguments: args context: self nativeContext constructor: false.
 
     "Created: / 06-02-2011 / 00:00:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 28-02-2011 / 16:57:31 / Marcel Hlopko <hlopik@gmail.com>"
     "Modified: / 19-08-2011 / 15:06:00 / cg"
-    "Modified: / 05-07-2012 / 23:49:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 30-01-2013 / 14:16:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _sun_reflect_Reflection_getCallerClass: this _:a1 _context: nativeContext
@@ -13073,7 +13068,7 @@
 
     framesToSkip := a1.
     framesSkipped := 0.
-    frame := nativeContext.
+    frame := self nativeContext.
     [ framesSkipped == framesToSkip ] whileFalse:[
         frame := frame sender.
         "Frames for java,lang.reflect.Method.invoke() does not count, sigh.
@@ -13093,6 +13088,7 @@
         ifFalse:[nil]
 
     "Created: / 25-10-2010 / 16:32:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 30-01-2013 / 14:12:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _sun_reflect_Reflection_getClassAccessFlags: this _:a1 _context: nativeContext