JavaNativeMethodImpl_OpenJDK6.st
branchrefactoring-vmdata
changeset 1970 a78cd5a84c77
parent 1969 beb598c730b2
child 1972 130185d6e2ae
--- a/JavaNativeMethodImpl_OpenJDK6.st	Wed Jan 16 18:50:04 2013 +0000
+++ b/JavaNativeMethodImpl_OpenJDK6.st	Wed Jan 16 19:18:27 2013 +0000
@@ -71,6 +71,12504 @@
 "
 ! !
 
+!JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - com.sun.management'!
+
+_com_sun_management_UnixOperatingSystem_initialize: nativeContext
+
+    <javanative: 'com/sun/management/UnixOperatingSystem' name: 'initialize()V'>
+
+Logger log: 'mh did not set page_size here, which he should :)' severity:#info facility:#JVM.
+^self.
+
+    "Modified: / 03-11-2011 / 18:59:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - java.awt'!
+
+_java_awt_AWTEvent_initIDs: nativeContext
+
+    <javanative: 'java/awt/AWTEvent' name: 'initIDs'>
+
+    "Intentionally left blank"
+
+    "Modified: / 12-08-2011 / 19:08:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_awt_Button_initIDs: nativeContext
+
+    <javanative: 'java/awt/Button' name: 'initIDs()V'>
+
+    "Modified: / 09-02-2012 / 22:54:34 / mh <hlopik@gmail.com>"
+!
+
+_java_awt_Color_initIDs: nativeContext
+
+    <javanative: 'java/awt/Color' name: 'initIDs()V'>
+
+        "/ new with jdk1.2 ...
+
+    "Created: / 28.1.1998 / 22:19:23 / cg"
+!
+
+_java_awt_Component_initIDs: nativeContext
+
+    <javanative: 'java/awt/Component' name: 'initIDs'>
+
+        "/ introduced with jdk1.2 ... (sigh)
+
+    "Created: / 27.1.1998 / 19:53:29 / cg"
+!
+
+_java_awt_Container_initIDs: nativeContext
+
+    <javanative: 'java/awt/Container' name: 'initIDs'>
+
+    "Intentionally left blank"
+
+    "Modified: / 12-08-2011 / 19:09:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_awt_Cursor_initIDs: nativeContext
+
+    <javanative: 'java/awt/Cursor' name: 'initIDs()V'>
+
+    "Modified: / 09-02-2012 / 22:54:49 / mh <hlopik@gmail.com>"
+!
+
+_java_awt_Dialog_initIDs: nativeContext
+
+    <javanative: 'java/awt/Dialog' name: 'initIDs()V'>
+
+    "Modified: / 09-02-2012 / 22:54:09 / mh <hlopik@gmail.com>"
+!
+
+_java_awt_Dimension_initIDs: nativeContext
+
+    <javanative: 'java/awt/Dimension' name: 'initIDs'>
+
+    "Intentionally left blank"
+
+    "Modified: / 12-08-2011 / 19:08:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_awt_Event_initIDs: nativeContext
+
+    <javanative: 'java/awt/Event' name: 'initIDs()V'>
+
+    "Modified: / 09-02-2012 / 22:53:11 / mh <hlopik@gmail.com>"
+!
+
+_java_awt_FontMetrics_initIDs: nativeContext
+
+    <javanative: 'java/awt/FontMetrics' name: 'initIDs()V'>
+
+    ^ JavaVM unimplementedNativeMethodSignal raise
+!
+
+_java_awt_Frame_initIDs: nativeContext
+
+    <javanative: 'java/awt/Frame' name: 'initIDs()V'>
+
+    "Modified: / 09-02-2012 / 22:53:52 / mh <hlopik@gmail.com>"
+!
+
+_java_awt_Insets_initIDs: nativeContext
+
+    <javanative: 'java/awt/Insets' name: 'initIDs()V'>
+
+    "Modified: / 09-02-2012 / 22:54:54 / mh <hlopik@gmail.com>"
+!
+
+_java_awt_KeyboardFocusManager_initIDs: nativeContext
+
+    <javanative: 'java/awt/KeyboardFocusManager' name: 'initIDs()V'>
+
+    "Modified: / 09-02-2012 / 22:55:04 / mh <hlopik@gmail.com>"
+!
+
+_java_awt_MenuComponent_initIDs: nativeContext
+
+    <javanative: 'java/awt/MenuComponent' name: 'initIDs()V'>
+
+    "Modified: / 09-02-2012 / 22:53:22 / mh <hlopik@gmail.com>"
+!
+
+_java_awt_MenuItem_initIDs: nativeContext
+
+    <javanative: 'java/awt/MenuItem' name: 'initIDs()V'>
+
+    "Modified: / 09-02-2012 / 22:54:40 / mh <hlopik@gmail.com>"
+!
+
+_java_awt_Rectangle_initIDs: nativeContext
+
+    <javanative: 'java/awt/Rectangle' name: 'initIDs()V'>
+
+    "Intentionally left blank"
+
+    "Modified: / 27-10-2011 / 15:07:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_awt_Toolkit_initIDs: nativeContext
+
+    <javanative: 'java/awt/Toolkit' name: 'initIDs'>
+
+        "/ introduced with jdk1.2 ... (sigh)
+
+    "Created: / 27.1.1998 / 19:53:50 / cg"
+!
+
+_java_awt_Window_initIDs: nativeContext
+
+    <javanative: 'java/awt/Window' name: 'initIDs()V'>
+
+    "Modified: / 09-02-2012 / 22:53:47 / mh <hlopik@gmail.com>"
+! !
+
+!JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - java.awt.event'!
+
+_java_awt_event_InputEvent_initIDs: nativeContext
+
+    <javanative: 'java/awt/event/InputEvent' name: 'initIDs()V'>
+
+    "Modified: / 09-02-2012 / 22:53:27 / mh <hlopik@gmail.com>"
+!
+
+_java_awt_event_KeyEvent_initIDs: nativeContext
+
+    <javanative: 'java/awt/event/KeyEvent' name: 'initIDs()V'>
+
+    "Modified: / 09-02-2012 / 22:53:33 / mh <hlopik@gmail.com>"
+!
+
+_java_awt_event_MouseEvent_initIDs: nativeContext
+
+    <javanative: 'java/awt/event/MouseEvent' name: 'initIDs()V'>
+
+    "Modified: / 09-02-2012 / 22:53:40 / mh <hlopik@gmail.com>"
+! !
+
+!JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - java.io'!
+
+_java_io_FileDescriptor_initIDs: nativeContext
+
+    <javanative: 'java/io/FileDescriptor' name: 'initIDs'>
+
+        "/ introduced with jdk1.2 ... (sigh)
+
+    "Created: / 27.1.1998 / 18:16:29 / cg"
+!
+
+_java_io_FileDescriptor_set: nativeContext
+
+    <javanative: 'java/io/FileDescriptor' name: 'set(I)J'>
+
+    "SunJDK Speciofic method, we don't need handles, so return
+     FD instead"
+
+    ^nativeContext argAt:1
+
+    "Modified: / 18-08-2011 / 19:54:36 / jv"
+!
+
+_java_io_FileDescriptor_sync: nativeContext
+
+    <javanative: 'java/io/FileDescriptor' name: 'sync'>
+    "
+    /**
+    * Force all system buffers to synchronize with the underlying
+    * device.  This method returns after all modified data and
+    * attributes of this FileDescriptor have been written to the
+    * relevant device(s).  In particular, if this FileDescriptor
+    * refers to a physical storage medium, such as a file in a file
+    * system, sync will not return until all in-memory modified copies
+    * of buffers associated with this FileDescriptor have been
+    * written to the physical medium.
+    *
+    * sync is meant to be used by code that requires physical
+    * storage (such as a file) to be in a known state  For
+    * example, a class that provided a simple transaction facility
+    * might use sync to ensure that all changes to a file caused
+    * by a given transaction were recorded on a storage medium.
+    *
+    * sync only affects buffers downstream of this FileDescriptor.  If
+    * any in-memory buffering is being done by the application (for
+    * example, by a BufferedOutputStream object), those buffers must
+    * be flushed into the FileDescriptor (for example, by invoking
+    * OutputStream.flush) before that data will be affected by sync.
+    *
+    * @exception SyncFailedException
+    *        Thrown when the buffers cannot be flushed,
+    *        or because the system cannot guarantee that all the
+    *        buffers have been synchronized with physical media.
+    * @since     JDK1.1
+    */
+    public native void sync() throws SyncFailedException;
+    "
+
+    OpenFileTable do:[:stream|
+        stream notNil ifTrue:[stream flush].
+    ].
+
+    "Created: / 12-11-1998 / 19:26:25 / cg"
+    "Modified (format): / 10-08-2011 / 19:04:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_io_FileInputStream_available: nativeContext
+
+    <javanative: 'java/io/FileInputStream' name: 'available'>
+
+        |file|
+
+    file := self validateFile:(nativeContext receiver).
+    file == Stdin ifTrue:[
+        file := StdinReplacementFileQuerySignal raiseRequest.
+        file isNil ifTrue:[
+            ^ 1
+        ]
+    ].
+    file isFileStream ifTrue:[
+        ^ file size - file position + 1
+    ].
+    file atEnd ifTrue:[
+        ^ 0.
+    ].
+    self halt.
+    ^ 1
+
+    "Modified: / 14-01-1998 / 15:12:52 / cg"
+    "Modified: / 28-07-2012 / 02:45:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_io_FileInputStream_close0: nativeContext
+
+    <javanative: 'java/io/FileInputStream' name: 'close0'>
+
+    ^self commonClose: nativeContext
+
+    "Modified: / 10-08-2011 / 14:03:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_io_FileInputStream_initIDs: nativeContext
+
+    <javanative: 'java/io/FileInputStream' name: 'initIDs'>
+
+        "/ introduced with jdk1.2 ... (sigh)
+
+    "Created: / 27.1.1998 / 18:15:51 / cg"
+!
+
+_java_io_FileInputStream_open: nativeContext
+
+    <javanative: 'java/io/FileInputStream' name: 'open'>
+
+    |fs fd name stream fileNo|
+
+    fs := nativeContext receiver.
+    fd := fs instVarNamed:'fd'.
+    (fileNo := fd instVarNamed:'fd') ~~ 0 ifTrue:[
+        fileNo ~~ -1 ifTrue:[
+            self halt:'file already open'.
+            self internalError:'file already open'.
+            ^ self.
+        ]
+    ].
+
+    name := nativeContext argAt:1.
+    name := Java as_ST_String:name.
+
+    name := self fixFilename:name.
+
+    FileOpenTrace ifTrue:[
+        ('JAVA: opening ' , name) infoPrintCR.
+    ].
+
+    stream := self fileStreamForReading:name.
+    stream isNil ifTrue:[
+        ^ self.
+    ].
+    stream buffered:false.
+
+"/    FileOpenConfirmation ifTrue:[
+"/        (self confirm:('JAVA Security check\\Opening ''' , name , ''' for reading.\Grant permission ?') withCRs)
+"/        ifFalse:[
+"/            self throwIOExceptionWithMessage:('no permission to open ' , name , ' for reading').
+"/            ^ self
+"/        ]
+"/    ].
+
+    fileNo := self addOpenFile:stream.
+
+    FileOpenTrace ifTrue:[
+        ('JAVA: opened ' , name , ' as FD ' , fileNo printString) infoPrintCR.
+    ].
+
+    fd instVarNamed:'fd' put:fileNo.
+    "Kludge for finalization..."
+
+    "Created: / 04-01-1998 / 16:47:12 / cg"
+    "Modified: / 28-01-1999 / 17:24:07 / cg"
+    "Modified: / 24-07-2012 / 02:17:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_io_FileInputStream_read: nativeContext
+
+    <javanative: 'java/io/FileInputStream' name: 'read()I'>
+
+        |file byte|
+
+    file := self validateFile:(nativeContext receiver).
+
+    file == Stdin ifTrue:[
+        file := StdinReplacementFileQuerySignal raiseRequest.
+        file isNil ifTrue:[
+            ^ -1
+        ]
+    ].
+
+    FileIOTrace ifTrue:[
+        ('JAVA: read 1 byte from ' , file pathName) infoPrintCR.
+    ].
+
+    byte := file nextByte.
+    byte isNil ifTrue:[
+        ^ -1
+    ].
+    "Java bytes are signed"
+    byte > 127 ifTrue:[
+        byte := 
+            byte"/ - 255.
+    ].
+    ^ byte
+
+    "Created: / 05-01-1998 / 02:17:08 / cg"
+    "Modified (format): / 12-12-2012 / 23:53:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_io_FileInputStream_readBytes: nativeContext
+
+    <javanative: 'java/io/FileInputStream' name: 'readBytes'>
+
+    ^ self anyStream_readBytes:nativeContext
+
+    "Modified: / 04-02-1998 / 15:23:08 / cg"
+    "Modified (format): / 10-08-2011 / 21:32:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_io_FileInputStream_skip: nativeContext
+
+    <javanative: 'java/io/FileInputStream' name: 'skip(J)J'>
+
+        "/ long skip (long)
+    |file nSkip nSkipped|
+
+    file := self validateFile:(nativeContext receiver).
+    nSkip := nativeContext argAt:1.
+
+    file == Stdin ifTrue:[
+        file := StdinReplacementFileQuerySignal raiseRequest.
+        file isNil ifTrue:[
+            ^ -1
+        ]
+    ].
+
+    FileIOTrace ifTrue:[
+        (('JAVA: skip %1 byte(s) from ' bindWith:nSkip printString) , file pathName) infoPrintCR.
+    ].
+
+    file skip:nSkip.
+    ^ nSkip
+
+    "Modified: / 27.1.1999 / 20:36:11 / cg"
+!
+
+_java_io_FileOutputStream_close0: nativeContext
+
+    <javanative: 'java/io/FileOutputStream' name: 'close0'>
+
+    ^self commonClose: nativeContext
+
+    "Modified: / 10-08-2011 / 14:03:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_io_FileOutputStream_initIDs: nativeContext
+
+    <javanative: 'java/io/FileOutputStream' name: 'initIDs'>
+
+        "/ introduced with jdk1.2 ... (sigh)
+
+    "Created: / 27.1.1998 / 18:16:40 / cg"
+!
+
+_java_io_FileOutputStream_open: nativeContext
+
+    <javanative: 'java/io/FileOutputStream' name: 'open'>
+
+    ^ self commonOpen: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>"
+!
+
+_java_io_FileOutputStream_openAppend: nativeContext
+
+    <javanative: 'java/io/FileOutputStream' name: 'openAppend'>
+
+    ^ self commonOpen: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>"
+!
+
+_java_io_FileOutputStream_write: nativeContext
+
+    <javanative: 'java/io/FileOutputStream' name: 'write'>
+    "
+     /**
+     * Writes the specified byte to this file output stream. Implements
+     * the <code>write</code> method of <code>OutputStream</code>.
+     *
+     * @param      b   the byte to be written.
+     * @exception  IOException  if an I/O error occurs.
+     */
+     public native void write(int b) throws IOException;
+    "
+
+    | fdobj fd stream b |
+    b := nativeContext argAt:1.
+    "/Java byte is signed, make it integer in 0-255"
+    b < 0 ifTrue:[b := b + 256].
+    fdobj := (nativeContext receiver instVarNamed: #fd).
+    fd    := fdobj instVarNamed: #fd.
+    stream := self getOpenFileAt:fd.
+    [
+        stream nextPut: b
+    ] on: Error do:[:ex|
+        self throwIOExceptionWithMessage: ex description
+    ]
+
+    "Modified: / 15-12-2012 / 16:31:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_io_FileOutputStream_writeBytes: nativeContext
+
+    <javanative: 'java/io/FileOutputStream' name: 'writeBytes'>
+
+        ^ self anyStream_writeBytes:nativeContext
+
+    "Modified: / 4.2.1998 / 15:24:20 / cg"
+!
+
+_java_io_FileSystem_getFileSystem: aJavaContext
+    <javanative: 'java/io/FileSystem' name: 'getFileSystem'>
+    OperatingSystem isUNIXlike ifTrue: [
+        ^ (self classForName: 'java.io.UnixFileSystem') new
+    ].
+    OperatingSystem isMSWINDOWSlike ifTrue: [
+        ^ (Java classForName: 'java.io.WinNTFileSystem') new
+    ].
+    self error: 'Unknown/Unsupported platform'
+
+    "Created: / 09-12-2010 / 17:58:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 01-04-2011 / 18:09:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_io_ObjectInputStream_latestUserDefinedLoader: nativeContext
+
+    <javanative: 'java/io/ObjectInputStream' name: 'latestUserDefinedLoader'>
+
+    "
+    /**
+    * Returns the first non-null class loader (not counting class loaders of
+    * generated reflection implementation classes) up the execution stack, or
+    * null if only code from the null class loader is on the stack.  This
+    * method is also called via reflection by the following RMI-IIOP class:
+    *
+    *     com.sun.corba.se.internal.util.JDKClassLoader
+    *
+    * This method should not be removed or its signature changed without
+    * corresponding modifications to the above class.
+    */
+    // REMIND: change name to something more accurate?
+    private static native ClassLoader latestUserDefinedLoader();
+    "
+
+    | ctx cl |
+    ctx := nativeContext.
+    [ ctx notNil ] whileTrue:[
+        ctx receiver isJavaObject ifTrue:[
+            (cl := ctx receiver class classLoader) notNil ifTrue:[
+                "/self breakPoint: #jv info: 'Should not count class loaders of generated reflection implementation classes'.
+                "/Please check"
+                ^cl.
+            ]
+        ].
+        ctx := ctx sender.
+    ].
+    ^nil
+
+    "Modified: / 30-08-2011 / 16:00:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_io_ObjectStreamClass_hasStaticInitializer: nativeContext
+
+    <javanative: 'java/io/ObjectStreamClass' name: 'hasStaticInitializer'>
+
+    | cls |
+    cls := self reflection classForJavaClassObject: (nativeContext argAt:1).
+    ^(cls includesSelector: #'<clinit>()V') ifTrue:[1] ifFalse:[0]
+
+    "Modified: / 10-08-2011 / 01:13:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_io_ObjectStreamClass_initNative: aJavaContext
+
+    <javanative: 'java/io/ObjectStreamClass' name: 'initNative'>
+
+
+    "
+    /**
+     * Initializes native code.
+     */
+    "
+    "Nothing to do"
+
+    "Created: / 20-12-2010 / 17:43:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_io_RandomAccessFile_close0: nativeContext
+
+    <javanative: 'java/io/RandomAccessFile' name: 'close0()V'>
+
+    ^ self commonClose:nativeContext
+
+    "Modified: / 06-07-2012 / 00:09:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_io_RandomAccessFile_getFilePointer: nativeContext
+    "
+    /**
+     * Returns the current offset in this file.
+     *
+     * @return     the offset from the beginning of the file, in bytes,
+     *             at which the next read or write occurs.
+     * @exception  IOException  if an I/O error occurs.
+     */
+    "
+    <javanative: 'java/io/RandomAccessFile' name: 'getFilePointer()J'>
+
+    | file |
+
+    file := self validateFile:(nativeContext receiver).
+
+    FileIOTrace ifTrue:[
+        ('JAVA: getFilePointer on ' , file pathName) infoPrintCR.
+    ].
+    ^file position0Based
+
+    "Modified: / 06-07-2012 / 12:40:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_io_RandomAccessFile_initIDs: nativeContext
+
+    <javanative: 'java/io/RandomAccessFile' name: 'initIDs'>
+
+    "Nothing to do"
+
+    "Modified: / 10-08-2011 / 21:49:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_io_RandomAccessFile_length: nativeContext
+
+    <javanative: 'java/io/RandomAccessFile' name: 'length()J'>
+
+        |file sz|
+
+    file := self validateFile:(nativeContext receiver).
+
+    FileIOTrace ifTrue:[
+        ('JAVA: length of ' , file pathName) infoPrintCR.
+    ].
+
+    sz := file size.
+    ^ sz.
+
+    "Created: / 4.2.1998 / 13:27:58 / cg"
+!
+
+_java_io_RandomAccessFile_open: nativeContext
+
+    <javanative: 'java/io/RandomAccessFile' name: 'open'>
+
+    |fs fd nm mode filename dir stream fileNo answer readonly|
+
+
+    fs := nativeContext receiver.
+    fd := fs instVarNamed:'fd'.
+    (fd instVarNamed:'fd') ~~ -1 ifTrue:[
+        self halt:'file already open'.
+        self internalError:'file already open'.
+        ^ self.
+    ].
+
+    nm := nativeContext argAt:1.
+    nm := Java as_ST_String:nm.
+    nm := self fixFilename:nm.
+    mode := nativeContext argAt:2.
+
+    "
+    private static final int O_RDONLY = 1;
+    private static final int O_RDWR =   2;
+    private static final int O_SYNC =   4;
+    private static final int O_DSYNC =  8;
+    "
+    readonly := (mode bitAnd:1) == 1.
+
+    FileOpenTrace ifTrue:[
+        ('JAVA: opening ' , nm) infoPrintCR.
+    ].
+
+    dir := (filename := nm utf8Encoded asFilename) directory pathName.
+
+    (PermittedDirectories notNil
+    and:[PermittedDirectories includes:dir]) ifFalse:[
+        FileOpenConfirmation ifTrue:[
+            answer := Dialog
+                    confirmWithCancel:('JAVA Security check\\Opening ''' , nm , ''' for read/write.\Grant permission ?') withCRs
+                               labels:#('no' 'grant' 'readonly')
+                               values:#(false true #readonly)
+                              default:3.
+            answer == false ifTrue:[
+                self throwIOExceptionWithMessage:('no permission to open ' , nm , ' for writing').
+                ^ self
+            ].
+            readonly := (answer == #readonly).
+
+            readonly ifFalse:[
+                (self confirm:('JAVA Security check\\Always permit writes in this directory (''' , dir , ''') ?') withCRs)
+                ifTrue:[
+                    PermittedDirectories isNil ifTrue:[
+                        PermittedDirectories := Set new
+                    ].
+                    PermittedDirectories add:dir.
+                ]
+            ]
+        ]
+    ].
+
+    (filename exists not and:[readonly]) ifTrue:[
+        self throwIOExceptionWithMessage:'File ', nm , ' does not exist'
+    ].
+
+    readonly ifTrue:[
+        stream := self commonOpenStreamUsing:[filename readStream].
+    ] ifFalse:[
+        stream := self commonOpenStreamUsing:[filename readWriteStream].
+        stream isNil ifTrue:[
+            self throwIOExceptionWithMessage:('cannot open ' , nm , ' for writing').
+        ].
+    ].
+
+
+    fileNo := self addOpenFile:stream.
+
+    FileOpenTrace ifTrue:[
+        ('JAVA: opened ' , nm , ' as FD ' , fileNo printString , ' for writing') infoPrintCR.
+    ].
+
+    fd instVarNamed:'fd' put:fileNo.
+    "Kludge for finalization..."
+    fs finalizationLobby registerChange: fs
+
+    "Created: / 04-02-1998 / 00:14:48 / cg"
+    "Modified: / 12-11-1998 / 21:29:46 / cg"
+    "Modified: / 23-07-2012 / 19:37:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_io_RandomAccessFile_read: nativeContext
+
+    <javanative: 'java/io/RandomAccessFile' name: 'read()I'>
+
+        |file byte|
+
+    file := self validateFile:(nativeContext receiver).
+
+    FileIOTrace ifTrue:[
+        ('JAVA: read 1 byte from ' , file pathName) infoPrintCR.
+    ].
+
+    byte := file nextByte.
+    byte isNil ifTrue:[
+        ^ -1
+    ].
+    ^ byte
+
+    "Modified: / 5.1.1998 / 02:17:25 / cg"
+    "Created: / 27.1.1999 / 19:01:15 / cg"
+!
+
+_java_io_RandomAccessFile_readBytes: nativeContext
+
+    <javanative: 'java/io/RandomAccessFile' name: 'readBytes([BII)I'>
+
+    ^ self anyStream_readBytes:nativeContext
+
+    "Modified: / 04-02-1998 / 15:23:27 / cg"
+    "Modified (format): / 06-07-2012 / 00:08:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_io_RandomAccessFile_seek: nativeContext
+
+    <javanative: 'java/io/RandomAccessFile' name: 'seek(J)V'>
+
+        |file pos|
+
+    file := self validateFile:(nativeContext receiver).
+
+    FileIOTrace ifTrue:[
+        ('JAVA: seek on ' , file pathName) infoPrintCR.
+    ].
+
+    pos := nativeContext argAt:1.
+    file position0Based:pos
+
+    "Created: / 04-02-1998 / 13:25:38 / cg"
+    "Modified (comment): / 06-07-2012 / 12:39:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_io_RandomAccessFile_writeBytes: nativeContext
+
+    <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"
+!
+
+_java_io_UnixFileSystem_canonicalize0: aJavaContext
+
+    <javanative: 'java/io/UnixFileSystem' name: 'canonicalize0'>
+
+    |  path |
+
+    path := Java as_ST_String: (aJavaContext argAt: 1).
+    ^(Java as_String: path utf8Encoded asFilename asAbsoluteFilename pathName utf8Decoded)
+
+    "Created: / 10-12-2010 / 14:40:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_io_UnixFileSystem_checkAccess: nativeContext
+
+    <javanative: 'java/io/UnixFileSystem' name: 'checkAccess'>
+
+    "
+     public static final int ACCESS_READ    = 0x04;
+     public static final int ACCESS_WRITE   = 0x02;
+     public static final int ACCESS_EXECUTE = 0x01;
+    "
+
+    | fileobj file access result |
+    fileobj := nativeContext argAt:1.
+    file := (Java as_ST_String:(fileobj instVarNamed:#path)) asFilename.
+    access := nativeContext argAt:2.
+    [
+        access == 16r01 ifTrue:[result := file isExecutable].
+        access == 16r02 ifTrue:[result := file isWritable].
+        access == 16r04 ifTrue:[result := file isReadable].
+    ] on: Error do:[
+        result := false.
+    ].
+    ^result ifTrue:[1] ifFalse:[0].
+
+    "Modified: / 09-08-2011 / 17:09:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_io_UnixFileSystem_createDirectory: nativeContext
+
+    <javanative: 'java/io/UnixFileSystem' name: 'createDirectory'>
+
+    | fileobj file |
+    fileobj := (nativeContext argAt:1).
+    file := Java as_ST_String: (fileobj instVarNamed:#path).
+    file := file asFilename.
+    file exists ifFalse:[
+        [
+            file recursiveMakeDirectory.
+            ^1.
+        ] on: Error do:[:ex|
+            self throwIOExceptionWithMessage:ex description.
+        ].
+    ].
+    ^0
+
+    "Modified: / 05-12-2011 / 23:04:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_io_UnixFileSystem_createFileExclusively: nativeContext
+
+    <javanative: 'java/io/UnixFileSystem' name: 'createFileExclusively'>
+
+    | file |
+    file := Java as_ST_String: (nativeContext argAt:1).
+    file := file asFilename.
+    file exists ifFalse:[
+        [
+            file createAsEmptyFile
+        ] on: Error do:[:ex|
+            self throwIOExceptionWithMessage:ex description.
+        ].
+        ^1
+    ].
+    ^0
+
+    "Modified: / 10-08-2011 / 13:42:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_io_UnixFileSystem_delete0: nativeContext
+
+    <javanative: 'java/io/UnixFileSystem' name: 'delete0'>
+    "
+      /**
+      * Delete the file or directory denoted by the given abstract pathname,
+      * returning <code>true</code> if and only if the operation succeeds.
+      */
+      public abstract boolean delete(File f);
+    "
+    | file |
+
+    file := (Java as_ST_String: ((nativeContext argAt:1) instVarNamed: #path)) asFilename.
+    file exists ifFalse:[^0].
+    ^[
+        file remove.
+        true
+    ] on: Error do:[
+        false
+    ]
+
+    "Modified: / 09-08-2011 / 17:09:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_io_UnixFileSystem_getBooleanAttributes0: aJavaContext
+    <javanative: 'java/io/UnixFileSystem' name: 'getBooleanAttributes0'>
+    | file  path  retval  fileSystemClass |
+    retval := 0.
+    file := (aJavaContext argAt: 1).
+    path := Java as_ST_String: ((aJavaContext argAt: 1) perform: #'getAbsolutePath()Ljava/lang/String;').
+    fileSystemClass := (self classForName: 'java.io.FileSystem').
+    path asFilename exists ifTrue: [
+        retval := retval bitOr: (fileSystemClass instVarNamed: #'BA_EXISTS')
+    ] ifFalse: [ ^ 0. ].
+    path asFilename isDirectory ifTrue: [
+        retval := retval bitOr: (fileSystemClass instVarNamed: #'BA_DIRECTORY')
+    ].
+    path asFilename isRegularFile ifTrue: [
+        retval := retval bitOr: (fileSystemClass instVarNamed: #'BA_REGULAR')
+    ].
+    path asFilename isHidden ifTrue: [
+        retval := retval bitOr: (fileSystemClass instVarNamed: #'BA_HIDDEN')
+    ].
+    ^ retval
+
+    "Modified: / 10-12-2010 / 14:43:31 / Jan Kurs <kurs.jan@post.cz>"
+    "Created: / 10-12-2010 / 14:46:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 11-12-2010 / 19:44:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 03-11-2011 / 11:03:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+_java_io_UnixFileSystem_getLastModifiedTime: aJavaContext
+
+    <javanative: 'java/io/UnixFileSystem' name: 'getLastModifiedTime'>
+
+    | file  filename  |
+
+    file := aJavaContext argAt: 1.
+    filename := (Java as_ST_String: (file instVarNamed: #path)) utf8Encoded asFilename.
+    ^filename exists ifTrue:[
+        filename modificationTime asMilliseconds
+    ] ifFalse:[
+        0
+    ].
+
+    "Modified: / 10-12-2010 / 14:43:31 / Jan Kurs <kurs.jan@post.cz>"
+    "Created: / 27-03-2011 / 15:32:59 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 06-07-2012 / 08:57:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_io_UnixFileSystem_getLength: nativeContext
+
+    <javanative: 'java/io/UnixFileSystem' name: 'getLength'>
+
+    | file |
+
+    file := (Java as_ST_String: ((nativeContext argAt:1) instVarNamed: #path)) asFilename.
+    file exists ifFalse:[^0].
+    ^file fileSize
+
+    "Modified: / 09-08-2011 / 15:38:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_io_UnixFileSystem_initIDs: aJavaContext
+
+    <javanative: 'java/io/UnixFileSystem' name: 'initIDs'>
+
+
+    self breakPoint: #libjava
+
+    "Created: / 10-12-2010 / 14:47:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 10-12-2010 / 20:58:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_io_UnixFileSystem_list: nativeContext
+
+    <javanative: 'java/io/UnixFileSystem' name: #'list(Ljava/io/File;)[Ljava/lang/String;'>
+    "
+    /**
+    * Returns an array of strings naming the files and directories in the
+    * directory denoted by this abstract pathname.
+    *
+    * <p> If this abstract pathname does not denote a directory, then this
+    * method returns {@code null}.  Otherwise an array of strings is
+    * returned, one for each file or directory in the directory.  Names
+    * denoting the directory itself and the directory's parent directory are
+    * not included in the result.  Each string is a file name rather than a
+    * complete path.
+    *
+    * <p> There is no guarantee that the name strings in the resulting array
+    * will appear in any specific order; they are not, in particular,
+    * guaranteed to appear in alphabetical order.
+    *
+    * @return  An array of strings naming the files and directories in the
+    *          directory denoted by this abstract pathname.  The array will be
+    *          empty if the directory is empty.  Returns {@code null} if
+    *          this abstract pathname does not denote a directory, or if an
+    *          I/O error occurs.
+    */
+   "
+    | fileobj file names jnames |
+    fileobj := (nativeContext argAt:1).
+    file := Java as_ST_String: (fileobj instVarNamed:#path).
+    file := file asFilename.
+    file exists ifFalse:[^nil].
+    file isDirectory ifFalse:[^nil].
+
+    names := file directoryContents.
+    jnames := (Java at:'java.lang.String') javaArrayClass new: names size.
+    1 to: names size do:[:i|
+        jnames at: i put: (Java as_String:(names at: i))
+    ].
+    ^jnames
+
+    "Modified: / 23-07-2012 / 21:57:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_io_UnixFileSystem_rename0: nativeContext
+
+    <javanative: 'java/io/UnixFileSystem' name: 'rename0(Ljava/io/File;Ljava/io/File;)Z'>
+
+    | file1 file2 |
+
+    file1 := (Java as_ST_String: ((nativeContext argAt:1) instVarNamed: #path)) asFilename.
+    file2 := (Java as_ST_String: ((nativeContext argAt:2) instVarNamed: #path)) asFilename.
+    file1 exists ifFalse:[^0].
+    ^[
+        file1 moveTo: file2.
+        true
+    ] on: Error do:[
+        false
+    ]
+
+    "Modified: / 09-12-2011 / 20:01:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_io_UnixFileSystem_setLastModifiedTime: nativeContext
+
+    <javanative: 'java/io/UnixFileSystem' name: 'setLastModifiedTime(Ljava/io/File;J)Z'>
+
+    | f mtime file |
+    f := nativeContext argAt: 1.
+    mtime := nativeContext argAt: 2.
+    file := (Java as_ST_String: (f instVarNamed: #path)) asFilename.
+
+    self breakPoint: #jv. "There is no interface for that in St/X"
+
+    "Modified: / 05-12-2011 / 23:42:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_io_UnixFileSystem_setPermission: nativeContext
+
+    <javanative: 'java/io/UnixFileSystem' name: 'setPermission'>
+    "
+    /**
+     * Set on or off the access permission (to owner only or to all) to the file
+     * or directory denoted by the given abstract pathname, based on the parameters
+     * enable, access and oweronly.
+     */
+    public abstract boolean setPermission(File f, int access, boolean enable, boolean owneronly);
+    "
+    | f access enable owneronly file perms |
+    f := nativeContext argAt: 1.
+    access := nativeContext argAt: 2.
+    enable := (nativeContext argAt: 3) == 1.
+    owneronly := (nativeContext argAt: 4) == 1.
+    file := (Java as_ST_String: (f instVarNamed: #path)) asFilename.
+    "
+    public static final int ACCESS_READ    = 0x04;
+    public static final int ACCESS_WRITE   = 0x02;
+    public static final int ACCESS_EXECUTE = 0x01;
+    "
+
+    access == 16r04 ifTrue:[
+        perms := owneronly ifFalse:[#(readUser readGroup readOthers)] ifTrue:[#(readUser)].
+    ].
+    access == 16r02 ifTrue:[
+        perms := owneronly ifFalse:[#(writeUser writeGroup writeOthers)] ifTrue:[#(writeUser)].
+    ].
+    access == 16r01 ifTrue:[
+        perms := owneronly ifFalse:[#(executeUser executeGroup executeOthers)] ifTrue:[#(executeUser)].
+    ].
+    [
+        enable ifTrue:[
+            file addAccessRights: perms
+        ] ifFalse:[
+            file removeAccessRights: perms
+        ].
+        ^ 1.
+    ] on: Error do:[
+        ^ 0
+    ].
+    ^0
+
+    "Modified: / 09-08-2011 / 17:18:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_io_UnixFileSystem_setReadOnly: nativeContext
+
+    <javanative: 'java/io/UnixFileSystem' name: 'setReadOnly'>
+
+    | fileobj file |
+    fileobj := (nativeContext argAt:1).
+    file := Java as_ST_String: (fileobj instVarNamed:#path).
+    file := file asFilename.
+    file exists ifFalse:[^0].
+    [
+        file  removeAccessRights: #(writeUser writeGroup writeOthers).
+        ^1
+    ] on: Error do:[
+        ^0
+    ].
+    ^0
+
+    "Modified: / 10-08-2011 / 13:40:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_io_Win32FileSystem_initIDs: nativeContext
+
+    <javanative: 'java/io/Win32FileSystem' name: 'initIDs()V'>
+
+    "Intentionally left blank"
+!
+
+_java_io_WinNTFileSystem_canonicalize0: aJavaContext
+
+    <javanative: 'java/io/WinNTFileSystem' name: 'canonicalize0(Ljava/lang/String;)Ljava/lang/String;'>
+
+
+    |  path |
+
+    path := Java as_ST_String: (aJavaContext argAt: 1).
+    ^(Java as_String: path asFilename asAbsoluteFilename pathName)
+
+    "Created: / 01-04-2011 / 23:00:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_io_WinNTFileSystem_canonicalizeWithPrefix0: nativeContext
+
+    <javanative: 'java/io/WinNTFileSystem' name: 'canonicalizeWithPrefix0(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;'>
+
+    |  path |
+
+    path := Java as_ST_String: (nativeContext argAt: 2).
+    ^(Java as_String: path utf8Encoded asFilename asAbsoluteFilename pathName utf8Decoded)
+
+    "Modified: / 01-09-2011 / 21:50:47 / jv"
+!
+
+_java_io_WinNTFileSystem_checkAccess: nativeContext
+
+    <javanative: 'java/io/WinNTFileSystem' name: 'checkAccess(Ljava/io/File;I)Z'>
+
+    ^ JavaVM unimplementedNativeMethodSignal raise
+!
+
+_java_io_WinNTFileSystem_createDirectory: nativeContext
+
+    <javanative: 'java/io/WinNTFileSystem' name: 'createDirectory(Ljava/io/File;)Z'>
+
+    ^ JavaVM unimplementedNativeMethodSignal raise
+!
+
+_java_io_WinNTFileSystem_createFileExclusively: nativeContext
+
+    <javanative: 'java/io/WinNTFileSystem' name: 'createFileExclusively(Ljava/lang/String;)Z'>
+
+    ^ self _java_io_UnixFileSystem_createFileExclusively: nativeContext
+
+    "Modified: / 18-08-2011 / 17:26:11 / jv"
+!
+
+_java_io_WinNTFileSystem_delete0: nativeContext
+
+    <javanative: 'java/io/WinNTFileSystem' name: 'delete0(Ljava/io/File;)Z'>
+
+    ^ JavaVM unimplementedNativeMethodSignal raise
+!
+
+_java_io_WinNTFileSystem_getBooleanAttributes: aJavaContext
+
+    <javanative: 'java/io/WinNTFileSystem' name: 'getBooleanAttributes(Ljava/io/File;)I'>
+
+    ^ self _java_io_UnixFileSystem_getBooleanAttributes0:aJavaContext
+
+    "Created: / 01-04-2011 / 18:10:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_io_WinNTFileSystem_getLastModifiedTime: nativeContext
+
+    <javanative: 'java/io/WinNTFileSystem' name: 'getLastModifiedTime(Ljava/io/File;)J'>
+
+    ^ self _java_io_UnixFileSystem_getLastModifiedTime: nativeContext
+
+    "Modified: / 18-08-2011 / 14:12:07 / jv"
+!
+
+_java_io_WinNTFileSystem_getLength: nativeContext
+
+    <javanative: 'java/io/WinNTFileSystem' name: 'getLength(Ljava/io/File;)J'>
+
+    ^ self _java_io_UnixFileSystem_getLength: nativeContext
+
+    "Modified: / 18-08-2011 / 14:15:36 / jv"
+!
+
+_java_io_WinNTFileSystem_list: nativeContext
+
+    <javanative: 'java/io/WinNTFileSystem' name: 'list(Ljava/io/File;)[Ljava/lang/String;'>
+
+    ^ self _java_io_UnixFileSystem_list: nativeContext
+
+    "Modified: / 01-09-2011 / 21:46:37 / jv"
+! !
+
+!JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - java.lang'!
+
+_java_lang_ClassLoader_NativeLibrary_load: nativeContext
+    <javanative: 'java/lang/ClassLoader$NativeLibrary' name: 'load'>
+    "/ introduced with jdk1.2 ... (sigh)
+
+    | nativeLoader  jLibName  libName  libHandle  index |
+
+    nativeLoader := nativeContext receiver.
+    jLibName := nativeContext argAt: 1.
+    libName := (Java as_ST_String: jLibName) asFilename baseName.
+    (index := SimulatedNativeLibs indexOf: libName) ~~ 0 ifTrue: [
+        "/        ('JAVA: builtIn nativeLibLoad simulated: ' , libName) printNL.
+        nativeLoader instVarNamed: 'handle' put: index.
+        ^ self
+        "/ void
+    ].
+    (LoadedNativeLibs notNil and: [ LoadedNativeLibs includesKey: libName ]) ifTrue: [
+        "/        ('JAVA: native library already loaded: ' , libName) printNL.
+        nativeLoader instVarNamed: 'handle' put: (LoadedNativeLibs at: libName).
+        ^ self
+        "/ void
+    ].
+    (self confirm: 'permission to load native library: ' , libName , ' ?') ifFalse: [
+        ^ self
+    ].
+    self halt.
+    libName asFilename exists ifFalse: [
+        ('JAVA: no file to load nativeLib: ' , libName) printNL.
+        ^ self
+        "/ void
+    ].
+    libHandle := ObjectFileLoader loadLibrary: libName.
+    libHandle isNil ifTrue: [
+        ('JAVA: failed to load nativeLib: ' , libName) printNL.
+        ^ self
+        "/ void
+    ].
+    LoadedNativeLibs isNil ifTrue: [ LoadedNativeLibs := Dictionary new. ].
+    LoadedNativeLibs at: libName put: libHandle.
+    nativeLoader instVarNamed: 'handle' put: (LoadedNativeLibs at: libName).
+    ^ self
+    "/ void
+
+    "Modified: / 06-02-1998 / 03:12:17 / cg"
+    "Created: / 10-12-2010 / 15:11:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 03-11-2011 / 18:25:08 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+_java_lang_ClassLoader_defineClass1: nativeContext
+    <javanative: 'java/lang/ClassLoader' name: 'defineClass1'>
+    "
+     private native Class defineClass1(String name, byte[] b, int off, int len,
+                                      ProtectionDomain pd, String source);"
+
+    | className  b  off  len  pd  source  bs  cls |
+    className := Java as_ST_String: (nativeContext argAt: 1).
+    "if name starts with java.* or package is signed by something else and we are not signed, throw security exception"
+    "ClassLoadersTest>>testEyeOpeningClassLoaderLoadObject"
+    "18.11. mh revised - they really test it against java., totally ignoring boot class path.. That surpsised me"
+    (className startsWith: 'java.') ifTrue: [
+        self throwSecurityExceptionWith: 'className=' , className
+    ].
+    cls := nil.
+    b := nativeContext argAt: 2.
+    b ifNil: [self throwNullPointerException].
+    off := nativeContext argAt: 3.
+    len := nativeContext argAt: 4.
+    pd := nativeContext argAt: 5.
+    source := Java as_ST_String: (nativeContext argAt: 6).
+    bs := (off = 0 and: [ len = b size ])
+        ifTrue: [ b readStream ]
+        ifFalse: [ bs := (b copyFrom: off + 1 to: off + len) readStream ].
+    [
+        JavaClassReader classLoaderQuerySignal answer: nativeContext receiver
+            do: [ cls := JavaClassReader readStream: bs. ]
+    ] on: JavaClassReader invalidClassFormatSignal
+            do: [
+        :ex |
+        self throwClassFormatError: ex description.
+        ^ nil.
+    ].
+    self assert: cls classLoader == nativeContext receiver.
+     "FIXME: What to do with source?"
+    self registry registerClass: cls.
+    "JavaClassReader classLoaderQuerySignal answer: nativeContext receiver
+        do: [ cls resolveAll. ]."
+    ^ self reflection javaClassObjectForClass: cls.
+
+    "Modified: / 08-12-2011 / 20:56:51 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 20-02-2012 / 23:14:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 10-09-2012 / 22:21:22 / m"
+!
+
+_java_lang_ClassLoader_defineClass1_OLD: nativeContext
+    <javanative: 'java/lang/ClassLoader' name: 'defineClass1'>
+    "
+     private native Class defineClass1(String name, byte[] b, int off, int len,
+                                      ProtectionDomain pd, String source);"
+
+    | className  b  off  len  pd  source  bs  cls |
+    className := Java as_ST_String: (nativeContext argAt: 1).
+     "if name starts with java.* or package is signed by something else and we are not signed, throw security exception" "ClassLoadersTest>>testEyeOpeningClassLoaderLoadObject" "18.11. mh revised - they really test it against java., totally ignoring boot class path.. That surpsised me"
+    (className startsWith: 'java.') ifTrue: [
+        self throwSecurityExceptionWith: 'className=' , className
+    ].
+    cls := ClassRegistry
+                classForName: className asSlashedJavaClassName
+                loader: nativeContext receiver
+                ifAbsentPut: [
+                    b := nativeContext argAt: 2.
+                    off := nativeContext argAt: 3.
+                    len := nativeContext argAt: 4.
+                    pd := nativeContext argAt: 5.
+                    source := Java as_ST_String: (nativeContext argAt: 6).
+                    (off = 0 and: [ len = b size ]) ifTrue: [ bs := b readStream ] ifFalse: [
+                        bs := (b copyFrom: off + 1 to: off + len) readStream
+                    ].
+                    [
+                        JavaClassReader classLoaderQuerySignal answer: nativeContext receiver
+                            do: [ cls := JavaClassReader readStream: bs. ]
+                    ] on: JavaClassReader invalidClassFormatSignal
+                            do: [
+                        :ex |
+                        self throwClassFormatError: ex description.
+                        ^ nil.
+                    ].
+                    self assert: cls classLoader == nativeContext receiver.
+                     "FIXME: What to do with source?"
+                    cls.
+                ].
+    "JavaClassReader classLoaderQuerySignal answer: nativeContext receiver
+        do: [ cls resolveAll. ]."
+    ^ self reflection javaClassObjectForClass: cls.
+
+    "Modified: / 30-10-2011 / 21:46:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 08-12-2011 / 20:56:51 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Created: / 20-02-2012 / 23:10:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_ClassLoader_findBootstrapClass: nativeContext
+    <javanative: 'java/lang/ClassLoader' name: 'findBootstrapClass'>
+    "Return class loaded by bootstrap (primordial) classloader or null.
+     See OpenJDK, file src/jdk7/hostspot/src/share/vm/prims/jvm.cpp"
+
+    | nm  class |
+    nm := Java as_ST_String: (nativeContext argAt: 1).
+    class := ClassRegistry
+                classForName: nm asSlashedJavaClassName
+                loader: nil
+                ifAbsentPut: [ class := JavaVM usePrimordialCLToLoadClassNamed: nm. ].
+
+    ^ class notNil
+        ifTrue: [ self reflection javaClassObjectForClass: class ]
+        ifFalse: [ self throwClassNotFoundException: nm ].
+
+    "Modified: / 30-10-2011 / 21:45:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 02-11-2011 / 20:13:41 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+_java_lang_ClassLoader_findLoadedClass0: nativeContext
+
+    <javanative: 'java/lang/ClassLoader' name: 'findLoadedClass0'>
+
+    "
+    Return java class object for class with given name
+    loaded by the receiver or null if not found.
+    See OpenJDK:
+        src/jdk7/hostspot/src/share/vm/classfile/systemDictionary.cpp
+        src/jdk7/hostspot/src/share/vm/prims/jvm.cpp
+
+    "
+    | nm class |
+    nm := Java as_ST_String: (nativeContext argAt:1).
+    class := ClassRegistry classNamed: nm asSlashedJavaClassName loader: nativeContext receiver.
+
+    ^class notNil ifTrue: [
+        self reflection javaClassObjectForClass:class
+    ] ifFalse:[
+        nil
+    ]
+
+    "Modified: / 30-10-2011 / 21:48:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_ClassLoader_getCaller: nativeContext
+
+    <javanative: 'java/lang/ClassLoader' name: ''>
+    "
+    // index 0: java.lang.ClassLoader.class
+    // index 1: the immediate caller of index 0.
+    // index 2: the immediate caller of index 1.
+    private static native Class<? extends ClassLoader> getCaller(int index);
+    "
+
+    | ctx receiver |
+
+    ctx := nativeContext.
+
+    (nativeContext argAt:1) timesRepeat:[
+        ctx := ctx sender.
+    ].
+    receiver := ctx receiver.
+    receiver isJavaClass ifTrue:[
+        receiver := Reflection javaClassObjectForClass: receiver.
+    ].
+    ^receiver
+
+    "Modified: / 03-09-2012 / 18:50:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_ClassLoader_registerNatives: aJavaContext
+
+    <javanative: 'java/lang/ClassLoader' name: 'registerNatives'>
+
+
+    "Nothing to do"
+
+    "Created: / 09-11-2010 / 20:55:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_ClassLoader_resolveClass0: nativeContext
+    <javanative: 'java/lang/ClassLoader' name: 'resolveClass0'>
+    "resolve a new class as previously created by defineClass0"
+    "or to be more precise - link class"
+
+    | jClassLoader  jCls  cls |
+    jClassLoader := nativeContext receiver.
+    jCls := nativeContext argAt: 1.
+    jCls isNil ifTrue: [
+        self throwNullPointerException.
+        ^ nil
+    ].
+    cls := self reflection classForJavaClassObject: jCls.
+    self assert: cls notNil.
+    JavaClassReader classLoaderQuerySignal answer: jClassLoader
+     do: [ "cls resolveAll." ].
+    ^ cls.
+
+    "
+        Links the specified class.  This (misleadingly named) method may be
+        * used by a class loader to link a class.  If the class <tt>c</tt> has
+        * already been linked, then this method simply returns. Otherwise, the
+        * class is linked as described in the Execution chapter of the <a
+        * href=http://java.sun.com/docs/books/jls/>Java Language
+        * Specification</a>.
+        * </p>
+        *
+        * @param  c
+        *         The class to link
+        *
+        * @throws  NullPointerException
+         *          If <tt>c</tt> is <tt>null</tt>."
+
+    "Created: / 07-01-1998 / 13:12:27 / cg"
+    "Modified: / 20-10-1998 / 19:01:57 / cg"
+    "Modified: / 28-01-2011 / 15:28:18 / Marcel Hlopko <hlopik@gmail.com>"
+    "Modified: / 08-12-2011 / 20:52:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 12-12-2011 / 14:12:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_ClassLoader_retrieveDirectives: nativeContext
+
+    <javanative: 'java/lang/ClassLoader' name: 'retrieveDirectives()Ljava/lang/AssertionStatusDirectives;'>
+
+    | directives |
+    directives := (self classForName:'java.lang.AssertionStatusDirectives') new.
+    directives instVarNamed:#classes
+        put: ((self classForName:'java.lang.String') javaArrayClass new:0).
+    directives instVarNamed:#classEnabled
+        put: (Boolean javaArrayClass new:0).
+    directives instVarNamed:#packages
+        put: ((self classForName:'java.lang.String') javaArrayClass new:0).
+    directives instVarNamed:#packageEnabled
+        put: (Boolean javaArrayClass new:0).
+    directives instVarNamed:#deflt
+        put: ((AssertionsEnabled == true) ifTrue:[1] ifFalse:[0]).
+    ^directives
+
+    "Modified: / 06-07-2012 / 08:49:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Class_desiredAssertionStatus0: aJavaContext
+
+    <javanative: 'java/lang/Class' name: 'desiredAssertionStatus0'>
+
+
+    ^AssertionsEnabled == true
+
+    "Created: / 24-11-2010 / 08:58:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Class_forName0:aJavaContext
+    <javanative: 'java/lang/Class' name: 'forName0'>
+    |nm initialize loader class descriptor|
+
+    nm := Java as_ST_String:(aJavaContext argAt:1).
+     "Using Class.forName() to get a primitive type is not allowed"
+    (nm size == 1 and:[JavaDescriptor baseTypes includesKey:nm first]) ifTrue:[
+        ^ self throwClassNotFoundException:nm.
+    ].
+    (JavaDescriptor baseTypesByTypeName includesKey:nm) ifTrue:[
+        ^ self throwClassNotFoundException:nm.
+    ].
+    initialize := aJavaContext argAt:2.
+    loader := aJavaContext argAt:3.
+    JavaClassReader classLoaderQuerySignal answer:loader do:[
+        (nm first == $[) ifTrue:[
+            |nms|
+
+            nms := nm readStream.
+            descriptor := JavaDescriptor readFrom:nms
+                        onError:[^ self throwClassNotFoundException:nm].
+            nms atEnd ifFalse:[
+                ^ self throwClassNotFoundException:nm
+            ].
+            class := descriptor javaClass.
+        ] ifFalse:[
+            class := self classForName:nm
+        ]
+    ].
+    class isNil ifTrue:[
+        ^ self throwClassNotFoundException:nm
+    ].
+    ((initialize ~~ 0)
+        and:[class isJavaArrayClass not and:[class isJavaPrimitiveType not]])
+            ifTrue:[
+                [class classInit] on:Error do:[self throwExceptionInInitializerError:nm]
+            ].
+    ^ JavaVM javaClassObjectForClass:class.
+
+    "Created: / 24-11-2010 / 09:03:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 30-10-2011 / 23:30:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 02-11-2011 / 19:12:43 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified (format): / 03-12-2011 / 10:49:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Class_getClassLoader0: aJavaContext
+
+    <javanative: 'java/lang/Class' name: 'getClassLoader0'>
+
+    "get a classes loader"
+
+    |jClass cls |
+    jClass := aJavaContext receiver.
+    cls := self reflection classForJavaClassObject:jClass.
+    ^cls javaMirror getClassLoader
+
+    "Created: / 25-10-2010 / 22:49:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 28-01-2011 / 15:18:54 / Marcel Hlopko <hlopik@gmail.com>"
+    "Modified (format): / 31-07-2012 / 18:33:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Class_getComponentType: nativeContext
+
+    <javanative: 'java/lang/Class' name: 'getComponentType'>
+
+        |cls|
+
+    cls := self reflection classForJavaClassObject:(nativeContext receiver).
+    cls isJavaPrimitiveType ifTrue:[
+        self breakPoint:#jv.
+        ^ nil
+    ].
+    ^ self javaClassObjectForClass:cls javaComponentClass
+
+    "Created: / 12-11-1998 / 18:54:46 / cg"
+    "Modified: / 20-12-2010 / 22:56:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 28-01-2011 / 15:18:59 / Marcel Hlopko <hlopik@gmail.com>"
+!
+
+_java_lang_Class_getConstantPool: aJavaContext
+
+    <javanative: 'java/lang/Class' name: 'getConstantPool'>
+
+        | class |
+
+    class := self reflection classForJavaClassObject:aJavaContext receiver.
+    class isJavaClass ifFalse:[
+        ^nil
+    ].
+
+    ^ self reflection javaConstantPoolObjectFor:class constantPool.
+
+    "Created: / 21-12-2010 / 20:00:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 28-02-2011 / 18:05:13 / Marcel Hlopko <hlopik@gmail.com>"
+    "Modified: / 31-07-2012 / 00:47:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Class_getDeclaredClasses0: nativeContext
+
+    <javanative: 'java/lang/Class' name: 'getDeclaredClasses0'>
+
+    | class innerPrefix inners |
+    class := self reflection classForJavaClassObject: nativeContext receiver.
+    innerPrefix := class name , '$'.
+    inners := Set new.
+    JAVA allClassesDo:[:cls|
+        ((cls name startsWith: innerPrefix) and:[(cls name indexOf: $$ startingAt: innerPrefix size) == 0]) ifTrue:[
+            inners add: (self reflection javaClassObjectForClass: cls)
+        ].
+    ].
+    ^(Java at: 'java.lang.Class') javaArrayClass withAll: inners
+
+    "Modified: / 31-07-2012 / 12:07:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Class_getDeclaredConstructors0:aJavaContext
+    <javanative: 'java/lang/Class' name: 'getDeclaredConstructors0'>
+
+    | class publicOnly |
+
+    class := self reflection classForJavaClassObject:(aJavaContext receiver).
+    publicOnly := (aJavaContext argAt:1) == 1.
+    ^class javaMirror getDeclaredConstructors: publicOnly.
+
+    "Created: / 24-11-2010 / 09:25:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 09-02-2011 / 01:24:03 / Marcel Hlopko <hlopik@gmail.com>"
+    "Modified (format): / 01-08-2012 / 11:15:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Class_getDeclaredFields0:aJavaContext
+    <javanative: 'java/lang/Class' name: 'getDeclaredFields0'>
+    |javaClassObject class fields publicOnly|
+
+    class := self reflection
+                classForJavaClassObject:(javaClassObject := aJavaContext argAt:0).
+    (class isJavaPrimitiveType or:[class isJavaArrayClass]) ifTrue:[
+        ^(self classForName:'java.lang.reflect.Field') javaArrayClass new:0.
+    ].
+
+    publicOnly := (aJavaContext argAt:1) == 1.
+    fields := class javaMirror getDeclaredFields: publicOnly.
+    ^fields
+
+    "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>"
+!
+
+_java_lang_Class_getDeclaredMethods0:aJavaContext
+    <javanative: 'java/lang/Class' name: 'getDeclaredMethods0'>
+
+    | class publicOnly |
+
+    class := self reflection classForJavaClassObject:(aJavaContext receiver).
+    publicOnly := (aJavaContext argAt:1) == 1.
+    ^class javaMirror getDeclaredMethods: publicOnly.
+
+    "Created: / 21-12-2010 / 22:39:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 28-01-2011 / 15:19:09 / Marcel Hlopko <hlopik@gmail.com>"
+    "Modified: / 04-06-2011 / 17:07:04 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 01-08-2012 / 11:15:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Class_getDeclaringClass: nativeContext
+    <javanative: 'java/lang/Class' name: 'getDeclaringClass'>
+    "
+     /**
+     * If the class or interface represented by this {@code Class} object
+     * is a member of another class, returns the {@code Class} object
+     * representing the class in which it was declared.  This method returns
+     * null if this class or interface is not a member of any other class.  If
+     * this {@code Class} object represents an array class, a primitive
+     * type, or void,then this method returns null.
+     *
+     * @return the declaring class for this class
+     * @since JDK1.1
+     */"
+
+    | cls  enclosingClsName  enclosingCls |
+
+    cls := self reflection classForJavaClassObject: (nativeContext receiver).
+    (cls isJavaPrimitiveType or: [ cls isJavaArrayClass ]) ifTrue: [ ^ nil ].
+    (cls name includes: $$) ifFalse: [ ^ nil ].
+    enclosingClsName := cls name copyTo: (cls name lastIndexOf: $$) - 1.
+    enclosingCls := self classForName: enclosingClsName.
+    enclosingCls isNil ifTrue: [ self error: 'Cannot fins declaring class' ].
+    ^ self reflection javaClassObjectForClass: enclosingCls
+
+    "Modified: / 13-08-2011 / 02:01:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Class_getEnclosingMethod0: nativeContext
+
+    <javanative: 'java/lang/Class' name: 'getEnclosingMethod0'>
+
+    ^nil "/Not true"
+
+    "Modified: / 14-08-2011 / 20:05:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Class_getGenericSignature: nativeContext
+
+    <javanative: 'java/lang/Class' name: 'getGenericSignature'>
+
+    |cls sig |
+
+    cls := self reflection classForJavaClassObject:(nativeContext receiver).
+    sig := cls javaMirror getGenericSignature.
+    ^sig notNil ifTrue:[
+        Java as_String: sig
+    ] ifFalse:[
+        nil
+    ]
+
+    "Modified: / 22-08-2012 / 11:58:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Class_getInterfaces:nativeContext
+    <javanative: 'java/lang/Class' name: 'getInterfaces'>
+    |jClass cls interfaces jInterfaces|
+
+    jClass := nativeContext receiver.
+    cls := self reflection classForJavaClassObject:jClass.
+    interfaces := cls javaMirror getInterfaces.
+    jInterfaces := (self classForName:'java.lang.Class') javaArrayClass new:interfaces size.
+    interfaces
+        withIndexDo:[:iface :idx | jInterfaces at:idx put:(self javaClassObjectForClass:iface) ].
+    ^ jInterfaces
+
+    "Modified: / 28-01-2011 / 15:19:11 / Marcel Hlopko <hlopik@gmail.com>"
+    "Modified: / 22-08-2012 / 11:08:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Class_getModifiers: aJavaContext
+    <javanative: 'java/lang/Class' name: 'getModifiers'>
+    | cls |
+
+    cls := (self reflection classForJavaClassObject: aJavaContext receiver).
+    ^cls javaMirror getModifiers
+
+    "Created: / 12-11-1998 / 18:54:53 / cg"
+    "Modified: / 28-01-2011 / 15:19:14 / Marcel Hlopko <hlopik@gmail.com>"
+    "Modified: / 22-08-2012 / 11:04:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Class_getName0: aJavaContext
+
+    <javanative: 'java/lang/Class' name: 'getName0'>
+
+        |class|
+
+    class := aJavaContext receiver.
+    class := self reflection classForJavaClassObject:aJavaContext receiver.
+    ^ self reflection
+        javaStringObjectForString:class javaMirror getName
+        interned:true.
+
+    "Created: / 22-11-2010 / 17:50:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 09-02-2011 / 01:06:53 / Marcel Hlopko <hlopik@gmail.com>"
+    "Modified: / 22-08-2012 / 10:47:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Class_getPrimitiveClass: nativeContext
+
+    <javanative: 'java/lang/Class' name: 'getPrimitiveClass'>
+
+        "get a primitive class by name"
+
+    |jClassName className|
+
+    jClassName := nativeContext argAt:1.
+    className := Java as_ST_String:jClassName.
+    (JavaDescriptor baseTypesByTypeName keys includes: className)
+        ifFalse:[self throwClassNotFoundException:className].
+    ^self reflection javaClassObjectForClassNamed: className
+
+    "Created: / 04-01-1998 / 00:46:03 / cg"
+    "Modified: / 28-01-2011 / 15:30:45 / Marcel Hlopko <hlopik@gmail.com>"
+    "Modified: / 03-02-2011 / 21:43:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Class_getProtectionDomain0: nativeContext
+
+    <javanative: 'java/lang/Class' name: 'getProtectionDomain0'>
+
+    ^(self reflection classForJavaClassObject: nativeContext receiver) javaMirror getProtectionDomain
+
+    "Modified: / 22-08-2012 / 12:55:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Class_getRawAnnotations: aJavaContext
+
+    <javanative: 'java/lang/Class' name: 'getRawAnnotations'>
+
+    |class |
+
+    class := self reflection classForJavaClassObject:aJavaContext receiver.
+    class isJavaArrayClass ifTrue:[
+        ^nil
+    ].
+    class isJavaPrimitiveType ifTrue:[
+        ^nil
+    ].
+    class isJavaClass ifFalse:[
+        ^nil.
+    ].
+    ^ class runtimeVisibleAnnotationsAsBytesOrNil
+
+    "Created: / 21-12-2010 / 19:35:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 28-01-2011 / 15:19:20 / Marcel Hlopko <hlopik@gmail.com>"
+    "Modified: / 31-07-2012 / 00:46:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Class_getSuperclass: nativeContext
+    <javanative: 'java/lang/Class' name: 'getSuperclass'>
+    "return a classes superclass"
+
+    | jClass  cls  superCls |
+
+    jClass := nativeContext receiver.
+    cls := self reflection classForJavaClassObject: jClass.
+
+    cls isJavaPrimitiveType ifTrue: [ ^ nil ].
+    cls isJavaArrayClass ifTrue: [
+        ^ self javaClassObjectForClass: (Java at: 'java.lang.Object')
+    ].
+    cls == Object ifTrue: [
+        ^ self javaClassObjectForClass: (Java at: 'java.lang.Object')
+    ].
+    cls isInterface ifTrue: [ ^ nil ].
+    superCls := cls superclass.
+    superCls == JavaObject ifTrue: [ ^ nil. ].
+    superCls ==     Object ifTrue: [ ^ nil ]. "/for Java
+    ^ self javaClassObjectForClass: superCls
+
+    "Created: / 12-01-1998 / 12:38:36 / cg"
+    "Modified: / 04-02-1998 / 14:51:22 / cg"
+    "Modified: / 28-01-2011 / 14:12:47 / Marcel Hlopko <hlopik@gmail.com>"
+    "Modified: / 31-07-2012 / 00:50:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Class_isArray: nativeContext
+
+    <javanative: 'java/lang/Class' name: 'isArray'>
+
+        ^ (self reflection classForJavaClassObject:nativeContext receiver) isJavaArrayClass
+        ifTrue:[1]
+        ifFalse:[0]
+
+    "Created: / 12-11-1998 / 18:54:24 / cg"
+    "Modified: / 20-12-2010 / 23:20:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 28-01-2011 / 15:19:24 / Marcel Hlopko <hlopik@gmail.com>"
+!
+
+_java_lang_Class_isAssignableFrom: nativeContext
+
+    <javanative: 'java/lang/Class' name: 'isAssignableFrom'>
+
+        "
+    /**
+     * Determines if the class or interface represented by this
+     * {@code Class} object is either the same as, or is a superclass or
+     * superinterface of, the class or interface represented by the specified
+     * {@code Class} parameter. It returns {@code true} if so;
+     * otherwise it returns {@code false}. If this {@code Class}
+     * object represents a primitive type, this method returns
+     * {@code true} if the specified {@code Class} parameter is
+     * exactly this {@code Class} object; otherwise it returns
+     * {@code false}.
+     *
+     * <p> Specifically, this method tests whether the type represented by the
+     * specified {@code Class} parameter can be converted to the type
+     * represented by this {@code Class} object via an identity conversion
+     * or via a widening reference conversion. See <em>The Java Language
+     * Specification</em>, sections 5.1.1 and 5.1.4 , for details.
+     *
+     * @param cls the {@code Class} object to be checked
+     * @return the {@code boolean} value indicating whether objects of the
+     * type {@code cls} can be assigned to objects of this class
+     * @exception NullPointerException if the specified Class parameter is
+     *            null.
+     * @since JDK1.1
+     */
+    "
+    | clsObj me other |
+    clsObj := nativeContext argAt: 1.
+    clsObj ifNil:[^self throwNullPointerException].
+    me := self reflection classForJavaClassObject: nativeContext receiver.
+    other := self reflection classForJavaClassObject: clsObj.
+
+    "/    Determines if the class or interface represented by this
+    "/    @code Class} object is either the same as, or is a superclass or
+    "/    superinterface of, the class or interface represented by the specified
+    "/    {@code Class} parameter.
+
+    ^(other includesBehavior: me)
+        ifTrue:[1]
+        ifFalse:[0]
+
+    "Created: / 12-11-1998 / 18:54:16 / cg"
+    "Modified: / 05-02-2011 / 23:38:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Class_isInstance: nativeContext
+
+    <javanative: 'java/lang/Class' name: 'isInstance'>
+
+        "
+    /**
+     * Determines if the specified {@code Object} is assignment-compatible
+     * with the object represented by this {@code Class}.  This method is
+     * the dynamic equivalent of the Java language {@code instanceof}
+     * operator. The method returns {@code true} if the specified
+     * {@code Object} argument is non-null and can be cast to the
+     * reference type represented by this {@code Class} object without
+     * raising a {@code ClassCastException.} It returns {@code false}
+     * otherwise.
+     *
+     * <p> Specifically, if this {@code Class} object represents a
+     * declared class, this method returns {@code true} if the specified
+     * {@code Object} argument is an instance of the represented class (or
+     * of any of its subclasses); it returns {@code false} otherwise. If
+     * this {@code Class} object represents an array class, this method
+     * returns {@code true} if the specified {@code Object} argument
+     * can be converted to an object of the array class by an identity
+     * conversion or by a widening reference conversion; it returns
+     * {@code false} otherwise. If this {@code Class} object
+     * represents an interface, this method returns {@code true} if the
+     * class or any superclass of the specified {@code Object} argument
+     * implements this interface; it returns {@code false} otherwise. If
+     * this {@code Class} object represents a primitive type, this method
+     * returns {@code false}.
+     *
+     * @param   obj the object to check
+     * @return  true if {@code obj} is an instance of this class
+     *
+     * @since JDK1.1
+     */
+    public native boolean isInstance(Object obj);
+    "
+
+    |jClass cls obj|
+
+    obj := nativeContext argAt:1.
+    obj isNil ifTrue:[^ 0].
+    jClass := nativeContext receiver.
+    cls := self reflection classForJavaClassObject:jClass.
+    ^self _INSTANCEOF:obj _:cls
+
+    "Modified: / 09-02-1998 / 14:56:23 / cg"
+    "Modified: / 28-01-2011 / 14:12:42 / Marcel Hlopko <hlopik@gmail.com>"
+    "Modified: / 25-02-2011 / 18:37:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Class_isInterface: nativeContext
+
+    <javanative: 'java/lang/Class' name: 'isInterface'>
+
+        "return true, if this class is an interface"
+
+    |jClass cls|
+
+    jClass := nativeContext receiver.
+    cls := self reflection classForJavaClassObject:jClass.
+    cls isJavaClass ifFalse:[
+        ^ 0
+    ].
+    cls isInterface ifTrue:[
+        ^ 1 "TRUE"
+    ].
+    ^ 0 "FALSE"
+
+    "Created: / 12-01-1998 / 12:37:02 / cg"
+    "Modified: / 28-01-2011 / 14:12:35 / Marcel Hlopko <hlopik@gmail.com>"
+    "Modified: / 03-02-2011 / 21:50:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Class_isPrimitive: nativeContext
+
+    <javanative: 'java/lang/Class' name: 'isPrimitive'>
+
+        "return true, if this class is builtin primitive class
+     (i.e. byteArray, array, string etc."
+
+    |jClass cls|
+
+    jClass := nativeContext receiver.
+    cls := self reflection classForJavaClassObject:jClass.
+    ^cls isJavaPrimitiveType
+        ifTrue:[1"true"]
+        ifFalse:[0"false"].
+
+    "Created: / 09-02-1998 / 14:46:07 / cg"
+    "Modified: / 28-01-2011 / 14:12:30 / Marcel Hlopko <hlopik@gmail.com>"
+    "Modified: / 04-02-2011 / 11:56:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Class_registerNatives: aJavaContext
+
+    <javanative: 'java/lang/Class' name: 'registerNatives'>
+
+
+     "Nothing to do, native method are bound lazily"
+
+    "Created: / 20-10-2010 / 11:13:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Class_setProtectionDomain0: nativeContext
+
+    <javanative: 'java/lang/Class' name: 'getProtectionDomain0'>
+
+    (self reflection classForJavaClassObject: nativeContext receiver)
+        protectionDomain: (nativeContext argAt:1)
+
+    "Created: / 10-08-2011 / 15:20:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Compiler_disable: nativeContext
+
+    <javanative: 'java/lang/Compiler' name: 'disable()V'>
+
+    "Modified: / 09-02-2012 / 22:56:44 / mh <hlopik@gmail.com>"
+!
+
+_java_lang_Compiler_enable: nativeContext
+
+    <javanative: 'java/lang/Compiler' name: 'enable()V'>
+
+    "Modified: / 09-02-2012 / 22:57:15 / mh <hlopik@gmail.com>"
+!
+
+_java_lang_Compiler_registerNatives: nativeContext
+
+    <javanative: 'java/lang/Compiler' name: 'registerNatives()V'>
+
+    "Modified: / 09-02-2012 / 22:56:37 / mh <hlopik@gmail.com>"
+!
+
+_java_lang_Double_doubleToRawLongBits: aJavaContext
+
+    <javanative: 'java/lang/Double' name: 'doubleToRawLongBits'>
+
+        "
+    /**
+     * Returns a representation of the specified floating-point value
+     * according to the IEEE 754 floating-point 'double
+     * format' bit layout, preserving Not-a-Number (NaN) values.
+     *
+     * <p>Bit 63 (the bit that is selected by the mask
+     * {@code 0x8000000000000000L}) represents the sign of the
+     * floating-point number. Bits
+     * 62-52 (the bits that are selected by the mask
+     * {@code 0x7ff0000000000000L}) represent the exponent. Bits 51-0
+     * (the bits that are selected by the mask
+     * {@code 0x000fffffffffffffL}) represent the significand
+     * (sometimes called the mantissa) of the floating-point number.
+     *
+     * <p>If the argument is positive infinity, the result is
+     * {@code 0x7ff0000000000000L}.
+     *
+     * <p>If the argument is negative infinity, the result is
+     * {@code 0xfff0000000000000L}.
+     *
+     * <p>If the argument is NaN, the result is the {@code long}
+     * integer representing the actual NaN value.  Unlike the
+     * {@code doubleToLongBits} method,
+     * {@code doubleToRawLongBits} does not collapse all the bit
+     * patterns encoding a NaN to a single 'canonical' NaN
+     * value.
+     *
+     * <p>In all cases, the result is a {@code long} integer that,
+     * when given to the {@link #longBitsToDouble(long)} method, will
+     * produce a floating-point value the same as the argument to
+     * {@code doubleToRawLongBits}.
+     *
+     * @param   value   a {@code double} precision floating-point number.
+     * @return the bits that represent the floating-point number.
+     * @since 1.3
+     */
+    "
+      | f b |
+    f := aJavaContext argAt:1.
+    (f =  0.0) ifTrue:[^0].
+    (f = -0.0) ifTrue:[^(1 bitShift: 63)].
+
+    b := ByteArray streamContents:[:s|Float storeBinaryIEEEDouble:f on:s].
+    ^ LargeInteger digitBytes: b MSB: UninterpretedBytes isBigEndian not.
+
+
+"/    | f |
+"/    f := aJavaContext argAt:1.
+"/    f class == Float ifFalse:[ ^self throwIllegalArgumentException: 'Not a float'].
+"/%{
+"/    __int64__ *i = &(__floatVal(f));
+"/    RETURN (__MKINT64( i ));
+"/%}.
+"/    self primitiveFailed.
+
+    "Created: / 10-11-2010 / 14:48:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 16-12-2012 / 23:23:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Double_longBitsToDouble: nativeContext
+
+    <javanative: 'java/lang/Double' name: 'longBitsToDouble'>
+
+    |i aFloat|
+
+    i := nativeContext argAt:1.
+
+    aFloat := Float new.
+    UninterpretedBytes isBigEndian ifTrue:[
+        aFloat basicAt:1 put:((i bitShift:-56) bitAnd:16rFF).
+        aFloat basicAt:2 put:((i bitShift:-48) bitAnd:16rFF).
+        aFloat basicAt:3 put:((i bitShift:-40) bitAnd:16rFF).
+        aFloat basicAt:4 put:((i bitShift:-32) bitAnd:16rFF).
+        aFloat basicAt:5 put:((i bitShift:-24) bitAnd:16rFF).
+        aFloat basicAt:6 put:((i bitShift:-16) bitAnd:16rFF).
+        aFloat basicAt:7 put:((i bitShift:-8) bitAnd:16rFF).
+        aFloat basicAt:8 put:(i bitAnd:16rFF).
+    ] ifFalse:[
+        aFloat basicAt:1 put:(i bitAnd:16rFF).
+        aFloat basicAt:2 put:((i bitShift:-8) bitAnd:16rFF).
+        aFloat basicAt:3 put:((i bitShift:-16) bitAnd:16rFF).
+        aFloat basicAt:4 put:((i bitShift:-24) bitAnd:16rFF).
+        aFloat basicAt:5 put:((i bitShift:-32) bitAnd:16rFF).
+        aFloat basicAt:6 put:((i bitShift:-40) bitAnd:16rFF).
+        aFloat basicAt:7 put:((i bitShift:-48) bitAnd:16rFF).
+        aFloat basicAt:8 put:((i bitShift:-56) bitAnd:16rFF).
+    ].
+
+    ^ aFloat.
+
+
+"/    | i f|
+"/
+"/    i := nativeContext argAt:1.
+"/    f := Float new.
+"/%{
+"/    long long l;
+"/    l = __longIntVal(i);
+"/    double *d = &l;
+"/    __floatVal(f) = *d;
+"/%}.
+"/    ^f
+
+    "Modified: / 16-12-2012 / 23:24:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Float_floatToRawIntBits: aJavaContext
+
+    <javanative: 'java/lang/Float' name: 'floatToRawIntBits'>
+
+        "
+    /**
+     * Returns a representation of the specified floating-point value
+     * according to the IEEE 754 floating-point 'single format' bit
+     * layout, preserving Not-a-Number (NaN) values.
+     *
+     * <p>Bit 31 (the bit that is selected by the mask
+     * {@code 0x80000000}) represents the sign of the floating-point
+     * number.
+     * Bits 30-23 (the bits that are selected by the mask
+     * {@code 0x7f800000}) represent the exponent.
+     * Bits 22-0 (the bits that are selected by the mask
+     * {@code 0x007fffff}) represent the significand (sometimes called
+     * the mantissa) of the floating-point number.
+     *
+     * <p>If the argument is positive infinity, the result is
+     * {@code 0x7f800000}.
+     *
+     * <p>If the argument is negative infinity, the result is
+     * {@code 0xff800000}.
+     *
+     * <p>If the argument is NaN, the result is the integer representing
+     * the actual NaN value.  Unlike the {@code floatToIntBits}
+     * method, {@code floatToRawIntBits} does not collapse all the
+     * bit patterns encoding a NaN to a single 'canonical'
+     * NaN value.
+     *
+     * <p>In all cases, the result is an integer that, when given to the
+     * {@link #intBitsToFloat(int)} method, will produce a
+     * floating-point value the same as the argument to
+     * {@code floatToRawIntBits}.
+     *
+     * @param   value   a floating-point number.
+     * @return the bits that represent the floating-point number.
+     * @since 1.3
+     */
+    "
+    | f b |
+    f := aJavaContext argAt:1.
+    f class == ShortFloat ifFalse:[ self throwIllegalArgumentException: 'Not a float'].
+%{
+        int *ival = &__shortFloatVal(f);
+        RETURN (__MKINT(*ival));
+%}.
+    self primitiveFailed.
+
+    "Created: / 09-11-2010 / 20:59:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 16-12-2012 / 11:16:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Float_intBitsToFloat: nativeContext
+
+    <javanative: 'java/lang/Float' name: 'intBitsToFloat(I)F'>
+
+    | i f|
+
+    i := nativeContext argAt:1.
+    f := ShortFloat new.
+%{
+    int ival = __intVal(i);
+    float *fval = &ival;
+    __shortFloatVal(f) = *fval;
+%}.
+    ^f
+
+    "Modified: / 16-12-2012 / 10:39:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Object_clone: nativeContext
+
+    <javanative: 'java/lang/Object' name: 'clone'>
+
+        "clone an object"
+
+    |o rslt|
+
+    o := nativeContext receiver.
+    rslt := o shallowCopy.
+    ^ rslt
+
+    "Created: / 4.1.1998 / 19:39:26 / cg"
+!
+
+_java_lang_Object_getClass: nativeContext
+    <javanative: 'java/lang/Object' name: 'getClass'>
+    "return an objects class"
+
+    | o  cls  jClass |
+
+    o := nativeContext receiver.
+    cls := o class.
+    jClass := self javaClassObjectForClass: cls.
+    ^ jClass
+
+    "Created: / 6.1.1998 / 18:28:27 / cg"
+    "Modified: / 23.1.1998 / 17:48:22 / cg"
+!
+
+_java_lang_Object_hashCode: nativeContext
+
+    <javanative: 'java/lang/Object' name: 'hashCode'>
+
+        "identityHash"
+
+    |o rslt|
+
+    o := nativeContext receiver.
+    rslt := o identityHash.
+    ^ rslt
+
+    "Created: / 4.1.1998 / 19:40:26 / cg"
+!
+
+_java_lang_Object_notify: nativeContext
+    <javanative: 'java/lang/Object' name: 'notify'>
+    "wakeup"
+
+    self notify: (nativeContext receiver).
+
+    "Created: / 06-01-1998 / 21:09:26 / cg"
+    "Modified: / 22-11-2011 / 13:24:12 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+_java_lang_Object_notifyAll: nativeContext
+    <javanative: 'java/lang/Object' name: 'notifyAll'>
+    self notifyAll: (nativeContext receiver).
+
+    "Created: / 03-01-1998 / 03:06:56 / cg"
+    "Modified: / 22-11-2011 / 13:27:17 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+_java_lang_Object_registerNatives: aJavaContext
+
+    <javanative: 'java/lang/Object' name: 'registerNatives'>
+
+
+    "Nothing to do, native method are bound lazily"
+
+    "Created: / 19-10-2010 / 12:42:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 20-10-2010 / 10:57:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Object_wait: nativeContext
+    <javanative: 'java/lang/Object' name: 'wait'>
+    | tmo  handle |
+    handle := nativeContext receiver.
+    tmo := nativeContext argAt: 1.
+    tmo < 0 ifTrue:[
+        self throwIllegalArgumentException: '1'
+    ].
+    self
+        waitOn: handle forTimeout: tmo
+        state: #javaWait.
+
+    "Modified: / 30-12-1998 / 19:20:43 / cg"
+    "Modified: / 22-11-2011 / 13:17:51 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 19-09-2012 / 16:19:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Package_getSystemPackage0: nativeContext
+
+    <javanative: 'java/lang/Package' name: 'getSystemPackage0'>
+
+    "Based on code on OpenJDK, it is ok to return nil here:"
+
+    | syspkg syspkg_s |
+    syspkg := nativeContext argAt: 1.
+    syspkg isNil ifTrue:[ ^ nil ].
+    syspkg_s := Java as_ST_String: syspkg.
+    ^(ClassRegistry systemPackage: syspkg_s) notNil ifTrue:[
+        syspkg
+    ] ifFalse:[
+        nil
+    ].
+
+    "Modified: / 16-08-2012 / 17:45:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_ProcessEnvironment_environ: nativeContext
+
+    <javanative: 'java/lang/ProcessEnvironment' name: 'environ'>
+
+    | env jenv i|
+    env := OperatingSystem getEnvironment.
+    jenv :=  ByteArray javaArrayClass new: env size * 2.
+    i := 1.
+    env keysAndValuesDo:
+        [:name :value|
+        jenv
+            at: i   put: name  asByteArray;
+            at: i+1 put: value asByteArray.
+        i := i + 2].
+    ^jenv
+
+    "Modified: / 25-06-2011 / 08:57:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_ProcessEnvironment_environmentBlock: nativeContext
+
+    <javanative: 'java/lang/ProcessEnvironment' name: 'environmentBlock()Ljava/lang/String;'>
+
+    ^ JavaVM unimplementedNativeMethodSignal raise
+!
+
+_java_lang_Runtime_availableProcessors: nativeContext
+
+    <javanative: 'java/lang/Runtime' name: 'availableProcessors()I'>
+    "
+    /**
+     * Returns the number of processors available to the Java virtual machine.
+     *
+     * <p> This value may change during a particular invocation of the virtual
+     * machine.  Applications that are sensitive to the number of available
+     * processors should therefore occasionally poll this property and adjust
+     * their resource usage appropriately. </p>
+     *
+     * @return  the maximum number of processors available to the virtual
+     *          machine; never smaller than one
+     * @since 1.4
+     */
+    "
+
+    ^ 1 "/ Since Smalltalk/X is single-thread application
+
+    "Modified: / 03-09-2012 / 18:53:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Runtime_freeMemory: nativeContext
+
+    <javanative: 'java/lang/Runtime' name: 'freeMemory()J'>
+
+        "free memory - Returns the number of free bytes"
+
+    ^ ObjectMemory freeListSpace + ObjectMemory freeSpace
+
+    "Created: / 12.1.1998 / 12:59:53 / cg"
+!
+
+_java_lang_Runtime_gc: nativeContext
+
+    <javanative: 'java/lang/Runtime' name: 'gc'>
+
+        "Runs the garbage collector.
+     Ignored, since the ST-gc runs all the time."
+
+    ^ self
+
+    "Modified: / 12.1.1998 / 12:58:32 / cg"
+!
+
+_java_lang_Runtime_runFinalization0: nativeContext
+
+    <javanative: 'java/lang/Runtime' name: 'runFinalization0'>
+
+    Smalltalk garbageCollect
+
+    "Modified: / 08-08-2011 / 17:48:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_SecurityManager_getClassContext: nativeContext
+
+    <javanative: 'java/lang/SecurityManager' name: 'getClassContext'>
+    "
+    /**
+     * Returns the current execution stack as an array of classes.
+     * <p>
+     * The length of the array is the number of methods on the execution
+     * stack. The element at index <code>0</code> is the class of the
+     * currently executing method, the element at index <code>1</code> is
+     * the class of that method's caller, and so on.
+     *
+     * @return  the execution stack.
+     */
+
+    "
+
+    | classes ctx jclasses |
+    classes := OrderedCollection new.
+    ctx := thisContext.
+    [ ctx notNil ] whileTrue: [
+        ctx isJavaContext ifTrue:[
+            classes add: ctx method javaClass.
+        ].
+        ctx := ctx sender.
+    ].
+
+    jclasses := (self classForName:'java.lang.Class') javaArrayClass new: classes size.
+    1 to: classes size do:[:i|
+        jclasses at: i put: (self reflection javaClassObjectForClass: (classes at: i)).
+    ].
+    ^jclasses
+
+    "Created: / 12-11-1998 / 18:56:06 / cg"
+    "Modified: / 15-11-2011 / 00:27:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Shutdown_halt0: nativeContext
+
+    <javanative: 'java/lang/Shutdown' name: 'halt0'>
+
+    AbortOperationRequest raise
+
+    "Modified: / 06-07-2012 / 13:13:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_StrictMath_cbrt: nativeContext
+
+    <javanative: 'java/lang/StrictMath' name: 'cbrt'>
+
+    ^ JavaMathSupport cbrt: (nativeContext argAt:1)
+
+    "Modified: / 07-09-2011 / 17:34:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_StrictMath_ceil: nativeContext
+
+    <javanative: 'java/lang/StrictMath' name: 'ceil(D)D'>
+
+    ^ (nativeContext argAt:1) ceiling
+
+    "Modified: / 21-08-2012 / 18:01:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_StrictMath_cos: nativeContext
+
+    <javanative: 'java/lang/StrictMath' name: 'cos'>
+
+    ^ JavaMathSupport cos: (nativeContext argAt:1)
+
+    "Modified: / 07-09-2011 / 17:34:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_StrictMath_cosh: nativeContext
+
+    <javanative: 'java/lang/StrictMath' name: 'cosh'>
+
+    "
+    /**
+     * Returns the hyperbolic cosine of a {@code double} value.
+     * The hyperbolic cosine of <i>x</i> is defined to be
+     * (<i>e<sup>x</sup>&nbsp;+&nbsp;e<sup>-x</sup></i>)/2
+     * where <i>e</i> is {@linkplain Math#E Euler's number}.
+     *
+     * <p>Special cases:
+     * <ul>
+     *
+     * <li>If the argument is NaN, then the result is NaN.
+     *
+     * <li>If the argument is infinite, then the result is positive
+     * infinity.
+     *
+     * <li>If the argument is zero, then the result is {@code 1.0}.
+     *
+     * </ul>
+     *
+     * @param   x The number whose hyperbolic cosine is to be returned.
+     * @return  The hyperbolic cosine of {@code x}.
+     * @since 1.5
+     */
+    public static native double cosh(double x);
+    "
+
+    ^JavaMathSupport cosh: (nativeContext argAt:1)
+
+    "Modified: / 06-09-2011 / 19:25:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_StrictMath_expm1: nativeContext
+
+    <javanative: 'java/lang/StrictMath' name: 'expm1'>
+
+    ^ JavaMathSupport expm1: (nativeContext argAt:1)
+
+    "Modified: / 07-09-2011 / 17:34:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_StrictMath_floor: nativeContext
+
+    <javanative: 'java/lang/StrictMath' name: 'floor'>
+
+   ^ JavaMathSupport floor: (nativeContext argAt:1)
+
+    "Modified: / 07-09-2011 / 17:33:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_StrictMath_pow: nativeContext
+
+    <javanative: 'java/lang/StrictMath' name: 'pow(DD)D'>
+
+    ^JavaMathSupport pow: (nativeContext argAt:1) to: (nativeContext argAt:3)
+
+    "Modified: / 07-09-2011 / 17:33:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_StrictMath_sin: nativeContext
+
+    <javanative: 'java/lang/StrictMath' name: 'cos'>
+
+    ^ JavaMathSupport sin: (nativeContext argAt:1)
+
+    "Modified: / 07-09-2011 / 17:32:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_StrictMath_sinh: nativeContext
+
+    <javanative: 'java/lang/StrictMath' name: 'sinh'>
+
+    "
+    /**
+     * Returns the hyperbolic sine of a {@code double} value.
+     * The hyperbolic sine of <i>x</i> is defined to be
+     * (<i>e<sup>x</sup>&nbsp;-&nbsp;e<sup>-x</sup></i>)/2
+     * where <i>e</i> is {@linkplain Math#E Euler's number}.
+     *
+     * <p>Special cases:
+     * <ul>
+     *
+     * <li>If the argument is NaN, then the result is NaN.
+     *
+     * <li>If the argument is infinite, then the result is an infinity
+     * with the same sign as the argument.
+     *
+     * <li>If the argument is zero, then the result is a zero with the
+     * same sign as the argument.
+     *
+     * </ul>
+     *
+     * @param   x The number whose hyperbolic sine is to be returned.
+     * @return  The hyperbolic sine of {@code x}.
+     * @since 1.5
+     */
+    public static native double sinh(double x);
+
+    "
+
+    ^ JavaMathSupport sinh: (nativeContext argAt:1)
+
+    "Modified: / 06-09-2011 / 19:36:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (format): / 07-09-2011 / 17:31:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_StrictMath_sqrt: nativeContext
+
+    <javanative: 'java/lang/StrictMath' name: 'sqrt(D)D'>
+
+    ^(nativeContext argAt:1) sqrt
+
+    "Modified: / 17-07-2012 / 20:53:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_StrictMath_tan: nativeContext
+
+    <javanative: 'java/lang/StrictMath' name: 'tan(D)D'>
+
+    ^ JavaVM unimplementedNativeMethodSignal raise
+!
+
+_java_lang_StrictMath_tanh: nativeContext
+
+    <javanative: 'java/lang/StrictMath' name: 'tanh'>
+    "
+    /**
+     * Returns the hyperbolic tangent of a {@code double} value.
+     * The hyperbolic tangent of <i>x</i> is defined to be
+     * (<i>e<sup>x</sup>&nbsp;-&nbsp;e<sup>-x</sup></i>)/(<i>e<sup>x</sup>&nbsp;+&nbsp;e<sup>-x</sup></i>),
+     * in other words, {@linkplain Math#sinh
+     * sinh(<i>x</i>)}/{@linkplain Math#cosh cosh(<i>x</i>)}.  Note
+     * that the absolute value of the exact tanh is always less than
+     * 1.
+     *
+     * <p>Special cases:
+     * <ul>
+     *
+     * <li>If the argument is NaN, then the result is NaN.
+     *
+     * <li>If the argument is zero, then the result is a zero with the
+     * same sign as the argument.
+     *
+     * <li>If the argument is positive infinity, then the result is
+     * {@code +1.0}.
+     *
+     * <li>If the argument is negative infinity, then the result is
+     * {@code -1.0}.
+     *
+     * </ul>
+     *
+     * @param   x The number whose hyperbolic tangent is to be returned.
+     * @return  The hyperbolic tangent of {@code x}.
+     * @since 1.5
+     */
+    public static native double tanh(double x);
+    "
+
+    ^ JavaMathSupport tanh: (nativeContext argAt:1)
+
+    "Modified: / 07-09-2011 / 17:32:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_String_intern: nativeContext
+
+    <javanative: 'java/lang/String' name: 'intern'>
+
+        |jString|
+
+    jString := nativeContext receiver.
+    ^ Java intern:jString
+!
+
+_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
+    ].
+
+    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
+            ]
+        ].
+        ^ 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.
+        ]
+    ].
+    ^ nil.
+
+    "Modified: / 08-09-2011 / 15:25:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_System_currentTimeMillis: nativeContext
+
+    <javanative: 'java/lang/System' name: 'currentTimeMillis'>
+
+    "return the milliseconds since 1.jan.1970"
+
+    "Should be OK, see Timestamp>>getMilliseconds & Timestamp>>getSeconds & Timestamp>>utcSecondsSince1970"
+    ^ Timestamp now getMilliseconds
+
+    "
+     JavaVM _System_currentTimeMillis:nil
+    "
+
+    "Modified: / 23-12-1998 / 21:54:50 / cg"
+    "Modified: / 19-07-2012 / 11:44:56 / jv"
+!
+
+_java_lang_System_identityHashCode: nativeContext
+
+    <javanative: 'java/lang/System' name: 'identityHashCode'>
+
+        |obj|
+
+    obj := nativeContext argAt:1.
+    ^ obj identityHash
+
+    "Modified: / 12.11.1998 / 18:52:07 / cg"
+    "Created: / 12.11.1998 / 18:54:00 / cg"
+!
+
+_java_lang_System_initProperties: nativeContext
+
+    <javanative: 'java/lang/System' name: 'initProperties'>
+
+        |props stProps|
+
+    props := nativeContext argAt:1.
+    stProps := self systemProperties.
+
+    "/ recursively invoke myself on the Java HashTable.
+    "/ calling 'put' to stuff in the values ...
+
+    stProps keysAndValuesDo:[:key :value |
+        |keyObj valueObj|
+
+        keyObj := Java as_String:key.
+        valueObj := Java as_String:value.
+
+        props
+            perform:#'put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;'
+            with:keyObj
+            with:valueObj.
+    ].
+    ^ props
+
+    "Created: / 3.1.1998 / 14:25:22 / cg"
+    "Modified: / 4.1.1998 / 14:23:18 / cg"
+!
+
+_java_lang_System_mapLibraryName: aJavaContext
+
+    <javanative: 'java/lang/System' name: 'mapLibraryName'>
+
+
+    | name |
+    name := Java as_ST_String: (aJavaContext argAt: 1).
+
+    OperatingSystem isUNIXlike ifTrue:[
+        ^Java as_String: ('lib' , name , '.so').
+    ].
+
+    OperatingSystem isMSWINDOWSlike ifTrue:[
+        ^Java as_String: ( name , '.dll').
+    ].
+
+    self error:'Unknown/Unsupported platform'
+
+    "Created: / 09-12-2010 / 18:16:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "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'>
+
+
+    "Nothing to do, native method are bound lazily"
+
+    "Created: / 20-10-2010 / 10:56:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_System_setErr0: nativeContext
+
+    <javanative: 'java/lang/System' name: 'setErr0'>
+
+        |stream|
+
+    stream := nativeContext argAt:1.
+
+    self setOpenFile:(self javaConsoleStream ? Stderr) at:2.
+
+    nativeContext receiver instVarNamed:'err' put:stream.
+
+    "Created: / 18.3.1997 / 15:02:05 / cg"
+    "Modified: / 4.1.1998 / 16:21:15 / cg"
+!
+
+_java_lang_System_setIn0: nativeContext
+
+    <javanative: 'java/lang/System' name: 'setIn0'>
+
+        |stream|
+
+    stream := nativeContext argAt:1.
+
+    self setOpenFile:Stdin at:0.
+
+    nativeContext receiver instVarNamed:'in' put:stream.
+
+    "Created: / 4.1.1998 / 16:16:38 / cg"
+    "Modified: / 4.1.1998 / 16:20:44 / cg"
+!
+
+_java_lang_System_setOut0: nativeContext
+
+    <javanative: 'java/lang/System' name: 'setOut0'>
+
+        |stream|
+
+    stream := nativeContext argAt:1.
+
+    self setOpenFile:(self javaConsoleStream ? Stdout) at:1.
+
+    nativeContext receiver instVarNamed:'out' put:stream.
+
+    "Created: / 4.1.1998 / 16:18:26 / cg"
+    "Modified: / 4.1.1998 / 16:20:23 / cg"
+!
+
+_java_lang_Thread_currentThread: nativeContext
+    <javanative: 'java/lang/Thread' name: 'currentThread'>
+    | t  p |
+    p := Processor activeProcess.
+    t := self javaThreadForSTProcess: p.
+    nativeContext sender receiver class name
+        = 'java/util/concurrent/locks/ReentrantLock$NonfairSync'
+            ifTrue: [
+                | owner |
+                owner := (nativeContext sender receiver
+                            perform: #'getExclusiveOwnerThread()Ljava/lang/Thread;').
+                (owner notNil and: [ owner ~= t ]) ifTrue: [ self breakPoint: #mh. ]
+            ].
+    t notNil ifTrue: [ ^ t ].
+    t := self newThread: p name.
+    t instVarNamed: 'tid' put: p id.
+    Java addThread: t for: p.
+    ^ t
+
+    "Modified: / 04-12-2011 / 20:11:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 09-12-2011 / 12:52:39 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+_java_lang_Thread_holdsLock: aJavaContext
+    <javanative: 'java/lang/Thread' name: 'holdsLock'>
+    | obj  mon  thisProcess |
+    obj := aJavaContext argAt: 1.
+    obj isNil ifTrue: [self throwNullPointerException:'null given to _java_lang_Thread_holdsLock'].
+    mon := obj getJavaMonitor.
+    thisProcess := Processor activeProcess.
+    (mon isOwnedBy: thisProcess) ifTrue: [ ^ 1 ] ifFalse: [ ^ 0 ].
+
+    "Created: / 30-04-2011 / 22:06:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 09-12-2011 / 11:13:57 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 27-08-2012 / 11:36:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Thread_interrupt0: nativeContext
+    <javanative: 'java/lang/Thread' name: 'interrupt0()V'>
+    | jThread  stProcess |
+    jThread := nativeContext receiver.
+    stProcess := self stProcessForJavaThread: jThread.
+    self assert: stProcess notNil.
+    stProcess javaInterrupt.
+
+    "Modified: / 02-01-1998 / 21:49:06 / cg"
+    "Created: / 10-04-1998 / 15:21:43 / cg"
+    "Modified: / 30-11-2011 / 13:36:56 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+_java_lang_Thread_isAlive: nativeContext
+
+    <javanative: 'java/lang/Thread' name: 'isAlive'>
+
+        "is it alive ?"
+
+    |jThread stProcess|
+
+    jThread := nativeContext receiver.
+    stProcess := JavaVM stProcessForJavaThread:jThread.
+    stProcess isNil ifTrue:[
+        ThreadTrace == true ifTrue:[
+            ('JAVA: no stProcess for javaThread: ' , jThread displayString) printNL.
+        ].
+        ^ 0 "FALSE"
+    ].
+    stProcess isDead ifTrue:[^ 0 "FALSE"].
+    ^ 1 "TRUE"
+
+    "Created: / 5.1.1998 / 02:03:51 / cg"
+    "Modified: / 6.2.1998 / 02:15:01 / cg"
+!
+
+_java_lang_Thread_isInterrupted: nativeContext
+    <javanative: 'java/lang/Thread' name: 'isInterrupted'>
+    "ask if a thread is interrupted (clear interruptState if arg is true)"
+
+    | jThread  stProcess  clearInterrupt  wasInterrupted |
+    jThread := nativeContext receiver.
+    stProcess := self stProcessForJavaThread: jThread.
+    self assert: stProcess notNil.
+    clearInterrupt := nativeContext argAt: 1.
+    wasInterrupted := stProcess isInterrupted.
+    clearInterrupt ~~ 0 ifTrue: [ stProcess clearInterrupted ].
+    stProcess isDead ifTrue: [ ^ 0 ].
+    wasInterrupted ifTrue: [ ^ 1 ] ifFalse: [ ^ 0 ].
+
+    "Modified: / 02-01-1998 / 21:49:06 / cg"
+    "Created: / 07-01-1998 / 18:50:26 / cg"
+    "Modified: / 05-08-2011 / 22:21:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 30-11-2011 / 12:22:34 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+_java_lang_Thread_registerNatives: aJavaContext
+
+    <javanative: 'java/lang/Thread' name: 'registerNatives'>
+
+
+    "Nothing to do, native method are bound lazily"
+
+    "Created: / 20-10-2010 / 11:12:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Thread_resume0: nativeContext
+
+    <javanative: 'java/lang/Thread' name: 'resume0()V'>
+
+        "yield"
+
+    |jThread stProcess|
+
+    jThread := nativeContext receiver.
+    stProcess := JavaVM stProcessForJavaThread:jThread.
+    stProcess isNil ifTrue:[
+        ThreadTrace == true ifTrue:[
+            ('JAVA: no stProcess for javaThread: ' , jThread displayString) printNL.
+        ].
+        ^ nil "void"
+    ].
+    stProcess resume
+
+    "Created: / 8.1.1998 / 01:06:27 / cg"
+    "Modified: / 6.2.1998 / 02:15:08 / cg"
+!
+
+_java_lang_Thread_setPriority0: nativeContext
+
+    <javanative: 'java/lang/Thread' name: 'setPriority0'>
+
+   |t p prio|
+
+    t := nativeContext receiver.
+    p := JavaVM stProcessForJavaThread:t.
+    prio := nativeContext argAt:1.
+
+    p isNil ifTrue:[
+        ThreadTrace == true ifTrue:[
+            'JAVA [info]: no process yet (in setPriority)' infoPrintCR.
+        ].
+        ^ nil
+    ].
+
+    "Modified: / 01-05-2011 / 13:25:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Thread_sleep: nativeContext
+    <javanative: 'java/lang/Thread' name: 'sleep'>
+    "sleep for some milliseconds "
+
+    | millis |
+    millis := nativeContext argAt: 1.
+    millis < 0 ifTrue: [
+        self throwIllegalArgumentException: ('negative timeout: %1 in Thread.sleep' bindWith: millis)
+    ].
+    Logger
+        log: ('%1 going to sleep for %2'
+                bindWith: Processor activeProcess printString
+                with: millis)
+        severity: #debug
+        facility: #JVM.
+    self sleepForTimeout: millis state: #sleep.
+
+    "Modified: / 08-01-1999 / 16:42:52 / cg"
+    "Modified: / 30-11-2011 / 13:58:36 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+_java_lang_Thread_start0: nativeContext
+
+    <javanative: 'java/lang/Thread' name: 'start0'>
+
+
+    ^self threadStart: nativeContext
+
+    "Modified: / 24-12-1999 / 03:14:33 / cg"
+    "Created: / 22-11-2010 / 17:48:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 14-12-2010 / 21:31:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Thread_stop0: nativeContext
+
+    <javanative: 'java/lang/Thread' name: 'stop0(Ljava/lang/Object;)V'>
+
+        "terminate a thread"
+
+    | jThread  stProcess  death |
+    jThread := nativeContext receiver.
+    stProcess := JavaVM stProcessForJavaThread: jThread.
+    stProcess isNil ifTrue: [
+        ThreadTrace == true ifTrue: [
+            ('JAVA: no stProcess for javaThread: ' , jThread displayString) printNL.
+        ].
+        ^ nil "void"
+    ].
+    stProcess == JavaScreenUpdaterThread ifTrue: [ self halt ].
+    stProcess == JavaEventQueueThread ifTrue: [ self halt ].
+    death := nativeContext argAt: 1.
+    stProcess
+        interruptWith: [
+            JavaVM javaExceptionSignal
+                handle: [
+                    :ex |
+                    Processor activeProcess == JavaScreenUpdaterThread ifTrue: [ self halt ].
+                    Processor activeProcess == JavaEventQueueThread ifTrue: [ self halt ].
+                    Processor activeProcess terminate
+                ]
+                do: [
+                    ThreadTrace == true ifTrue: [
+                        ('JAVA: thread exit: ' , jThread displayString) infoPrintNL.
+                    ].
+
+                    jThread perform: #'exit()V'.
+
+                    self throwException: death.
+                ]
+        ].
+
+    "Created: / 08-01-1998 / 13:11:17 / cg"
+    "Modified: / 24-12-1999 / 02:32:45 / cg"
+    "Modified: / 01-12-2011 / 18:26:51 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+_java_lang_Thread_yield: nativeContext
+
+    <javanative: 'java/lang/Thread' name: 'yield()V'>
+
+        "yield"
+
+    |jThread stProcess|
+
+    Processor yield.
+"/    jThread := nativeContext receiver.
+"/    stProcess := JavaVM stProcessForJavaThread:jThread.
+"/    stProcess isNil ifTrue:[
+"/        ThreadTrace == true ifTrue:[
+"/            ('JAVA: no stProcess for javaThread: ' , jThread displayString) printNL.
+"/        ].
+"/        ^ nil "void"
+"/    ].
+"/    stProcess == Processor activeProcess ifTrue:[
+"/        Processor yield.
+"/    ] ifFalse:[
+"/        self halt.
+"/    ].
+
+    "Created: / 5.1.1998 / 02:03:51 / cg"
+    "Modified: / 23.12.1998 / 19:19:17 / cg"
+!
+
+_java_lang_Throwable_fillInStackTrace: nativeContext
+    <javanative: 'java/lang/Throwable' name: 'fillInStackTrace'>
+    | java_lang_Throwable  exceptionObject  list  con |
+
+    java_lang_Throwable := Java classNamed: 'java/lang/Throwable'.
+    exceptionObject := nativeContext receiver.
+
+    "/
+    "/ debugging only
+    "/
+
+    (java_lang_Throwable notNil and:[(exceptionObject isKindOf: java_lang_Throwable) not]) ifTrue: [
+        self error:'Thrown object is not a java.lang.Throwable'.
+    ].
+    con := thisContext sender.
+
+    "/
+    "/ we are not interrested in all intermediate Exception frames ...
+    "/
+
+    FullExceptionTrace ifFalse: [
+        "/ first, skip any JavaVM contexts
+        [ con receiver == exceptionObject ] whileFalse: [ con := con sender ].
+
+        "/ then, all exception-init contexts
+
+        [ con receiver == exceptionObject ] whileTrue: [ con := con sender ].
+    ].
+    list := OrderedCollection new.
+    [ con notNil ] whileTrue: [
+        (con isJavaContext) ifTrue: [
+            "/ add a copy, in case the context continues with some
+            "/ cleanup ...
+            list add: con shallowCopy
+        ].
+        con := con sender
+    ].
+    exceptionObject instVarNamed: 'backtrace' put: (list asArray).
+    ^ nil.
+
+    "Created: / 04-01-1998 / 14:27:40 / cg"
+    "Modified: / 08-05-1998 / 21:29:53 / cg"
+    "Modified: / 21-10-2011 / 13:41:48 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 28-10-2011 / 22:15:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Throwable_getStackTraceDepth: nativeContext
+
+    <javanative: 'java/lang/Throwable' name: 'getStackTraceDepth'>
+
+
+    ^(nativeContext receiver instVarNamed: #backtrace) size
+
+    "Modified: / 01-05-2011 / 20:25:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Throwable_getStackTraceElement: nativeContext
+
+    <javanative: 'java/lang/Throwable' name: 'getStackTraceElement'>
+
+    | throwable index ctx stackTraceElement |
+    throwable := nativeContext receiver.
+    index :=  nativeContext argAt: 1.
+    ctx := (throwable instVarNamed:#backtrace) at: index + 1.
+
+    stackTraceElement := (self classForName: 'java.lang.StackTraceElement') new.
+
+    stackTraceElement
+        instVarNamed: #declaringClass
+        put: (Java as_String:(ctx method javaClass javaName));
+
+        instVarNamed: #methodName
+        put: (Java as_String:"(ctx method printStringForBrowserWithSelector:ctx method selector inClass: ctx method javaClass) asString"ctx method selector);
+
+        instVarNamed: #lineNumber
+        put: ctx lineNumber.
+
+    ctx method javaClass sourceFile notNil ifTrue:[
+        stackTraceElement
+            instVarNamed: #fileName
+            put: (Java as_String:(ctx method javaClass sourceFile))
+    ].
+    ^ stackTraceElement
+
+    "Modified: / 02-12-2011 / 23:36:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_UNIXProcess_forkAndExec: nativeContext
+
+    <javanative: 'java/lang/UNIXProcess' name: 'forkAndExec'>
+
+    "^ UnimplementedNativeMethodSignal raise"
+!
+
+_java_lang_UNIXProcess_initIDs: nativeContext
+
+    <javanative: 'java/lang/UNIXProcess' name: 'initIDs'>
+
+    "Nothing to do"
+
+    "Modified: / 25-06-2011 / 10:05:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_UNIXProcess_waitForProcessExit: nativeContext
+
+    <javanative: 'java/lang/UNIXProcess' name: 'waitForProcessExit(I)I'>
+
+    "^ UnimplementedNativeMethodSignal raise"
+
+! !
+
+!JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - java.lang.ref'!
+
+_java_lang_ref_Finalizer_invokeFinalizeMethod: nativeContext
+
+    <javanative: 'java/lang/ref/Finalizer' name: 'invokeFinalizeMethod(Ljava/lang/Object;)V'>
+
+    | o |
+
+    o := nativeContext argAt:1.
+
+    Logger log: 'Finalizing ' , o printString  severity: #debug facility: 'JVM' .
+    o perform:#'finalize()V'
+
+    "Modified: / 24-07-2012 / 11:11:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - java.lang.reflect'!
+
+_java_lang_reflect_Array_getLength: nativeContext
+
+    <javanative: 'java/lang/reflect/Array' name: 'getLength(Ljava/lang/Object;)I'>
+
+    ^(nativeContext argAt: 1) size
+
+    "Modified: / 17-08-2011 / 09:02:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_reflect_Array_multiNewArray: nativeContext
+
+    <javanative: 'java/lang/reflect/Array' name: 'multiNewArray(Ljava/lang/Class;[I)Ljava/lang/Object;'>
+
+    |componentClass sizes cls array |
+
+    (nativeContext argAt:1) isNil ifTrue:[
+        self throwNullPointerException.
+        ^nil.
+    ].
+    (nativeContext argAt:2) isNil ifTrue:[
+        self throwNullPointerException.
+        ^nil.
+    ].
+
+    componentClass := self reflection
+                classForJavaClassObject:(nativeContext argAt:1).
+    componentClass == UndefinedObject ifTrue:[
+        self throwIllegalArgumentException:'invalid class: void'.
+        ^nil
+    ].
+    sizes := nativeContext argAt:2.
+    sizes class == SignedIntegerArray ifFalse:[
+        self throwIllegalArgumentException:('sizes arguments not instance of int[] (is: %1)' bindWith: sizes class).
+        ^nil
+    ].
+    sizes size == 0 ifTrue:[
+        self throwIllegalArgumentException:('sizes argument has no elements').
+        ^nil
+    ].
+    array := nil.
+    cls := componentClass.
+    sizes do:[:size|
+        | newArray |
+        size > SmallInteger maxVal ifTrue:[
+            "This is just for Mauve tests"
+            self throwExceptionClassName:'java.lang.OutOfMemoryError'
+                             withMessage:'array size too big'.
+            ^nil.
+        ].
+        size <  0 ifTrue:[
+            self throwExceptionClassName:'java.lang.NegativeArraySizeException'
+                             withMessage:'negative array size not allowed'.
+            ^nil
+        ].
+        cls := cls javaArrayClass.
+        newArray := cls new: size.
+        1 to: size do:[:i|
+            newArray at:i put: array copy.
+        ].
+        array := newArray.
+    ].
+    ^array.
+
+    "Modified: / 22-11-2011 / 10:42:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_reflect_Array_newArray:aJavaContext
+    <javanative: 'java/lang/reflect/Array' name: 'newArray'>
+    |componentClass size|
+
+    (aJavaContext argAt:1) isNil ifTrue:[
+        self throwNullPointerException.
+        ^nil.
+    ].
+    componentClass := self reflection
+                classForJavaClassObject:(aJavaContext argAt:1).
+    componentClass == UndefinedObject ifTrue:[
+        self throwIllegalArgumentException:'invalid class: void'.
+        ^nil
+    ].
+    size := aJavaContext argAt:2.
+    size < 0 ifTrue:[
+        self throwExceptionClassName:'java.lang.NegativeArraySizeException'
+                         withMessage:'negative array size not allowed'.
+        ^nil
+    ].
+    ^ componentClass javaArrayClass new:size
+
+    "Created: / 17-12-2010 / 14:49:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 28-01-2011 / 15:18:50 / Marcel Hlopko <hlopik@gmail.com>"
+    "Modified: / 04-06-2011 / 17:06:41 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 22-11-2011 / 09:13:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_reflect_Array_set: nativeContext
+
+    <javanative: 'java/lang/reflect/Array' name: 'set'>
+
+    | array index value |
+    array :=  nativeContext at:1.
+    index := (nativeContext at:2) + 1.
+    value :=  nativeContext at:3.
+
+    array isJavaArray ifFalse:[
+        self throwIllegalArgumentException:'passed object is not an array'.
+        ^nil.
+    ].
+    index < 1 ifTrue:[
+        self throwIllegalArgumentException:'index is negative'.
+        ^nil.
+    ].
+    index > array size ifTrue:[
+        self throwArrayIndexOutOfBoundsException: index.
+        ^nil.
+    ].
+    value isNil ifTrue:[
+        array at: index put: nil.
+        ^nil
+    ].
+    (self canCast: value class to: array class javaComponentClass) ifFalse:[
+        self throwIllegalArgumentException:'type-incompatible value'.
+        ^nil.
+    ].
+    array at: index put: value.
+
+    "Modified: / 22-11-2011 / 11:06:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_reflect_Proxy_defineClass0: nativeContext
+
+    <javanative: 'java/lang/reflect/Proxy' name: 'defineClass0'>
+
+        "
+    private static native Class defineClass0(ClassLoader loader, String name,
+                                             byte[] b, int off, int len);
+    "
+    | loader name b off len  bs cls |
+    loader := nativeContext argAt: 1.
+    name := nativeContext argAt: 2.
+    b := nativeContext argAt: 3.
+    off := nativeContext argAt: 4.
+    len := nativeContext argAt: 5.
+
+    bs := (off = 0 and: [len = b size])
+            ifTrue:[b readStream]
+            ifFalse:[(b copyFrom: off + 1 to: off + len) readStream].
+
+    cls := JavaClassReader readStream: bs.
+    cls classLoader: loader.
+    self classRegistry registerClass: cls.
+
+    ^self reflection javaClassObjectForClass: cls.
+
+    "Created: / 06-02-2011 / 16:55:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - java.net'!
+
+_java_net_DatagramPacket_init: nativeContext
+
+    <javanative: 'java/net/DatagramPacket' name: 'init'>
+
+    "Nothing to do"
+
+    "Modified: / 13-09-2011 / 22:33:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_net_Inet4AddressImpl_getHostByAddr: nativeContext
+
+    <javanative: 'java/net/Inet4AddressImpl' name: 'getHostByAddr([B)Ljava/lang/String;'>
+
+    ^ JavaVM unimplementedNativeMethodSignal raise
+!
+
+_java_net_Inet4AddressImpl_getLocalHostName: nativeContext
+
+    <javanative: 'java/net/Inet4AddressImpl' name: 'getLocalHostName()Ljava/lang/String;'>
+
+    ^Java as_String: OperatingSystem getHostName
+
+    "Modified: / 13-09-2011 / 22:36:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_net_Inet4AddressImpl_lookupAllHostAddr: nativeContext
+
+    <javanative: 'java/net/Inet4AddressImpl' name: 'lookupAllHostAddr(Ljava/lang/String;)[Ljava/net/InetAddress;'>
+
+    | hostname sockaddr inet4Address |
+    hostname := Java as_ST_String: (nativeContext argAt:1).
+    [
+        sockaddr := IPSocketAddress hostName: hostname.
+    ] on: HostNameLookupError do: [:ex|
+        self throwExceptionClassName: 'java.net.UnknownHostException' withMessage: (ex description , '(' , hostname , ')').
+        ^nil.
+    ].
+    "Bad, here we have an access to just one inet address,
+     that's fine for now, however"
+
+    inet4Address := (self classForName:'java.net.Inet4Address') newCleared.
+    inet4Address
+        instVarNamed: #family put: 1; "/IPv4
+        instVarNamed: #address put: (sockaddr address doubleWordAt: 1 MSB: true);
+        instVarNamed: #hostName put: (nativeContext argAt:1);
+        instVarNamed: #canonicalHostName put: (nativeContext argAt:1).
+
+    ^(self classForName:'java.net.InetAddress') javaArrayClass with: inet4Address.
+
+    "Modified: / 08-11-2011 / 10:10:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_net_Inet4Address_init: nativeContext
+
+    <javanative: 'java/net/Inet4Address' name: 'init()V'>
+
+    "Nothing to do"
+
+    "Modified: / 13-09-2011 / 22:31:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_net_Inet6Address_init: nativeContext
+
+    <javanative: 'java/net/Inet6Address' name: 'init()V'>
+
+    "Nothing to do"
+
+    "Modified: / 13-09-2011 / 22:32:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_net_InetAddressImplFactory_isIPv6Supported: nativeContext
+
+    <javanative: 'java/net/InetAddressImplFactory' name: 'isIPv6Supported'>
+
+    ^ 0 "IPv6 is not supported!!"
+
+    "Modified: / 13-09-2011 / 19:43:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_net_InetAddress_init: nativeContext
+
+    <javanative: 'java/net/InetAddress' name: 'init'>
+
+    "Nothing to do"
+
+    "Created: / 27-01-1998 / 18:16:40 / cg"
+    "Modified (comment): / 13-09-2011 / 22:32:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_net_NetworkInterface_getAll: nativeContext
+
+    <javanative: 'java/net/NetworkInterface' name: 'getAll()[Ljava/net/NetworkInterface;'>
+
+    ^ JavaVM unimplementedNativeMethodSignal raise
+!
+
+_java_net_NetworkInterface_getByName0: nativeContext
+
+    <javanative: 'java/net/NetworkInterface' name: 'getByName0(Ljava/lang/String;)Ljava/net/NetworkInterface;'>
+
+    ^ JavaVM unimplementedNativeMethodSignal raise
+!
+
+_java_net_NetworkInterface_init: nativeContext
+
+    <javanative: 'java/net/NetworkInterface' name: 'init'>
+
+    "Nothing to do"
+
+    "Modified: / 13-09-2011 / 22:33:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_net_PlainDatagramSocketImpl_bind0: nativeContext
+
+    <javanative: 'java/net/PlainDatagramSocketImpl' name: 'bind0(ILjava/net/InetAddress;)V'>
+
+    | port addr sock fd |
+
+    port := nativeContext argAt: 1.
+    addr := nativeContext argAt: 2.
+    addr isNil ifTrue:[
+        self throwSocketException: 'Passed InetAddress object is null'.
+        ^nil.
+    ].
+    fd := nativeContext receiver instVarNamed: #fd.
+    fd isNil ifTrue:[
+        self throwSocketException: 'Socket closed'.
+        ^nil.
+    ].
+    sock := self validateFile: nativeContext receiver.
+
+    addr := addr perform: #'getAddress()[B'.
+    addr = #[0 0 0 0] ifTrue:[
+        addr := nil
+    ] ifFalse:[
+        self throwSocketException: 'Only all-interface bind is supported by underlaing socket implementation, sorry'.
+        ^nil
+    ].
+    [
+        sock bindTo: port address: addr reuseAddress: true.
+        nativeContext receiver instVarNamed: #localPort put: sock port.
+    ] on: Error do:[:ex|
+        self throwSocketException: 'bind0() failed: ', ex description
+    ]
+
+    "Modified: / 07-11-2011 / 21:45:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_net_PlainDatagramSocketImpl_datagramSocketClose: nativeContext
+
+    <javanative: 'java/net/PlainDatagramSocketImpl' name: 'datagramSocketClose()V'>
+
+        |jsock sock|
+
+    jsock := nativeContext receiver.
+
+    sock := self validateFile:jsock.
+    sock notNil ifTrue:[
+        FileIOTrace ifTrue:[
+            'JAVA: datagram close socket' infoPrintCR
+        ].
+        sock close.
+    ].
+
+    "Modified: / 21.8.1997 / 17:09:40 / cg"
+    "Created: / 25.1.1998 / 20:04:24 / cg"
+!
+
+_java_net_PlainDatagramSocketImpl_datagramSocketCreate: nativeContext
+
+    <javanative: 'java/net/PlainDatagramSocketImpl' name: 'datagramSocketCreate()V'>
+
+        |jsock fd sock fileNo|
+
+    jsock := nativeContext receiver.
+
+    fd := jsock instVarNamed:'fd'.
+    (fd instVarNamed:'fd') ~~ -1 ifTrue:[
+        self halt:'file already open'.
+        self internalError:'file already open'.
+        self throwIOExceptionWithMessage:'file already open in socketCreate'.
+        ^ self.
+    ].
+
+    FileOpenTrace ifTrue:[
+        ('JAVA: create datagram socket') infoPrintCR.
+    ].
+
+    sock := self commonOpenStreamUsing:[Socket newUDP].
+    sock isNil ifTrue:[
+        self throwIOExceptionWithMessage:'socketCreate failed'.
+    ].
+
+    fileNo := self addOpenFile:sock.
+    fd instVarNamed:'fd' put:fileNo.
+    "Kludge for finalization..."
+    jsock finalizationLobby registerChange: jsock
+
+    "Created: / 25-01-1998 / 19:59:25 / cg"
+    "Modified: / 30-12-1998 / 20:10:38 / cg"
+    "Modified: / 23-07-2012 / 19:37:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_net_PlainDatagramSocketImpl_init: nativeContext
+
+    <javanative: 'java/net/PlainDatagramSocketImpl' name: 'init'>
+
+    "Nothing to do"
+
+    "Modified: / 13-09-2011 / 22:36:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_net_PlainDatagramSocketImpl_receive0: nativeContext
+
+    <javanative: 'java/net/PlainDatagramSocketImpl' name: 'receive0(Ljava/net/DatagramPacket;)V'>
+
+    ^ JavaVM unimplementedNativeMethodSignal raise
+!
+
+_java_net_PlainDatagramSocketImpl_send: nativeContext
+
+    <javanative: 'java/net/PlainDatagramSocketImpl' name: 'send(Ljava/net/DatagramPacket;)V'>
+
+        |jsock jdatagramPacket sock ok|
+
+    jsock := nativeContext receiver.
+    jdatagramPacket := nativeContext argAt:1.
+
+    sock := self validateFile:jsock.
+    sock notNil ifTrue:[
+        FileIOTrace ifTrue:[
+            ('JAVA: socket send') infoPrintCR
+        ].
+        ^ -1.
+    ].
+    ^ -1
+
+    "Created: / 4.2.1998 / 15:06:20 / cg"
+    "Modified: / 30.12.1998 / 20:10:16 / cg"
+!
+
+_java_net_PlainDatagramSocketImpl_socketSetOption: nativeContext
+
+    <javanative: 'java/net/PlainDatagramSocketImpl' name: 'socketSetOption(ILjava/lang/Object;)V'>
+
+        "/ native void socketSetOption (int arg1, java.lang.Object arg2)
+
+    |jsock opt optVal sock ok err jSocketOptions|
+
+    jsock := nativeContext receiver.
+    opt := nativeContext argAt:1.
+    optVal := nativeContext argAt:2.
+
+    sock := self validateFile:jsock.
+    sock notNil ifTrue:[
+        FileIOTrace ifTrue:[
+            ('JAVA: socket setOption ' , opt printString) infoPrintCR
+        ].
+
+        jSocketOptions := Java at:'java.net.SocketOptions'.
+        (opt == (jSocketOptions instVarNamed:'TCP_NODELAY')) ifTrue:[
+        ] ifFalse:[
+            (opt == (jSocketOptions instVarNamed:'SO_BINDADDR')) ifTrue:[
+            ] ifFalse:[
+                (opt == (jSocketOptions instVarNamed:'SO_REUSEADDR')) ifTrue:[
+                ] ifFalse:[
+                    (opt == (jSocketOptions instVarNamed:'IP_MULTICAST_IF')) ifTrue:[
+                    ] ifFalse:[
+                        (opt == (jSocketOptions instVarNamed:'SO_LINGER')) ifTrue:[
+                        ] ifFalse:[
+                            (opt == (jSocketOptions instVarNamed:'SO_TIMEOUT')) ifTrue:[
+                            ] ifFalse:[
+                                self throwIOExceptionWithMessage:'bad arg to setOption'.
+                            ]
+                        ]
+                    ]
+                ]
+            ]
+        ].
+        self throwIOExceptionWithMessage:'unimplemented: setOption'.
+self halt.
+        ^ nil.  "/ void
+    ].
+
+    "Created: / 4.2.1998 / 15:06:20 / cg"
+    "Modified: / 30.12.1998 / 20:10:16 / cg"
+!
+
+_java_net_PlainSocketImpl_initProto: nativeContext
+
+    <javanative: 'java/net/PlainSocketImpl' name: 'initProto'>
+
+    "Nothing to do"
+
+    "Created: / 12-01-1998 / 12:56:52 / cg"
+    "Modified (comment): / 13-09-2011 / 22:36:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_net_PlainSocketImpl_socketAccept: nativeContext
+
+    <javanative: 'java/net/PlainSocketImpl' name: 'socketAccept(Ljava/net/SocketImpl;)V'>
+
+    |jsock fd newJSock sock newSock fileNo|
+
+    jsock := nativeContext receiver.
+
+    sock := self validateFile:jsock.
+    sock isNil ifTrue:[
+        self throwIOExceptionWithMessage:'nil socket in accept'.
+        ^ self.
+    ].
+
+    newJSock := nativeContext argAt:1.
+    fd := newJSock instVarNamed:'fd'.
+    (fd instVarNamed:'fd') ~~ -1 ifTrue:[
+        self halt:'file already open'.
+        self internalError:'file already open'.
+        self throwIOExceptionWithMessage:'socket already open in socketAccept'.
+        ^ self.
+    ].
+    FileIOTrace ifTrue:[
+        'JAVA: socket accept' infoPrintCR
+    ].
+    [
+        newSock := self commonOpenStreamUsing:[sock accept].
+    ] on: Error do:[:ex|
+        self throwSocketException:'accept failed: ' , ex description.
+        ^nil.
+    ].
+    newSock isNil ifTrue:[
+        self throwSocketException:'accept failed'.
+        ^nil.
+    ].
+    fileNo := self addOpenFile:newSock.
+    fd instVarNamed:'fd' put:fileNo.
+    newJSock instVarNamed:'localport' put: newSock port.
+    newJSock instVarNamed:'port' put: newSock getPeer port.
+
+    "Kludge for finalization..."
+    newJSock finalizationLobby registerChange: newJSock.
+
+    "Created: / 04-02-1998 / 15:26:49 / cg"
+    "Modified: / 30-12-1998 / 20:10:01 / cg"
+    "Modified: / 23-07-2012 / 19:37:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_net_PlainSocketImpl_socketAvailable: nativeContext
+
+    <javanative: 'java/net/PlainSocketImpl' name: 'socketAvailable()I'>
+
+        |jSock sock n|
+
+    jSock := nativeContext receiver.
+
+    sock := self validateFile:jSock.
+    sock isNil ifTrue:[
+        self throwIOExceptionWithMessage:'socketAvailable on closed socket'.
+        ^ self.
+    ].
+
+    n := sock numAvailable.
+    ^ n
+
+    "Created: / 4.2.1998 / 16:58:49 / cg"
+    "Modified: / 30.12.1998 / 20:10:08 / cg"
+!
+
+_java_net_PlainSocketImpl_socketBind: nativeContext
+
+    <javanative: 'java/net/PlainSocketImpl' name: 'socketBind(Ljava/net/InetAddress;I)V'>
+
+    |jsock jaddr port sock hostName ok err|
+
+    jsock := nativeContext receiver.
+    jaddr := nativeContext argAt:1.
+    port := nativeContext argAt:2.
+
+    hostName := jaddr instVarNamed:'hostName'.
+    hostName isNil ifTrue:[
+        self halt.
+    ] ifFalse:[
+        hostName := Java as_ST_String:hostName
+    ].
+
+    sock := self validateFile:jsock.
+    sock notNil ifTrue:[
+        FileIOTrace ifTrue:[
+            ('JAVA: socket bind to ' , hostName printString, ' port ' , port printString) infoPrintCR
+        ].
+
+        [
+            ok := sock bindTo:port address:nil "hostName".
+        ] on: Error do: [:ex|
+            self
+                throwExceptionClassName: 'java.net.BindException'
+                withMessage:'bind failed: ' , ex description.
+        ].
+        ok ifFalse:[
+            err := OperatingSystem lastErrorString.
+            self
+                throwExceptionClassName: 'java.net.BindException'
+                withMessage:'bind failed: ' , err.
+        ].
+       jsock instVarNamed: #localport put: sock port.
+       jsock instVarNamed: #address put: jaddr.
+    ].
+
+    "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>"
+!
+
+_java_net_PlainSocketImpl_socketClose0: nativeContext
+
+    <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>"
+!
+
+_java_net_PlainSocketImpl_socketConnect: nativeContext
+
+    <javanative: 'java/net/PlainSocketImpl' name: 'socketConnect(Ljava/net/InetAddress;II)V'>
+
+    |jsock jaddr port sock addr hostName ok|
+
+    jsock := nativeContext receiver.
+    jaddr := nativeContext argAt:1.
+    port := nativeContext argAt:2.
+
+    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:[
+                    self 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:[
+                self throwExceptionClassName:'java.net.ConnectException' withMessage:'connect failed'.
+            ].
+            jsock instVarNamed: #localport put: sock port.
+            jsock instVarNamed: #address put: jaddr.
+        ] on: Error do:[:ex|
+            self 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>"
+!
+
+_java_net_PlainSocketImpl_socketCreate: nativeContext
+
+    <javanative: 'java/net/PlainSocketImpl' name: 'socketCreate(Z)V'>
+
+    |jsock isStream fd sock fileNo|
+
+    jsock := nativeContext receiver.
+    isStream := (nativeContext argAt:1) == 1.
+
+    fd := jsock instVarNamed:'fd'.
+    fd isNil ifTrue:[
+        self throwSocketException: 'null fd object'.
+    ].
+    (fd instVarNamed:'fd') ~~ -1 ifTrue:[
+        self halt:'file already open'.
+        self internalError:'file already open'.
+        self throwSocketException:'socket already open in socketCreate'.
+        ^ self.
+    ].
+
+    FileOpenTrace ifTrue:[
+        ('JAVA: create socket') infoPrintCR.
+    ].
+
+    isStream ifTrue:[
+        sock := self commonOpenStreamUsing:[JavaSocket newTCP].
+    ] ifFalse:[
+        sock := self commonOpenStreamUsing:[JavaSocket newUDP].
+    ].
+    sock isNil ifTrue:[
+        self throwIOExceptionWithMessage:'socketCreate failed'.
+    ].
+
+    (jsock instVarNamed: #serverSocket) notNil ifTrue:[
+        "/If this is a server socket then enable SO_REUSEADDR
+        [
+            Object primitiveFailureSignal
+        ] on: Object primitiveFailureSignal do:[:ex|
+            self throwIOExceptionWithMessage:'cannot set SO_REUSEADDR: ' , ex description.
+            ^nil.
+        ]
+    ].
+
+
+
+    fileNo := self addOpenFile:sock.
+    fd instVarNamed:'fd' put:fileNo.
+    "Kludge for finalization..."
+    jsock finalizationLobby registerChange: jsock
+
+    "Created: / 25-01-1998 / 19:59:25 / cg"
+    "Modified: / 30-12-1998 / 20:10:38 / cg"
+    "Modified: / 23-07-2012 / 19:38:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_net_PlainSocketImpl_socketGetOption: nativeContext
+
+    <javanative: 'java/net/PlainSocketImpl' name: 'socketGetOption(ILjava/lang/Object;)I'>
+
+    | opt arg sock ret |
+    opt := nativeContext argAt: 1.
+    arg := nativeContext argAt: 2.
+
+    sock := self validateFile: nativeContext receiver.
+
+"/  TCP_NODELAY = 1;
+    opt = 1 ifTrue:[
+        ret := sock getSocketOption: #TCP_NODELAY.
+        ^ret ifTrue:[1] ifFalse:[-1].
+    ].
+"/  SO_BINDADDR = 15;
+    opt = 15 ifTrue:[
+        self breakPoint: #jv.
+        ^-1 "/Unsupported
+    ].
+
+"/  SO_REUSEADDR = 4;
+    opt = 4 ifTrue:[
+        ret := sock getSocketOption: #SO_REUSEADDR.
+        ^ret ifTrue:[1] ifFalse:[-1].
+    ].
+"/  IP_TOS = 3;
+    opt = 3 ifTrue:[
+        self breakPoint: #jv.
+        ^-1 "/Unsupported
+    ].
+"/  SO_LINGER = 128;
+    opt = 128 ifTrue:[
+        ret := sock getSocketOption:#SO_LINGER.
+        ^ret
+    ].
+"/  SO_TIMEOUT = 4102;
+    opt = 4102 ifTrue:[
+        self breakPoint: #jv.
+        ^-1 "/Unsupported                   .
+    ].
+"/  SO_SNDBUF = 4097;
+    opt = 4097 ifTrue:[
+        ret := sock getSocketOption: #SO_SNDBUF.
+        ^ret
+    ].
+
+"/  SO_RCVBUF = 4098;
+    opt = 4098 ifTrue:[
+        ret := sock getSocketOption: #SO_RCVBUF.
+        ^ret
+    ].
+
+"/  SO_KEEPALIVE = 8;
+    opt = 8 ifTrue:[
+        ret := sock getSocketOption: #SO_KEEPALIVE.
+        ^ret ifTrue:[1] ifFalse:[-1].
+    ].
+
+"/  SO_OOBINLINE = 4099;
+    opt = 4099 ifTrue:[
+        ret := sock getSocketOption: #SO_OOBINLINE.
+        ^ret ifTrue:[1] ifFalse:[-1].
+    ]
+
+    "Modified: / 13-11-2011 / 23:06:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_net_PlainSocketImpl_socketListen: nativeContext
+
+    <javanative: 'java/net/PlainSocketImpl' name: 'socketListen(I)V'>
+
+        |jSock time sock ok|
+
+    jSock := nativeContext receiver.
+    time := nativeContext argAt:1.
+
+    sock := self validateFile:jSock.
+    sock notNil ifTrue:[
+        FileIOTrace ifTrue:[
+            ('JAVA: socket listen with timeout ' , time printString) infoPrintCR.
+        ].
+        ok := sock listenFor:5.
+        ok ifFalse:[
+            self throwIOExceptionWithMessage:'listen failed'.
+            ^ self.
+        ].
+        time ~~ 0 ifTrue:[
+            sock readWaitWithTimeoutMs:time
+        ]
+    ].
+
+    "Created: / 04-02-1998 / 15:17:48 / cg"
+    "Modified: / 30-12-1998 / 20:10:46 / cg"
+    "Modified: / 17-08-2012 / 15:27:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_net_PlainSocketImpl_socketSetOption: nativeContext
+
+    <javanative: 'java/net/PlainSocketImpl' name: 'socketSetOption(IZLjava/lang/Object;)V'>
+
+    | opt on val sock o arg1 arg2 |
+    opt := nativeContext argAt: 1.
+    on  := nativeContext argAt: 2.
+    val := nativeContext argAt: 3.
+
+    sock := self validateFile: nativeContext receiver.
+
+"/  TCP_NODELAY = 1;
+    opt = 1 ifTrue:[
+        o := #TCP_NODELAY.
+        arg1 := (on == 1)
+    ].
+"/  SO_BINDADDR = 15;
+    opt = 15 ifTrue:[
+        ^self "/Unsupported
+    ].
+
+"/  SO_REUSEADDR = 4;
+    opt = 4 ifTrue:[
+        o := #SO_REUSEADDR.
+        arg1 := (on == 1)
+    ].
+"/  IP_TOS = 3;
+    opt = 3 ifTrue:[
+        ^self "/Unssuported
+    ].
+"/  SO_LINGER = 128;
+    opt = 128 ifTrue:[
+        o := #SO_LINGER.
+        arg1 := (on == 1).
+        arg2 := val instVarNamed: #value.
+    ].
+"/  SO_TIMEOUT = 4102;
+    opt = 4102 ifTrue:[
+        ^self "/Unssuported
+                   .
+    ].
+"/  SO_SNDBUF = 4097;
+    opt = 4097 ifTrue:[
+        o := #SO_SNDBUF.
+        arg1 := val instVarNamed: #value.
+    ].
+
+"/  SO_RCVBUF = 4098;
+    opt = 4098 ifTrue:[
+        o := #SO_RCVBUF.
+        arg1 := val instVarNamed: #value.
+    ].
+
+"/  SO_KEEPALIVE = 8;
+    opt = 8 ifTrue:[
+        o := #SO_KEEPALIVE.
+        arg1 := (on == 1)
+    ].
+
+"/  SO_OOBINLINE = 4099;
+    opt = 4099 ifTrue:[
+        o := #SO_OOBINLINE.
+        arg1 := (on == 1)
+    ].
+
+    [
+        sock setSocketOption: o argument: arg1 argument: arg2.
+    ] on: Error do:[:ex|
+        self throwSocketException: 'Error setting socket option: ', ex description.
+    ].
+
+    "Modified: / 13-11-2011 / 23:05:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_net_SocketInputStream_init: nativeContext
+
+    <javanative: 'java/net/SocketInputStream' name: 'init()V'>
+
+    "Nothing to do"
+
+    "Modified: / 09-11-2011 / 22:27:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_net_SocketInputStream_socketRead0: nativeContext
+
+    <javanative: 'java/net/SocketInputStream' name: 'socketRead0(Ljava/io/FileDescriptor;[BIII)I'>
+
+    | fdObj data off len timeout sock nread |
+    fdObj   := nativeContext argAt:1.
+    data    := nativeContext argAt:2.
+    off     := nativeContext argAt:3.
+    len     := nativeContext argAt:4.
+    timeout := nativeContext argAt:5.
+
+    fdObj isNil ifTrue:[
+        self throwSocketException: 'Socket closed (null fdObj passed to socketRead0)'.
+        ^ -1.
+    ].
+
+    sock := self validateFile: fdObj.
+
+    timeout ~~ 0 ifTrue:[
+        [
+            (sock readWaitWithTimeout: timeout) ifTrue:[
+                self throwExceptionClassName:'java.net.SocketTimeoutException' withMessage: 'Read timed out'.
+                ^ -1.
+            ].
+        ] on: Error do:[:ex|
+            self throwSocketException: 'Error when reading: ', ex description.
+        ]
+    ].
+
+    [
+        nread := sock nextAvailableBytes: len into: data startingAt: off + 1
+    ] on: Error do:[:ex|
+        self throwSocketException: 'Error when reading: ', ex description.
+    ].
+
+    ^nread
+
+    "Modified: / 04-12-2011 / 20:24:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_net_SocketOutputStream_init: nativeContext
+
+    <javanative: 'java/net/SocketOutputStream' name: 'init()V'>
+
+    "Nothing to do"
+
+    "Modified: / 09-11-2011 / 23:44:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_net_SocketOutputStream_socketWrite0: nativeContext
+
+    <javanative: 'java/net/SocketOutputStream' name: 'socketWrite0(Ljava/io/FileDescriptor;[BII)V'>
+
+    | fdObj data off len  sock |
+    fdObj   := nativeContext argAt:1.
+    data    := nativeContext argAt:2.
+    off     := nativeContext argAt:3.
+    len     := nativeContext argAt:4.
+
+
+    fdObj isNil ifTrue:[
+        self throwSocketException: 'Socket closed (null fdObj passed to socketRead0)'.
+        ^ -1.
+    ].
+
+    sock := self validateFile: fdObj.
+
+    [
+        sock nextPutBytes: len from: data startingAt: off + 1.
+    ] on: Error do:[:ex|
+        self throwIOExceptionWithMessage: 'Error when writing: ', ex description.
+    ].
+
+    "Modified: / 13-11-2011 / 23:53:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - java.nio'!
+
+_java_nio_Bits_copyFromByteArray: nativeContext
+    "
+    static native void copyFromByteArray(Object src, long srcPos, long dstAddr,
+                                         long length);
+    "
+
+
+    <javanative: 'java/nio/Bits' name: 'copyFromByteArray(Ljava/lang/Object;JJJ)V'>
+
+    | src srcPos dstAddr length |
+    src := nativeContext argAt: 1.
+    srcPos := nativeContext argAt: 2.
+    dstAddr := nativeContext argAt: 4.
+    length := nativeContext argAt: 6.
+    SimulatedNativeMemory  bcopy: dstAddr length: length from: src offset: srcPos.
+
+    "Modified: / 11-07-2012 / 10:37:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_nio_Bits_copyToByteArray: nativeContext
+    "
+    static native void copyToByteArray(long srcAddr, Object dst, long dstPos,
+                                       long length);
+    "
+
+    <javanative: 'java/nio/Bits' name: 'copyToByteArray(JLjava/lang/Object;JJ)V'>
+
+    | srcAddr dst dstPos length |
+
+    srcAddr := nativeContext argAt: 1.
+    dst := nativeContext argAt: 3.
+    dstPos := nativeContext argAt: 4.
+    length := nativeContext argAt: 6.
+    SimulatedNativeMemory bcopy: srcAddr length: length into: dst offset: dstPos.
+
+    "Modified: / 11-07-2012 / 10:34:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - java.security'!
+
+_java_security_AccessController_doPrivileged: aJavaContext
+    <javanative: 'java/security/AccessController' name: 'doPrivileged'>
+    "we don't care about permissions, we will just allow this. Now it's guaranteed that called code will not perform access permission checks"
+
+    | retval |
+    JavaVM privilegedAccessQuery answer: true
+        do: [
+            retval := (aJavaContext argAt: 1) perform: #'run()Ljava/lang/Object;'.
+        ].
+    ^ retval
+
+    "Created: / 20-10-2010 / 12:31:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 09-10-2011 / 23:56:31 / Marcel Hlopko <hlopik@gmail.com>"
+    "Modified: / 18-10-2011 / 23:28:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 10-09-2012 / 23:22:59 / m"
+!
+
+_java_security_AccessController_getStackAccessControlContext: nativeContext
+    <javanative: 'java/security/AccessController' name: 'getStackAccessControlContext'>
+    "/ introduced with jdk1.2
+    "/ supposed to do more here ...
+
+    ^nil.
+
+    "Created: / 27-01-1998 / 18:22:15 / cg"
+    "Modified: / 09-10-2011 / 23:40:46 / Marcel Hlopko <hlopik@gmail.com>"
+! !
+
+!JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - java.sql'!
+
+_java_sql_DriverManager_getCallerClassLoader: nativeContext
+
+    <javanative: 'java/sql/DriverManager' name: 'getCallerClassLoader()Ljava/lang/ClassLoader;'>
+
+    ^nativeContext
+        sender sender
+        receiver class theNonMetaclass
+        classLoader
+
+    "Modified: / 05-12-2011 / 11:34:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - java.text'!
+
+_java_text_Bidi_nativeBidiChars: nativeContext
+
+    <javanative: 'java/text/Bidi' name: 'nativeBidiChars(Ljava/text/Bidi;[CI[BIII)V'>
+
+    ^ JavaVM unimplementedNativeMethodSignal raise
+! !
+
+!JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - java.util'!
+
+_java_util_ResourceBundle_getClassContext: nativeContext
+
+    <javanative: 'java/util/ResourceBundle' name: 'getClassContext'>
+
+    "returns an array filled with the contextChain receivers classes.
+     What an ugly, messy interface."
+
+    |chain con cls jClass|
+
+    chain := OrderedCollection new.
+    con := thisContext sender.
+    [
+        con notNil
+            and:[con receiver isMethod not or:[con receiver isJavaMethod not]]
+    ] whileTrue:[con := con sender.].
+    con := con sender sender sender.
+    [con notNil] whileTrue:[
+        (true) "con isJavaContext" ifTrue:[
+            cls := con receiver class.
+            cls isMeta ifTrue:[
+                "/ t'was a static method
+                cls := cls soleInstance
+            ].
+            cls isJavaClass ifTrue:[
+                jClass := self reflection javaClassObjectForClass:cls.
+                chain add:jClass.
+            ]
+        ].
+        con := con sender.
+    ].
+    ^(self classForName:'java.lang.Class') javaArrayClass withAll: chain
+
+    "Created: / 05-01-1998 / 02:47:00 / cg"
+    "Modified: / 24-12-1998 / 00:34:57 / cg"
+    "Modified: / 28-01-2011 / 15:31:28 / Marcel Hlopko <hlopik@gmail.com>"
+    "Modified: / 09-01-2013 / 18:11:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_util_TimeZone_getSystemGMTOffsetID: nativeContext
+
+    <javanative: 'java/util/TimeZone' name: 'getSystemGMTOffsetID()Ljava/lang/String;'>
+
+    ^ Java as_String: 'GMT'
+
+    "Modified: / 09-01-2013 / 16:18:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_util_TimeZone_getSystemTimeZoneID: nativeContext
+
+    <javanative: 'java/util/TimeZone' name: 'getSystemTimeZoneID'>
+
+    "JV@2011-06-25: TODO: finish, returning nil here means GMT"
+
+    ^ nil
+
+    "Modified: / 25-06-2011 / 08:26:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - java.util.concurrent.atomic'!
+
+_java_util_concurrent_atomic_AtomicLong_VMSupportsCS8: nativeContext
+
+    <javanative: 'java/util/concurrent/atomic/AtomicLong' name: 'VMSupportsCS8'>
+
+    "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>"
+! !
+
+!JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - java.util.jar'!
+
+_java_util_jar_JarFile_getMetaInfEntryNames: nativeContext
+
+    <javanative: 'java/util/jar/JarFile' name: 'getMetaInfEntryNames'>
+    "
+    private native String[] getMetaInfEntryNames();
+    "
+    | zipArchive entries jentries |
+
+    zipArchive := ZipCache at: (nativeContext receiver instVarNamed: #jzfile).
+    entries := (zipArchive entries select:[:entry|entry size > 9 and:[entry startsWith: 'META-INF/']]) asArray.
+    jentries := Java java_lang_String javaArrayClass new: entries size.
+    1 to: entries size do:[:i|
+        jentries at: i put: (Java as_String: (entries at: i))
+    ].
+    ^jentries
+
+    "Modified: / 10-12-2012 / 05:42:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - java.util.zip'!
+
+_java_util_zip_Adler32_updateBytes: nativeContext
+
+    <javanative: 'java/util/zip/Adler32' name: 'updateBytes'>
+
+    ^ JavaVM unimplementedNativeMethodSignal raise
+!
+
+_java_util_zip_CRC32_update: nativeContext
+
+    <javanative: 'java/util/zip/CRC32' name: 'update(II)I'>
+
+    ^ JavaVM unimplementedNativeMethodSignal raise
+!
+
+_java_util_zip_CRC32_updateBytes: nativeContext
+
+    <javanative: 'java/util/zip/CRC32' name: 'updateBytes(I[BII)I'>
+
+    | crc b off len |
+    crc := nativeContext argAt: 1.
+    b   := nativeContext argAt: 2.
+    off := nativeContext argAt: 3.
+    len := nativeContext argAt: 4.
+
+    ^ZipStream crc32BytesIn:b from:off + 1  to: off + len crc:crc
+
+    "Modified: / 05-12-2011 / 00:41:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_util_zip_Deflater_deflateBytes: nativeContext
+
+    <javanative: 'java/util/zip/Deflater' name: 'deflateBytes(J[BII)I'>
+
+    "
+    private native int deflateBytes(long addr, byte[] b, int off, int len);
+    "
+
+    | addr b off len deflater ret |
+    addr := nativeContext argAt: 1."long takes 2 slots"
+    b := nativeContext argAt: 3.
+    off := nativeContext argAt: 4.
+    len := nativeContext argAt: 5.
+
+    deflater := ZipInflaters at: addr.
+
+    ret := deflater deflate: b offset: off length: len flush: 0 deflater: nativeContext receiver.
+
+    ^ret.
+
+    "Modified: / 25-10-2012 / 20:19:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_util_zip_Deflater_end: nativeContext
+
+    <javanative: 'java/util/zip/Deflater' name: 'end(J)V'>
+
+    | addr deflater |
+    addr := nativeContext argAt: 1.
+    deflater := ZipInflaters at: addr.
+    ZipInflaters at: addr put: nil.
+    deflater end.
+
+    "Modified: / 25-10-2012 / 20:24:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_util_zip_Deflater_getBytesRead: nativeContext
+
+    <javanative: 'java/util/zip/Deflater' name: 'getBytesRead(J)J'>
+
+    | addr deflater |
+    addr := nativeContext argAt: 1.
+    deflater := ZipInflaters at: addr.
+    ^deflater bytesRead.
+
+    "Modified: / 25-10-2012 / 20:19:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_util_zip_Deflater_getBytesWritten: nativeContext
+
+    <javanative: 'java/util/zip/Deflater' name: 'getBytesWritten(J)J'>
+
+    | addr deflater |
+    addr := nativeContext argAt: 1.
+    deflater := ZipInflaters at: addr.
+    ^deflater bytesWritten.
+
+    "Modified: / 25-10-2012 / 20:19:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_util_zip_Deflater_init: nativeContext
+
+    <javanative: 'java/util/zip/Deflater' name: 'init(IIZ)J'>
+
+    | level strategy nowrap deflater |
+    level := nativeContext argAt: 1.
+    strategy := nativeContext argAt: 2.
+    nowrap := nativeContext argAt:3.
+    deflater := JavaZipSupport deflaterFor: self.
+    deflater init: strategy level: level nowrap: nowrap.
+    1 to: ZipInflaters size do:[:i|
+        (ZipInflaters at: i) isNil ifTrue:[
+            ZipInflaters at: i put: deflater.
+            ^i
+        ].
+    ].
+    ZipInflaters add: deflater.
+    ^ZipInflaters size.
+    "/^deflater
+
+    "Modified: / 25-10-2012 / 20:25:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_util_zip_Deflater_initIDs: nativeContext
+    <javanative: 'java/util/zip/Deflater' name: 'initIDs'>
+
+    "Nothing to do here"
+
+    "Modified: / 08-12-2011 / 21:11:41 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 10-05-2012 / 17:03:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_util_zip_Deflater_reset: nativeContext
+
+    <javanative: 'java/util/zip/Deflater' name: 'reset(J)V'>
+
+    | addr deflater |
+    addr := nativeContext argAt: 1.
+    deflater := ZipInflaters at: addr.
+    deflater reset.
+
+    "Modified: / 25-10-2012 / 20:19:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_util_zip_Inflater_end: nativeContext
+
+    <javanative: 'java/util/zip/Inflater' name: 'end(J)V'>
+
+     "
+    private native static void reset(long addr);
+    "
+    | addr inflater |
+    addr := nativeContext argAt: 1.
+    inflater := ZipInflaters at: addr.
+    ZipInflaters at: addr put: nil.
+    inflater end.
+
+    "Modified: / 25-10-2012 / 20:24:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_util_zip_Inflater_getBytesRead: nativeContext
+
+    <javanative: 'java/util/zip/Inflater' name: 'getBytesRead(J)J'>
+
+    | addr inflater |
+    addr := nativeContext argAt: 1.
+    inflater := ZipInflaters at: addr.
+    ^inflater bytesRead.
+
+    "Modified: / 25-10-2012 / 20:20:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_util_zip_Inflater_getBytesWritten: nativeContext
+
+    <javanative: 'java/util/zip/Inflater' name: 'getBytesWritten'>
+
+    | addr inflater |
+    addr := nativeContext argAt: 1.
+    inflater := ZipInflaters at: addr.
+    ^inflater bytesWritten.
+
+    "Modified: / 25-10-2012 / 20:20:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_util_zip_Inflater_inflateBytes: nativeContext
+
+    <javanative: 'java/util/zip/Inflater' name: 'inflateBytes'>
+    "
+    private native int inflateBytes(long addr, byte[] b, int off, int len)
+    "
+
+    | addr b off len inflater ret |
+    addr := nativeContext argAt: 1."long takes 2 slots"
+    b := nativeContext argAt: 3.
+    off := nativeContext argAt: 4.
+    len := nativeContext argAt: 5.
+
+    inflater := ZipInflaters at: addr.
+
+    ret := inflater inflate: b offset: off length: len inflater: nativeContext receiver.
+
+    ^ret.
+
+    "Created: / 30-04-2011 / 23:02:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 25-10-2012 / 20:20:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_util_zip_Inflater_init: nativeContext
+
+    <javanative: 'java/util/zip/Inflater' name: 'init'>
+
+
+    | nowrap inflater |
+    nowrap := nativeContext argAt:1.
+    inflater := JavaZipSupport inflaterFor: self.
+    inflater init: nowrap.
+    1 to: ZipInflaters size do:[:i|
+        (ZipInflaters at: i) isNil ifTrue:[
+            ZipInflaters at: i put: inflater.
+            ^i
+        ].
+    ].
+    ZipInflaters add: inflater.
+    ^ ZipInflaters size.
+
+    "Created: / 01-02-1998 / 20:14:01 / cg"
+    "Modified: / 25-10-2012 / 20:25:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_util_zip_Inflater_initIDs: aJavaContext
+
+    <javanative: 'java/util/zip/Inflater' name: 'initIDs'>
+
+
+    "Nothing to do, used only to register natives"
+
+    "Created: / 30-04-2011 / 21:55:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_util_zip_Inflater_reset: nativeContext
+
+    <javanative: 'java/util/zip/Inflater' name: 'reset'>
+    "
+    private native static void reset(long addr);
+    "
+    | addr inflater |
+    addr := nativeContext argAt: 1.
+    inflater := ZipInflaters at: addr.
+    inflater reset.
+
+    "Created: / 01-02-1998 / 20:14:13 / cg"
+    "Modified: / 25-10-2012 / 20:20:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_util_zip_ZipEntry_initFields: aJavaContext
+
+    <javanative: 'java/util/zip/ZipEntry' name: 'initFields'>
+
+        | entry jzentry zmember |
+
+    entry := aJavaContext receiver.
+    jzentry := aJavaContext argAt: 1.
+    zmember := ZipEntryCache at: jzentry.
+
+    entry
+        instVarNamed: #name     put: (Java as_String: zmember fileName);
+        instVarNamed: #time     put: -1"zmember lastModFileTime";
+        instVarNamed: #crc      put: zmember crc32;
+        instVarNamed: #size     put: zmember uncompressedSize;
+        instVarNamed: #csize    put: zmember compressedSize;
+        instVarNamed: #method   put: zmember compressionMethod;
+        instVarNamed: #extra    put: zmember extraField;
+        instVarNamed: #comment  put: (zmember fileComment ifNotNil:[Java as_String: zmember fileComment]).
+
+    "Created: / 01-04-2011 / 13:04:24 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 05-12-2011 / 23:42:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_util_zip_ZipEntry_initIDs: aJavaContext
+
+    <javanative: 'java/util/zip/ZipEntry' name: 'initIDs'>
+
+        "hopefully nothing to do"
+
+    "Created: / 01-04-2011 / 13:02:06 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+_java_util_zip_ZipFile_close: nativeContext
+
+    <javanative: 'java/util/zip/ZipFile' name: 'close(J)V'>
+
+    | jzfile zar |
+    jzfile := nativeContext argAt: 1.
+    zar := ZipCache at: jzfile.
+    zar close.
+    ZipCache at: jzfile put: nil.
+
+    "Modified: / 03-11-2011 / 22:22:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_util_zip_ZipFile_freeEntry: nativeContext
+
+    <javanative: 'java/util/zip/ZipFile' name: 'freeEntry'>
+
+    | 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>"
+!
+
+_java_util_zip_ZipFile_getCSize: aJavaContext
+
+    <javanative: 'java/util/zip/ZipFile' name: 'getCSize'>
+
+
+    | jzentry zmember |
+    jzentry := aJavaContext argAt: 1.
+    zmember := ZipEntryCache at: jzentry.
+
+    ^zmember compressedSize
+
+    "Created: / 30-04-2011 / 21:50:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_util_zip_ZipFile_getEntry: nativeContext
+
+    <javanative: 'java/util/zip/ZipFile' name: 'getEntry'>
+
+    | zipArchive  filename  member |
+
+    zipArchive := ZipCache at: (nativeContext argAt: 1).
+    filename := Java as_ST_String: (nativeContext argAt: 3).
+    member := (zipArchive findMemberAllowForMissingTrailingSlash: filename).
+    member isNil ifTrue: [
+        ^ 0
+    ] ifFalse: [
+        ^ ZipEntryCache indexOf: member ifAbsent:[
+            ZipEntryCache add: member.
+            ZipEntryCache size.
+        ]
+    ]
+
+    "Created: / 27-03-2011 / 16:59:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 01-04-2011 / 16:03:01 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 18-08-2011 / 19:44:56 / jv"
+    "Modified: / 20-07-2012 / 19:27:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_util_zip_ZipFile_getMethod: aJavaContext
+
+    <javanative: 'java/util/zip/ZipFile' name: 'getMethod'>
+
+
+    | jzentry zmember |
+    jzentry := aJavaContext argAt: 1.
+    zmember := ZipEntryCache at: jzentry.
+
+    ^zmember compressionMethod
+
+    "Created: / 30-04-2011 / 21:53:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_util_zip_ZipFile_getNextEntry: nativeContext
+
+    <javanative: 'java/util/zip/ZipFile' name: 'getNextEntry(JI)J'>
+
+    | zipArchive  index i |
+
+    zipArchive := ZipCache at: (nativeContext at: 1).
+    index := nativeContext at: 3.
+    i := 0.
+    zipArchive zipMembersDo:[:member |
+        index == i ifTrue:[
+            ^ ZipEntryCache indexOf: member ifAbsent:[
+                ZipEntryCache add: member.
+                ZipEntryCache size.
+            ]
+        ].
+        i := i + 1.
+    ].
+    ^0
+
+    "Modified: / 05-12-2011 / 11:19:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_util_zip_ZipFile_getSize: aJavaContext
+
+    <javanative: 'java/util/zip/ZipFile' name: 'getSize'>
+
+
+    | jzentry zmember |
+    jzentry := aJavaContext argAt: 1.
+    zmember := ZipEntryCache at: jzentry.
+
+    ^zmember uncompressedSize
+
+    "Created: / 30-04-2011 / 21:53:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_util_zip_ZipFile_getTotal: nativeContext
+
+    <javanative: 'java/util/zip/ZipFile' name: 'getTotal'>
+
+    | zar|
+    zar := ZipCache at: (nativeContext argAt: 1).
+    ^ zar entries size.
+
+    "Modified: / 23-07-2012 / 23:35:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_util_zip_ZipFile_initIDs: aJavaContext
+
+    <javanative: 'java/util/zip/ZipFile' name: 'initIDs'>
+
+
+    "Nothing to do"
+
+    "Created: / 23-03-2011 / 19:37:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_util_zip_ZipFile_open: nativeContext
+
+    <javanative: 'java/util/zip/ZipFile' name: 'open'>
+
+    | path  mode  lastModTime  result |
+
+    path := Java as_ST_String: (nativeContext at: 1).
+    "/(path endsWith:'.jar') ifFalse:[self breakPoint: #jv].
+    mode := nativeContext at: 2.
+    lastModTime := nativeContext at: 3.
+    result := path asFilename.
+    result ifNil: [ JavaVM throwZipException ].
+    ^[
+        | i zar |
+        zar := ZipArchive readingFrom: result readStream.
+        i := ZipCache indexOf: nil.
+        i ~~ 0 ifTrue:[
+            ZipCache at: i put: zar.
+            i
+        ] ifFalse:[
+            ZipCache add: zar.
+            ZipCache size.
+        ].
+    ] on: Error do:[:ex|
+        self throwZipException: 'Cannot open zip file: ', ex description
+    ]
+
+    "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>"
+!
+
+_java_util_zip_ZipFile_read: aJavaContext
+
+    <javanative: 'java/util/zip/ZipFile' name: 'read'>
+
+
+    | jzfile jzentry pos b off len zar zmember bytesToRead |
+    jzfile := aJavaContext argAt: 1.
+    jzentry := aJavaContext argAt: 3. "first arg is long!!!!!!"
+    pos := aJavaContext argAt: 5. "jzentry arg is long!!!!!!"
+    b := aJavaContext argAt: 7.
+    off := aJavaContext argAt: 8.
+    len := aJavaContext argAt: 9.
+
+    zar := ZipCache at: jzfile.
+    zmember := ZipEntryCache at: jzentry.
+
+    bytesToRead := len min: (zmember compressedSize - pos).
+
+    ^zar nextBytes: bytesToRead of: zmember startingAt: pos into: b startingAt: off + 1.
+
+    "Created: / 30-04-2011 / 22:15:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 01-05-2011 / 16:22:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - old-style'!
+
+_AccessController_beginPrivileged:nativeContext
+    "/ introduced with jdk1.2
+
+    "Created: / 27.1.1998 / 18:18:11 / cg"
+!
+
+_AccessController_endPrivileged:nativeContext
+    "/ introduced with jdk1.2
+
+    "Created: / 27.1.1998 / 18:18:32 / cg"
+!
+
+_AudioDevice_audioClose:nativeContext
+    |device fd stream|
+
+    device := nativeContext receiver.
+    device notNil ifTrue:[
+        fd := device instVarNamed:'dev'.
+        (fd notNil and:[fd > 0]) ifTrue:[
+            stream := self getOpenFileAt:fd.
+            stream notNil ifTrue:[
+                stream close.
+                device instVarNamed:'dev' put:0.
+            ]
+        ]
+    ]
+
+    "Created: / 10.1.1998 / 15:45:16 / cg"
+    "Modified: / 13.1.1998 / 18:08:20 / cg"
+!
+
+_AudioDevice_audioOpen:nativeContext
+    |f stream fileNo|
+
+    NoAudio ifTrue:[
+        Transcript showCR:'JAVA: audio disabled'.
+        ^ -1
+    ].
+
+    Stream streamErrorSignal handle:[:ex |
+        Stream streamErrorSignal handle:[:ex |
+            stream := nil.
+            ex return.
+        ] do:[
+            stream := SoundStream writing.
+        ].
+    ] do:[
+        stream := SoundStream writing.
+        stream notNil ifTrue:[
+            stream setSampleRate:8000.
+        ]
+    ].
+    stream isNil ifTrue:[
+"/        ^ -1.
+
+        f := '/dev/audio' asFilename.
+        f exists ifFalse:[
+            Transcript showCR:'JAVA: neither SoundStream nor /dev/audio available'.
+            ^ -1
+        ].
+        stream := self commonOpenStreamUsing: [f readWriteStream].
+        stream isNil ifTrue:[
+            Transcript showCR:'JAVA: /dev/audio exists, but cannot be opened'.
+            ^ -1
+        ].
+        fileNo := self addOpenFile:stream.
+    ].
+
+    fileNo := self addOpenFile:stream.
+
+    FileOpenTrace ifTrue:[
+        ('JAVA: opened audioDevice as FD ' , fileNo printString) infoPrintCR.
+    ].
+
+    ^ fileNo
+
+    "Created: / 10-01-1998 / 15:45:30 / cg"
+    "Modified: / 14-10-1998 / 15:20:52 / cg"
+    "Modified: / 23-07-2012 / 19:36:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_AudioDevice_audioWrite:nativeContext
+    |device fd stream bytes count|
+
+    device := nativeContext receiver.
+    device notNil ifTrue:[
+        fd := device instVarNamed:'dev'.
+        (fd notNil and:[fd > 0]) ifTrue:[
+            stream := self getOpenFileAt:fd.
+            stream notNil ifTrue:[
+                bytes := nativeContext argAt:1.
+                count := nativeContext argAt:2.
+                stream nextPutBytes:count from:bytes startingAt:1
+            ]
+        ]
+    ]
+
+    "Created: / 10.1.1998 / 15:45:16 / cg"
+    "Modified: / 13.1.1998 / 18:07:20 / cg"
+!
+
+_BigInteger_plumbInit:nativeContext
+    JavaVM unimplementedNativeMethodSignal raiseRequest
+
+    "Modified: / 12.11.1998 / 19:23:00 / cg"
+!
+
+_ColorModel_deletepData:nativeContext
+    "/ void deletepData ()
+    JavaVM unimplementedNativeMethodSignal raiseRequest
+
+    "Created: / 12.11.1998 / 19:22:05 / cg"
+!
+
+_ColorModel_initIDs:nativeContext
+    "/ new with jdk1.2 ...
+
+    "Created: / 28.1.1998 / 22:19:23 / cg"
+!
+
+_Constructor_getModifiers:nativeContext
+    "/ int getModifiers ()
+
+JavaVM unimplementedNativeMethodSignal raiseRequest.
+
+    "Modified: / 27.1.2000 / 02:53:55 / cg"
+    "Created: / 27.1.2000 / 02:54:38 / cg"
+!
+
+_Constructor_newInstance:nativeContext
+    "/ java.lang.Object newInstance (java.lang.Object[])
+
+JavaVM unimplementedNativeMethodSignal raiseRequest.
+
+    "Modified: / 27.1.2000 / 02:53:55 / cg"
+!
+
+_Field_get:nativeContext
+    "/ java.lang.Object get (java.lang.Object)
+
+JavaVM unimplementedNativeMethodSignal raiseRequest.
+
+    "Modified: / 27.1.2000 / 02:53:55 / cg"
+    "Created: / 27.1.2000 / 03:04:18 / cg"
+!
+
+_Field_getBoolean:nativeContext
+    "/ boolean getBoolean (java.lang.Object)
+
+JavaVM unimplementedNativeMethodSignal raiseRequest.
+
+    "Modified: / 27.1.2000 / 02:53:55 / cg"
+    "Created: / 27.1.2000 / 03:05:16 / cg"
+!
+
+_Field_getByte:nativeContext
+    "/ byte getByte (java.lang.Object)
+
+JavaVM unimplementedNativeMethodSignal raiseRequest.
+
+    "Modified: / 27.1.2000 / 02:53:55 / cg"
+    "Created: / 27.1.2000 / 03:05:30 / cg"
+!
+
+_Field_getChar:nativeContext
+    "/ char getChar (java.lang.Object)
+
+JavaVM unimplementedNativeMethodSignal raiseRequest.
+
+    "Modified: / 27.1.2000 / 02:53:55 / cg"
+    "Created: / 27.1.2000 / 03:03:37 / cg"
+!
+
+_Field_getDouble:nativeContext
+    "/ double getDouble (java.lang.Object)
+
+JavaVM unimplementedNativeMethodSignal raiseRequest.
+
+    "Modified: / 27.1.2000 / 02:53:55 / cg"
+    "Created: / 27.1.2000 / 03:07:49 / cg"
+!
+
+_Field_getFloat:nativeContext
+    "/ float getFloat (java.lang.Object)
+
+JavaVM unimplementedNativeMethodSignal raiseRequest.
+
+    "Modified: / 27.1.2000 / 02:53:55 / cg"
+    "Created: / 27.1.2000 / 03:05:41 / cg"
+!
+
+_Field_getInt:nativeContext
+    "/ int getInt (java.lang.Object)
+
+JavaVM unimplementedNativeMethodSignal raiseRequest.
+
+    "Modified: / 27.1.2000 / 02:53:55 / cg"
+    "Created: / 27.1.2000 / 03:04:47 / cg"
+!
+
+_Field_getLong:nativeContext
+    "/ long getLong (java.lang.Object)
+
+JavaVM unimplementedNativeMethodSignal raiseRequest.
+
+    "Modified: / 27.1.2000 / 02:53:55 / cg"
+    "Created: / 27.1.2000 / 03:05:54 / cg"
+!
+
+_Field_getModifiers:nativeContext
+    "/ int getModifiers ()
+
+JavaVM unimplementedNativeMethodSignal raiseRequest.
+
+    "Modified: / 27.1.2000 / 02:53:55 / cg"
+    "Created: / 27.1.2000 / 03:07:03 / cg"
+!
+
+_Field_getShort:nativeContext
+    "/ unsigned short getShort (java.lang.Object)
+
+JavaVM unimplementedNativeMethodSignal raiseRequest.
+
+    "Modified: / 27.1.2000 / 02:53:55 / cg"
+    "Created: / 27.1.2000 / 03:07:35 / cg"
+!
+
+_Field_set:nativeContext
+    "/ void set (java.lang.Object java.lang.Object)
+
+JavaVM unimplementedNativeMethodSignal raiseRequest.
+
+    "Modified: / 27.1.2000 / 02:53:55 / cg"
+    "Created: / 27.1.2000 / 03:04:33 / cg"
+!
+
+_Field_setBoolean:nativeContext
+    "/ void setBoolean (java.lang.Object boolean)
+
+JavaVM unimplementedNativeMethodSignal raiseRequest.
+
+    "Modified: / 27.1.2000 / 02:53:55 / cg"
+    "Created: / 27.1.2000 / 03:06:06 / cg"
+!
+
+_Field_setByte:nativeContext
+    "/ void setByte (java.lang.Object byte)
+
+JavaVM unimplementedNativeMethodSignal raiseRequest.
+
+    "Modified: / 27.1.2000 / 02:53:55 / cg"
+    "Created: / 27.1.2000 / 03:06:20 / cg"
+!
+
+_Field_setChar:nativeContext
+    "/ void setChar (java.lang.Object char)
+
+JavaVM unimplementedNativeMethodSignal raiseRequest.
+
+    "Modified: / 27.1.2000 / 02:53:55 / cg"
+    "Created: / 27.1.2000 / 03:03:48 / cg"
+!
+
+_Field_setDouble:nativeContext
+    "/ void setDouble (java.lang.Object double)
+
+JavaVM unimplementedNativeMethodSignal raiseRequest.
+
+    "Modified: / 27.1.2000 / 02:53:55 / cg"
+    "Created: / 27.1.2000 / 03:04:02 / cg"
+!
+
+_Field_setFloat:nativeContext
+    "/ void setFloat (java.lang.Object float)
+
+JavaVM unimplementedNativeMethodSignal raiseRequest.
+
+    "Modified: / 27.1.2000 / 02:53:55 / cg"
+    "Created: / 27.1.2000 / 03:06:48 / cg"
+!
+
+_Field_setInt:nativeContext
+    "/ void setInt (java.lang.Object int)
+
+JavaVM unimplementedNativeMethodSignal raiseRequest.
+
+    "Modified: / 27.1.2000 / 02:53:55 / cg"
+    "Created: / 27.1.2000 / 03:05:04 / cg"
+!
+
+_Field_setLong:nativeContext
+    "/ void setLong (java.lang.Object long)
+
+JavaVM unimplementedNativeMethodSignal raiseRequest.
+
+    "Modified: / 27.1.2000 / 02:53:55 / cg"
+    "Created: / 27.1.2000 / 03:06:37 / cg"
+!
+
+_Field_setShort:nativeContext
+    "/ void setShort (java.lang.Object unsigned short)
+
+JavaVM unimplementedNativeMethodSignal raiseRequest.
+
+    "Modified: / 27.1.2000 / 02:53:55 / cg"
+    "Created: / 27.1.2000 / 03:03:23 / cg"
+!
+
+_FileDescriptor_initSystemFD:nativeContext
+    |descriptor fileNo myStream|
+
+    descriptor := nativeContext argAt:1.
+    fileNo := nativeContext argAt:2.
+
+    fileNo == 0 ifTrue:[
+        myStream := Stdin
+    ] ifFalse:[
+        fileNo == 1 ifTrue:[
+           myStream := JavaConsoleStream ? Stdout
+        ] ifFalse:[
+            fileNo == 2 ifTrue:[
+                myStream := JavaConsoleStream ? Stderr
+            ] ifFalse:[
+                self halt:'invalid fileNo given'.
+                self internalError:'invalid fileNo given'.
+            ]
+        ]
+    ].
+
+    self setOpenFile:myStream at:fileNo.
+
+    descriptor instVarNamed:'fd' put:fileNo.
+    ^ descriptor
+
+    "Modified: / 27-01-1998 / 18:15:28 / cg"
+    "Modified (format): / 28-07-2012 / 02:46:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_FileDescriptor_valid:nativeContext
+    "/ boolean valid ()
+    |descriptor fileNo stream|
+
+    descriptor := nativeContext receiver.
+    fileNo := descriptor instVarNamed:'fd'.
+    stream := self getOpenFileAt:fileNo.
+    stream isNil ifTrue:[^ 0]. "/ FALSE
+    stream isOpen ifFalse:[^ 0].  "/ FALSE
+
+    ^ 1 "/ TRUE
+
+    "Modified: / 11.12.1998 / 13:02:47 / cg"
+!
+
+_FileInputStream_close:nativeContext
+    ^ self anyStream_close:nativeContext
+
+    "Created: / 4.1.1998 / 17:45:23 / cg"
+    "Modified: / 4.2.1998 / 15:20:46 / cg"
+!
+
+_FileOutputStream_close:nativeContext
+    ^ self anyStream_close:nativeContext
+
+    "Created: / 13.1.1998 / 09:33:16 / cg"
+    "Modified: / 4.2.1998 / 15:20:53 / cg"
+!
+
+_File_canRead0:nativeContext
+    |file path f|
+
+    file := nativeContext receiver.
+    path := file instVarNamed:'path'.
+    path notNil ifTrue:[
+        path := Java as_ST_String:path.
+
+        FileAccessTrace == true ifTrue:[
+            path storeString print. ' ' print. thisContext printCR
+        ].
+
+        path := self fixFilename:path.
+        (f := path asFilename) isReadable ifTrue:[
+            ^ 1 "/ TRUE
+        ]
+    ].
+    ^ 0 "/ FALSE
+
+    "Created: / 4.1.1998 / 18:09:55 / cg"
+    "Modified: / 27.1.1999 / 18:57:55 / cg"
+!
+
+_File_canWrite0:nativeContext
+    |file path f|
+
+    file := nativeContext receiver.
+    path := file instVarNamed:'path'.
+    path notNil ifTrue:[
+        FileAccessTrace == true ifTrue:[
+            path storeString print. ' ' print. thisContext printCR
+        ].
+        path := Java as_ST_String:path.
+        path := self fixFilename:path.
+        (f := path asFilename) isWritable ifTrue:[
+            ^ 1 "/ TRUE
+        ]
+    ].
+    ^ 0 "/ FALSE
+
+    "Created: / 4.2.1998 / 00:19:55 / cg"
+    "Modified: / 27.1.1999 / 18:57:52 / cg"
+!
+
+_File_canonPath:nativeContext
+    "/ introduced with jdk1.2 ... (sigh)
+
+    |jPath path realPath|
+
+    jPath := nativeContext argAt:1.
+    jPath isNil ifTrue:[^ jPath].
+
+    path := Java as_ST_String:jPath.
+    realPath := path asFilename pathName.
+
+    ^ Java as_String:realPath
+
+    "Created: / 27.1.1998 / 18:35:58 / cg"
+    "Modified: / 27.1.1998 / 21:36:03 / cg"
+!
+
+_File_delete0:nativeContext
+    "/ boolean delete0 ()
+    |oldFile oldPath oldF|
+
+    oldFile := nativeContext receiver.
+    oldPath := oldFile instVarNamed:'path'.
+    oldPath isNil ifTrue:[^ 0].    "/ FALSE
+
+    oldPath := Java as_ST_String:oldPath.
+    oldF := oldPath asFilename.
+
+    oldF exists ifFalse:[
+        ^ 1 "/ TRUE
+    ].
+
+    (self checkWritePermissionOfDirectory:oldF directory message:('JAVA Security check\\Delete of ''' , oldPath , '''.\Grant permission ?'))
+    ifFalse:[
+        ^ 0 "/ FALSE
+    ].
+
+    OperatingSystem accessDeniedErrorSignal handle:[:ex |
+        ^ 0 "/ FALSE
+    ] do:[
+        oldF delete.
+        ^ 1 "/ TRUE
+    ].
+    ^ 0 "/ FALSE
+
+    "Modified: / 30.12.1998 / 20:15:06 / cg"
+!
+
+_File_exists0:nativeContext
+    |file path f|
+
+    file := nativeContext receiver.
+    path := file instVarNamed:'path'.
+    path notNil ifTrue:[
+        path := Java as_ST_String:path.
+        path := self fixFilename:path.
+        FileAccessTrace == true ifTrue:[
+            path storeString print. ' ' print. thisContext printCR
+        ].
+        (f := path asFilename) exists ifTrue:[
+            ^ 1 "TRUE"
+        ]
+    ].
+    ^ 0 "FALSE"
+
+    "Created: / 5.1.1998 / 02:07:48 / cg"
+    "Modified: / 27.1.1999 / 18:57:46 / cg"
+!
+
+_File_initIDs:nativeContext
+    "/ introduced with jdk1.2 ... (sigh)
+
+    "Created: / 27.1.1998 / 18:25:19 / cg"
+!
+
+_File_isAbsolute:nativeContext
+    |file path f|
+
+    file := nativeContext receiver.
+    path := file instVarNamed:'path'.
+    path notNil ifTrue:[
+        path := Java as_ST_String:path.
+        path := self fixFilename:path.
+        (f := path asFilename) isAbsolute ifTrue:[
+            ^ 1 "/ TRUE
+        ]
+    ].
+    ^ 0 "/ FALSE
+
+    "Created: / 11.1.1998 / 09:54:38 / cg"
+    "Modified: / 20.10.1998 / 20:59:53 / cg"
+!
+
+_File_isDirectory0:nativeContext
+    |file path f|
+
+    file := nativeContext receiver.
+    path := file instVarNamed:'path'.
+    path notNil ifTrue:[
+        FileAccessTrace == true ifTrue:[
+            path storeString print. ' ' print. thisContext printCR
+        ].
+        path := Java as_ST_String:path.
+        path := self fixFilename:path.
+        (f := path asFilename) exists ifTrue:[
+            f isDirectory ifTrue:[^ 1 "TRUE"]
+        ]
+    ].
+    ^ 0 "FALSE"
+
+    "Created: / 7.1.1998 / 10:31:37 / cg"
+    "Modified: / 27.1.1999 / 18:58:01 / cg"
+!
+
+_File_isFile0:nativeContext
+    |file path f|
+
+    file := nativeContext receiver.
+    path := file instVarNamed:'path'.
+    path notNil ifTrue:[
+        FileAccessTrace == true ifTrue:[
+            path storeString print. ' ' print. thisContext printCR
+        ].
+        path := Java as_ST_String:path.
+        path := self fixFilename:path.
+        (f := path asFilename) exists ifTrue:[
+            f isDirectory ifFalse:[^ 1 "TRUE"]
+        ]
+    ].
+    ^ 0 "/ FALSE
+
+    "Created: / 11.1.1998 / 11:40:22 / cg"
+    "Modified: / 27.1.1999 / 18:58:04 / cg"
+!
+
+_File_lastModified0:nativeContext
+    |file path f|
+
+    file := nativeContext receiver.
+    path := file instVarNamed:'path'.
+    path notNil ifTrue:[
+        path := Java as_ST_String:path.
+        path := self fixFilename:path.
+        (f := path asFilename) exists ifTrue:[
+            ^ f modificationTime getMilliseconds.
+        ]
+    ].
+    ^ 0
+
+    "Created: / 4.2.1998 / 16:50:30 / cg"
+    "Modified: / 20.10.1998 / 21:00:05 / cg"
+!
+
+_File_length0:nativeContext
+    |file path f|
+
+    file := nativeContext receiver.
+    path := file instVarNamed:'path'.
+    path notNil ifTrue:[
+        FileAccessTrace == true ifTrue:[
+            thisContext printCR
+        ].
+        path := Java as_ST_String:path.
+        path := self fixFilename:path.
+        (f := path asFilename) exists ifTrue:[
+            ^ f fileSize
+        ]
+    ].
+    ^ -1
+
+    "Created: / 7.1.1998 / 12:18:57 / cg"
+    "Modified: / 27.1.1999 / 18:57:06 / cg"
+!
+
+_File_list0:nativeContext
+    |file path f files|
+
+    file := nativeContext receiver.
+    path := file instVarNamed:'path'.
+    path notNil ifTrue:[
+        path := Java as_ST_String:path.
+        path := self fixFilename:path.
+        (f := path asFilename) exists ifTrue:[
+            f isDirectory ifTrue:[
+                files := f directoryContents asArray.
+                files := files collect:[:nm | Java as_String:nm].
+                ^ files
+            ]
+        ]
+    ].
+    ^ nil
+
+    "Created: / 14.1.1998 / 21:30:22 / cg"
+    "Modified: / 20.10.1998 / 21:00:21 / cg"
+!
+
+_File_mkdir0:nativeContext
+    |file path f|
+
+    file := nativeContext receiver.
+    path := file instVarNamed:'path'.
+    path notNil ifTrue:[
+        path := Java as_ST_String:path.
+        path := self fixFilename:path.
+        f := path asFilename.
+        (f exists and:[f isDirectory]) ifTrue:[
+            ^ 0 "/ FALSE
+        ].
+
+        FileOpenConfirmation ifTrue:[
+            (self confirm:('JAVA Security check\\Create directory ''' , path , '''.\Grant permission ?') withCRs)
+            ifFalse:[
+                ^ 0 "/ FALSE
+            ]
+        ].
+        OperatingSystem accessDeniedErrorSignal handle:[:ex |
+            ^ 0 "/ FALSE
+        ] do:[
+            f makeDirectory.
+        ].
+        f  exists ifTrue:[
+            f isDirectory ifTrue:[^ 1 "TRUE"]
+        ]
+    ].
+    ^ 0 "FALSE"
+
+    "Created: / 4.2.1998 / 00:19:05 / cg"
+    "Modified: / 4.12.1998 / 14:04:03 / cg"
+!
+
+_File_renameTo0:nativeContext
+    "/ void renameTo0 (java.io.File)
+
+    |oldFile newFile oldPath newPath oldF newF|
+
+    oldFile := nativeContext receiver.
+    oldPath := oldFile instVarNamed:'path'.
+    oldPath isNil ifTrue:[^ 0].    "/ FALSE
+
+    oldPath := Java as_ST_String:oldPath.
+    oldF := oldPath asFilename.
+
+    newFile := nativeContext argAt:1.
+    newPath := newFile instVarNamed:'path'.
+    newPath isNil ifTrue:[^ 0].    "/ FALSE
+    newPath := Java as_ST_String:newPath.
+
+    newF := newPath asFilename.
+
+    (self checkWritePermissionOfDirectory:oldF directory message:('JAVA Security check\\Rename of ''' , oldPath , ''' to ''' , newPath , '''.\Grant permission ?'))
+    ifFalse:[
+        ^ 0 "/ FALSE
+    ].
+    oldF directory pathName ~= newF directory pathName ifTrue:[
+        (self checkWritePermissionOfDirectory:newF directory message:('JAVA Security check\\Rename of ''' , oldPath , ''' to ''' , newPath , '''.\Grant permission ?'))
+        ifFalse:[
+            ^ 0 "/ FALSE
+        ].
+    ].
+
+    OperatingSystem accessDeniedErrorSignal handle:[:ex |
+        ^ 0 "/ FALSE
+    ] do:[
+        oldF renameTo:newF.
+        ^ 1 "/ TRUE
+    ].
+    ^ 0 "/ FALSE
+
+    "Modified: / 3.12.1998 / 21:01:08 / cg"
+!
+
+_File_rmdir0:nativeContext
+    "/ boolean rmdir0 ()
+    JavaVM unimplementedNativeMethodSignal raiseRequest
+
+    "Modified: / 12.11.1998 / 19:01:48 / cg"
+    "Created: / 12.11.1998 / 19:03:52 / cg"
+!
+
+_Float_floatToIntBits:nativeContext
+    |f i|
+
+    f := nativeContext argAt:1.
+
+    UninterpretedBytes isBigEndian ifTrue:[
+        i := f basicAt:4.
+        i := i bitOr:((f basicAt:3) bitShift:8).
+        i := i bitOr:((f basicAt:2) bitShift:16).
+        i := i bitOr:((f basicAt:1) bitShift:24).
+    ] ifFalse:[
+        i := f basicAt:1.
+        i := i bitOr:((f basicAt:2) bitShift:8).
+        i := i bitOr:((f basicAt:3) bitShift:16).
+        i := i bitOr:((f basicAt:4) bitShift:24).
+    ].
+
+    ^ i.
+
+    "Created: / 4.1.1998 / 01:25:50 / cg"
+!
+
+_FontDescriptor_initIDs:nativeContext
+    "/ new with jdk1.2 ...
+
+    "Created: / 28.1.1998 / 22:30:52 / cg"
+!
+
+_Font_initIDs:nativeContext
+    "/ new with jdk1.2 ...
+
+    "Created: / 27.1.1998 / 21:43:25 / cg"
+!
+
+_GifImageDecoder_parseImage:nativeContext
+    |decoder width height bool1 depth subHdrBytes dstBytes i1 i2 colorModel
+     stream byte compressedData compressedSize index count data
+     leftOffs topOffs codeLen flags pixelStore clrModel t buffSize
+     countGot countGot2|
+
+    decoder := nativeContext receiver.
+
+    i1 := nativeContext argAt:1.
+    i2 := nativeContext argAt:2.
+    width := nativeContext argAt:3.
+    height := nativeContext argAt:4.
+    bool1 := nativeContext argAt:5.
+    depth := nativeContext argAt:6.
+    subHdrBytes := nativeContext argAt:7.
+    dstBytes := nativeContext argAt:8.
+    colorModel := nativeContext argAt:9.
+
+    leftOffs := subHdrBytes wordAt:1 MSB:false.
+    topOffs := subHdrBytes wordAt:3 MSB:false.
+    width := subHdrBytes wordAt:5 MSB:false.
+    height := subHdrBytes wordAt:7 MSB:false.
+    flags := subHdrBytes at:9.
+    codeLen := subHdrBytes at:10.
+
+    stream := decoder instVarNamed:'input'.
+    pixelStore := decoder instVarNamed:'store'.
+    pixelStore isNil ifTrue:[
+        ^ 0
+    ].
+
+    buffSize := (width * height // 2) max:4096.
+    compressedData := ByteArray uninitializedNew:buffSize.
+    "get compressed data"
+    index := 1.
+    count := stream perform:#'read()I'.
+
+    [count notNil and:[count > 0]] whileTrue:[
+        (index + count) > buffSize ifTrue:[
+            t := ByteArray uninitializedNew:(buffSize * 2).
+            t replaceFrom:1 to:buffSize with:compressedData startingAt:1.
+            compressedData := t.
+            buffSize := buffSize * 2.
+        ].
+        [count ~~ 0] whileTrue:[
+            countGot := stream
+                        perform:#'read([BII)I'
+                        with:compressedData
+                        with:index-1
+                        with:count.
+
+            countGot > 0 ifTrue:[
+                count := count - countGot.
+                index := index + countGot.
+            ] ifFalse:[
+                count := -1.
+            ]
+        ].
+
+        count >= 0 ifTrue:[
+            count := stream perform:#read.
+        ]
+    ].
+    compressedSize := index - 1.
+
+    data := pixelStore perform:#'allocateLines(I)Ljava/lang/Object;' with:height.
+    (data isMemberOf:ByteArray) ifFalse:[
+        self halt.
+        ^ 0.
+    ].
+"/    'GIFReader: decompressing ...' infoPrintCR.
+
+
+    GIFReader
+        decompressGIFFrom:compressedData
+        count:compressedSize
+        into:data
+        startingAt:1
+        codeLen:(codeLen + 1).
+
+    clrModel := pixelStore instVarNamed:'colormodel'.
+
+    pixelStore
+        perform:#'setPixels(IIII[BII)Z'
+        withArguments:
+            (Array
+                with:0        "/ x
+                with:0        "/ y
+                with:width    "/ w
+                with:height   "/ h
+                with:data
+                with:0        "/ offs
+                with:width).   "/ scanSize
+
+    pixelStore  perform:#'imageComplete()V'.
+"/        perform:#'imageComplete(I)V'
+"/        with:((Java at:'java.awt.image.ImageConsumer') instVarNamed:'STATICIMAGEDONE').
+
+"/ self internalError:'breakPoint'.
+    ^ 1 "/ true
+
+    "Modified: / 10.4.1998 / 14:31:59 / cg"
+!
+
+_ImageRepresentation_disposeImage:nativeContext
+    |imgRep img|
+
+    imgRep := nativeContext receiver.
+
+    img := imgRep instVarNamed:'pData'.
+    (img notNil and:[img ~~ 0]) ifTrue:[
+        ImageStretchCache notNil ifTrue:[
+            ImageStretchCache removeKey:img ifAbsent:nil.
+        ]
+    ].
+
+    imgRep instVarNamed:'pData' put:0.
+"/    self halt.
+
+    "Created: / 7.1.1998 / 22:31:46 / cg"
+    "Modified: / 17.1.1998 / 13:26:55 / cg"
+!
+
+_ImageRepresentation_finish:nativeContext
+    |imgRep bool|
+
+    imgRep := nativeContext receiver.
+    bool := nativeContext argAt:1.
+"/ self halt.
+"/    'JAVA: ImageRepresentation_finish ignored for now' infoPrintCR.
+
+    ^ 1 "/ true
+
+    "Created: / 8.1.1998 / 00:11:40 / cg"
+    "Modified: / 6.2.1998 / 02:12:54 / cg"
+!
+
+_ImageRepresentation_imageDraw:nativeContext
+    |imgRep x y img deviceImage jGraphics gc clr|
+
+    imgRep := nativeContext receiver.
+    img := imgRep instVarNamed:'pData'.
+    (img isNil or:[img == 0]) ifTrue:[
+        "/ self halt.
+        ^ self.
+    ].
+    jGraphics := nativeContext argAt:1.
+    gc := jGraphics instVarNamed:'pData'.
+    gc realized ifFalse:[^ self].
+
+    x := nativeContext argAt:2.
+    y := nativeContext argAt:3.
+    clr := nativeContext argAt:4.
+
+    deviceImage := img onDevice:gc device.
+    deviceImage ~~ img ifTrue:[
+        imgRep instVarNamed:'pData' put:deviceImage.
+    ].
+    gc realized ifFalse:[^ self].
+    deviceImage displayOn:gc x:x y:y.
+    ^ 1.
+
+    "Created: / 13.1.1998 / 13:32:28 / cg"
+    "Modified: / 25.11.1998 / 15:36:38 / cg"
+!
+
+_ImageRepresentation_imageStretch:nativeContext
+    |imgRep x1 y1 x2 y2 srcX1 srcY1 w h
+     img deviceImage jGraphics gc clr stretchWidth stretchHeight|
+
+    imgRep := nativeContext receiver.
+    img := imgRep instVarNamed:'pData'.
+    (img isNil or:[img == 0]) ifTrue:[
+        "/ self halt.
+        ^ self.
+    ].
+
+    jGraphics := nativeContext argAt:1.
+    gc := jGraphics instVarNamed:'pData'.
+    gc realized ifFalse:[^ self].
+
+    x1 := nativeContext argAt:2.
+    y1 := nativeContext argAt:3.
+    x2 := nativeContext argAt:4.
+    y2:= nativeContext argAt:5.
+    srcX1 := nativeContext argAt:6.
+    srcY1 := nativeContext argAt:7.
+    w := nativeContext argAt:8.
+    h := nativeContext argAt:9.
+    clr := nativeContext argAt:10.
+
+    (srcX1 ~~ 0 or:[srcY1 ~~ 0]) ifTrue:[
+        self halt.
+        ^ self.
+    ].
+    (w ~~ img width or:[h ~~ img height]) ifTrue:[
+        self halt.
+        ^ self
+    ].
+
+    "/ TODO: remember magnified images somewhere for a while,
+    "/ to avoid repeated action ...
+
+    stretchWidth := (x2-x1).
+    stretchHeight := (y2-y1).
+
+    (stretchWidth == img width
+    and:[stretchHeight == img height]) ifTrue:[
+        deviceImage := img onDevice:gc device.
+        deviceImage ~~ img ifTrue:[
+            imgRep instVarNamed:'pData' put:deviceImage.
+        ].
+    ] ifFalse:[
+        ImageStretchCache notNil ifTrue:[
+            deviceImage := ImageStretchCache at:img ifAbsent:nil.
+        ].
+        (deviceImage isNil
+        or:[deviceImage width ~~ stretchWidth
+        or:[deviceImage height ~~ stretchHeight]]) ifTrue:[
+            deviceImage := (img magnifiedTo:stretchWidth@stretchHeight) onDevice:gc device.
+            ImageStretchCache isNil ifTrue:[
+                ImageStretchCache := WeakIdentityDictionary new.
+            ].
+            ImageStretchCache at:img put:deviceImage
+        ].
+    ].
+    deviceImage displayOn:gc x:x1 y:y1
+
+    "Created: / 13.1.1998 / 13:32:28 / cg"
+    "Modified: / 15.1.1998 / 13:14:47 / cg"
+!
+
+_ImageRepresentation_offscreenInit:nativeContext
+    |imgRep jclr w h form screenDevice|
+
+    imgRep := nativeContext receiver.
+    jclr := nativeContext argAt:1.
+
+    w := imgRep instVarNamed:'width'.
+    h := imgRep instVarNamed:'height'.
+
+    screenDevice := Screen current.
+    form := Form width:w height:h depth:(screenDevice depth) on:screenDevice.
+
+    imgRep instVarNamed:'pData' put:form.
+    "/ self halt.
+
+    "Created: / 7.1.1998 / 22:31:46 / cg"
+    "Modified: / 17.1.1998 / 12:36:43 / cg"
+!
+
+_ImageRepresentation_setBytePixels:nativeContext
+    |imgRep x y w h clrModel bytes offs i2
+     img depth cmap rgbMap opaque transparentColorIndex
+     scanLineWidth nBytes srcIdx dstIdx|
+
+    imgRep := nativeContext receiver.
+    x := nativeContext argAt:1.
+    y := nativeContext argAt:2.
+    w := nativeContext argAt:3.
+    h := nativeContext argAt:4.
+    clrModel := nativeContext argAt:5.
+    bytes := nativeContext argAt:6.
+    offs := nativeContext argAt:7.  "/ offset ??
+    scanLineWidth := nativeContext argAt:8.
+
+    depth := clrModel instVarNamed:'pixel_bits'.
+    (clrModel instVarNamed:'map_size') ~~ 0 ifTrue:[
+        rgbMap := clrModel instVarNamed:'rgb'.
+        cmap := Array new:rgbMap size.
+        rgbMap
+            keysAndValuesDo:[:idx :rgb |
+                cmap at:idx put:(Color rgbValue:(rgb bitAnd:16rFFFFFF))
+            ].
+    ].
+
+    opaque := (clrModel instVarNamed:'opaque') ~~ 0.
+    opaque ifFalse:[
+        transparentColorIndex := clrModel instVarNamed:'transparent_index'
+    ].
+
+    img := imgRep instVarNamed:'pData'.
+    (img isNil or:[img == 0]) ifFalse:[
+"/        self halt
+    ].
+
+    (offs ~~ 0 or:[scanLineWidth ~~ w]) ifTrue:[
+        nBytes := ByteArray new:w*h.
+        srcIdx := offs+1.
+        dstIdx := 1.
+        1 to:h do:[:y |
+            nBytes replaceFrom:dstIdx to:(dstIdx+w-1) with:bytes startingAt:srcIdx.
+            srcIdx := srcIdx + scanLineWidth.
+            dstIdx := dstIdx + w.
+        ].
+        bytes := nBytes.
+    ].
+    img := Image width:w height:h depth:depth fromArray:bytes.
+    cmap notNil ifTrue:[
+        img colorMap:cmap.
+        img photometric:#palette
+    ].
+    opaque ifFalse:[
+        img mask:(ImageReader
+                    buildMaskFromColor:transparentColorIndex
+                    for:bytes
+                    width:w
+                    height:h)
+    ].
+
+    imgRep instVarNamed:'pData' put:img.
+    ^ 1.
+
+    "Created: / 7.1.1998 / 22:31:46 / cg"
+    "Modified: / 21.10.1998 / 00:35:45 / cg"
+!
+
+_ImageRepresentation_setIntPixels:nativeContext
+    |imgRep x y w h clrModel ints offs scanLineWidth
+     img depth cmap rgbMap opaque transparentColorIndex
+     bytes srcIdx dstIdx val red green blue
+     redMask greenMask blueMask redShift greenShift blueShift|
+
+    imgRep := nativeContext receiver.
+    x := nativeContext argAt:1.
+    y := nativeContext argAt:2.
+    w := nativeContext argAt:3.
+    h := nativeContext argAt:4.
+    clrModel := nativeContext argAt:5.
+    ints := nativeContext argAt:6.
+    offs := nativeContext argAt:7.  "/ offset ??
+    scanLineWidth := nativeContext argAt:8.  "/ scanLineWidth ??
+    opaque := false.
+offs ~~ 0 ifTrue:[
+ self halt
+].
+
+    depth := clrModel instVarNamed:'pixel_bits'.
+    clrModel class == (Java at:'java.awt.image.DirectColorModel') ifTrue:[
+    ] ifFalse:[
+        (clrModel instVarNamed:'map_size') ~~ 0 ifTrue:[
+            rgbMap := clrModel instVarNamed:'rgb'.
+            cmap := Array new:rgbMap size.
+            rgbMap
+                keysAndValuesDo:[:idx :rgb |
+                    cmap at:idx put:(Color rgbValue:(rgb bitAnd:16rFFFFFF))
+                ].
+        ].
+        opaque := (clrModel instVarNamed:'opaque') ~~ 0.
+        opaque ifFalse:[
+            transparentColorIndex := clrModel instVarNamed:'transparent_index'
+        ].
+    ].
+
+    img := imgRep instVarNamed:'pData'.
+    (img isNil or:[img == 0]) ifFalse:[
+"/        self halt.
+    ].
+
+    depth == 32 ifTrue:[
+        "/ temporary kludge - ony use 24 bits/pixel
+        bytes := ByteArray new:w*h*3.
+        srcIdx := 1.
+        dstIdx := 1.
+        redMask := clrModel instVarNamed:'red_mask'.
+        greenMask := clrModel instVarNamed:'green_mask'.
+        blueMask := clrModel instVarNamed:'blue_mask'.
+        redShift := (clrModel instVarNamed:'red_offset') negated.
+        greenShift := (clrModel instVarNamed:'green_offset') negated.
+        blueShift := (clrModel instVarNamed:'blue_offset') negated.
+
+        1 to:h do:[:y |
+            1 to:w do:[:x |
+                val := ints at:srcIdx.
+                red := (val bitAnd:redMask) bitShift:redShift.
+                green := (val bitAnd:greenMask) bitShift:greenShift.
+                blue := (val bitAnd:blueMask) bitShift:blueShift.
+                bytes at:dstIdx put:red.
+                bytes at:dstIdx+1 put:green.
+                bytes at:dstIdx+2 put:blue.
+                dstIdx := dstIdx + 3.
+                srcIdx := srcIdx + 1.
+            ].
+            srcIdx := srcIdx + (scanLineWidth - w).
+        ].
+        img := Depth24Image width:w height:h depth:24 fromArray:bytes.
+        img photometric:#rgb.
+    ] ifFalse:[
+        scanLineWidth ~~ w ifTrue:[
+            self halt
+        ].
+        img := Image width:w height:h depth:depth fromArray:ints.
+        cmap notNil ifTrue:[
+            img colorMap:cmap.
+            img photometric:#palette
+        ] ifFalse:[
+            img photometric:#rgb
+        ].
+    ].
+    opaque ifFalse:[
+        img mask:(ImageReader
+                    buildMaskFromColor:transparentColorIndex
+                    for:ints
+                    width:w
+                    height:h)
+    ].
+
+    imgRep instVarNamed:'pData' put:img.
+    ^ 1.
+
+    "Created: / 1.2.1998 / 17:38:47 / cg"
+    "Modified: / 21.10.1998 / 00:35:37 / cg"
+!
+
+_InetAddressImpl_getHostByAddr:nativeContext
+    "/ java.lang.String getHostByAddr (int)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:08:04 / cg"
+!
+
+_InetAddressImpl_getInetFamily:nativeContext
+    "/ self unimplementedNativeMethod.
+    ^ 0
+
+    "Modified: / 15.8.1997 / 17:04:43 / cg"
+    "Created: / 5.1.1998 / 02:05:48 / cg"
+!
+
+_InetAddressImpl_getLocalHostName:nativeContext
+    ""
+
+    |hostName|
+
+    hostName := OperatingSystem getHostName.
+
+    ^ (Java as_String:hostName).
+
+    "Modified: / 7.8.1997 / 21:16:55 / cg"
+    "Created: / 5.1.1998 / 02:07:03 / cg"
+!
+
+_InetAddressImpl_lookupAllHostAddr:nativeContext
+    ""
+
+    |jAddrImpl jHostName hostName addrBytes|
+
+    jAddrImpl := nativeContext receiver.
+    jHostName := nativeContext argAt:1.
+
+    hostName := Java as_ST_String:jHostName.
+    addrBytes := Socket ipAddressOfHost:hostName.
+    addrBytes isNil ifTrue:[
+        addrBytes := #[0 0 0 0] copy
+    ].
+    ^ Array with:addrBytes
+
+    "Modified: / 8.8.1997 / 12:04:25 / cg"
+    "Created: / 7.1.1998 / 18:51:31 / cg"
+!
+
+_InetAddressImpl_makeAnyLocalAddress:nativeContext
+    ""
+
+    |jAddrImpl jAddr hostName addrBytes address|
+
+    jAddrImpl := nativeContext receiver.
+    jAddr := nativeContext argAt:1.
+
+    hostName := OperatingSystem getHostName.
+    addrBytes := Socket ipAddressOfHost:hostName.
+    addrBytes isNil ifTrue:[
+        addrBytes := #[127 0 0 0].
+    ].
+    "/ MSB first into an integer.
+    address := (addrBytes at:1).
+    address := (address bitShift:8) bitOr:(addrBytes at:2).
+    address := (address bitShift:8) bitOr:(addrBytes at:3).
+    address := (address bitShift:8) bitOr:(addrBytes at:4).
+
+    jAddr instVarNamed:'hostName' put:(Java as_String:hostName).
+    jAddr instVarNamed:'address' put:address.
+    jAddr instVarNamed:'family' put:0.
+
+    ^ nil
+
+    "Created: / 5.1.1998 / 02:06:27 / cg"
+    "Modified: / 21.10.1998 / 03:30:29 / cg"
+!
+
+_InetAddress_getInetFamily:nativeContext
+    "/ self unimplementedNativeMethod.
+    ^ 0
+
+    "Modified: / 15.8.1997 / 17:04:43 / cg"
+    "Created: / 17.11.1998 / 23:54:38 / cg"
+!
+
+_InetAddress_getLocalHostName:nativeContext
+    ""
+
+    |hostName|
+
+    hostName := OperatingSystem getHostName.
+
+    ^ Java as_String:hostName.
+
+    "Modified: / 7.8.1997 / 21:16:55 / cg"
+    "Created: / 17.11.1998 / 23:54:54 / cg"
+!
+
+_InetAddress_lookupAllHostAddr:nativeContext
+    ""
+
+    |jAddrImpl jHostName hostName addrBytes|
+
+    jAddrImpl := nativeContext receiver.
+    jHostName := nativeContext argAt:1.
+
+    hostName := Java as_ST_String:jHostName.
+    addrBytes := Socket ipAddressOfHost:hostName.
+    addrBytes isNil ifTrue:[
+        addrBytes := #[0 0 0 0] copy
+    ].
+    ^ Array with:addrBytes
+
+    "Modified: / 8.8.1997 / 12:04:25 / cg"
+    "Created: / 17.11.1998 / 23:56:10 / cg"
+!
+
+_InetAddress_lookupHostByAddr:nativeContext
+    "java.lang.Object[] lookupHostByAddr (int)"
+
+JavaVM unimplementedNativeMethodSignal raise.
+
+    "Created: / 27.1.2000 / 02:59:22 / cg"
+!
+
+_InetAddress_lookupHostByName:nativeContext
+    "java.lang.Object[] lookupHostByName (java.lang.String)"
+
+JavaVM unimplementedNativeMethodSignal raise.
+
+    "Modified: / 27.1.2000 / 02:58:53 / cg"
+!
+
+_InetAddress_makeAnyLocalAddress:nativeContext
+    ""
+
+    |jAddrImpl jAddr hostName addrBytes address|
+
+    jAddrImpl := nativeContext receiver.
+    jAddr := nativeContext argAt:1.
+
+    hostName := OperatingSystem getHostName.
+    addrBytes := Socket ipAddressOfHost:hostName.
+    addrBytes isNil ifTrue:[
+        addrBytes := #[127 0 0 0].
+    ].
+    "/ MSB first into an integer.
+    address := (addrBytes at:1).
+    address := (address bitShift:8) bitOr:(addrBytes at:2).
+    address := (address bitShift:8) bitOr:(addrBytes at:3).
+    address := (address bitShift:8) bitOr:(addrBytes at:4).
+
+    jAddr instVarNamed:'hostName' put:(Java as_String:hostName).
+    jAddr instVarNamed:'address' put:address.
+    jAddr instVarNamed:'family' put:0.
+
+    ^ nil
+
+    "Modified: / 21.10.1998 / 03:30:29 / cg"
+    "Created: / 17.11.1998 / 23:54:00 / cg"
+!
+
+_Inflater_end0:nativeContext
+    "/ void end0 ()
+
+JavaVM unimplementedNativeMethodSignal raise.
+
+    "Modified: / 27.1.2000 / 03:08:47 / cg"
+    "Created: / 27.1.2000 / 03:11:21 / cg"
+!
+
+_Inflater_getAdler0:nativeContext
+    "/ int getAdler0 ()
+
+JavaVM unimplementedNativeMethodSignal raise.
+
+    "Modified: / 27.1.2000 / 03:08:47 / cg"
+    "Created: / 27.1.2000 / 03:12:15 / cg"
+!
+
+_Inflater_getTotalIn0:nativeContext
+    "/ int getTotalIn0 ()
+
+JavaVM unimplementedNativeMethodSignal raise.
+
+    "Created: / 27.1.2000 / 03:10:50 / cg"
+    "Modified: / 27.1.2000 / 03:11:08 / cg"
+!
+
+_Inflater_getTotalOut0:nativeContext
+    "/ int getTotalOut0 ()
+
+JavaVM unimplementedNativeMethodSignal raise.
+
+    "Modified: / 27.1.2000 / 03:08:47 / cg"
+    "Created: / 27.1.2000 / 03:12:01 / cg"
+!
+
+_Inflater_inflate0:nativeContext
+    "/ int inflate0 (byte[] int int)
+
+JavaVM unimplementedNativeMethodSignal raise.
+
+    "Modified: / 27.1.2000 / 03:08:47 / cg"
+    "Created: / 27.1.2000 / 03:11:39 / cg"
+!
+
+_Inflater_reset0:nativeContext
+    "/ void reset0 ()
+
+JavaVM unimplementedNativeMethodSignal raise.
+
+    "Modified: / 27.1.2000 / 03:08:47 / cg"
+    "Created: / 27.1.2000 / 03:11:02 / cg"
+!
+
+_Inflater_setDictionary0:nativeContext
+    "/ void setDictionary0 (byte[] int int)
+
+JavaVM unimplementedNativeMethodSignal raise.
+
+    "Modified: / 27.1.2000 / 03:08:47 / cg"
+    "Created: / 27.1.2000 / 03:10:33 / cg"
+!
+
+_InputThread_run:nativeContext
+    self _WToolkit_eventLoop:nativeContext.
+
+    "Created: / 28.1.1998 / 22:34:47 / cg"
+    "Modified: / 28.1.1998 / 22:35:16 / cg"
+!
+
+_Introspector_getMethodDescriptor:nativeContext
+    "java.lang.String getMethodDescriptor (java.lang.reflect.Method)"
+
+JavaVM unimplementedNativeMethodSignal raise.
+
+    "Created: / 27.1.2000 / 02:47:43 / cg"
+!
+
+_Introspector_getMethodParameterCount:nativeContext
+    "int getMethodParameterCount (java.lang.reflect.Method)"
+
+JavaVM unimplementedNativeMethodSignal raise.
+
+    "Created: / 27.1.2000 / 02:49:15 / cg"
+!
+
+_Introspector_getPublicDeclaredMethods0:nativeContext
+    "java.lang.reflect.Method[] getPublicDeclaredMethods0 (java.lang.Class)"
+
+JavaVM unimplementedNativeMethodSignal raise.
+
+    "Created: / 27.1.2000 / 02:48:49 / cg"
+!
+
+_JPEGImageDecoder_readImage:nativeContext
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 18:53:30 / cg"
+    "Modified: / 12.11.1998 / 18:53:40 / cg"
+!
+
+_MButtonPeer_create:nativeContext
+    ^ self _WButtonPeer_create:nativeContext
+!
+
+_MCanvasPeer_create:nativeContext
+    |jCanvasPeer jFrame frame subView|
+
+    jCanvasPeer := nativeContext receiver.
+
+    jFrame := nativeContext argAt:1.
+    jFrame isNil ifTrue:[
+        self halt:'no frame in canvasPeer create'.
+        self internalError:'no frame in canvasPeer create'.
+        ^ self.
+    ].
+    frame := jFrame instVarNamed:'pData'.
+
+    subView := JavaView in:frame.
+    subView delegate:self.
+    subView javaPeer:jCanvasPeer.
+
+    self createdWindowsView:subView for:jCanvasPeer.
+
+    WindowCreationTrace == true ifTrue:[
+        'WCanvasPeer_create: ' print. frame print. ' -> ' print. subView printNL.
+    ].
+
+    "Modified: / 16.1.1998 / 13:40:00 / cg"
+    "Created: / 18.11.1998 / 00:14:44 / cg"
+!
+
+_MComponentPeer_cacheInit:nativeContext
+
+    "Created: / 28.1.1998 / 22:22:30 / cg"
+!
+
+_MComponentPeer_handleEvent:nativeContext
+    ^ self _WComponentPeer_handleEvent:nativeContext
+
+    "Created: / 18.11.1998 / 00:21:17 / cg"
+!
+
+_MComponentPeer_nativeHandleEvent:nativeContext
+    ^ self _WComponentPeer_nativeHandleEvent:nativeContext
+!
+
+_MComponentPeer_pHide:nativeContext
+    ^ self _WComponentPeer_hide:nativeContext
+
+    "Created: / 18.11.1998 / 00:15:18 / cg"
+!
+
+_MComponentPeer_pInitialize:nativeContext
+
+    "Created: / 28.1.1998 / 22:27:25 / cg"
+!
+
+_MComponentPeer_pReshape:nativeContext
+    self commonReshapeComponent:nativeContext
+
+    "Created: / 18.11.1998 / 00:18:17 / cg"
+!
+
+_MComponentPeer_pSetBackground:nativeContext
+    |view jClr rgb clr|
+
+    view := self viewForWPeer:nativeContext.
+    jClr := nativeContext argAt:1.
+    rgb := jClr instVarNamed:'value'.
+
+    clr := Color rgbValue:rgb.
+
+    clr := clr on:(view device).
+    (view isKindOf:ScrollableView) ifTrue:[
+        view := view scrolledView
+    ].
+    view viewBackground:clr.
+    view backgroundPaint:clr.
+!
+
+_MComponentPeer_pSetFont:nativeContext
+    |view jFont stFont name style size|
+
+    view := self viewForWPeer:nativeContext.
+    jFont := nativeContext argAt:1.
+
+    stFont := jFont instVarNamed:'pData'.
+    (stFont isNil or:[stFont == 0]) ifTrue:[
+        name := jFont instVarNamed:'name'.
+        style := jFont instVarNamed:'style'.
+        size := jFont instVarNamed:'size'.
+
+        stFont := self replacementFontFor:(Java as_ST_String:name) style:style size:size.
+        jFont instVarNamed:'pData' put:stFont.
+    ].
+    view font:stFont.
+
+    ^ nil
+!
+
+_MComponentPeer_pSetForeground:nativeContext
+    |view jClr rgb clr|
+
+    view := self viewForWPeer:nativeContext.
+    jClr := nativeContext argAt:1.
+    rgb := jClr instVarNamed:'value'.
+
+    clr := Color rgbValue:rgb.
+
+    clr := clr on:(view device).
+
+    (view isKindOf:ScrollableView) ifTrue:[
+        view := view scrolledView
+    ].
+    view foregroundColor:clr.
+!
+
+_MComponentPeer_pShow:nativeContext
+    |view|
+
+    view := self viewForWPeer:nativeContext.
+
+    "/ frame views are under my browsers own control
+    (view isMemberOf:JavaEmbeddedFrameView) ifFalse:[
+        view beVisible.
+        view realize.
+    ].
+
+"/    view windowGroup notNil ifTrue:[
+"/        windowServer addGroup:(view windowGroup)
+"/    ].
+
+    ^ nil
+
+"/ self halt.
+
+    "Modified: / 25.1.1998 / 09:54:07 / cg"
+    "Created: / 18.11.1998 / 00:21:51 / cg"
+!
+
+_MComponentPeer_setBackground:nativeContext
+    |jClr rgb clr view|
+
+    view := self viewForWPeer:nativeContext.
+
+    jClr := nativeContext argAt:1.
+    rgb := jClr instVarNamed:'value'.
+"/ self halt.
+    clr := Color rgbValue:rgb.
+
+
+    clr := clr on:(view device).
+
+    (view isKindOf:ScrollableView) ifTrue:[
+        view := view scrolledView
+    ].
+    view viewBackground:clr.
+    view backgroundPaint:clr.
+
+    "Created: / 17.11.1998 / 23:49:41 / cg"
+!
+
+_MComponentPeer_setCursor:nativeContext
+
+    "Created: / 28.1.1998 / 22:27:35 / cg"
+!
+
+_MComponentPeer_setFont:nativeContext
+    |view|
+
+    view := self viewForWPeer:nativeContext.
+"/ self halt.
+
+    "Modified: / 25.1.1998 / 01:22:19 / cg"
+    "Created: / 17.11.1998 / 23:43:48 / cg"
+!
+
+_MComponentPeer_setForeground:nativeContext
+    |jClr rgb clr view|
+
+    view := self viewForWPeer:nativeContext.
+
+    jClr := nativeContext argAt:1.
+    rgb := jClr instVarNamed:'value'.
+"/ self halt.
+    clr := Color rgbValue:rgb.
+
+    clr := clr on:(view device).
+
+    view paint:clr.
+
+    "Created: / 17.11.1998 / 23:50:31 / cg"
+    "Modified: / 17.11.1998 / 23:57:29 / cg"
+!
+
+_MFramePeer_create:nativeContext
+    ^ self _WFramePeer_create:nativeContext
+
+    "Created: / 28.1.1998 / 22:25:44 / cg"
+!
+
+_MFramePeer_getWindowBackgroundColor:nativeContext
+    ^ View defaultViewBackgroundColor rgbValue.
+
+    "Created: / 17.11.1998 / 23:55:42 / cg"
+!
+
+_MFramePeer_pHide:nativeContext
+    ^ self _WComponentPeer_hide:nativeContext
+
+    "Created: / 28.1.1998 / 22:27:04 / cg"
+!
+
+_MFramePeer_pReshape:nativeContext
+    self commonReshapeComponent:nativeContext
+
+    "Created: / 28.1.1998 / 22:28:00 / cg"
+    "Modified: / 28.1.1998 / 22:29:34 / cg"
+!
+
+_MFramePeer_pSetTitle:nativeContext
+    self _WWindowPeer__setTitle:nativeContext
+
+    "Created: / 28.1.1998 / 22:30:23 / cg"
+!
+
+_MFramePeer_pShow:nativeContext
+    |view|
+
+    view := self viewForWPeer:nativeContext.
+
+    "/ frame views are under my browsers own control
+    (view isMemberOf:JavaEmbeddedFrameView) ifFalse:[
+        view beVisible.
+        view realize.
+    ].
+
+"/    view windowGroup notNil ifTrue:[
+"/        windowServer addGroup:(view windowGroup)
+"/    ].
+
+    ^ nil
+
+"/ self halt.
+
+    "Modified: / 25.1.1998 / 09:54:07 / cg"
+    "Created: / 18.11.1998 / 00:19:59 / cg"
+!
+
+_MFramePeer_setInsets:nativeContext
+
+    "Created: / 17.11.1998 / 23:55:32 / cg"
+!
+
+_MFramePeer_setResizable:nativeContext
+    |view onOff|
+
+    view := self viewForWPeer:nativeContext.
+
+    onOff := (nativeContext argAt:1) == 1.
+    view isTopView ifTrue:[
+        onOff ifTrue:[
+            view minExtent:10@10.
+            view maxExtent:(Screen current extent).
+        ] ifFalse:[
+            view minExtent:view extent.
+            view maxExtent:view extent.
+        ]
+    ] ifFalse:[
+        (view isMemberOf:JavaEmbeddedFrameView) ifFalse:[
+            self halt.
+        ]
+    ].
+
+"/ 'JAVA: WWindowPeer_setResizable: ' print. view print. ' yes/no: ' print. onOff printNL.
+
+    ^ nil
+
+    "Modified: / 16.1.1998 / 18:08:00 / cg"
+    "Created: / 17.11.1998 / 23:51:45 / cg"
+!
+
+_MToolkit_callbackLoop: nativeContext
+    | toolKit |
+    toolKit := nativeContext receiver.
+    ^ self.
+    self halt.
+        self halt: 'monitors has changer, update me if you know how and why'.
+    "self wakeup: toolKit."
+    self halt.
+    (JavaEventThread notNil and: [ JavaEventThread isDead not ]) ifTrue: [
+        'JavaVM [warning]: oops - two threads executing eventLoop' errorPrintCR.
+    ].
+    JavaEventThread := Processor activeProcess.
+    [
+        [ true ] whileTrue: [
+            AbortSignal handle: [:ex | ex return ] do: [ self doWindowsEventThread. ]
+        ].
+    ] valueNowOrOnUnwindDo: [ JavaEventThread := nil. ].
+
+    "Created: / 17-11-1998 / 23:58:33 / cg"
+    "Modified: / 08-01-1999 / 17:08:35 / cg"
+    "Modified: / 22-11-2011 / 13:25:18 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+_MToolkit_eventLoop: nativeContext
+    | toolKit |
+    (JavaEventThread notNil and: [ JavaEventThread isDead not ]) ifTrue: [
+        'JavaVM [warning]: oops - two threads executing eventLoop' errorPrintCR.
+    ].
+    toolKit := nativeContext receiver.
+    self halt: 'monitors has changer, update me if you know how and why'.
+    "self wakeup: toolKit."
+    self halt.
+    JavaEventThread := Processor activeProcess.
+    [
+        [ true ] whileTrue: [
+            AbortSignal handle: [:ex | ex return ] do: [ self doWindowsEventThread. ]
+        ].
+    ] valueNowOrOnUnwindDo: [ JavaEventThread := nil. ].
+
+    "Created: / 17-11-1998 / 23:04:29 / cg"
+    "Modified: / 08-01-1999 / 17:08:21 / cg"
+    "Modified: / 22-11-2011 / 13:24:56 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+_MToolkit_init:nativeContext
+
+    "Created: / 28.1.1998 / 22:21:54 / cg"
+!
+
+_MToolkit_loadSystemColors:nativeContext
+    ^ self _WToolkit_loadSystemColors:nativeContext
+!
+
+_MToolkit_run:nativeContext
+
+    "Created: / 28.1.1998 / 22:22:10 / cg"
+!
+
+_Math_IEEEremainder:nativeContext
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 18:52:36 / cg"
+!
+
+_Math_acos:nativeContext
+    "arc cosine"
+
+    |dVal|
+
+    dVal := nativeContext argAt:1.
+"/    (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
+"/        dVal isReal ifTrue:[
+"/            'JAVAVM [info]: missing double flag in Math>>acos' infoPrintCR.
+"/        ] ifFalse:[
+"/            self halt:'expected double arg'
+"/        ]
+"/    ].
+    ^ dVal arcCos
+
+    "Created: / 7.5.1998 / 00:34:50 / cg"
+    "Modified: / 11.11.1998 / 15:08:20 / cg"
+!
+
+_Math_asin:nativeContext
+    "arc sine"
+
+    |dVal|
+
+    dVal := nativeContext argAt:1.
+"/    (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
+"/        dVal isReal ifTrue:[
+"/            'JAVAVM [info]: missing double flag in Math>>asin' infoPrintCR.
+"/        ] ifFalse:[
+"/            self halt:'expected double arg'
+"/        ]
+"/    ].
+    ^ dVal arcSin
+
+    "Created: / 7.5.1998 / 00:34:26 / cg"
+    "Modified: / 11.11.1998 / 15:08:15 / cg"
+!
+
+_Math_atan2:nativeContext
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 18:52:52 / cg"
+!
+
+_Math_atan:nativeContext
+    "arc tangens"
+
+    |dVal|
+
+    dVal := nativeContext argAt:1.
+"/    (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
+"/        dVal isReal ifTrue:[
+"/            'JAVAVM [info]: missing double flag in Math>>atan' infoPrintCR.
+"/        ] ifFalse:[
+"/            self halt:'expected double arg'
+"/        ]
+"/    ].
+    ^ dVal arcTan
+
+    "Created: / 6.2.1998 / 01:24:12 / cg"
+    "Modified: / 11.11.1998 / 15:08:11 / cg"
+!
+
+_Math_ceil:nativeContext
+    "ceiling"
+
+    |dVal|
+
+    dVal := nativeContext argAt:1.
+"/    (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
+"/        dVal isReal ifTrue:[
+"/            'JAVAVM [info]: missing double flag in Math>>ceil' infoPrintCR.
+"/        ] ifFalse:[
+"/            self halt:'expected double arg'
+"/        ]
+"/    ].
+    ^ dVal ceilingAsFloat
+
+    "Created: / 7.1.1998 / 15:43:00 / cg"
+    "Modified: / 11.11.1998 / 15:08:04 / cg"
+!
+
+_Math_cos:nativeContext
+    "cosine"
+
+    |dVal|
+
+    dVal := nativeContext argAt:1.
+"/    (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
+"/        dVal isReal ifTrue:[
+"/            'JAVAVM [info]: missing double flag in Math>>cos' infoPrintCR.
+"/        ] ifFalse:[
+"/            self halt:'expected double arg'
+"/        ]
+"/    ].
+    ^ dVal cos
+
+    "Created: / 7.1.1998 / 15:41:30 / cg"
+    "Modified: / 11.11.1998 / 15:07:59 / cg"
+!
+
+_Math_exp:nativeContext
+    "exponential"
+
+    |dVal|
+
+    dVal := nativeContext argAt:1.
+"/    (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
+"/        dVal isReal ifTrue:[
+"/            'JAVAVM [info]: missing double flag in Math>>exp' infoPrintCR.
+"/        ] ifFalse:[
+"/            self halt:'expected double arg'
+"/        ]
+"/    ].
+    ^ dVal exp
+
+    "Created: / 7.5.1998 / 00:36:19 / cg"
+    "Modified: / 11.11.1998 / 15:07:50 / cg"
+!
+
+_Math_floor:nativeContext
+    "floor"
+
+    |dVal|
+
+    dVal := nativeContext argAt:1.
+"/    (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
+"/        dVal isReal ifTrue:[
+"/            'JAVAVM [info]: missing double flag in Math>>floor' infoPrintCR.
+"/        ] ifFalse:[
+"/            self halt:'expected double arg'
+"/        ]
+"/    ].
+    ^ dVal floorAsFloat
+
+    "Created: / 7.1.1998 / 19:09:21 / cg"
+    "Modified: / 11.11.1998 / 15:07:45 / cg"
+!
+
+_Math_log:nativeContext
+    "natural logarithm"
+
+    |dVal|
+
+    dVal := nativeContext argAt:1.
+"/    (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
+"/        dVal isReal ifTrue:[
+"/            'JAVAVM [info]: missing double flag in Math>>log' infoPrintCR.
+"/        ] ifFalse:[
+"/            self halt:'expected double arg'
+"/        ]
+"/    ].
+    ^ dVal ln
+
+    "Created: / 7.1.1998 / 15:42:19 / cg"
+    "Modified: / 30.12.1998 / 17:41:42 / cg"
+!
+
+_Math_pow:nativeContext
+    "power"
+
+    |dVal1 dVal2|
+
+    dVal1 := nativeContext argAt:1.
+"/    (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
+"/        dVal1 isReal ifTrue:[
+"/            'JAVAVM [info]: missing double flag in Math>>pow' infoPrintCR.
+"/        ] ifFalse:[
+"/            self halt:'expected double arg'
+"/        ]
+"/    ].
+    dVal2 := nativeContext argAt:3.
+"/    (nativeContext argAt:4) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
+"/        dVal2 isReal ifTrue:[
+"/            'JAVAVM [info]: missing double flag in Math>>pow' infoPrintCR.
+"/        ] ifFalse:[
+"/            self halt:'expected double arg'
+"/        ]
+"/    ].
+    ^ dVal1 raisedTo:dVal2
+
+    "Created: / 7.1.1998 / 15:44:13 / cg"
+    "Modified: / 11.11.1998 / 15:07:33 / cg"
+!
+
+_Math_rint:nativeContext
+    |dVal|
+
+    dVal := nativeContext argAt:1.
+    ^ dVal rounded asFloat.
+!
+
+_Math_sin:nativeContext
+    "sine"
+
+    |dVal|
+
+    dVal := nativeContext argAt:1.
+"/    (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
+"/        dVal isReal ifTrue:[
+"/            'JAVAVM [info]: missing double flag in Math>>sin' infoPrintCR.
+"/        ] ifFalse:[
+"/            self halt:'expected double arg'
+"/        ]
+"/    ].
+    ^ dVal sin
+
+    "Created: / 7.1.1998 / 15:41:40 / cg"
+    "Modified: / 11.11.1998 / 15:07:09 / cg"
+!
+
+_Math_sqrt:nativeContext
+    "square root"
+
+    |dVal|
+
+    dVal := nativeContext argAt:1.
+"/    (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
+"/        dVal isReal ifTrue:[
+"/            'JAVAVM [info]: missing double flag in Math>>sqrt' infoPrintCR.
+"/        ] ifFalse:[
+"/            self halt:'expected double arg'
+"/        ]
+"/    ].
+
+    "/ how about domain errors ?
+    dVal < 0 ifTrue:[
+        ^ 0.0
+    ].
+    ^ dVal sqrt
+
+    "Created: / 7.1.1998 / 15:42:40 / cg"
+    "Modified: / 29.12.1998 / 13:22:36 / cg"
+!
+
+_Math_tan:nativeContext
+    "tangent"
+
+    |dVal|
+
+    dVal := nativeContext argAt:1.
+"/    (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
+"/        dVal isReal ifTrue:[
+"/            'JAVAVM [info]: missing double flag in Math>>tan' infoPrintCR.
+"/        ] ifFalse:[
+"/            self halt:'expected double arg'
+"/        ]
+"/    ].
+    ^ dVal tan
+
+    "Created: / 7.5.1998 / 00:34:03 / cg"
+    "Modified: / 11.11.1998 / 15:07:14 / cg"
+!
+
+_MemoryAdvice_register0:nativeContext
+    "private native void register0()"
+
+    "/ UnimplementedNativeMethodSignal raise
+!
+
+_Method_getModifiers:nativeContext
+    |jMethod mthd retVal|
+
+    jMethod := nativeContext receiver.
+
+    mthd := JavaMethods at:jMethod ifAbsent:nil.
+    mthd isNil ifTrue:[
+        self halt.
+        ^ 0
+    ].
+    ^ mthd accessFlags
+
+    "Modified: / 9.4.1998 / 17:50:01 / cg"
+!
+
+_MozillaAppletContext_pMochaOnLoad:nativeContext
+    |id|
+
+    id := nativeContext argAt:1.
+"/ 'JAVA: MozillaAppletContext_pMochaOnLoad: ' print. id printNL.
+    ^ nil
+
+    "Created: / 6.1.1998 / 20:37:13 / cg"
+    "Modified: / 6.2.1998 / 02:13:09 / cg"
+!
+
+_MozillaAppletContext_pShowDocument:nativeContext
+    |jAppletContext s1 s2 s3 js|
+
+    jAppletContext := nativeContext receiver.
+    js := nativeContext argAt:1.
+    s1 := Java as_ST_String:js.
+    js := nativeContext argAt:2.
+    s2 := Java as_ST_String:js.
+    js := nativeContext argAt:3.
+    s2 := Java as_ST_String:js.
+
+    "/ somehow pass it to the html browser ....
+Transcript show:'pShowDocument: '; show:s1; show:' / ';
+           show:s2; show:' / '; showCR:s3.
+
+    ^ nil
+
+    "Created: / 29.3.1998 / 15:53:17 / cg"
+    "Modified: / 29.12.1998 / 13:32:41 / cg"
+!
+
+_MozillaAppletContext_pShowStatus:nativeContext
+    |s js|
+
+    js := nativeContext argAt:1.
+    js isNil ifTrue:[
+        s := ''
+    ] ifFalse:[
+        s := Java as_ST_String:js.
+    ].
+
+    self activityNotification:s.
+"/ Transcript showCR:s.
+    ^ nil
+
+    "Created: / 6.1.1998 / 18:31:34 / cg"
+    "Modified: / 22.10.1998 / 01:17:46 / cg"
+!
+
+_MozillaAppletContext_setConsoleState0:nativeContext
+    "/ void setConsoleState0 (int)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:23:22 / cg"
+!
+
+_ObjectInputStream_allocateNewArray:nativeContext
+    "/ java.lang.Object allocateNewArray (java.lang.Class int)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Modified: / 12.11.1998 / 19:01:48 / cg"
+    "Created: / 12.11.1998 / 19:02:52 / cg"
+!
+
+_ObjectInputStream_allocateNewObject:nativeContext
+    "/ java.lang.Object allocateNewObject (java.lang.Class java.lang.Class)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Modified: / 12.11.1998 / 19:01:48 / cg"
+    "Created: / 12.11.1998 / 19:02:40 / cg"
+!
+
+_ObjectInputStream_inputClassFields:nativeContext
+    "/ void inputClassFields (java.lang.Object java.lang.Class int[])
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Modified: / 12.11.1998 / 19:01:48 / cg"
+    "Created: / 12.11.1998 / 19:02:22 / cg"
+!
+
+_ObjectInputStream_invokeDefaultReadObject:nativeContext
+    "/ void invokeDefaultReadObject (java.lang.Object java.lang.Class)
+
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 27.1.2000 / 03:00:47 / cg"
+!
+
+_ObjectInputStream_invokeObjectReader:nativeContext
+    "/ boolean invokeObjectReader (java.lang.Object java.lang.Class)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Modified: / 12.11.1998 / 19:01:48 / cg"
+    "Created: / 12.11.1998 / 19:03:06 / cg"
+!
+
+_ObjectInputStream_invokeReadObject:nativeContext
+    "/ void invokeReadObject (java.lang.Object java.lang.Class)
+
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 27.1.2000 / 03:01:02 / cg"
+!
+
+_ObjectInputStream_loadClass0:nativeContext
+    "/ java.lang.Class loadClass0 (java.lang.Class java.lang.String)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:01:15 / cg"
+    "Modified: / 12.11.1998 / 19:01:48 / cg"
+!
+
+_ObjectOutputStream_invokeDefaultWriteObject:nativeContext
+    "/ void invokeDefaultWriteObject (java.lang.Object java.lang.Class)
+
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 27.1.2000 / 03:01:36 / cg"
+!
+
+_ObjectOutputStream_invokeObjectWriter:nativeContext
+    "/ boolean invokeObjectWriter (java.lang.Object java.lang.Class)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:00:36 / cg"
+    "Modified: / 12.11.1998 / 19:01:45 / cg"
+!
+
+_ObjectOutputStream_invokeWriteObject:nativeContext
+    "/ void invokeWriteObject (java.lang.Object java.lang.Class)
+
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 27.1.2000 / 03:01:52 / cg"
+!
+
+_ObjectOutputStream_outputClassFields:nativeContext
+    "/ void outputClassFields (java.lang.Object java.lang.Class int[])
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:00:09 / cg"
+    "Modified: / 12.11.1998 / 19:01:42 / cg"
+!
+
+_ObjectStreamClass_doMismatchedRead:nativeContext
+    "/ void doMismatchedRead (java.io.ObjectInputStream java.lang.Object)
+
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 27.1.2000 / 02:50:55 / cg"
+!
+
+_ObjectStreamClass_findObjectMethod0:nativeContext
+    "/ boolean findObjectMethod0 (java.lang.Class int)
+
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 27.1.2000 / 02:51:50 / cg"
+!
+
+_ObjectStreamClass_getClassAccess:nativeContext
+    "/ int getClassAccess (java.lang.Class)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Modified: / 12.11.1998 / 19:01:48 / cg"
+    "Created: / 12.11.1998 / 19:04:19 / cg"
+!
+
+_ObjectStreamClass_getClassDefinedUID:nativeContext
+    "/ long getClassDefinedUID (java.lang.Class)
+
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 27.1.2000 / 02:51:33 / cg"
+!
+
+_ObjectStreamClass_getFieldAccess:nativeContext
+    "/ int getFieldAccess (java.lang.Class java.lang.String)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Modified: / 12.11.1998 / 19:01:48 / cg"
+    "Created: / 12.11.1998 / 19:05:19 / cg"
+!
+
+_ObjectStreamClass_getFieldSignatures:nativeContext
+    "/ java.lang.String[] getFieldSignatures (java.lang.Class)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Modified: / 12.11.1998 / 19:01:48 / cg"
+    "Created: / 12.11.1998 / 19:05:04 / cg"
+!
+
+_ObjectStreamClass_getFields0:nativeContext
+    "/ java.io.ObjectStreamField[] getFields0 (java.lang.Class)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Modified: / 12.11.1998 / 19:01:48 / cg"
+    "Created: / 12.11.1998 / 19:05:32 / cg"
+!
+
+_ObjectStreamClass_getMethodAccess:nativeContext
+    "/ int getMethodAccess (java.lang.Class java.lang.String)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Modified: / 12.11.1998 / 19:01:48 / cg"
+    "Created: / 12.11.1998 / 19:04:51 / cg"
+!
+
+_ObjectStreamClass_getMethodSignatures:nativeContext
+    "/ java.lang.String[] getMethodSignatures (java.lang.Class)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Modified: / 12.11.1998 / 19:01:48 / cg"
+    "Created: / 12.11.1998 / 19:04:34 / cg"
+!
+
+_ObjectStreamClass_getSerialVersionUID:nativeContext
+    "/ long getSerialVersionUID (java.lang.Class)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Modified: / 12.11.1998 / 19:01:48 / cg"
+    "Created: / 12.11.1998 / 19:05:43 / cg"
+!
+
+_ObjectStreamClass_hasWriteObject:nativeContext
+    "/ boolean hasWriteObject (java.lang.Class)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Modified: / 12.11.1998 / 19:01:48 / cg"
+    "Created: / 12.11.1998 / 19:05:53 / cg"
+!
+
+_OffScreenImageSource_sendPixels:nativeContext
+    "/ self halt.
+    "/ UnimplementedNativeMethodSignal raise
+
+    "Modified: / 16.1.1998 / 18:22:23 / cg"
+    "Created: / 17.1.1998 / 12:36:25 / cg"
+!
+
+_PackedColorModel_initIDs:nativeContext
+    "/ new with jdk1.2 ...
+
+    "Created: / 28.1.1998 / 22:19:35 / cg"
+!
+
+_PlainDatagramSocketImpl_bind:nativeContext
+    |jsock jaddr port sock hostName ok err|
+
+    jsock := nativeContext receiver.
+    port := nativeContext argAt:1.
+    jaddr := nativeContext argAt:2.
+
+    hostName := jaddr instVarNamed:'hostName'.
+    hostName isNil ifTrue:[
+        self halt.
+    ] ifFalse:[
+        hostName := Java as_ST_String:hostName
+    ].
+
+    sock := self validateFile:jsock.
+    sock notNil ifTrue:[
+        FileIOTrace ifTrue:[
+            ('JAVA: socket bind to ' , hostName printString, ' port ' , port printString) infoPrintCR
+        ].
+
+        ok := sock bindTo:port address:nil "hostName".
+        ok ifFalse:[
+            err := OperatingSystem lastErrorString.
+            Transcript showCR:'sock err: ' , err printString.
+            self throwIOExceptionWithMessage:'bind failed'.
+        ]
+    ].
+
+    "Created: / 4.2.1998 / 15:06:20 / cg"
+    "Modified: / 30.12.1998 / 20:10:16 / cg"
+!
+
+_PlainDatagramSocketImpl_join:nativeContext
+    "/ native void join (InetAddress arg1)
+
+    |jsock addr sock ok err|
+
+    jsock := nativeContext receiver.
+    addr := nativeContext argAt:1.
+
+    sock := self validateFile:jsock.
+    sock notNil ifTrue:[
+        FileIOTrace ifTrue:[
+            ('JAVA: socket join ' , addr printString) infoPrintCR
+        ].
+        self throwIOExceptionWithMessage:'unimplemented: join'.
+self halt.
+        ^ nil.  "/ void
+    ].
+
+    "Created: / 4.2.1998 / 15:06:20 / cg"
+    "Modified: / 30.12.1998 / 20:10:16 / cg"
+!
+
+_PlainDatagramSocketImpl_receive:nativeContext
+    |jsock jdatagramPacket sock ok|
+
+    jsock := nativeContext receiver.
+    jdatagramPacket := nativeContext argAt:1.
+
+    sock := self validateFile:jsock.
+    sock notNil ifTrue:[
+        FileIOTrace ifTrue:[
+            ('JAVA: socket receive') infoPrintCR
+        ].
+        ^ -1.
+    ].
+    ^ -1
+
+    "Created: / 4.2.1998 / 15:06:20 / cg"
+    "Modified: / 30.12.1998 / 20:10:16 / cg"
+!
+
+_PlainDatagramSocketImpl_socketGetOption:nativeContext
+    |jsock opt port sock hostName ok err|
+
+    jsock := nativeContext receiver.
+    opt := nativeContext argAt:1.
+
+    sock := self validateFile:jsock.
+    sock notNil ifTrue:[
+        FileIOTrace ifTrue:[
+            ('JAVA: socket getOption ' , opt printString) infoPrintCR
+        ].
+        self throwIOExceptionWithMessage:'unimplemented: getOption'.
+self halt.
+        ^ -1.
+    ].
+    ^ -1.
+
+    "Created: / 4.2.1998 / 15:06:20 / cg"
+    "Modified: / 30.12.1998 / 20:10:16 / cg"
+!
+
+_PlainSocketImpl_socketAvailable:nativeContext
+    |jSock sock n|
+
+    jSock := nativeContext receiver.
+
+    sock := self validateFile:jSock.
+    sock isNil ifTrue:[
+        self throwIOExceptionWithMessage:'socketAvailable on closed socket'.
+        ^ self.
+    ].
+
+    n := sock numAvailable.
+    ^ n
+
+    "Created: / 4.2.1998 / 16:58:49 / cg"
+    "Modified: / 30.12.1998 / 20:10:08 / cg"
+!
+
+_PlainSocketImpl_socketClose:nativeContext
+    |jsock sock|
+
+    jsock := nativeContext receiver.
+
+    sock := self validateFile:jsock.
+    sock notNil ifTrue:[
+        FileIOTrace ifTrue:[
+            'JAVA: close socket' infoPrintCR
+        ].
+        sock close.
+    ].
+
+    "Modified: / 21.8.1997 / 17:09:40 / cg"
+    "Created: / 25.1.1998 / 20:04:24 / cg"
+!
+
+_PlatformFont_initIDs:nativeContext
+    "/ new with jdk1.2 ...
+
+    "Created: / 28.1.1998 / 22:30:41 / cg"
+!
+
+_PrintStream_isOutputStreamLocalised:nativeContext
+    "/ boolean isOutputStreamLocalised (java.io.DataOutputStream)
+
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 27.1.2000 / 03:00:20 / cg"
+!
+
+_RandomAccessFile_close:nativeContext
+    ^ self anyStream_close:nativeContext
+
+    "Created: / 4.2.1998 / 13:26:53 / cg"
+    "Modified: / 4.2.1998 / 15:21:08 / cg"
+!
+
+_Runtime_buildLibName:nativeContext
+    |jPath jFileName path fileName libName|
+
+    jPath := nativeContext argAt:1.
+    jFileName := nativeContext argAt:2.
+
+    path := Java as_ST_String:jPath.
+    fileName := Java as_ST_String:jFileName.
+
+    path = '__builtIn__' ifTrue:[
+        libName := path , '/' , fileName
+    ] ifFalse:[
+        libName := path , '/lib' , fileName , '.so'.
+    ].
+    ^ Java as_String:libName.
+
+    "Modified: / 8.8.1997 / 12:05:05 / cg"
+    "Created: / 4.1.1998 / 19:07:14 / cg"
+!
+
+_Runtime_execInternal: nativeContext
+    "Run a unix-command; return a process object."
+
+    | cmdAndArgArray  envArray  cmd  jProcessClass  jProcess |
+
+    cmdAndArgArray := nativeContext argAt: 1.
+    envArray := nativeContext argAt: 2.
+    cmd := cmdAndArgArray at: 1.
+    OperatingSystem isUNIXlike ifTrue: [
+        jProcessClass := self classForName: 'java.lang.UNIXProcess'.
+    ] ifFalse: [ jProcessClass := Java classForName: 'java.lang.Win32Process'. ].
+
+"/
+
+    jProcessClass notNil ifTrue: [
+        self halt.
+        jProcess := jProcessClass newCleared.
+        jProcess
+            perform: #'<init>([Ljava/lang/String;[Ljava/lang/String;)V'
+            with: cmdAndArgArray
+            with: envArray.
+        ^ jProcess
+    ].
+    self halt.
+    self
+        throwIOExceptionWithMessage: 'Process execution disabled/unimplemented'.
+    ^ nil
+
+    "Created: / 15.1.1998 / 01:50:31 / cg"
+    "Modified: / 11.12.1998 / 13:09:36 / cg"
+!
+
+_Runtime_initializeLinkerInternal:nativeContext
+    "init sharedLib linker, return searchPath as javaString"
+
+    |path|
+
+    "/ mhmh - what is done here ?
+
+    path := ''.
+    LibPath do:[:comp | path size == 0 ifTrue:[
+                            path := path , comp
+                        ] ifFalse:[
+                            path := path , ':' , comp
+                        ]
+               ].
+
+    ^ Java as_String:path
+
+    "Modified: / 7.8.1997 / 21:17:03 / cg"
+    "Created: / 4.1.1998 / 17:53:15 / cg"
+!
+
+_Runtime_isInputStreamLocalised:nativeContext
+    "/ boolean isInputStreamLocalised (java.io.DataInputStream)
+
+JavaVM unimplementedNativeMethodSignal raise.
+
+    "Created: / 27.1.2000 / 03:03:01 / cg"
+!
+
+_Runtime_isOutputStreamLocalised:nativeContext
+    "/ boolean isOutputStreamLocalised (java.io.DataOutputStream)
+
+JavaVM unimplementedNativeMethodSignal raise.
+
+    "Created: / 27.1.2000 / 03:02:49 / cg"
+!
+
+_Runtime_loadFileInternal:nativeContext
+    "load a sharedLib, return boolean 0 (false) if fail; 1 (true) if ok"
+
+    |ret|
+
+    ret := self _Runtime_loadFileInternalI:nativeContext.
+    ret < 0 ifTrue:[ ret := 0 ].
+    ^ ret
+
+    "Created: / 4.1.1998 / 19:10:20 / cg"
+    "Modified: / 4.1.1998 / 19:11:04 / cg"
+!
+
+_Runtime_loadFileInternalI:nativeContext
+    "1.1b3 change; load a sharedLib like 'loadFileInternal',
+     but return integer:
+        -1   outOfMemory error
+        0    failed to load
+        1    loaded or already loaded (i.e. ok)"
+
+    |jLibName libName libHandle|
+
+    jLibName := nativeContext argAt:1.
+    libName := Java as_ST_String:jLibName.
+
+    (SimulatedLibs includes:libName) ifTrue:[
+"/        ('JAVA: builtIn libLoad simulated: ' , libName) printNL.
+        ^ 1
+    ].
+    (LoadedLibs notNil and:[LoadedLibs includesKey:libName]) ifTrue:[
+"/        ('JAVA: already loaded: ' , libName) printNL.
+        ^ 1
+    ].
+
+    libName asFilename exists ifFalse:[
+        ('JAVA: no file to load: ' , libName) printNL.
+        ^ 0
+    ].
+
+    (self confirm:'permission to load native library: ' , libName , ' ?') ifFalse:[
+        ^ 0
+    ].
+
+    libHandle := ObjectFileLoader loadLibrary:libName.
+    libHandle isNil ifTrue:[
+        ('JAVA: failed to load: ' , libName) printNL.
+        ^ 0
+    ].
+
+    LoadedLibs isNil ifTrue:[
+        LoadedLibs := Dictionary new.
+    ].
+
+    LoadedLibs at:libName put:libHandle.
+    ^ 1
+
+    "Created: / 4.1.1998 / 19:10:54 / cg"
+    "Modified: / 6.2.1998 / 03:11:59 / cg"
+!
+
+_Runtime_runFinalization:nativeContext
+    "/ void runFinalization ()
+"/    UnimplementedNativeMethodSignal raise
+
+    "Modified: / 12.11.1998 / 18:52:07 / cg"
+    "Created: / 12.11.1998 / 18:59:01 / cg"
+!
+
+_Runtime_runFinalizersOnExit0:nativeContext
+    ""
+
+    |onOff|
+
+    onOff := nativeContext argAt:1.
+    ^ 1
+
+    "Modified: / 6.2.1998 / 03:11:59 / cg"
+    "Created: / 15.10.1998 / 23:34:55 / cg"
+!
+
+_Runtime_setInputStreamLocalised:nativeContext
+
+JavaVM unimplementedNativeMethodSignal raise.
+
+    "Modified: / 27.1.2000 / 03:02:27 / cg"
+!
+
+_Runtime_setOutputStreamLocalised:nativeContext
+
+JavaVM unimplementedNativeMethodSignal raise.
+
+    "Modified: / 27.1.2000 / 03:02:32 / cg"
+!
+
+_Runtime_totalMemory:nativeContext
+    "free memory - Returns the total number of bytes"
+
+    ^ ObjectMemory oldSpaceSize + ObjectMemory newSpaceSize
+
+    "Created: / 12.1.1998 / 12:59:23 / cg"
+!
+
+_Runtime_traceInstructions:nativeContext
+    "/ void traceInstructions (boolean)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Modified: / 12.11.1998 / 18:52:07 / cg"
+    "Created: / 12.11.1998 / 18:59:18 / cg"
+!
+
+_Runtime_traceMethodCalls:nativeContext
+    "/ void traceMethodCalls (boolean)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Modified: / 12.11.1998 / 18:52:07 / cg"
+    "Created: / 12.11.1998 / 18:59:37 / cg"
+!
+
+_ScrollPane_initIDs:nativeContext
+    "/ new with jdk1.2 ...
+
+    "Created: / 28.1.1998 / 22:19:23 / cg"
+!
+
+_SecurityManager_classDepth:nativeContext
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Modified: / 12.11.1998 / 18:52:07 / cg"
+    "Created: / 12.11.1998 / 18:56:27 / cg"
+!
+
+_SecurityManager_classLoaderDepth:nativeContext
+    |con depth|
+
+    con := thisContext sender.
+    depth := 1.
+    [con notNil] whileTrue:[
+        con receiver == JavaClassReader classLoaderQuerySignal ifTrue:[
+            con selector == #handle:do: ifTrue:[
+                depth := depth + 1
+            ]
+        ].
+        con := con sender.
+    ].
+'JAVA: classLoaderDepth -> ' infoPrint. depth infoPrintCR.
+    ^ depth.
+
+    "Created: / 13.1.1998 / 09:21:46 / cg"
+    "Modified: / 13.1.1998 / 09:33:43 / cg"
+!
+
+_SecurityManager_currentClassLoader:nativeContext
+    |loader|
+
+    loader := JavaClassReader classLoaderQuerySignal query.
+"/ 'JAVA: currentClassLoader -> ' infoPrint. loader displayString infoPrintCR.
+    ^ loader.
+
+    "Created: / 13.1.1998 / 09:23:28 / cg"
+    "Modified: / 11.12.1998 / 12:39:59 / cg"
+!
+
+_SecurityManager_currentLoadedClass0:nativeContext
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Modified: / 12.11.1998 / 18:52:07 / cg"
+    "Created: / 12.11.1998 / 18:56:41 / cg"
+!
+
+_SocketInputStream_socketRead:nativeContext
+    ^ self anyStream_readBytes:nativeContext
+
+    "Created: / 25.1.1998 / 20:56:53 / cg"
+    "Modified: / 4.2.1998 / 15:52:31 / cg"
+!
+
+_SocketOutputStream_socketWrite:nativeContext
+    ^ self anyStream_writeBytes:nativeContext
+
+    "Created: / 25.1.1998 / 21:06:55 / cg"
+    "Modified: / 4.2.1998 / 15:52:40 / cg"
+!
+
+_String_compareTo:nativeContext
+    "int compareTo (java.lang.String)"
+
+    |jString1 jString2|
+
+    jString1 := nativeContext receiver.
+    jString2 := nativeContext argAt:1.
+JavaVM unimplementedNativeMethodSignal raise.
+
+    "Created: / 27.1.2000 / 02:28:59 / cg"
+!
+
+_String_equals:nativeContext
+    |jString1 jString2|
+
+    jString1 := nativeContext receiver.
+    jString2 := nativeContext argAt:1.
+    ^ (jString1 instVarAt:1) = (jString2 instVarAt:1)
+
+    "Created: / 18.11.1998 / 00:52:03 / cg"
+    "Modified: / 18.11.1998 / 00:53:01 / cg"
+!
+
+_String_equalsIgnoreCase:nativeContext
+    "boolean equalsIgnoreCase (java.lang.String)"
+
+    |jString1 jString2|
+
+self halt:'untested'.
+
+    jString1 := nativeContext receiver.
+    jString2 := nativeContext argAt:1.
+    ^ (jString1 instVarAt:1) sameAs: (jString2 instVarAt:1)
+
+    "Modified: / 18.11.1998 / 00:53:01 / cg"
+    "Created: / 27.1.2000 / 02:27:46 / cg"
+!
+
+_String_indexOf:nativeContext
+    "int indexOf (java.lang.String int)"
+
+    |jString1 jString2 idx|
+
+    jString1 := nativeContext receiver.
+    jString2 := nativeContext argAt:1.
+    idx := nativeContext argAt:2.
+JavaVM unimplementedNativeMethodSignal raise.
+
+    "Created: / 27.1.2000 / 02:30:22 / cg"
+!
+
+_String_lastIndexOf:nativeContext
+    "int lastIndexOf (java.lang.String int)"
+
+    |jString1 jString2 idx|
+
+    jString1 := nativeContext receiver.
+    jString2 := nativeContext argAt:1.
+    idx := nativeContext argAt:2.
+JavaVM unimplementedNativeMethodSignal raise.
+
+    "Created: / 27.1.2000 / 02:33:59 / cg"
+!
+
+_String_length:nativeContext
+    |jString|
+
+    jString := nativeContext receiver.
+    ^ (jString instVarAt:3)
+
+    "Created: / 18.11.1998 / 00:53:50 / cg"
+    "Modified: / 18.11.1998 / 00:54:18 / cg"
+!
+
+_String_regionMatches2:nativeContext
+    "boolean regionMatches (boolean int java.lang.String int int)"
+
+    |jString1 bool jString2 idx1 idx2|
+
+    jString1 := nativeContext receiver.
+    bool := nativeContext argAt:1.
+    jString2 := nativeContext argAt:2.
+    idx1 := nativeContext argAt:3.
+    idx2 := nativeContext argAt:4.
+JavaVM unimplementedNativeMethodSignal raise.
+
+    "Created: / 27.1.2000 / 02:33:40 / cg"
+!
+
+_String_regionMatches:nativeContext
+    "boolean regionMatches (int java.lang.String int int)"
+
+    |jString1 jString2 idx1 idx2|
+
+    jString1 := nativeContext receiver.
+    jString2 := nativeContext argAt:1.
+    idx1 := nativeContext argAt:2.
+    idx2 := nativeContext argAt:3.
+JavaVM unimplementedNativeMethodSignal raise.
+
+    "Created: / 27.1.2000 / 02:32:29 / cg"
+!
+
+_String_startsWith:nativeContext
+    "boolean startsWith (java.lang.String int)"
+
+    |jString1 jString2 idx|
+
+    jString1 := nativeContext receiver.
+    jString2 := nativeContext argAt:1.
+    idx := nativeContext argAt:2.
+JavaVM unimplementedNativeMethodSignal raise.
+
+    "Created: / 27.1.2000 / 02:31:40 / cg"
+!
+
+_SystemColor_GetSysColor:nativeContext
+    "/ int GetSysColor (int)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 27.1.2000 / 02:44:41 / cg"
+!
+
+_SystemResourceManager_getEntryFromKey:nativeContext
+    "get a resource by name"
+
+    |key s|
+
+    key := nativeContext argAt:1.
+
+    s := Java effectiveClassPath at:(key+1) ifAbsent:nil.
+    s isNil ifTrue:[^ nil].
+    ^ Java as_String:s
+
+    "Modified: / 22-11-2010 / 13:44:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_SystemResourceManager_validateSystemResource:nativeContext
+    "check a resource"
+
+    |bool str1 str2|
+
+    bool := nativeContext argAt:1.
+    str1 := nativeContext argAt:2.
+    str2 := nativeContext argAt:3.
+    ^ 1 "/ true
+!
+
+_System_getCallerClass:nativeContext
+    "/ introduced with jdk1.2
+
+    |senderContext cls|
+
+    senderContext := nativeContext sender.
+    [senderContext receiver == (Java at:'java.lang.System')] whileTrue:[
+        senderContext := senderContext sender.
+    ].
+
+    senderContext method isStatic ifTrue:[
+        cls := senderContext receiver
+    ] ifFalse:[
+        cls := senderContext receiver class
+    ].
+    cls isJavaClass ifTrue:[
+        ^ self javaClassObjectForClass:cls
+    ].
+    (cls isMemberOf:(Java at:'java.lang.Class')) ifTrue:[
+        ^ Java at:'java.lang.Class'
+    ].
+    self halt.
+    ^ nil
+
+    "Modified: / 27.1.1998 / 18:33:13 / cg"
+!
+
+_System_validateSecurityManager:nativeContext
+    "void validateSecurityManager (java.lang.SecurityManager)"
+
+JavaVM unimplementedNativeMethodSignal raise.
+
+    "Created: / 27.1.2000 / 02:43:25 / cg"
+!
+
+_ThreadGroup_initMainThreadGroup0:nativeContext
+    "void initMainThreadGroup0 (java.lang.ThreadGroup)"
+
+JavaVM unimplementedNativeMethodSignal raise.
+
+    "Created: / 27.1.2000 / 02:45:52 / cg"
+!
+
+_Thread_countStackFrames:nativeContext
+    "/ int countStackFrames ()
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:06:21 / cg"
+!
+
+_Thread_start: nativeContext
+    "start the thread"
+
+    | jThread  jName  name  stProcess |
+    jThread := nativeContext receiver.
+    (jThread instVarNamed: 'priority') < 1 ifTrue: [
+        self halt.
+        jThread instVarNamed: 'priority' put: 1.
+    ].
+    stProcess := JavaProcess
+                for: [
+                    | procName |
+                    Object abortSignal
+                        handle: [
+                            :ex |
+                            procName := stProcess name.
+                            (procName startsWith: 'JAVA-AWT-EventQueue') ifTrue: [
+                                ('JAVA [info]: thread ' , procName , ' aborted - restarting process.')
+                                    infoPrintCR.
+                                ex restart.
+                            ] ifFalse: [
+                                (stProcess == JavaScreenUpdaterThread
+                                    or: [ stProcess == JavaEventQueueThread ])
+                                        ifTrue: [
+                                            ('JAVA [info]: thread ' , procName , ' aborted - restarting process.')
+                                                infoPrintCR.
+                                            ex restart
+                                        ]
+                                        ifFalse: [ ('JAVA [info]: thread ' , procName , ' aborted.') infoPrintCR. ]
+                            ].
+                        ]
+                        do: [
+                            [
+                                JavaVM javaExceptionSignal
+                                    handle: [
+                                        :ex |
+                                        | exClass |
+                                        procName := stProcess name.
+                                        exClass := ex parameter class.
+                                        exClass == (Java at: 'java.lang.ThreadDeath') ifTrue: [
+                                            ('JAVA: thread ' , procName , ' terminated') infoPrintCR.
+                                        ] ifFalse: [
+                                            Transcript
+                                                showCR: ('JAVA: thread ''' , procName , ''' terminated with exception: '
+                                                        , exClass name).
+                                        ].
+                                        ex return.
+                                    ]
+                                    do: [
+                                        Object messageNotUnderstoodSignal
+                                            handle: [
+                                                :ex |
+                                                |
+                                                "/ remap doesNotUnderstand with nil-receiver to
+                                                "/ a nullPointerException ...
+                                                 con  m |
+                                                con := ex suspendedContext.
+                                                con receiver isNil ifTrue: [
+                                                    ((m := con sender method) notNil and: [ m isJavaMethod ]) ifTrue: [
+                                                        self throwNullPointerException.
+                                                        AbortSignal raise.
+
+                                                        "/ ex proceed.
+                                                    ]
+                                                ].
+                                                ex reject.
+                                            ]
+                                            do: [
+                                                "/ Transcript showCR:(Timestamp now printString , 'start thread: ', stProcess name).
+                                                jThread perform: #'run()V'.
+                                                ThreadTrace == true ifTrue: [
+                                                    ('JAVA: thread ' , stProcess name , ' terminated') infoPrintCR.
+                                                ].
+                                                jThread perform: #'exit()V'.
+                                                ThreadTrace == true ifTrue: [
+                                                    ('JAVA: after exit of thread ' , stProcess name) infoPrintCR.
+                                                ]
+                                            ]
+                                    ]
+                            ] ensure: [
+                                | monitors |
+                                monitors := EnteredMonitorsPerProcess at: stProcess ifAbsent: nil.
+                                monitors notNil ifTrue: [
+                                    monitors do: [
+                                        :obj |
+                                        | mon |
+                                        mon := obj getJavaMonitorFor.
+                                        mon notNil ifTrue: [
+                                            mon owningProcess == stProcess ifTrue: [
+                                                ('JAVA: release monitor owned by dying thread: ' , stProcess name)
+                                                    infoPrintCR.
+                                                mon exit
+                                            ].
+                                        ].
+                                    ].
+                                    EnteredMonitorsPerProcess removeKey: stProcess.
+                                    stProcess == JavaScreenUpdaterThread ifTrue: [
+                                        JavaScreenUpdaterThread := nil.
+                                    ].
+                                    stProcess == JavaEventQueueThread ifTrue: [ JavaEventQueueThread := nil. ].
+
+"/                                    screenUpdaterClass := Java at:'sun.awt.ScreenUpdater'.
+"/                                    screenUpdaterClass notNil ifTrue:[
+"/                                        screenUpdaterClass instVarNamed:'updater' put:nil.
+"/                                    ].
+                                ].
+                                Java removeThread: jThread ifAbsent: [].
+                            ]
+                        ]
+                ]
+                priority: (Processor activePriority).
+    jName := jThread instVarNamed: 'name'.
+    jName isString ifFalse: [ name := Java as_ST_String: jName. ] ifTrue: [
+        name := jName
+    ].
+
+    "/ kludge - remember the ScreenUpdater ...
+
+    name = 'Screen Updater' ifTrue: [ JavaScreenUpdaterThread := stProcess. ] ifFalse: [
+        name = 'AWT-Windows' ifTrue: [ JavaEventThread := stProcess. ] ifFalse: [
+            (name startsWith: 'AWT-EventQueue') ifTrue: [
+                JavaEventQueueThread := stProcess.
+            ].
+        ]
+    ].
+
+"/name = 'UserDialogShowThread' ifTrue:[
+"/self halt
+"/].
+    "/ when that process terminates, wakup any waiters
+
+    stProcess addExitAction: [ self notify: jThread ].
+    stProcess name: 'JAVA-' , name.
+    stProcess restartable: true.
+    stProcess resume.
+    Java addThread: jThread for: stProcess.
+    ^ nil
+
+    "Created: / 03-01-1998 / 02:05:52 / cg"
+    "Modified: / 24-12-1999 / 03:14:33 / cg"
+    "Modified: / 09-12-2011 / 12:52:27 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 27-08-2012 / 11:36:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_Thread_suspend0:nativeContext
+    "yield"
+
+    |jThread stProcess|
+
+    jThread := nativeContext receiver.
+    stProcess := JavaVM stProcessForJavaThread:jThread.
+    stProcess isNil ifTrue:[
+        ThreadTrace == true ifTrue:[
+            ('JAVA: no stProcess for javaThread: ' , jThread displayString) printNL.
+        ].
+        ^ nil "void"
+    ].
+    stProcess suspend
+
+    "Created: / 8.1.1998 / 01:05:49 / cg"
+    "Modified: / 6.2.1998 / 02:15:23 / cg"
+!
+
+_Throwable_printStackTrace0:nativeContext
+    |out outStream exceptionObject contextList|
+
+    outStream := nativeContext argAt:1.
+    exceptionObject := nativeContext receiver.
+
+    contextList := exceptionObject instVarNamed:'backtrace'.
+
+    out := self javaConsoleStream.
+    out cr.
+    out nextPutLine:'JAVA: stackTrace:'.
+
+    contextList do:[:con |
+        out
+            nextPutAll:'  ';
+            nextPutAll:(con method javaClass fullName);
+            nextPutAll:'.';
+            nextPutAll:(con method selector);
+            nextPutAll:' [';
+            nextPutAll:(con method javaClass sourceFile);
+            nextPutAll:' ';
+            nextPutAll:(con quickLineNumber displayString);
+            nextPutAll:']'.
+        out cr
+    ].
+    out nextPutLine:'----------------------------------------------------'
+
+    "Created: / 4.1.1998 / 14:27:40 / cg"
+    "Modified: / 10.11.1998 / 14:19:32 / cg"
+!
+
+_URLConnection_close:nativeContext
+    "/ void close ()
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:26:03 / cg"
+!
+
+_URLConnection_finalize:nativeContext
+    "/ void finalize ()
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:25:22 / cg"
+!
+
+_URLConnection_getContentLength0:nativeContext
+    "/ int getContentLength0 ()
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:25:34 / cg"
+!
+
+_URLConnection_getContentType0:nativeContext
+    "/ java.lang.String getContentType0 ()
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:25:42 / cg"
+!
+
+_URLConnection_getHeaderField0:nativeContext
+    "/ java.lang.String getHeaderField0 (java.lang.String)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:25:53 / cg"
+!
+
+_URLConnection_pCreate:nativeContext
+    "/ void pCreate (java.lang.String java.lang.String)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:25:14 / cg"
+!
+
+_URLInputStream_available:nativeContext
+    "/ int available ()
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:24:26 / cg"
+!
+
+_URLInputStream_open:nativeContext
+    "/ void open ()
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:24:01 / cg"
+!
+
+_URLInputStream_read:nativeContext
+    "/ int read (byte[] int int)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:24:12 / cg"
+!
+
+_URLOutputStream_open:nativeContext
+    "/ void open ()
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:24:38 / cg"
+!
+
+_URLOutputStream_pClose:nativeContext
+    "/ void pClose ()
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:25:02 / cg"
+!
+
+_URLOutputStream_write:nativeContext
+    "/ void write (int)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:24:45 / cg"
+!
+
+_URLOutputStream_writeBytes:nativeContext
+    "/ void writeBytes (byte[] int int)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:24:55 / cg"
+!
+
+_URLStreamHandlerFactory_pInit:nativeContext
+    "/ self unimplementedNativeMethod.
+
+    "Created: / 10.1.1998 / 15:47:24 / cg"
+!
+
+_URLStreamHandlerFactory_pSupportsProtocol:nativeContext
+    "/ boolean pSupportsProtocol (java.lang.String)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:23:43 / cg"
+!
+
+_VM_getState:nativeContext
+    "/ int getState ()
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:06:44 / cg"
+!
+
+_VM_resetJavaMonitor:nativeContext
+    "/ void resetJavaMonitor ()
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 14.11.1998 / 10:43:23 / cg"
+!
+
+_VM_resumeJavaMonitor:nativeContext
+    "/ void resumeJavaMonitor ()
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 14.11.1998 / 10:42:49 / cg"
+!
+
+_VM_suspendJavaMonitor:nativeContext
+    "/ void suspendJavaMonitor ()
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 14.11.1998 / 10:43:07 / cg"
+!
+
+_VM_threadsSuspended:nativeContext
+    "/ boolean threadsSuspended ()
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:07:10 / cg"
+!
+
+_VM_unsuspendSomeThreads:nativeContext
+    "/ void unsuspendSomeThreads ()
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:07:29 / cg"
+!
+
+_VM_unsuspendThreads:nativeContext
+    "/ void unsuspendThreads ()
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:07:20 / cg"
+!
+
+_VM_writeJavaMonitorReport:nativeContext
+    "/ void writeJavaMonitorReport ()
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 14.11.1998 / 10:43:37 / cg"
+!
+
+_WButtonPeer_create:nativeContext
+    |jButtonPeer jButton jFrame frame button
+     lbl|
+
+    jButtonPeer := nativeContext receiver.
+    jButton := jButtonPeer instVarNamed:'target'.
+
+    jFrame := nativeContext argAt:1.
+    frame := jFrame instVarNamed:'pData'.
+
+    button := Button in:frame.
+    button sizeFixed:true.
+    button action:[
+                        jButtonPeer perform:#'handleAction()V'.
+                  ].
+
+    lbl := jButton instVarNamed:'label'.
+    lbl notNil ifTrue:[
+        lbl := Java as_ST_String:lbl.
+        button label:lbl
+    ].
+    self createdWindowsView:button for:jButtonPeer.
+
+    WindowCreationTrace == true ifTrue:[
+        'WButtonPeer_create: ' print. frame print. ' -> ' print. button printNL.
+    ].
+
+    "Created: / 5.1.1998 / 01:53:30 / cg"
+    "Modified: / 11.12.1998 / 00:19:22 / cg"
+!
+
+_WButtonPeer_setLabel:nativeContext
+    |label jString|
+
+    jString := nativeContext argAt:1.
+
+    label := self viewForWPeer:nativeContext.
+    label label:(Java as_ST_String:jString)
+
+    "Modified: / 8.1.1998 / 17:35:50 / cg"
+    "Created: / 1.2.1998 / 17:05:47 / cg"
+!
+
+_WCanvasPeer_create:nativeContext
+    |jCanvasPeer jFrame frame subView|
+
+    jCanvasPeer := nativeContext receiver.
+
+    jFrame := nativeContext argAt:1.
+    jFrame isNil ifTrue:[
+        self halt:'no frame in canvasPeer create'.
+        subView := JavaView new.
+"/        self internalError:'no frame in canvasPeer create'.
+"/        ^ self.
+    ] ifFalse:[
+        frame := jFrame instVarNamed:'pData'.
+        subView := JavaView in:frame.
+    ].
+
+    subView delegate:self.
+    subView javaPeer:jCanvasPeer.
+
+    self createdWindowsView:subView for:jCanvasPeer.
+
+    WindowCreationTrace == true ifTrue:[
+        'WCanvasPeer_create: ' print. frame print. ' -> ' print. subView printNL.
+    ].
+
+    "Created: / 5.1.1998 / 00:59:19 / cg"
+    "Modified: / 16.1.1998 / 13:40:00 / cg"
+!
+
+_WCheckboxMenuItemPeer_setState:nativeContext
+    "/ void setState (boolean)
+"/    UnimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:14:35 / cg"
+    "Modified: / 3.12.1998 / 21:41:13 / cg"
+!
+
+_WCheckboxPeer_create:nativeContext
+    |jCheckboxPeer jCheckbox jFrame frame checkBox lbl|
+
+    jCheckboxPeer := nativeContext receiver.
+    jCheckbox := jCheckboxPeer instVarNamed:'target'.
+
+    jFrame := nativeContext argAt:1.
+    frame := jFrame instVarNamed:'pData'.
+
+    checkBox := CheckBox in:frame.
+    checkBox action:[
+                        jCheckboxPeer
+                            perform:#'handleAction(Z)V'
+                            with:(checkBox isOn ifTrue:[1] ifFalse:[0])
+                    ].
+
+    lbl := jCheckbox instVarNamed:'label'.
+    lbl notNil ifTrue:[
+        lbl := Java as_ST_String:lbl.
+        checkBox label:lbl
+    ].
+
+    self createdWindowsView:checkBox for:jCheckboxPeer.
+
+    WindowCreationTrace == true ifTrue:[
+        'WCheckboxPeer_create: ' print. frame print. ' -> ' print. checkBox printNL.
+    ].
+
+    "Created: / 7.1.1998 / 21:48:03 / cg"
+    "Modified: / 15.1.1998 / 12:27:04 / cg"
+!
+
+_WCheckboxPeer_setCheckboxGroup:nativeContext
+    |checkBox jGroup|
+
+    checkBox := self viewForWPeer:nativeContext.
+
+    jGroup := nativeContext argAt:1.
+
+    "Created: / 7.1.1998 / 21:48:47 / cg"
+    "Modified: / 25.1.1998 / 01:20:42 / cg"
+!
+
+_WCheckboxPeer_setLabel:nativeContext
+    "/ void setLabel (java.lang.String)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:14:53 / cg"
+!
+
+_WCheckboxPeer_setState:nativeContext
+    |checkBox state|
+
+    checkBox := self viewForWPeer:nativeContext.
+
+    state := nativeContext argAt:1.
+    state ~~ 0 ifTrue:[
+        checkBox turnOn
+    ] ifFalse:[
+        checkBox turnOff
+    ].
+
+    "Created: / 7.1.1998 / 21:49:13 / cg"
+    "Modified: / 25.1.1998 / 01:26:18 / cg"
+!
+
+_WChoicePeer_addItem:nativeContext
+    |jString index comboBox|
+
+    comboBox := self viewForWPeer:nativeContext.
+
+    jString := nativeContext argAt:1.
+    index := nativeContext argAt:2.
+
+    comboBox model list addLast:(Java as_ST_String:jString).
+    comboBox model changed:#list.
+
+    "Created: / 7.1.1998 / 21:45:12 / cg"
+    "Modified: / 24.1.1998 / 18:51:32 / cg"
+!
+
+_WChoicePeer_create:nativeContext
+    |jChoicePeer jChoice jFrame frame comboBox|
+
+    jChoicePeer := nativeContext receiver.
+    jChoice := jChoicePeer instVarNamed:'target'.
+
+    jFrame := nativeContext argAt:1.
+    frame := jFrame instVarNamed:'pData'.
+
+    comboBox := ComboListView in:frame.
+    comboBox model:(SelectionInList new list:(OrderedCollection new)).
+    comboBox action:[:index |
+                        jChoicePeer
+                            perform:#'handleAction(I)V'
+                            with:(comboBox model selectionIndex - 1)
+                    ].
+
+    self createdWindowsView:comboBox for:jChoicePeer.
+
+    WindowCreationTrace == true ifTrue:[
+        'WChoicePeer_create: ' print. frame print. ' -> ' print. comboBox printNL.
+    ].
+
+    "Created: / 7.1.1998 / 21:44:31 / cg"
+    "Modified: / 28.1.1998 / 23:19:17 / cg"
+!
+
+_WChoicePeer_remove:nativeContext
+    "/ void remove (int)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:12:20 / cg"
+!
+
+_WChoicePeer_reshape:nativeContext
+    self commonReshapeComponent:nativeContext.
+"/    self pReshape:nativeContext.
+    ^ self.
+
+    "Created: / 7.1.1998 / 21:46:18 / cg"
+    "Modified: / 23.12.1998 / 19:08:07 / cg"
+!
+
+_WChoicePeer_select:nativeContext
+    |comboBox index|
+
+    comboBox := self viewForWPeer:nativeContext.
+
+    index := nativeContext argAt:1.
+    comboBox model selectionIndex:(index + 1).  "/ JAVA indexing starts at 0
+
+    "Created: / 7.1.1998 / 21:45:43 / cg"
+    "Modified: / 25.1.1998 / 09:55:05 / cg"
+!
+
+_WClipboard_getClipboardText:nativeContext
+    "/ java.lang.String getClipboardText ()
+
+    |str|
+
+    str := Screen current rootView getTextSelection.
+    str isNil ifTrue:[
+        str := ''.
+    ].
+    ^ Java as_String:''.
+
+    "Modified: / 10.12.1998 / 21:28:29 / cg"
+!
+
+_WClipboard_init:nativeContext
+"/ self halt.
+
+    "Modified: / 18.3.1997 / 18:43:18 / cg"
+    "Created: / 4.1.1998 / 19:03:59 / cg"
+!
+
+_WClipboard_setClipboardText:nativeContext
+    "/ void setClipboardText (java.awt.datatransfer.StringSelection)
+
+    |strSel data|
+
+    strSel := nativeContext argAt:1.
+    data := strSel instVarNamed:'data'.
+    data class == (Java at:'java.lang.String') ifTrue:[
+        Screen current rootView setTextSelection:(Java as_ST_String:data)
+    ].
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:15:31 / cg"
+    "Modified: / 10.12.1998 / 21:25:20 / cg"
+!
+
+_WColor_getDefaultColor: nativeContext
+    | clrIndex  jClr  clr |
+
+    clrIndex := nativeContext argAt: 1.
+
+    "/ windows defaults:
+    "/  1: view background
+
+    clrIndex == 1 ifTrue: [
+        clr := View defaultViewBackgroundColor.
+        clr isColor ifFalse: [ clr := Color gray: 50. ].
+    ].
+    clrIndex == 2 ifTrue: [ clr := Color black. ].
+    clr isNil ifTrue: [
+        self halt.
+        self internalError: 'breakpoint'.
+        ^ nil.
+    ].
+    clr := clr on: (Screen current).
+    jClr := (self classForName: 'java.awt.Color') new.
+    jClr instVarNamed: 'pData' put: clr.
+    jClr instVarNamed: 'value' put: (clr rgbValue).
+
+"/ self halt.
+
+    ^ jClr.
+
+    "Created: / 15.8.1997 / 15:38:10 / cg"
+    "Modified: / 4.1.1998 / 18:06:51 / cg"
+!
+
+_WComponentPeer__beginValidate:nativeContext
+    "/ void _beginValidate ()
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:10:08 / cg"
+!
+
+_WComponentPeer__dispose:nativeContext
+    |view jPeer|
+
+    view := self viewForWPeer:nativeContext.
+
+    Object errorSignal catch:[
+        view destroy.
+    ].
+    JavaWindowGroup removeView:view.
+
+    jPeer := nativeContext receiver.
+    jPeer instVarNamed:'pData' put:0.
+
+    "Created: / 7.1.1998 / 22:36:25 / cg"
+    "Modified: / 25.1.1998 / 16:43:06 / cg"
+!
+
+_WComponentPeer__setBackground:nativeContext
+    |rgb clr view|
+
+    view := self viewForWPeer:nativeContext.
+    view isNil ifTrue:[^ self].
+
+    rgb := nativeContext argAt:1.
+    clr := Color rgbValue:rgb.
+
+"/ self halt.
+"/ self internalError:'breakPoint'.
+
+    clr := clr on:(view device).
+
+"/    (view superView isMemberOf:JavaEmbeddedFrameView) ifTrue:[
+"/        view viewBackground:(view superView viewBackground).
+"/        view backgroundPaint:(view superView viewBackground).
+"/    ] ifFalse:[
+"/        (view isMemberOf:JavaView) ifTrue:[
+"/            view viewBackground:clr.
+"/            view backgroundPaint:clr.
+"/        ]
+"/    ].
+
+    (view isKindOf:ScrollableView) ifTrue:[
+        view := view scrolledView
+    ].
+    view viewBackground:clr.
+    view backgroundPaint:clr.
+
+    "Created: / 4.1.1998 / 18:07:39 / cg"
+    "Modified: / 4.12.1998 / 17:26:06 / cg"
+!
+
+_WComponentPeer__setForeground:nativeContext
+    |rgb clr view|
+
+    view := self viewForWPeer:nativeContext.
+
+    rgb := nativeContext argAt:1.
+    clr := Color rgbValue:rgb.
+
+"/ self halt.
+"/ self internalError:'breakPoint'.
+
+    clr := clr on:(view device).
+
+    view paint:clr.
+
+    "Created: / 4.1.1998 / 18:08:13 / cg"
+    "Modified: / 8.1.1998 / 17:32:45 / cg"
+!
+
+_WComponentPeer_disable:nativeContext
+    |view|
+
+    view := self viewForWPeer:nativeContext.
+
+    Object errorSignal handle:[:ex |
+    ] do:[
+        view disable
+    ]
+
+    "Created: / 6.1.1998 / 18:26:36 / cg"
+    "Modified: / 8.1.1998 / 17:32:53 / cg"
+!
+
+_WComponentPeer_enable:nativeContext
+    |view|
+
+    view := self viewForWPeer:nativeContext.
+
+    Object errorSignal handle:[:ex |
+    ] do:[
+        view enable
+    ]
+
+    "Modified: / 8.1.1998 / 17:32:53 / cg"
+    "Created: / 13.1.1998 / 23:08:05 / cg"
+!
+
+_WComponentPeer_endValidate:nativeContext
+    "/ void endValidate ()
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:10:20 / cg"
+!
+
+_WComponentPeer_getLocationOnScreen: nativeContext
+    "/ java.awt.Point getLocationOnScreen ()
+
+    | view  p  jP |
+
+    view := self viewForWPeer: nativeContext.
+    view isNil ifTrue: [ ^ nil ].
+    p := view originRelativeTo: nil.
+    jP := (self classForName: 'java.awt.Point') basicNew.
+    jP instVarNamed: 'x' put: p x.
+    jP instVarNamed: 'y' put: p y.
+    ^ jP
+
+    "Modified: / 5.12.1998 / 14:44:31 / cg"
+!
+
+_WComponentPeer_handleEvent:nativeContext
+    "this is invoked by java, to let a widget handle any event which
+     was not consumed (eaten) by java.
+     If the view in question is some ST-widget, forward it.
+     Ignore for JavaViews."
+
+    |view jEv stEv ignore|
+
+    view := self viewForWPeer:nativeContext.
+    view notNil ifTrue:[
+        jEv := nativeContext argAt:1.
+        stEv := jEv instVarNamed:'data'.
+        (stEv notNil and:[stEv ~~ 0]) ifTrue:[
+            ignore := true.
+            view isJavaView ifFalse:[
+                ignore := false
+            ] ifTrue:[
+                view isTopView ifTrue:[
+                    stEv type == #terminate ifTrue:[
+                        ignore := false
+                    ].
+                ]
+            ].
+
+            ignore ifFalse:[
+                EventTrace == true ifTrue:[
+                    ('JAVA: WComponent - handleEvent: ' , stEv type , ' for ' , view printString) infoPrintCR.
+                ].
+                view dispatchEvent:stEv.
+                ^ self.
+            ].
+
+            EventTrace == true ifTrue:[
+                ('JAVA: WComponent - handleEvent ignored:' , stEv type) infoPrintCR.
+            ].
+            ^ self
+        ]
+    ].
+    EventTrace == true ifTrue:[
+        ('JAVA: WComponent - handleEvent ignored') infoPrintCR.
+    ]
+
+    "Created: / 6.1.1998 / 21:10:17 / cg"
+    "Modified: / 11.12.1998 / 01:04:14 / cg"
+!
+
+_WComponentPeer_hide:nativeContext
+    |view|
+
+    view := self viewForWPeer:nativeContext.
+"/ view isPopUpView ifTrue:[self halt].
+
+    Object errorSignal handle:[:ex |
+    ] do:[
+        view beInvisible
+    ]
+
+    "Created: / 7.1.1998 / 22:35:32 / cg"
+    "Modified: / 4.12.1998 / 17:53:41 / cg"
+!
+
+_WComponentPeer_nativeHandleEvent:nativeContext
+    "this is invoked by java, to let a widget handle any event which
+     was not consumed (eaten) by java.
+     If the view in question is some ST-widget, forward it.
+     Ignore for JavaViews."
+
+    |view jEv stEv|
+
+^self.
+    view := self viewForWPeer:nativeContext.
+    view notNil ifTrue:[
+        (view isKindOf:JavaView) ifFalse:[
+            jEv := nativeContext argAt:1.
+            stEv := jEv instVarNamed:'data'.
+            (stEv notNil and:[stEv ~~ 0]) ifTrue:[
+                EventTrace == true ifTrue:[
+                    ('JAVA: WComponent - handleEvent: ' , stEv type , ' for ' , view printString) infoPrintCR.
+                ].
+                stEv sendEventWithFocusOn:nil.
+                ^ self.
+            ]
+        ]
+    ].
+    EventTrace == true ifTrue:[
+        ('JAVA: WComponent - handleEvent ignored') infoPrintCR.
+    ]
+
+    "Created: / 19.10.1998 / 21:26:16 / cg"
+    "Modified: / 19.10.1998 / 23:26:37 / cg"
+!
+
+_WComponentPeer_requestFocus:nativeContext
+    |view|
+
+    view := self viewForWPeer:nativeContext.
+"/ 'getFocus - ' print. view displayString printCR.
+
+"/    view getKeyboardFocus
+
+    "Created: / 7.1.1998 / 22:30:03 / cg"
+    "Modified: / 4.12.1998 / 19:42:18 / cg"
+!
+
+_WComponentPeer_reshape:nativeContext
+    self commonReshapeComponent:nativeContext
+
+    "Modified: / 18.3.1997 / 19:30:21 / cg"
+    "Created: / 4.1.1998 / 18:01:11 / cg"
+!
+
+_WComponentPeer_setBackground:nativeContext
+    |jClr rgb clr view|
+
+    view := self viewForWPeer:nativeContext.
+
+    jClr := nativeContext argAt:1.
+    rgb := jClr instVarNamed:'value'.
+"/ self halt.
+    clr := Color rgbValue:rgb.
+
+
+    clr := clr on:(view device).
+
+"/    (view superView isMemberOf:JavaEmbeddedFrameView) ifTrue:[
+"/        view viewBackground:(view superView viewBackground).
+"/        view backgroundPaint:(view superView viewBackground).
+"/    ] ifFalse:[
+"/        (view isMemberOf:JavaView) ifTrue:[
+"/            view viewBackground:clr.
+"/            view backgroundPaint:clr.
+"/        ]
+"/    ].
+
+    (view isKindOf:ScrollableView) ifTrue:[
+        view := view scrolledView
+    ].
+    view viewBackground:clr.
+    view backgroundPaint:clr.
+
+    "Created: / 16.10.1998 / 02:16:31 / cg"
+    "Modified: / 16.10.1998 / 02:26:29 / cg"
+!
+
+_WComponentPeer_setCursor:nativeContext
+    |view|
+
+    view := self viewForWPeer:nativeContext.
+"/ self halt.
+
+    "Created: / 5.1.1998 / 01:52:30 / cg"
+    "Modified: / 25.1.1998 / 01:21:52 / cg"
+!
+
+_WComponentPeer_setFont:nativeContext
+    |view|
+
+    view := self viewForWPeer:nativeContext.
+"/ self halt.
+
+    "Created: / 5.1.1998 / 00:55:17 / cg"
+    "Modified: / 25.1.1998 / 01:22:19 / cg"
+!
+
+_WComponentPeer_setForeground:nativeContext
+    |jClr rgb clr view|
+
+    view := self viewForWPeer:nativeContext.
+
+    jClr := nativeContext argAt:1.
+    rgb := jClr instVarNamed:'value'.
+"/ self halt.
+    clr := Color rgbValue:rgb.
+
+
+    clr := clr on:(view device).
+
+    (view isKindOf:ScrollableView) ifTrue:[
+        view := view scrolledView
+    ].
+    view paint:clr.
+
+    "Created: / 16.10.1998 / 02:18:58 / cg"
+    "Modified: / 16.10.1998 / 02:26:37 / cg"
+!
+
+_WComponentPeer_setZOrderPosition:nativeContext
+    |view|
+
+    view := self viewForWPeer:nativeContext.
+"/    self unimplementedNativeMethod.
+"/ self halt.
+"/ self internalError:'breakPoint'
+
+    "Created: / 4.1.1998 / 17:59:26 / cg"
+    "Modified: / 25.1.1998 / 01:22:32 / cg"
+!
+
+_WComponentPeer_show:nativeContext
+    |view|
+
+    view := self viewForWPeer:nativeContext.
+
+    "/ frame views are under my browsers own control
+    (view isMemberOf:JavaEmbeddedFrameView) ifFalse:[
+        view beVisible.
+        view realize.
+    ].
+
+"/    view windowGroup notNil ifTrue:[
+"/        windowServer addGroup:(view windowGroup)
+"/    ].
+
+    ^ nil
+
+"/ self halt.
+
+    "Created: / 5.1.1998 / 01:26:22 / cg"
+    "Modified: / 4.12.1998 / 17:43:53 / cg"
+!
+
+_WComponentPeer_start:nativeContext
+"/ self halt.
+
+    "Modified: / 18.3.1997 / 18:43:18 / cg"
+    "Created: / 5.1.1998 / 00:58:40 / cg"
+!
+
+_WContainerPeer_calculateInsets:nativeContext
+    "/ new with ns4.0 ...
+
+    "Created: / 16.10.1998 / 02:12:59 / cg"
+!
+
+_WDefaultFontCharset_canConvert:nativeContext
+    ^ 1
+
+    "Modified: / 21.8.1997 / 15:56:57 / cg"
+    "Created: / 5.1.1998 / 01:55:47 / cg"
+!
+
+_WDialogPeer__hide:nativeContext
+    |dialog|
+
+    dialog := self viewForWPeer:nativeContext.
+
+    dialog hide.
+
+    "Created: / 7.1.1998 / 22:34:10 / cg"
+    "Modified: / 8.1.1998 / 17:34:10 / cg"
+!
+
+_WDialogPeer__show:nativeContext
+    |dialog|
+
+    dialog := self viewForWPeer:nativeContext.
+"/
+"/ show does not work (yet); must setup windowgroup
+"/ for it to get events ...
+"/    dialog realize.
+
+dialog show.
+"/dialog fixSize.
+"/dialog makeFullyVisible.
+"/dialog openModal:[true] inGroup:JavaWindowGroup
+
+    "Created: / 7.1.1998 / 21:52:15 / cg"
+    "Modified: / 11.12.1998 / 14:43:05 / cg"
+!
+
+_WDialogPeer_create:nativeContext
+    |jDialogPeer dialog|
+
+    jDialogPeer := nativeContext receiver.
+
+    dialog := ModalBox new.
+    jDialogPeer instVarNamed:'pData' put:dialog.
+
+    self createdWindowsView:dialog for:jDialogPeer.
+    dialog windowGroup:JavaWindowGroup.
+    JavaWindowGroup addTopView:dialog.
+
+    WindowCreationTrace == true ifTrue:[
+        'WDialogPeer_create: ' print. dialog printNL.
+    ].
+
+    "Created: / 7.1.1998 / 21:51:00 / cg"
+    "Modified: / 15.1.1998 / 16:12:44 / cg"
+!
+
+_WDrawingSurfaceInfo_getDepth:nativeContext
+    "/ int getDepth ()
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:21:00 / cg"
+!
+
+_WDrawingSurfaceInfo_getHBitmap:nativeContext
+    "/ int getHBitmap ()
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:20:32 / cg"
+!
+
+_WDrawingSurfaceInfo_getHDC:nativeContext
+    "/ int getHDC ()
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:20:50 / cg"
+!
+
+_WDrawingSurfaceInfo_getHPalette:nativeContext
+    "/ int getHPalette ()
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:21:07 / cg"
+!
+
+_WDrawingSurfaceInfo_getHWnd:nativeContext
+    "/ int getHWnd ()
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:20:23 / cg"
+!
+
+_WDrawingSurfaceInfo_getPBits:nativeContext
+    "/ int getPBits ()
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:20:41 / cg"
+!
+
+_WDrawingSurfaceInfo_lock:nativeContext
+    "/ int lock ()
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:20:00 / cg"
+!
+
+_WDrawingSurfaceInfo_unlock:nativeContext
+    "/ void unlock ()
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:20:13 / cg"
+!
+
+_WEmbeddedFramePeer_create:nativeContext
+    "/ void create (sun.awt.windows.WComponentPeer)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:16:09 / cg"
+!
+
+_WFileDialogPeer_show:nativeContext
+    |jDialogPeer jDialog dialogView stDialog
+     title dir pattern f|
+
+    jDialogPeer := nativeContext receiver.
+    jDialog := jDialogPeer instVarNamed:'target'.
+    dialogView := jDialogPeer instVarNamed:'pData'.
+
+    stDialog := FileSelectionBox new.
+
+    dir := jDialog instVarNamed:'dir'.
+    dir notNil ifTrue:[
+        stDialog directory:(Java as_ST_String:dir).
+    ].
+    pattern := jDialog instVarNamed:'file'.
+    pattern notNil ifTrue:[
+        stDialog pattern:(Java as_ST_String:pattern).
+    ].
+    title := jDialog instVarNamed:'title'.
+    title notNil ifTrue:[
+        stDialog title:(Java as_ST_String:title).
+        stDialog label:(Java as_ST_String:title).
+    ].
+
+    stDialog show.
+
+    stDialog accepted ifTrue:[
+        f := stDialog pathName.
+
+        "/ cannot use the one below - it has a builtIn fileSeparator if '\' (sigh)
+        "/ jDialogPeer perform:#'handleSelected(Ljava/lang/String;)V' with:(Java as_String:f).
+
+        jDialog
+            perform:#'setFile(Ljava/lang/String;)V'
+            with:(Java as_String:(f asFilename baseName)).
+        jDialog
+            perform:#'setDirectory(Ljava/lang/String;)V'
+            with:(Java as_String:(f asFilename directoryName , Filename separator asString)).
+        jDialog
+            perform:#'setVisible(Z)V'
+            with:0.
+    ] ifFalse:[
+        jDialogPeer
+            perform:#'handleCancel()V'
+    ].
+"/ self halt.
+
+    "Created: / 7.1.1998 / 22:38:45 / cg"
+    "Modified: / 15.1.1998 / 13:04:05 / cg"
+!
+
+_WFontMetrics_bytesWidth:nativeContext
+    "/ int bytesWidth (byte[] int int)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:11:46 / cg"
+!
+
+_WFontMetrics_getMFCharSegmentWidth:nativeContext
+    "get multi-font string-segment width.
+     Not yet supported - use standard strings width"
+
+    |jMetrics jFont jFontDescr stFont w
+     bool1 cp offs lenght bp int1|
+
+    jMetrics := nativeContext receiver.
+    jFont := nativeContext argAt:1.
+    jFontDescr := nativeContext argAt:2.
+    bool1 := nativeContext argAt:3.
+    cp := nativeContext argAt:4.
+    offs := nativeContext argAt:5.
+    lenght := nativeContext argAt:6.
+    bp := nativeContext argAt:7.
+    int1 := nativeContext argAt:8.
+
+    stFont := jFont instVarNamed:'pData'.
+    (stFont isNil or:[stFont == 0]) ifTrue:[
+        self halt
+    ].
+
+    stFont device isNil ifTrue:[
+        stFont := stFont on:Display.
+        jFont instVarNamed:'pData' put:stFont.
+    ].
+    w := stFont widthOf:cp from:offs+1 to:offs+lenght.
+    ^ w.
+
+    "Created: / 5.1.1998 / 01:57:45 / cg"
+    "Modified: / 13.1.1998 / 23:44:03 / cg"
+!
+
+_WFontMetrics_init:nativeContext
+    |jMetrics jFont stFont widths family name style size|
+
+    jMetrics := nativeContext receiver.
+    jFont := jMetrics instVarNamed:'font'.
+
+    family := jFont instVarNamed:'family'.
+    family := Java as_ST_String:family.
+
+    name := jFont instVarNamed:'name'.
+    name := Java as_ST_String:name.
+
+    style := jFont instVarNamed:'style'.
+    size := jFont instVarNamed:'size'.
+
+    stFont := Font family:family size:size.
+    stFont isNil ifTrue:[
+        stFont := Font family:'helvetica' size:size.
+    ].
+    stFont := stFont on:Display.
+self halt.
+"/    stFont := jFont instVarNamed:'pData'.
+"/    stFont isNil ifTrue:[
+"/        self halt
+"/    ].
+
+    stFont := stFont on:Display.
+    jFont instVarNamed:'pData' put:stFont.
+
+    jMetrics instVarNamed:'ascent'     put:stFont ascent.
+    jMetrics instVarNamed:'descent'    put:stFont descent.
+    jMetrics instVarNamed:'leading'    put:0.
+    jMetrics instVarNamed:'height'     put:stFont height.
+    jMetrics instVarNamed:'maxAscent'  put:stFont maxAscent.
+    jMetrics instVarNamed:'maxDescent' put:stFont maxDescent.
+    jMetrics instVarNamed:'maxHeight'  put:stFont maxHeight.
+    jMetrics instVarNamed:'maxAdvance' put:stFont maxWidth.
+
+    widths := Array new:256.
+    0 to:255 do:[:i |
+        widths at:(i+1) put:(stFont widthOf:(Character value:i))
+    ].
+    jMetrics instVarNamed:'widths' put:widths.
+"/ self halt.
+
+    "Modified: / 8.8.1997 / 12:06:53 / cg"
+    "Created: / 5.1.1998 / 01:54:29 / cg"
+!
+
+_WFontMetrics_needsConversion:nativeContext
+    |jFont jFontDescr stFont|
+
+    jFont := nativeContext argAt:1.
+    jFontDescr := nativeContext argAt:2.
+
+    stFont := jFont instVarNamed:'pData'.
+"/    stFont isNil ifTrue:[
+"/        self halt
+"/    ].
+"/    stFont device isNil ifTrue:[
+"/        stFont := stFont on:Display.
+"/        jFont instVarNamed:'pData' put:stFont.
+"/    ].
+"/
+
+    ^ 0
+
+    "Modified: / 17.8.1997 / 17:16:29 / cg"
+    "Created: / 5.1.1998 / 01:56:42 / cg"
+!
+
+_WFramePeer__setIconImage:nativeContext
+    |frame imgRep image|
+
+    frame := self viewForWPeer:nativeContext.
+    imgRep := nativeContext argAt:1.
+    imgRep notNil ifTrue:[
+        image := imgRep instVarNamed:'pData'.
+        (image notNil and:[image ~~ 0]) ifTrue:[
+            frame icon:image.
+        ]
+    ].
+
+    "Created: / 27.4.1998 / 17:15:09 / cg"
+    "Modified: / 27.4.1998 / 17:18:24 / cg"
+!
+
+_WFramePeer_create:nativeContext
+    |jFramePeer jFrame top frame pDataIdx|
+
+    jFramePeer := nativeContext receiver.
+
+    "/ for now: a kludge to create an embedded frame for
+    "/ mozillaFrames
+
+    jFrame := jFramePeer instVarNamed:'target'.
+    (jFrame notNil
+    and:[(pDataIdx := jFrame class instVarOffsetOf:'pData') notNil])
+    ifTrue:[
+        ((frame := jFrame instVarAt:pDataIdx) notNil
+        and:[frame ~~ 0]) ifTrue:[
+            WindowCreationTrace == true ifTrue:[
+                'JAVA: targetFrame view already created: ' infoPrintCR.
+            ].
+            "/ sigh; pData was renamed to pNativeWidget in jdk1.2 ...
+            pDataIdx := jFramePeer class instVarOffsetOf:'pNativeWidget'.
+            pDataIdx isNil ifTrue:[
+                "/ ok, we are < 1.2
+                pDataIdx := jFramePeer class instVarOffsetOf:'pData'.
+            ].
+            jFramePeer instVarAt:pDataIdx put:frame.
+        ]
+    ] ifFalse:[
+        frame := jFramePeer instVarNamed:'pData'
+    ].
+
+    (frame notNil and:[frame ~~ 0]) ifTrue:[
+        WindowCreationTrace == true ifTrue:[
+            'JAVA: frame view already created: ' infoPrint.
+            jFramePeer class name infoPrintCR.
+        ].
+    ] ifFalse:[
+"/ OLD
+"/        frame := StandardSystemView new.
+"/        self createdWindowsView:frame for:jFramePeer.
+"/        JavaWindowGroup addTopView:frame.
+
+        frame := JavaTopView new.
+        frame delegate:self.
+        frame javaPeer:jFramePeer.
+        self createdWindowsView:frame for:jFramePeer.
+        JavaWindowGroup addTopView:frame.
+
+"/        top := StandardSystemView new.
+"/        frame := JavaView origin:0.0@0.0 corner:1.0@1.0 in:top.
+"/        frame delegate:self.
+"/        frame javaPeer:jFramePeer.
+"/        self createdWindowsView:frame for:jFramePeer.
+"/        JavaWindowGroup addTopView:top.
+
+    ].
+
+    WindowCreationTrace == true ifTrue:[
+        'JAVA: WFramePeer_create: ' print. jFramePeer displayString print.
+        ' frame: ' print. frame printNL.
+    ].
+
+    "Created: / 4.1.1998 / 17:56:39 / cg"
+    "Modified: / 3.12.1998 / 00:10:21 / cg"
+!
+
+_WFramePeer_setMenuBar0:nativeContext
+    |frame jMenuBarPeer menuPanel|
+
+    frame := self viewForWPeer:nativeContext.
+
+    jMenuBarPeer := nativeContext argAt:1.
+    jMenuBarPeer isNil ifTrue:[
+        "/ mhmh - JAVA wants to remove the frames menuPanel.
+        "/ but I have no handle on it (for destroy).
+        "/ search it in subViews of the frame.
+        frame subViews copy do:[:v |
+            (v isKindOf:MenuPanel) ifTrue:[
+                v destroy
+            ]
+        ]
+    ] ifFalse:[
+        menuPanel := jMenuBarPeer instVarNamed:'pData'.
+
+        menuPanel origin:0.0@0.0 corner:1.0@(menuPanel preferredExtent y).
+        frame addSubView:menuPanel.
+    ].
+    ^ nil
+
+    "Created: / 7.1.1998 / 21:41:35 / cg"
+    "Modified: / 8.1.1998 / 17:35:04 / cg"
+!
+
+_WFramePeer_setResizable:nativeContext
+    |view onOff|
+
+    view := self viewForWPeer:nativeContext.
+
+    onOff := (nativeContext argAt:1) == 1.
+    view isTopView ifTrue:[
+        onOff ifTrue:[
+            view minExtent:10@10.
+            view maxExtent:(Screen current extent).
+        ] ifFalse:[
+            view minExtent:view extent.
+            view maxExtent:view extent.
+        ]
+    ] ifFalse:[
+        (view isMemberOf:JavaEmbeddedFrameView) ifFalse:[
+            self halt.
+        ]
+    ].
+
+"/ 'JAVA: WWindowPeer_setResizable: ' print. view print. ' yes/no: ' print. onOff printNL.
+
+    ^ nil
+
+    "Modified: / 16.1.1998 / 18:08:00 / cg"
+    "Created: / 16.10.1998 / 02:21:34 / cg"
+!
+
+_WFramePeer_setTitle:nativeContext
+    |view jString string|
+
+    view := self viewForWPeer:nativeContext.
+
+    jString := nativeContext argAt:1.
+    string := Java as_ST_String:jString.
+
+"/ 'JAVA: WFramePeer_pSetTitle: ' print. string print. ' ' print. view printNL.
+
+    view label:string.
+    ^ nil
+
+    "Modified: / 8.1.1998 / 17:37:41 / cg"
+    "Created: / 27.1.1998 / 21:42:57 / cg"
+!
+
+_WGraphics__dispose:nativeContext
+    "/ void _dispose()
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:17:51 / cg"
+!
+
+_WGraphics_changeClip:nativeContext
+    |gc x y w h r bool|
+
+    gc := self gcForWGraphics:nativeContext.
+
+    x := nativeContext argAt:1.
+    y := nativeContext argAt:2.
+    w := nativeContext argAt:3.
+    h := nativeContext argAt:4.
+    bool := (nativeContext argAt:5) ~~ 0.
+
+    r := Rectangle left:x top:y width:w height:h.
+"/ 'WGraphics_changeClip: ' infoPrint. r infoPrintCR.
+    gc clippingRectangle:r.
+
+    "Created: / 6.1.1998 / 20:57:21 / cg"
+    "Modified: / 20.10.1998 / 19:40:10 / cg"
+!
+
+_WGraphics_clearRect:nativeContext
+    |gc x y w h|
+
+    gc := self gcForWGraphics:nativeContext.
+"/    gc isNil ifTrue:[^ self].
+
+    gc realized ifFalse:[
+        'JAVA: drawing on unrealized gc - ignored' infoPrintCR.
+        ^ self
+    ].
+
+    x := nativeContext argAt:1.
+    y := nativeContext argAt:2.
+    w := nativeContext argAt:3.
+    h := nativeContext argAt:4.
+
+"/ self halt.
+"/ self internalError:'breakPoint'.
+
+    gc clearRectangleX:x y:y width:w height:h.
+
+    "Created: / 8.1.1998 / 00:16:00 / cg"
+    "Modified: / 8.1.1998 / 00:21:09 / cg"
+!
+
+_WGraphics_close:nativeContext
+    "/ void close (sun.awt.windows.WPrintJob)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:19:40 / cg"
+!
+
+_WGraphics_copyArea:nativeContext
+    |gc srcX srcY w h deltaX deltaY|
+
+    gc := self gcForWGraphics:nativeContext.
+"/    gc isNil ifTrue:[^ self].
+
+    gc realized ifFalse:[
+        'JAVA: copyArea on unrealized gc - ignored' infoPrintCR.
+        ^ self
+    ].
+
+    srcX := nativeContext argAt:1.
+    srcY := nativeContext argAt:2.
+    w := nativeContext argAt:3.
+    h := nativeContext argAt:4.
+    deltaX := nativeContext argAt:5.
+    deltaY := nativeContext argAt:6.
+
+    gc
+        copyFrom:gc
+        x:srcX y:srcY
+        toX:srcX+deltaX y:srcY+deltaY
+        width:w height:h
+
+    "Created: / 8.1.1998 / 00:16:00 / cg"
+    "Modified: / 9.4.1998 / 22:01:32 / cg"
+!
+
+_WGraphics_createFromComponent:nativeContext
+    |jGraphics jWin view|
+
+    jGraphics := nativeContext receiver.
+    jWin := nativeContext argAt:1.
+
+    view := KnownWindows at:jWin ifAbsent:nil.
+    view isNil ifTrue:[
+        self halt.
+        ^ self
+    ].
+    view clippingRectangle:nil.
+
+"/    "/ just a consistency check ...
+"/    (jWin instVarNamed:'xid') ~~ view ifTrue:[
+"/        self halt:'consistency check'
+"/    ].
+
+    jGraphics instVarNamed:'pData' put:view.
+
+    "Created: / 6.1.1998 / 20:55:18 / cg"
+    "Modified: / 20.10.1998 / 19:38:18 / cg"
+!
+
+_WGraphics_createFromGraphics:nativeContext
+    |jGraphics graphics gc|
+
+    jGraphics := nativeContext receiver.
+    graphics := nativeContext argAt:1.
+    gc := graphics instVarNamed:'pData'.
+
+    jGraphics instVarNamed:'pData' put:gc.
+    gc clippingRectangle:nil.
+
+    "Created: / 8.1.1998 / 00:47:39 / cg"
+    "Modified: / 20.10.1998 / 19:37:58 / cg"
+!
+
+_WGraphics_createFromHDC:nativeContext
+    "/ void createFromHDC (int)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:17:32 / cg"
+!
+
+_WGraphics_createFromPrintJob:nativeContext
+    "/ void createFromPrintJob (sun.awt.windows.WPrintJob)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:17:20 / cg"
+!
+
+_WGraphics_dispose:nativeContext
+    |gc|
+
+    gc := self gcForWGraphics:nativeContext.
+    gc isNil ifTrue:[^ self].
+    gc clippingRectangle:nil.
+
+    "Created: / 6.1.1998 / 20:58:38 / cg"
+    "Modified: / 20.10.1998 / 19:35:05 / cg"
+!
+
+_WGraphics_drawArc:nativeContext
+    |gc x y w h startAngle endAngle|
+
+    gc := self gcForWGraphics:nativeContext.
+"/    gc isNil ifTrue:[^ self].
+    gc realized ifFalse:[^ self].
+
+    x := nativeContext argAt:1.
+    y := nativeContext argAt:2.
+    w := nativeContext argAt:3.
+    h := nativeContext argAt:4.
+    startAngle := nativeContext argAt:5.
+    endAngle := nativeContext argAt:6.
+
+    DrawOPTrace ifTrue:[
+        'drawArc x/y= ' print. x print. '@' print. y print.
+               ' w/h= ' print. w print. '@' print. h print.
+               ' startAngle= ' print. startAngle print. ' endAngle= ' print. endAngle printCR.
+    ].
+    gc
+        displayArcX:x y:y
+        width:w height:h
+        from:startAngle angle:(endAngle - startAngle).
+
+    "Created: / 6.1.1998 / 21:00:15 / cg"
+    "Modified: / 28.1.1999 / 17:38:45 / cg"
+!
+
+_WGraphics_drawBytes:nativeContext
+    "/ void drawBytes (byte[] int int int int)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:18:56 / cg"
+!
+
+_WGraphics_drawLine:nativeContext
+    |gc x y x2 y2|
+
+    gc := self gcForWGraphics:nativeContext.
+"/    gc isNil ifTrue:[^ self].
+    gc realized ifFalse:[^ self].
+
+    x := nativeContext argAt:1.
+    y := nativeContext argAt:2.
+    x2 := nativeContext argAt:3.
+    y2 := nativeContext argAt:4.
+
+    DrawOPTrace ifTrue:[
+        'drawLine x/y= ' print. x print. '@' print. y print. ' x2/y2= ' print. x2 print. '@' print. y2 printCR.
+    ].
+    gc displayLineFromX:x y:y toX:x2 y:y2
+
+    "Created: / 6.1.1998 / 20:59:27 / cg"
+    "Modified: / 8.1.1998 / 00:34:23 / cg"
+!
+
+_WGraphics_drawMFCharsConvertedSegment:nativeContext
+    "/ int drawMFCharsConvertedSegment (java.awt.Font sun.awt.FontDescriptor byte[] int int int)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:18:44 / cg"
+!
+
+_WGraphics_drawMFCharsSegment:nativeContext
+    |jFont jFontDescr s gc x y offs len|
+
+    gc := self gcForWGraphics:nativeContext.
+    gc realized ifFalse:[^ self].
+
+    jFont := nativeContext argAt:1.
+    jFontDescr := nativeContext argAt:2.
+    s := nativeContext argAt:3.
+    offs := nativeContext argAt:4.
+    len := nativeContext argAt:5.
+    x := nativeContext argAt:6.
+    y := nativeContext argAt:7.
+
+    DrawOPTrace ifTrue:[
+        'drawMFCharsSegment x/y= ' print. x print. '@' print. y print. ' s= ' print. s printCR.
+    ].
+    gc displayString:s from:offs+1 to:offs+len x:x y:y.
+    ^ (gc font onDevice:(gc graphicsDevice)) widthOf:s.
+
+    "Created: / 6.1.1998 / 21:01:07 / cg"
+    "Modified: / 25.1.1998 / 20:45:55 / cg"
+!
+
+_WGraphics_drawOval:nativeContext
+    |gc x y w h|
+
+    gc := self gcForWGraphics:nativeContext.
+"/    gc isNil ifTrue:[^ self].
+    gc realized ifFalse:[^ self].
+
+    x := nativeContext argAt:1.
+    y := nativeContext argAt:2.
+    w := nativeContext argAt:3.
+    h := nativeContext argAt:4.
+
+    DrawOPTrace ifTrue:[
+        'drawOval x/y= ' print. x print. '@' print. y print.
+                ' w/h= ' print. w print. '@' print. h printCR.
+    ].
+    gc displayArcX:x y:y width:w height:h from:0 angle:360.
+
+    "Created: / 8.1.1998 / 00:44:31 / cg"
+    "Modified: / 9.4.1998 / 22:10:23 / cg"
+!
+
+_WGraphics_drawPolygon:nativeContext
+    |gc xVector yVector count points|
+
+    gc := self gcForWGraphics:nativeContext.
+"/    gc isNil ifTrue:[^ self].
+    gc realized ifFalse:[^ self].
+
+    xVector := nativeContext argAt:1.
+    yVector := nativeContext argAt:2.
+    count := nativeContext argAt:3.
+
+    DrawOPTrace ifTrue:[
+        'drawPolgon' printCR.
+    ].
+
+    points := (1 to:count) collect:[:i | (xVector at:i) @ (yVector at:i)].
+    gc displayPolygon:points
+
+    "Created: / 8.1.1998 / 00:57:28 / cg"
+    "Modified: / 8.1.1998 / 00:57:49 / cg"
+!
+
+_WGraphics_drawPolyline:nativeContext
+    "/ void drawPolyline (int[] int[] int)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:19:07 / cg"
+!
+
+_WGraphics_drawRect:nativeContext
+    |gc x y w h|
+
+    gc := self gcForWGraphics:nativeContext.
+"/    gc isNil ifTrue:[^ self].
+    gc realized ifFalse:[^ self].
+
+    x := nativeContext argAt:1.
+    y := nativeContext argAt:2.
+    w := nativeContext argAt:3.
+    h := nativeContext argAt:4.
+
+"/ self halt.
+"/ self internalError:'breakPoint'.
+
+    gc displayRectangleX:x y:y width:w height:h.
+
+    "Modified: / 8.1.1998 / 00:34:33 / cg"
+    "Created: / 8.1.1998 / 00:59:05 / cg"
+!
+
+_WGraphics_drawRoundRect:nativeContext
+    |gc x y w h|
+
+    gc := self gcForWGraphics:nativeContext.
+"/    gc isNil ifTrue:[^ self].
+    gc realized ifFalse:[^ self].
+
+    x := nativeContext argAt:1.
+    y := nativeContext argAt:2.
+    w := nativeContext argAt:3.
+    h := nativeContext argAt:4.
+
+"/ self halt.
+"/ self internalError:'breakPoint'.
+
+    gc displayRectangleX:x y:y width:w height:h.
+
+    "Modified: / 8.1.1998 / 00:34:33 / cg"
+    "Created: / 8.1.1998 / 00:59:26 / cg"
+!
+
+_WGraphics_drawSFChars:nativeContext
+    "/ void drawSFChars (char[]s, int pos1, int len, int x, int y)
+
+    |gc str x y idx1 nChars|
+
+    gc := self gcForWGraphics:nativeContext.
+    gc realized ifFalse:[^ self].
+
+    str := nativeContext argAt:1.
+    idx1 := nativeContext argAt:2.
+    nChars := nativeContext argAt:3.
+    x := nativeContext argAt:4.
+    y := nativeContext argAt:5.
+
+    DrawOPTrace ifTrue:[
+        'drawSFChars x/y= ' print. x print. '@' print. y print.
+               ' s= ' print. str printCR.
+    ].
+    gc displayString:str from:idx1+1 to:idx1+nChars x:x y:y
+
+    "Created: / 6.1.1998 / 21:11:31 / cg"
+    "Modified: / 8.1.1998 / 00:33:59 / cg"
+
+!
+
+_WGraphics_fillArc:nativeContext
+    |gc x y w h startAngle endAngle|
+
+    gc := self gcForWGraphics:nativeContext.
+"/    gc isNil ifTrue:[^ self].
+    gc realized ifFalse:[^ self].
+
+    x := nativeContext argAt:1.
+    y := nativeContext argAt:2.
+    w := nativeContext argAt:3.
+    h := nativeContext argAt:4.
+    startAngle := nativeContext argAt:5.
+    endAngle := nativeContext argAt:6.
+
+    DrawOPTrace ifTrue:[
+        'fillArc x/y= ' print. x print. '@' print. y print.
+               ' w/h= ' print. w print. '@' print. h print.
+               ' startAngle= ' print. startAngle print. ' endAngle= ' print. endAngle printCR.
+    ].
+    gc fillArcX:x y:y width:w height:h from:startAngle angle:(endAngle - startAngle)
+
+    "Created: / 6.1.1998 / 21:11:31 / cg"
+    "Modified: / 8.1.1998 / 00:33:59 / cg"
+!
+
+_WGraphics_fillOval:nativeContext
+    |gc x y w h|
+
+    gc := self gcForWGraphics:nativeContext.
+"/    gc isNil ifTrue:[^ self].
+    gc realized ifFalse:[^ self].
+
+    x := nativeContext argAt:1.
+    y := nativeContext argAt:2.
+    w := nativeContext argAt:3.
+    h := nativeContext argAt:4.
+
+    DrawOPTrace ifTrue:[
+        'drawOval x/y= ' print. x print. '@' print. y print.
+                ' w/h= ' print. w print. '@' print. h printCR.
+    ].
+    gc fillArcX:x y:y width:w height:h from:0 angle:360
+
+    "Created: / 8.1.1998 / 00:46:00 / cg"
+    "Modified: / 8.1.1998 / 00:46:20 / cg"
+!
+
+_WGraphics_fillPolygon:nativeContext
+    |gc xVector yVector count points|
+
+    gc := self gcForWGraphics:nativeContext.
+"/    gc isNil ifTrue:[^ self].
+    gc realized ifFalse:[^ self].
+
+    xVector := nativeContext argAt:1.
+    yVector := nativeContext argAt:2.
+    count := nativeContext argAt:3.
+
+    DrawOPTrace ifTrue:[
+        'fillPolgon' printCR.
+    ].
+
+    points := (1 to:count) collect:[:i | (xVector at:i) @ (yVector at:i)].
+    gc fillPolygon:points
+
+    "Created: / 8.1.1998 / 00:58:09 / cg"
+    "Modified: / 25.1.1998 / 11:03:19 / cg"
+!
+
+_WGraphics_fillRect:nativeContext
+    |gc x y w h|
+
+    gc := self gcForWGraphics:nativeContext.
+"/    gc isNil ifTrue:[^ self].
+    gc realized ifFalse:[^ self].
+
+    x := nativeContext argAt:1.
+    y := nativeContext argAt:2.
+    w := nativeContext argAt:3.
+    h := nativeContext argAt:4.
+
+"/ self halt.
+"/ self internalError:'breakPoint'.
+
+    gc fillRectangleX:x y:y width:w height:h.
+
+    "Created: / 15.8.1997 / 15:43:10 / cg"
+    "Modified: / 8.1.1998 / 00:34:33 / cg"
+!
+
+_WGraphics_fillRoundRect:nativeContext
+    |gc x y w h|
+
+    gc := self gcForWGraphics:nativeContext.
+"/    gc isNil ifTrue:[^ self].
+    gc realized ifFalse:[^ self].
+
+    x := nativeContext argAt:1.
+    y := nativeContext argAt:2.
+    w := nativeContext argAt:3.
+    h := nativeContext argAt:4.
+
+"/ self halt.
+"/ self internalError:'breakPoint'.
+
+    gc displayRectangleX:x y:y width:w height:h.
+
+    "Modified: / 8.1.1998 / 00:34:33 / cg"
+    "Created: / 8.1.1998 / 00:59:36 / cg"
+!
+
+_WGraphics_getClipBounds: nativeContext
+    | gc  rect  r  x  y  w  h |
+
+    gc := self gcForWGraphics: nativeContext.
+
+"/    gc isNil ifTrue:[^ nil].
+
+    rect := (self classForName: 'java.awt.Rectangle') basicNew.
+    (gc isMemberOf: JavaView) ifTrue: [
+        "/ r := gc clippingRectangleOrNil.
+        r := gc getNextUpdateRectangle.
+    ].
+    r isNil ifTrue: [ r := gc clippingRectangleOrNil. ].
+    r isNil ifTrue: [
+        x := y := 0.
+        w := (gc width).
+        h := (gc height).
+    ] ifFalse: [
+        x := (r left).
+        y := (r top).
+        w := (r width).
+        h := (r height).
+    ].
+    rect instVarNamed: 'x' put: x.
+    rect instVarNamed: 'y' put: y.
+    rect instVarNamed: 'width' put: w.
+    rect instVarNamed: 'height' put: h.
+
+"/ 'WGraphics__getClipBounds ' infoPrint. (x@y extent:w@h) infoPrintCR.
+
+    ^ rect
+
+    "Created: / 6.1.1998 / 20:58:07 / cg"
+    "Modified: / 23.12.1998 / 20:14:09 / cg"
+!
+
+_WGraphics_imageCreate:nativeContext
+    |jGraphics imgRep|
+
+    jGraphics := nativeContext receiver.
+    imgRep := nativeContext argAt:1.
+
+    jGraphics instVarNamed:'pData' put:(imgRep instVarNamed:'pData').
+"/ self halt.
+
+    "Created: / 11.1.1998 / 16:34:30 / cg"
+    "Modified: / 17.1.1998 / 12:37:18 / cg"
+!
+
+_WGraphics_pSetFont:nativeContext
+    |gc jFont stFont|
+
+    gc := self gcForWGraphics:nativeContext.
+    jFont := nativeContext argAt:1.
+
+    stFont := jFont instVarNamed:'pData'.
+    (stFont isNil or:[stFont == 0]) ifTrue:[
+"/ self halt.
+    ] ifFalse:[
+        gc font:stFont
+    ].
+
+    "Created: / 6.1.1998 / 20:56:47 / cg"
+    "Modified: / 15.1.1998 / 12:31:20 / cg"
+!
+
+_WGraphics_pSetForeground:nativeContext
+    |gc rgb clr|
+
+    gc := self gcForWGraphics:nativeContext.
+
+    rgb := nativeContext argAt:1.
+    rgb isInteger ifFalse:[
+        "/ its a java.awt.Color
+        rgb := rgb instVarNamed:'value'.
+    ].
+    clr := Color rgbValue:rgb.
+    gc paint:(clr nearestOn:gc device).
+
+"/ self halt.
+"/ self internalError:'breakPoint'.
+
+    "Created: / 6.1.1998 / 20:56:14 / cg"
+    "Modified: / 23.12.1998 / 20:10:49 / cg"
+!
+
+_WGraphics_print:nativeContext
+    "/ void print (sun.awt.windows.WComponentPeer)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:19:25 / cg"
+!
+
+_WGraphics_removeClip:nativeContext
+    "/ void removeClip ()
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:18:05 / cg"
+!
+
+_WGraphics_setPaintMode:nativeContext
+    |gc|
+
+    gc := self gcForWGraphics:nativeContext.
+    gc function:#copy.
+
+    true "DrawOPTrace" ifTrue:[
+        'copyMode' infoPrintCR.
+    ].
+
+    "Created: / 8.1.1998 / 00:33:44 / cg"
+    "Modified: / 28.1.1998 / 23:25:56 / cg"
+!
+
+_WGraphics_setXORMode:nativeContext
+    |gc jColor rgb invColor device|
+
+    gc := self gcForWGraphics:nativeContext.
+    jColor := nativeContext argAt:1.
+    device := gc graphicsDevice.
+
+"/    "/ on trueColor systems, use the provided
+"/    "/ rgb value for inverting.
+"/    "/ on palette systems, use white ^ black
+"/
+"/    device visualType == #TrueColor ifTrue:[
+"/        rgb := jColor instVarNamed:'value'.
+"/        rgb := rgb bitAnd:16rFFFFFF.
+"/        rgb == 0 ifTrue:[
+"/            rgb := 16rFFFFFF.
+"/        ].
+"/        invColor := rgb
+"/    ] ifFalse:[
+"/        invColor := device blackpixel bitXor:device whitepixel.
+"/    ].
+
+    invColor := device blackpixel bitXor:device whitepixel.
+
+"/    gc foreground:(Color colorId:invColor)
+"/       background:device blackColor.
+    device
+        setForeground:invColor background:0
+        in:gc gcId.
+    gc function:#xor.
+
+    true "DrawOPTrace" ifTrue:[
+        'xorMode' infoPrintCR.
+    ].
+
+    "Created: / 8.1.1998 / 00:36:17 / cg"
+    "Modified: / 28.1.1998 / 23:45:03 / cg"
+!
+
+_WLabelPeer_create:nativeContext
+    |jLabelPeer jLabel jFrame frame label
+     lbl|
+
+    jLabelPeer := nativeContext receiver.
+    jLabel := jLabelPeer instVarNamed:'target'.
+
+    lbl := jLabel instVarNamed:'text'.
+    lbl notNil ifTrue:[
+        lbl := Java as_ST_String:lbl
+    ].
+
+    jFrame := nativeContext argAt:1.
+    frame := jFrame instVarNamed:'pData'.
+
+    label := Label in:frame.
+    label sizeFixed:true.
+    lbl notNil ifTrue:[
+        label label:lbl
+    ].
+    self createdWindowsView:label for:jLabelPeer.
+
+    WindowCreationTrace == true ifTrue:[
+        'WLabelPeer_create: ' print. frame print. ' -> ' print. label printNL.
+    ].
+
+    "Created: / 7.1.1998 / 21:42:31 / cg"
+    "Modified: / 13.1.1998 / 22:10:47 / cg"
+!
+
+_WLabelPeer_setAlignment:nativeContext
+    |label alignNr|
+
+    alignNr := nativeContext argAt:1.
+    label := self viewForWPeer:nativeContext.
+    label notNil ifTrue:[
+    ].
+
+    "Created: / 7.1.1998 / 21:43:12 / cg"
+    "Modified: / 8.1.1998 / 17:35:29 / cg"
+!
+
+_WLabelPeer_setText:nativeContext
+    |label jString str|
+
+    jString := nativeContext argAt:1.
+
+    label := self viewForWPeer:nativeContext.
+    jString notNil ifTrue:[
+        str := Java as_ST_String:jString
+    ].
+    label label:str
+
+    "Created: / 7.1.1998 / 21:43:51 / cg"
+    "Modified: / 3.12.1998 / 14:59:18 / cg"
+!
+
+_WListPeer__addItem:nativeContext
+    |jString index1 length selListView m|
+
+    selListView := self viewForWPeer:nativeContext.
+
+    jString := nativeContext argAt:1.
+    index1 := nativeContext argAt:2.
+    length := nativeContext argAt:3.
+
+    (m := selListView model) notNil ifTrue:[
+        m list addLast:(Java as_ST_String:jString).
+        m changed:#list.
+    ].
+
+    "Created: / 26.10.1998 / 20:11:30 / cg"
+    "Modified: / 14.11.1998 / 01:21:03 / cg"
+!
+
+_WListPeer_addItem:nativeContext
+    |jString index selListView m|
+
+    selListView := self viewForWPeer:nativeContext.
+
+    jString := nativeContext argAt:1.
+    index := nativeContext argAt:2.
+
+    m := selListView model.
+    m isNil ifTrue:[
+        Transcript showCR:'JAVA: access to listModel of closed view'.
+    ] ifFalse:[
+        m list addLast:(Java as_ST_String:jString).
+        m changed:#list.
+    ]
+
+    "Created: / 24.1.1998 / 21:10:05 / cg"
+    "Modified: / 2.11.1998 / 17:12:52 / cg"
+!
+
+_WListPeer_create:nativeContext
+    |jListPeer jFrame frame selectionInListView|
+
+    jListPeer := nativeContext receiver.
+
+    jFrame := nativeContext argAt:1.
+    frame := jFrame instVarNamed:'pData'.
+
+    selectionInListView := ScrollableView for:SelectionInListView in:frame.
+    selectionInListView action:[:index | jListPeer perform:#'handleListChanged(I)V' with:(index - 1)].
+    selectionInListView doubleClickAction:[:index | jListPeer perform:#'handleAction(I)V' with:(index - 1)].
+    selectionInListView model:(SelectionInList new list:(List new)).
+    selectionInListView useIndex:true.
+
+    self createdWindowsView:selectionInListView for:jListPeer.
+
+    WindowCreationTrace == true ifTrue:[
+        'WTextAreaPeer_create: ' print. frame print. ' -> ' print. selectionInListView printNL.
+    ].
+
+    "Created: / 24.1.1998 / 19:58:54 / cg"
+    "Modified: / 9.4.1998 / 22:19:07 / cg"
+!
+
+_WListPeer_delItems:nativeContext
+    |jString index1 index2 selListView model list|
+
+    selListView := self viewForWPeer:nativeContext.
+
+    index1 := (nativeContext argAt:1) + 1. "/ java indices are 0-based.
+    index2 := (nativeContext argAt:2) + 1. "/ st indices are 1-based.
+
+    model := selListView model.
+    model isNil ifTrue:[^ self].
+    list := model list.
+    list size >= index1 ifTrue:[
+        list removeFromIndex:index1 toIndex:(index2 min:list size).
+        model changed:#list.
+    ].
+
+    "Created: / 9.4.1998 / 22:19:25 / cg"
+    "Modified: / 30.12.1998 / 20:00:50 / cg"
+!
+
+_WListPeer_deselect:nativeContext
+    "/ void deselect (int)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:15:10 / cg"
+!
+
+_WListPeer_getMaxWidth:nativeContext
+    "/ int getMaxWidth ()
+
+    ^ 1000 "/ a dummy value
+
+"/    UnimplementedNativeMethodSignal raise
+
+    "Created: / 14.11.1998 / 10:44:29 / cg"
+!
+
+_WListPeer_isSelected:nativeContext
+    |selectionInListView index model|
+
+    selectionInListView := self viewForWPeer:nativeContext.
+
+    index := nativeContext argAt:1.
+    (model := selectionInListView model) notNil ifTrue:[
+        (model selectionIndex == (index + 1))  "/ JAVA indexing starts at 0
+        ifTrue:[
+            ^ 1
+        ]
+    ].
+    ^ 0.
+
+    "Created: / 24.1.1998 / 22:42:31 / cg"
+    "Modified: / 25.1.1998 / 01:35:32 / cg"
+!
+
+_WListPeer_makeVisible:nativeContext
+    |selectionInListView lineNr|
+
+    selectionInListView := self viewForWPeer:nativeContext.
+
+    lineNr := nativeContext argAt:1.
+
+    selectionInListView makeLineVisible:(lineNr + 1)
+
+    "Modified: / 24.1.1998 / 20:01:06 / cg"
+    "Created: / 20.10.1998 / 14:14:50 / cg"
+!
+
+_WListPeer_select:nativeContext
+    |selectionInListView index model|
+
+    selectionInListView := self viewForWPeer:nativeContext.
+
+    index := nativeContext argAt:1.
+    (model := selectionInListView model) notNil ifTrue:[
+        model selectionIndex:(index + 1).  "/ JAVA indexing starts at 0
+    ]
+
+    "Created: / 24.1.1998 / 22:32:35 / cg"
+    "Modified: / 25.1.1998 / 01:28:46 / cg"
+!
+
+_WListPeer_setMultipleSelections:nativeContext
+    |selectionInListView onOff|
+
+    selectionInListView := self viewForWPeer:nativeContext.
+
+    onOff := (nativeContext argAt:1) ~~ 0.
+
+    selectionInListView multipleSelectOk:onOff.
+
+    "Modified: / 24.1.1998 / 20:01:06 / cg"
+!
+
+_WListPeer_updateMaxItemWidth:nativeContext
+    |selectionInListView lineNr|
+
+    selectionInListView := self viewForWPeer:nativeContext.
+
+    "Created: / 26.10.1998 / 20:09:46 / cg"
+!
+
+_WMenuBarPeer_addMenu:nativeContext
+    "/ void addMenu (java.awt.Menu)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:14:00 / cg"
+!
+
+_WMenuBarPeer_create:nativeContext
+    |jMenuBarPeer jMenuBar jFrame frame menuBar|
+
+    jMenuBarPeer := nativeContext receiver.
+    jMenuBar := jMenuBarPeer instVarNamed:'target'.
+
+    jFrame := nativeContext argAt:1.
+    frame := jFrame instVarNamed:'pData'.
+
+    menuBar := MenuPanel in:frame.
+    menuBar verticalLayout:false.
+    menuBar realize.
+
+    self createdWindowsView:menuBar for:jMenuBarPeer.
+
+    WindowCreationTrace == true ifTrue:[
+        'WMenuBarPeer_create: ' print. frame print. ' -> ' print. menuBar printNL.
+    ].
+
+    "Created: / 7.1.1998 / 21:38:31 / cg"
+    "Modified: / 25.1.1998 / 13:19:03 / cg"
+!
+
+_WMenuBarPeer_delMenu:nativeContext
+    "/ void delMenu (int)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:14:11 / cg"
+!
+
+_WMenuItemPeer__dispose:nativeContext
+    |jMenuItemPeer item|
+
+    jMenuItemPeer := nativeContext receiver.
+    item := jMenuItemPeer instVarNamed:'pData'.
+
+"/ what should be done here ?
+
+    "Created: / 29.3.1998 / 17:16:05 / cg"
+    "Modified: / 29.3.1998 / 17:16:35 / cg"
+!
+
+_WMenuItemPeer__setLabel:nativeContext
+    "/ void _setLabel (java.lang.String)
+
+    |jMenuItemPeer item label|
+
+    jMenuItemPeer := nativeContext receiver.
+    item := jMenuItemPeer instVarNamed:'pData'.
+    (item isNil or:[item == 0]) ifTrue:[
+        'JAVA [warning]: NULL menu item in setLabel' infoPrintCR.
+        ^ self
+    ].
+
+    label := nativeContext argAt:1.
+    label isNil ifTrue:[
+        label := ''
+    ] ifFalse:[
+        label := Java as_ST_String:label
+    ].
+    item label:label.
+
+    "Modified: / 11.12.1998 / 16:40:18 / cg"
+!
+
+_WMenuItemPeer_create:nativeContext
+    |jMenuItemPeer jMenuItem jMenuPeer menu item lbl|
+
+    jMenuItemPeer := nativeContext receiver.
+    jMenuItem := jMenuItemPeer instVarNamed:'target'.
+
+    jMenuPeer := nativeContext argAt:1.
+    menu := jMenuPeer instVarNamed:'pData'.
+    (menu isNil or:[menu == 0]) ifTrue:[
+        'JAVA: no menu to create item in' infoPrintCR.
+        ^ self
+    ].
+    item := menu createAtIndex:nil.
+    item value:[
+                jMenuItemPeer perform:#'handleAction(I)V' with:0
+               ].
+
+    lbl := jMenuItem instVarNamed:'label'.
+    lbl notNil ifTrue:[
+        lbl := Java as_ST_String:lbl.
+        item label:lbl
+    ].
+
+    jMenuItemPeer instVarNamed:'pData' put:item.
+
+    WindowOPTrace == true ifTrue:[
+        'WMenuItem_create: ' print. menu print. ' -> ' print. item printNL.
+    ].
+
+    "Created: / 7.1.1998 / 21:40:44 / cg"
+    "Modified: / 3.12.1998 / 20:43:20 / cg"
+!
+
+_WMenuItemPeer_enable:nativeContext
+    |jMenuItemPeer item state|
+
+    jMenuItemPeer := nativeContext receiver.
+    item := jMenuItemPeer instVarNamed:'pData'.
+    (item isNil or:[item == 0]) ifTrue:[
+        'JAVA [warning]: NULL menu item in enable' infoPrintCR.
+        ^ self
+    ].
+
+    state := nativeContext argAt:1.
+    item enabled:(state ~~ 0)
+
+    "Created: / 7.1.1998 / 22:41:38 / cg"
+    "Modified: / 11.12.1998 / 16:40:26 / cg"
+!
+
+_WMenuPeer_addSeparator:nativeContext
+    "/ void addSeparator ()
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:13:14 / cg"
+!
+
+_WMenuPeer_createMenu:nativeContext
+    |jMenuPeer jMenu jMenuBarPeer menuPanel menu
+     lbl item|
+
+    jMenuPeer := nativeContext receiver.
+    jMenu := jMenuPeer instVarNamed:'target'.
+
+    jMenuBarPeer := nativeContext argAt:1.
+    menuPanel := jMenuBarPeer instVarNamed:'pData'.
+
+    item := menuPanel createAtIndex:nil.
+    lbl := jMenu instVarNamed:'label'.
+    lbl notNil ifTrue:[
+        lbl := Java as_ST_String:lbl.
+        item label:lbl
+    ].
+
+    menu := MenuPanel new.
+    item submenu:menu.
+
+    jMenuPeer instVarNamed:'pData' put:menu.
+
+'createMenuPeer: ' print. menuPanel print. ' -> ' print. menu printNL.
+
+    "Created: / 7.1.1998 / 21:39:50 / cg"
+    "Modified: / 13.1.1998 / 22:11:09 / cg"
+!
+
+_WMenuPeer_createSubMenu:nativeContext
+    "/ void createSubMenu (sun.awt.windows.WMenuPeer)
+"/    UnimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:13:43 / cg"
+    "Modified: / 3.12.1998 / 21:41:07 / cg"
+!
+
+_WMenuPeer_delItem:nativeContext
+    "/ void delItem (int)
+    |jMenuPeer jMenu menuPanel itemIndex|
+
+    jMenuPeer := nativeContext receiver.
+    menuPanel := jMenuPeer instVarNamed:'pData'.
+
+    itemIndex := nativeContext argAt:1.
+    menuPanel remove:itemIndex.
+
+"/    UnimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:13:30 / cg"
+    "Modified: / 10.12.1998 / 21:12:29 / cg"
+!
+
+_WPanelPeer_calculateInsets:nativeContext
+    "/ new with jdk1.2 ...
+
+    "Created: / 27.1.1998 / 21:40:00 / cg"
+!
+
+_WPopupMenuPeer__show:nativeContext
+    "/ void _show (java.awt.Event)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:12:53 / cg"
+!
+
+_WPopupMenuPeer_createMenu:nativeContext
+    "/ void createMenu (sun.awt.windows.WComponentPeer)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:12:43 / cg"
+!
+
+_WPrintJob_end:nativeContext
+    "/ void end ()
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:11:28 / cg"
+!
+
+_WScrollPanePeer__getHScrollbarHeight:nativeContext
+    |scrollPane|
+
+    scrollPane := self viewForWPeer:nativeContext.
+    ^ HorizontalScrollBar new preferredExtent y.
+
+    "Created: / 9.4.1998 / 17:30:56 / cg"
+    "Modified: / 10.4.1998 / 14:59:28 / cg"
+!
+
+_WScrollPanePeer__getVScrollbarWidth:nativeContext
+    |scrollPane|
+
+    scrollPane := self viewForWPeer:nativeContext.
+    ^ ScrollBar new preferredExtent x.
+
+    "Created: / 9.4.1998 / 17:29:48 / cg"
+    "Modified: / 10.4.1998 / 15:00:33 / cg"
+!
+
+_WScrollPanePeer_create:nativeContext
+    |jScrollPanePeer jScrollPane jFrame frame scrollPane
+     lbl|
+
+    jScrollPanePeer := nativeContext receiver.
+    jScrollPane := jScrollPanePeer instVarNamed:'target'.
+
+    jFrame := nativeContext argAt:1.
+    frame := jFrame instVarNamed:'pData'.
+
+    "/ create with a simple view ...
+    scrollPane := ScrollableView for:JavaView in:frame.
+
+    self createdWindowsView:scrollPane for:jScrollPanePeer.
+
+    WindowCreationTrace == true ifTrue:[
+        'WScrollPanePeer_create: ' print. frame print. ' -> ' print. scrollPane printNL.
+    ].
+
+    "Created: / 9.4.1998 / 17:25:08 / cg"
+    "Modified: / 9.4.1998 / 22:06:09 / cg"
+!
+
+_WScrollPanePeer_getOffset:nativeContext
+    "/ int getOffset (int)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:16:29 / cg"
+!
+
+_WScrollPanePeer_getScrollChild:nativeContext
+    "/ java.awt.Component getScrollChild ()
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:17:00 / cg"
+!
+
+_WScrollPanePeer_setInsets:nativeContext
+
+    "Modified: / 9.4.1998 / 17:26:11 / cg"
+    "Created: / 9.4.1998 / 17:29:10 / cg"
+!
+
+_WScrollPanePeer_setScrollPosition:nativeContext
+    "/ void setScrollPosition (int int)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:16:44 / cg"
+!
+
+_WScrollPanePeer_setSpans:nativeContext
+
+    "Created: / 9.4.1998 / 17:31:44 / cg"
+!
+
+_WScrollbarPeer__setValues:nativeContext
+    |scrollBar value visibleAmount min max|
+
+    scrollBar := self viewForWPeer:nativeContext.
+
+    value := nativeContext argAt:1.
+    visibleAmount := nativeContext argAt:2.
+    min := nativeContext argAt:3.
+    max := nativeContext argAt:4.
+
+    (min ~~ 0 or:[max ~~ 100]) ifTrue:[
+        scrollBar thumb start:min stop:max.
+    ].
+
+    scrollBar thumbOrigin:value thumbHeight:visibleAmount.
+
+    "Created: / 13.1.1998 / 22:13:57 / cg"
+    "Modified: / 14.10.1998 / 14:53:00 / cg"
+!
+
+_WScrollbarPeer_create:nativeContext
+    |jScrollbarPeer jScrollbar jFrame frame scrollBar
+     min max|
+
+    jScrollbarPeer := nativeContext receiver.
+    jScrollbar := jScrollbarPeer instVarNamed:'target'.
+
+    jFrame := nativeContext argAt:1.
+    frame := jFrame instVarNamed:'pData'.
+
+    (jScrollbar instVarNamed:'orientation') == 0 "HORIZONTAL" ifTrue:[
+        scrollBar := HorizontalScrollBar in:frame.
+    ] ifFalse:[
+        scrollBar := ScrollBar in:frame.
+    ].
+    min := jScrollbar instVarNamed:'minimum'.
+    max := jScrollbar instVarNamed:'maximum'.
+
+    scrollBar scrollDownAction:[
+                        scrollBar thumbOrigin:(scrollBar thumbOrigin + ((max-min)/10) min:max).
+                        jScrollbarPeer perform:#'dragAbsolute(I)V' with:scrollBar thumbOrigin rounded.
+                     ].
+    scrollBar scrollUpAction:[
+                        scrollBar thumbOrigin:(scrollBar thumbOrigin - ((max-min)/10) max:min).
+                        jScrollbarPeer perform:#'dragAbsolute(I)V' with:scrollBar thumbOrigin rounded.
+                     ].
+    scrollBar scrollAction:[:org |
+                        jScrollbarPeer perform:#'dragAbsolute(I)V' with:org rounded.
+                     ].
+    self createdWindowsView:scrollBar for:jScrollbarPeer.
+
+    WindowCreationTrace == true ifTrue:[
+        'WScrollbarPeer_create: ' print. frame print. ' -> ' print. scrollBar printNL.
+    ].
+
+    "Created: / 5.1.1998 / 01:53:30 / cg"
+    "Modified: / 14.10.1998 / 15:36:19 / cg"
+!
+
+_WScrollbarPeer_setLineIncrement:nativeContext
+    |scrollBar inc|
+
+Transcript showCR:'JavaVM: WScrollbarPeer_setLineIncrement unimplemented'.
+
+    scrollBar := self viewForWPeer:nativeContext.
+
+    inc := nativeContext argAt:1.
+"/    scrollBar thumb lineIncrement:inc.
+
+    "Created: / 25.1.1998 / 11:52:19 / cg"
+    "Modified: / 14.10.1998 / 14:53:56 / cg"
+!
+
+_WScrollbarPeer_setPageIncrement:nativeContext
+    |scrollBar inc|
+
+Transcript showCR:'JavaVM: WScrollbarPeer_setPageIncrement unimplemented'.
+
+    scrollBar := self viewForWPeer:nativeContext.
+
+    inc := nativeContext argAt:1.
+"/    scrollBar thumb pageIncrement:inc.
+
+    "Created: / 25.1.1998 / 11:52:01 / cg"
+    "Modified: / 14.10.1998 / 14:54:04 / cg"
+!
+
+_WTextAreaPeer_create:nativeContext
+    |jTextAreaPeer jFrame frame editTextView|
+
+    jTextAreaPeer := nativeContext receiver.
+
+    jFrame := nativeContext argAt:1.
+    frame := jFrame instVarNamed:'pData'.
+
+    editTextView := HVScrollableView for:EditTextView in:frame.
+
+    self createdWindowsView:editTextView for:jTextAreaPeer.
+
+    WindowCreationTrace == true ifTrue:[
+        'WTextAreaPeer_create: ' print. frame print. ' -> ' print. editTextView printNL.
+    ].
+
+    "Created: / 7.1.1998 / 21:49:49 / cg"
+    "Modified: / 15.1.1998 / 12:56:18 / cg"
+!
+
+_WTextAreaPeer_insertText:nativeContext
+    |textView pos string jstring|
+
+    textView := self viewForWPeer:nativeContext.
+    (textView isKindOf:ScrollableView) ifTrue:[
+        textView := textView scrolledView
+    ].
+
+    jstring := nativeContext argAt:1.
+    string := Java as_ST_String:jstring.
+    pos := nativeContext argAt:2.
+
+    textView insert:string at:pos.
+    textView cursorToCharacterPosition:pos + string size.
+    textView makeCursorVisible.
+"/ textView invalidateRepairNow:true.
+    ^ nil
+
+    "Created: / 7.1.1998 / 21:50:23 / cg"
+    "Modified: / 5.4.1998 / 17:37:24 / cg"
+!
+
+_WTextAreaPeer_replaceText:nativeContext
+    "/ void replaceText (java.lang.String int int)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:11:14 / cg"
+!
+
+_WTextComponentPeer_enableEditing:nativeContext
+    |textView enabled|
+
+    textView := self viewForWPeer:nativeContext.
+    enabled := (nativeContext argAt:1) ~~ 0.
+
+    ^ textView readOnly:enabled not
+
+    "Created: / 5.1.1998 / 01:29:38 / cg"
+    "Modified: / 25.1.1998 / 16:29:56 / cg"
+!
+
+_WTextComponentPeer_getSelectionEnd:nativeContext
+    |textView|
+
+    textView := self viewForWPeer:nativeContext.
+
+    ^ textView characterPositionOfSelectionEnd
+
+    "Created: / 8.1.1998 / 17:41:56 / cg"
+    "Modified: / 15.1.1998 / 15:47:18 / cg"
+!
+
+_WTextComponentPeer_getSelectionStart:nativeContext
+    |textView|
+
+    textView := self viewForWPeer:nativeContext.
+
+    ^ textView characterPositionOfSelection - 1
+
+    "Created: / 15.8.1997 / 15:45:45 / cg"
+    "Modified: / 15.1.1998 / 15:46:51 / cg"
+!
+
+_WTextComponentPeer_getText:nativeContext
+    |textView string jString|
+
+    textView := self viewForWPeer:nativeContext.
+
+    string := textView contents asString.
+    jString := Java as_String:string.
+    ^ jString
+
+    "Created: / 6.1.1998 / 21:05:15 / cg"
+    "Modified: / 8.1.1998 / 17:36:52 / cg"
+!
+
+_WTextComponentPeer_select:nativeContext
+    |textView selStart selEnd|
+
+    textView := self viewForWPeer:nativeContext.
+    selStart := nativeContext argAt:1.
+    selEnd := nativeContext argAt:2.
+
+    selStart == selEnd ifTrue:[
+        "/ clear selection
+        textView unselect.
+        "/ and set caret
+        textView cursorToCharacterPosition:selStart + 1
+    ] ifFalse:[
+        "/ change selection
+        textView selectFromCharacterPosition:selStart+1 to:selEnd
+    ].
+
+    "Created: / 15.8.1997 / 15:45:58 / cg"
+    "Modified: / 15.1.1998 / 21:55:57 / cg"
+!
+
+_WTextComponentPeer_setText:nativeContext
+    |textView string jstring|
+
+    textView := self viewForWPeer:nativeContext.
+
+    jstring := nativeContext argAt:1.
+    jstring notNil ifTrue:[
+        string := Java as_ST_String:jstring
+    ].
+
+    textView contents:string.
+
+    "Created: / 5.1.1998 / 01:28:23 / cg"
+    "Modified: / 11.12.1998 / 12:16:46 / cg"
+!
+
+_WTextFieldPeer_create:nativeContext
+    |jTextFieldPeer jFrame frame editField|
+
+    jTextFieldPeer := nativeContext receiver.
+
+    jFrame := nativeContext argAt:1.
+    frame := jFrame instVarNamed:'pData'.
+
+    editField := EditField in:frame.
+
+    self createdWindowsView:editField for:jTextFieldPeer.
+
+    editField crAction:[
+                        jTextFieldPeer perform:#handleAction.
+                  ].
+    WindowCreationTrace == true ifTrue:[
+        'WTextFieldPeer_create: ' print. frame print. ' -> ' print. editField printNL.
+    ].
+
+    "Created: / 5.1.1998 / 01:27:37 / cg"
+    "Modified: / 4.11.1998 / 21:07:30 / cg"
+!
+
+_WTextFieldPeer_setEchoCharacter:nativeContext
+    |editField char|
+
+    editField := self viewForWPeer:nativeContext.
+
+    char := nativeContext argAt:1.
+    editField passwordCharacter:(Character value:char).
+
+    "Created: / 25.1.1998 / 16:28:30 / cg"
+!
+
+_WToolkit_beep:nativeContext
+    "/ void beep ()
+
+    Screen current beep
+
+    "Created: / 12.11.1998 / 19:09:23 / cg"
+    "Modified: / 11.12.1998 / 12:15:23 / cg"
+!
+
+_WToolkit_eventLoop:nativeContext
+    (JavaEventThread notNil and:[JavaEventThread isDead not]) ifTrue:[
+        'JavaVM [warning]: oops - two threads executing eventLoop' errorPrintCR.
+    ].
+
+    JavaEventThread := Processor activeProcess.
+    [
+        [true] whileTrue:[
+            AbortSignal handle:[:ex |
+                ex return
+            ] do:[
+                self doWindowsEventThread.
+            ]
+        ].
+    ] valueNowOrOnUnwindDo:[
+        JavaEventThread := nil.
+    ].
+
+    "Created: / 6.1.1998 / 21:01:44 / cg"
+    "Modified: / 8.1.1999 / 17:08:00 / cg"
+!
+
+_WToolkit_getComboHeightOffset:nativeContext
+    ^ 0
+
+    "Modified: / 20.3.1997 / 13:50:04 / cg"
+    "Created: / 22.10.1998 / 00:59:14 / cg"
+!
+
+_WToolkit_getScreenHeight:nativeContext
+    ^ Screen current height
+
+    "Modified: / 20.3.1997 / 13:50:04 / cg"
+    "Created: / 13.1.1998 / 09:24:45 / cg"
+!
+
+_WToolkit_getScreenResolution:nativeContext
+    ^ Screen current resolution x rounded
+
+    "Modified: / 20.3.1997 / 13:50:04 / cg"
+    "Created: / 17.1.1998 / 21:54:48 / cg"
+!
+
+_WToolkit_getScreenWidth:nativeContext
+    ^ Screen current width
+
+    "Modified: / 20.3.1997 / 13:50:04 / cg"
+    "Created: / 13.1.1998 / 09:24:37 / cg"
+!
+
+_WToolkit_init:nativeContext
+
+    "Created: / 3.1.1998 / 02:30:57 / cg"
+!
+
+_WToolkit_loadSystemColors:nativeContext
+"/ self halt.
+
+    "Modified: / 18.3.1997 / 18:43:26 / cg"
+    "Created: / 5.1.1998 / 02:19:09 / cg"
+!
+
+_WToolkit_makeColorModel:nativeContext
+    "/ java.awt.image.ColorModel makeColorModel ()
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:08:47 / cg"
+!
+
+_WToolkit_sync:nativeContext
+    "/ void sync ()
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:09:14 / cg"
+!
+
+_WWindowPeer__setResizable:nativeContext
+    |view onOff|
+
+    view := self viewForWPeer:nativeContext.
+
+    onOff := (nativeContext argAt:1) == 1.
+    view isTopView ifTrue:[
+        onOff ifTrue:[
+            view minExtent:10@10.
+            view maxExtent:(Screen current extent).
+        ] ifFalse:[
+            view minExtent:view extent.
+            view maxExtent:view extent.
+        ]
+    ] ifFalse:[
+        (view isMemberOf:JavaEmbeddedFrameView) ifFalse:[
+            self halt.
+        ]
+    ].
+
+"/ 'JAVA: WWindowPeer_setResizable: ' print. view print. ' yes/no: ' print. onOff printNL.
+
+    ^ nil
+
+    "Created: / 5.1.1998 / 00:57:59 / cg"
+    "Modified: / 16.1.1998 / 18:08:00 / cg"
+!
+
+_WWindowPeer__setTitle:nativeContext
+    |view jString string|
+
+    view := self viewForWPeer:nativeContext.
+
+    jString := nativeContext argAt:1.
+    string := Java as_ST_String:jString.
+
+"/ 'JAVA: WWindowPeer_pSetTitle: ' print. string print. ' ' print. view printNL.
+
+    view label:string.
+    ^ nil
+
+    "Created: / 5.1.1998 / 00:57:17 / cg"
+    "Modified: / 8.1.1998 / 17:37:41 / cg"
+!
+
+_WWindowPeer_create:nativeContext
+    "/ void create (sun.awt.windows.WComponentPeer)
+    |jWindowPeer jWindow top window pDataIdx|
+
+    jWindowPeer := nativeContext receiver.
+
+    jWindow := jWindowPeer instVarNamed:'target'.
+    window := jWindowPeer instVarNamed:'pData'.
+
+    (window notNil and:[window ~~ 0]) ifTrue:[
+        WindowCreationTrace == true ifTrue:[
+            'JAVA: window view already created: ' infoPrint.
+            jWindowPeer class name infoPrintCR.
+        ].
+    ] ifFalse:[
+"/ OLD
+"/        window := StandardSystemView new.
+"/        self createdWindowsView:window for:jWindowPeer.
+"/        JavaWindowGroup addTopView:window.
+
+        window := JavaPopUpView new.
+        window borderWidth:0.
+        window level:0.
+        window delegate:self.
+        window javaPeer:jWindowPeer.
+        self createdWindowsView:window for:jWindowPeer.
+        JavaWindowGroup addTopView:window.
+
+"/        top := StandardSystemView new.
+"/        window := JavaView origin:0.0@0.0 corner:1.0@1.0 in:top.
+"/        window delegate:self.
+"/        window javaPeer:jWindowPeer.
+"/        self createdWindowsView:window for:jWindowPeer.
+"/        JavaWindowGroup addTopView:top.
+
+    ].
+
+    WindowCreationTrace == true ifTrue:[
+        'JAVA: WWindowPeer_create: ' print. jWindowPeer displayString print.
+        ' window: ' print. window printNL.
+    ].
+
+    "Created: / 4.1.1998 / 17:56:39 / cg"
+    "Modified: / 4.12.1998 / 17:37:59 / cg"
+!
+
+_WWindowPeer_getContainerElement:nativeContext
+    "/ java.awt.Component getContainerElement (java.awt.Container int)
+    JavaVM unimplementedNativeMethodSignal raise
+
+    "Created: / 12.11.1998 / 19:10:54 / cg"
+!
+
+_WWindowPeer_toBack:nativeContext
+    |view|
+
+    view := self viewForWPeer:nativeContext.
+    view lower.
+
+    "Created: / 7.5.1998 / 00:23:03 / cg"
+!
+
+_WWindowPeer_toFront:nativeContext
+    |view|
+
+    view := self viewForWPeer:nativeContext.
+    view raise.
+
+    "Created: / 9.4.1998 / 22:17:28 / cg"
+!
+
+_WWindowPeer_updateInsets:nativeContext
+"/ self halt.
+
+    "Modified: / 18.3.1997 / 18:43:18 / cg"
+    "Created: / 4.1.1998 / 18:09:04 / cg"
+!
+
+_Win32Process_create:nativeContext
+    "really create a win32 process"
+
+    |env cmd jProcess p inPipe outPipe errorPipe|
+
+    jProcess := nativeContext receiver.
+    cmd := nativeContext argAt:1.
+    cmd := Java as_ST_String:cmd.
+
+    env := nativeContext argAt:2.
+    env notNil ifTrue:[
+        self halt
+    ].
+self halt.
+
+    p := Win32Process new.
+    p command:cmd.
+    p environment:env.
+    p inStream:inPipe.
+    p outStream:outPipe.
+    p errorStream:errorPipe.
+    p directory:nil.
+    p startProcess.
+self halt.
+
+    jProcess instVarNamed:'handle' put:p.
+
+    "Created: / 10.11.1998 / 19:50:31 / cg"
+    "Modified: / 10.11.1998 / 21:34:18 / cg"
+!
+
+_X11FontMetrics_getMFCharSegmentWidth:nativeContext
+    "get multi-font string-segment width.
+     Not yet supported - use standard strings width"
+
+    |jMetrics jFont jFontDescr stFont w
+     bool1 cp offs lenght bp int1|
+
+    jMetrics := nativeContext receiver.
+    jFont := nativeContext argAt:1.
+    jFontDescr := nativeContext argAt:2.
+    cp := nativeContext argAt:3.
+    lenght := nativeContext argAt:4.
+
+    stFont := jFont instVarNamed:'pData'.
+    (stFont isNil or:[stFont == 0]) ifTrue:[
+        self halt
+    ].
+
+    stFont device isNil ifTrue:[
+        stFont := stFont on:Display.
+        jFont instVarNamed:'pData' put:stFont.
+    ].
+    w := stFont widthOf:cp from:1 to:lenght.
+    ^ w.
+!
+
+_X11FontMetrics_init:nativeContext
+    ^ self _WFontMetrics_init:nativeContext
+!
+
+_X11GraphicsDevice_getConfigType:nativeContext
+    "/ new with jdk1.2 ...
+
+    |configNr cls|
+
+    "/ for now, only one config.
+    configNr := nativeContext argAt:1.
+
+    cls := Java classNamed:'java.awt.GraphicsDevice'.
+    ^ cls instVarNamed:'TYPE_RASTER_SCREEN'.
+
+    "Created: / 28.1.1998 / 22:19:05 / cg"
+!
+
+_X11GraphicsDevice_getNumConfigs:nativeContext
+    "/ new with jdk1.2 ...
+
+    ^ 1
+
+    "Created: / 28.1.1998 / 22:13:26 / cg"
+    "Modified: / 28.1.1998 / 22:14:33 / cg"
+!
+
+_X11GraphicsEnvironment_getNumScreens:nativeContext
+    "/ new with jdk1.2 ...
+
+    "/ could return the actual number of screens ...
+
+    ^ 1
+
+    "Created: / 28.1.1998 / 01:50:22 / cg"
+    "Modified: / 28.1.1998 / 22:12:32 / cg"
+!
+
+_X11GraphicsEnvironment_initDisplay:nativeContext
+    "/ new with jdk1.2 ...
+
+    "Created: / 28.1.1998 / 01:50:22 / cg"
+!
+
+_X11Graphics_changeClip:nativeContext
+    ^ self _WGraphics_changeClip:nativeContext
+!
+
+_X11Graphics_createFromComponent:nativeContext
+    ^ self _WGraphics_createFromComponent:nativeContext
+!
+
+_X11Graphics_disposeImpl:nativeContext
+    ^ self _WGraphics_dispose:nativeContext
+!
+
+_X11Graphics_drawMFCharsSegment:nativeContext
+    ^ self _WGraphics_drawMFCharsSegment:nativeContext
+!
+
+_X11Graphics_drawRect:nativeContext
+    ^ self _WGraphics_drawRect:nativeContext
+!
+
+_X11Graphics_fillOval:nativeContext
+    ^ self _WGraphics_fillOval:nativeContext
+!
+
+_X11Graphics_fillRect:nativeContext
+    ^ self _WGraphics_fillRect:nativeContext
+!
+
+_X11Graphics_pSetFont:nativeContext
+    ^ self _WGraphics_pSetFont:nativeContext
+!
+
+_X11Graphics_pSetForeground:nativeContext
+    ^ self _WGraphics_pSetForeground:nativeContext
+! !
+
+!JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - old-style (converted)'!
+
+_FileInputStream_skip:nativeContext
+    "/ long skip (long)
+    |file nSkip nSkipped|
+
+    file := self validateFile:(nativeContext receiver).
+    nSkip := nativeContext argAt:1.
+
+    file == Stdin ifTrue:[
+        file := StdinReplacementFileQuerySignal raiseRequest.
+        file isNil ifTrue:[
+            ^ -1
+        ]
+    ].
+
+    FileIOTrace ifTrue:[
+        (('JAVA: skip %1 byte(s) from ' bindWith:nSkip printString) , file pathName) infoPrintCR.
+    ].
+
+    file skip:nSkip.
+    ^ nSkip
+
+    "Modified: / 27.1.1999 / 20:36:11 / cg"
+! !
+
+!JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - stx.libjava'!
+
+_stx_libjava_ClassLoader_findClassS: nativeContext
+
+    <javanative: 'stx/libjava/ClassLoader' name: 'findCla'>
+
+    | nm cls |
+    nm := Java as_ST_String: (nativeContext argAt: 1).
+    (nm startsWith: 'SMALLTALK.') ifFalse:[
+        self throwClassNotFoundException: ('No such smalltalk class (%1)' bindWith: nm).
+        ^self
+    ].
+    nm := nm copyFrom: 'SMALLTALK.' size + 1.
+    cls := Smalltalk at: nm asSymbol.
+    cls isNil ifTrue:[
+        self throwClassNotFoundException: ('No such smalltalk class (%1)' bindWith: nm).
+        ^self
+    ].
+    ^Reflection javaClassObjectForClass: cls.
+
+    "Modified: / 30-07-2012 / 23:19:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - stx.libjava.groovy'!
+
+_stx_libjava_groovy_GroovyClassLoader_SystemClassCollector_getDefiningClassLoader: nativeContext
+
+    <javanative: 'stx/libjava/groovy/GroovyClassLoader$SystemClassCollector' name: 'getDefiningClassLoader()Lstx/libjava/groovy/GroovyClassLoader;'>
+
+    ^ SystemClassLoader
+
+    "Modified: / 20-02-2012 / 22:30:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - stx.libjava.tests'!
+
+_stx_libjava_tests_MonitorTests_abort: nativeContext
+
+    <javanative: 'stx/libjava/tests/MonitorTests' name: 'abort()V'>
+
+    AbortOperationRequest raiseRequest.
+
+    "Modified: / 04-11-2011 / 21:50:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - stx.libjava.tests.lang'!
+
+_stx_libjava_tests_lang_MonitorTests_abort: nativeContext
+    <javanative: 'stx/libjava/tests/lang/MonitorTests' name: 'abort()V'>
+        AbortOperationRequest raiseRequest.
+
+    "Modified: / 10-09-2012 / 22:56:16 / m"
+! !
+
+!JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - stx.libjava.tests.vm'!
+
+_stx_libjava_tests_vm_XLOAD_forcePatchupAndUnfix: nativeContext
+
+    <javanative: 'stx/libjava/tests/MonitorTests' name: 'abort()V'>
+
+    | ctx |
+
+    ctx := thisContext.
+
+    ObjectMemory garbageCollect.
+    [ ctx notNil ] whileTrue:[
+        1 to: ctx size do:[:i|
+                Transcript showCR: i printString , ' -> ', (ctx at: i) printString.
+        ].
+        ctx := ctx sender.
+
+    ].
+    ObjectMemory garbageCollect.
+
+
+    "Modified: / 04-11-2011 / 21:50:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - sun.font'!
+
+_sun_font_FontManager_initIDs: nativeContext
+
+    <javanative: 'sun/font/FontManager' name: 'initIDs()V'>
+
+    "Modified: / 09-02-2012 / 22:56:51 / mh <hlopik@gmail.com>"
+!
+
+_sun_font_FreetypeFontScaler_initIDs: nativeContext
+
+    <javanative: 'sun/font/FreetypeFontScaler' name: 'initIDs(Ljava/lang/Class;)V'>
+
+
+!
+
+_sun_font_StrikeCache_getGlyphCacheDescription: nativeContext
+    <javanative: 'sun/font/StrikeCache' name: 'getGlyphCacheDescription([J)V'>
+    (nativeContext argAt:1) at: 1 put: 4.
+
+    "Modified: / 09-02-2012 / 22:57:08 / mh <hlopik@gmail.com>"
+    "Modified: / 05-11-2012 / 17:07:52 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - sun.io'!
+
+_sun_io_Win32ErrorMode_setErrorMode: nativeContext
+
+    <javanative: 'sun/io/Win32ErrorMode' name: 'setErrorMode(J)J'>
+
+    "FIXME: Ignored for now"
+    ^0
+
+    "Modified (format): / 14-08-2012 / 11:35:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - sun.java2d'!
+
+_sun_java2d_Disposer_initIDs: nativeContext
+
+    <javanative: 'sun/java2d/Disposer' name: 'initIDs()V'>
+
+    "Modified: / 09-02-2012 / 22:54:59 / mh <hlopik@gmail.com>"
+! !
+
+!JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - sun.java2d.cmm.lcms'!
+
+_sun_java2d_cmm_lcms_LCMS_getTagData: nativeContext
+
+    <javanative: 'sun/java2d/cmm/lcms/LCMS' name: 'getTagData(JI[B)V'>
+
+    | profileId tag data |
+
+    profileId := nativeContext argAt: 1.
+    tag := nativeContext argAt: 3.
+    data := nativeContext argAt: 4.
+
+    self assert: (nativeContext argAt: 1) = 12344321.
+
+    tag = 1751474532 ifTrue:[
+        data replaceBytesFrom:1
+                with:#[0  3  146  96  108  99  109  115  4  0  0  0  115  112  97  99  51  67  76  82  88  89  90  32  7  216  0  4  0  10  0  10  0  24  0  22  97  99  115  112  65  80  80  76  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  1  0  0  246  214  0  1  0  0  0  0  211  45  108  99  109  115  240  231  92  85  210  30  77  140  137  67  22  250  239  246  146  191  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0]
+                startingAt: 1.
+        ^self.
+    ].
+
+    self breakPoint: #jv.
+
+    "Modified: / 18-04-2012 / 08:29:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_java2d_cmm_lcms_LCMS_getTagSize: nativeContext
+
+    <javanative: 'sun/java2d/cmm/lcms/LCMS' name: 'getTagSize(JI)I'>
+
+    | profileId tag |
+    profileId := nativeContext argAt: 1.
+    tag := nativeContext argAt: 3.
+
+    self assert: (nativeContext argAt: 1) = 12344321.
+
+    "Magic numbers based on trace of real Java code"
+
+    tag = 1751474532 ifTrue:[ ^ 128 ].
+
+
+    self breakPoint: #jv.
+
+    ^128 "Some magic default"
+
+    "Modified: / 18-04-2012 / 08:29:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_java2d_cmm_lcms_LCMS_initLCMS: nativeContext
+
+    <javanative: 'sun/java2d/cmm/lcms/LCMS' name: 'initLCMS(Ljava/lang/Class;Ljava/lang/Class;Ljava/lang/Class;)V'>
+
+    "Nothing to do"
+
+    "Modified: / 09-12-2011 / 18:25:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_java2d_cmm_lcms_LCMS_loadProfile: nativeContext
+
+    <javanative: 'sun/java2d/cmm/lcms/LCMS' name: 'loadProfile([B)J'>
+
+    "FAKE, return some magic"
+    ^12344321
+
+    "Modified: / 09-12-2011 / 18:56:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - sun.java2d.pipe'!
+
+_sun_java2d_pipe_Region_initIDs: nativeContext
+
+    <javanative: 'sun/java2d/pipe/Region' name: 'initIDs()V'>
+
+    "Modified: / 09-02-2012 / 22:55:09 / mh <hlopik@gmail.com>"
+! !
+
+!JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - sun.management'!
+
+_sun_management_MemoryImpl_getMemoryManagers0: nativeContext
+
+    <javanative: 'sun/management/MemoryImpl' name: 'getMemoryManagers0()[Ljava/lang/management/MemoryManagerMXBean;'>
+
+    "HACK, we'll see"
+
+    | beanCls |
+    beanCls := self classForName: 'java.lang.management.MemoryManagerMXBean'.
+    ^beanCls javaArrayClass new:0.
+
+    "Modified: / 04-12-2011 / 19:57:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_management_MemoryImpl_getMemoryPools0: nativeContext
+
+    <javanative: 'sun/management/MemoryImpl' name: 'getMemoryPools0()[Ljava/lang/management/MemoryPoolMXBean;'>
+
+    "HACK, we'll see"
+
+    | beanCls |
+    beanCls := self classForName: 'java.lang.management.MemoryPoolMXBean'.
+    ^beanCls javaArrayClass new:0.
+
+    "Modified: / 04-12-2011 / 19:58:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_management_VMManagementImpl_getStartupTime: nativeContext
+    <javanative: 'sun/management/VMManagementImpl' name: 'getStartupTime()J'>
+    ^ StartupTime.
+
+    "Modified: / 03-11-2011 / 19:17:57 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+_sun_management_VMManagementImpl_getVersion0: nativeContext
+    <javanative: 'sun/management/VMManagementImpl' name: 'getVersion0'>
+    ^ Java as_String: '1.2'.
+
+    "Modified: / 03-11-2011 / 18:42:48 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+_sun_management_VMManagementImpl_initOptionalSupportFields: nativeContext
+    <javanative: 'sun/management/VMManagementImpl' name: 'initOptionalSupportFields()V'>
+    | cls |
+    cls := nativeContext receiver.
+
+    cls instVarNamed: #compTimeMonitoringSupport put: 0.
+    cls instVarNamed: #threadContentionMonitoringSupport put: 0.
+    cls instVarNamed: #currentThreadCpuTimeSupport put: 0.
+    cls instVarNamed: #otherThreadCpuTimeSupport put: 0.
+    cls instVarNamed: #bootClassPathSupport put: 0.
+    cls instVarNamed: #synchronizerUsageSupport put: 0.
+    cls instVarNamed: #objectMonitorUsageSupport put: 0.
+    ^ self.
+
+    "Modified: / 13-12-2011 / 14:35:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+_sun_management_VMManagementImpl_isThreadCpuTimeEnabled: nativeContext
+
+    <javanative: 'sun/management/VMManagementImpl' name: 'isThreadCpuTimeEnabled()Z'>
+
+    ^ 0 "/false should be safe, we'll see...
+
+    "Modified: / 03-11-2011 / 22:45:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - sun.misc'!
+
+_sun_misc_GC_maxObjectInspectionAge: nativeContext
+
+    <javanative: 'sun/misc/GC' name: 'maxObjectInspectionAge()J'>
+
+    "
+    /**
+     * Returns the maximum <em>object-inspection age</em>, which is the number
+     * of real-time milliseconds that have elapsed since the
+     * least-recently-inspected heap object was last inspected by the garbage
+     * collector.
+     *
+     * <p> For simple stop-the-world collectors this value is just the time
+     * since the most recent collection.  For generational collectors it is the
+     * time since the oldest generation was most recently collected.  Other
+     * collectors are free to return a pessimistic estimate of the elapsed
+     * time, or simply the time since the last full collection was performed.
+     *
+     * <p> Note that in the presence of reference objects, a given object that
+     * is no longer strongly reachable may have to be inspected multiple times
+     * before it can be reclaimed.
+     */
+    public static native long maxObjectInspectionAge();
+    "
+
+    ^Random nextIntegerBetween: 0 and: 3600. "Just return some number"
+
+    "Modified: / 02-12-2011 / 21:56:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Signal_findSignal: aJavaContext
+
+    <javanative: 'sun/misc/Signal' name: 'findSignal'>
+
+        | input signame |
+
+    input := Java as_ST_String: (aJavaContext argAt: 1).
+    OperatingSystem isUNIXlike ifTrue:[
+        signame := 'SIG', (input asUppercase).
+        ^UnixOperatingSystem signalNamed: signame asSymbol.
+    ].
+    OperatingSystem isMSWINDOWSlike ifTrue:[
+        signame := 'sig', (input asUppercase).
+        ^Win32OperatingSystem perform: signame asSymbol.
+    ].
+    self error: 'Unsupported OS'
+
+    "Created: / 11-12-2010 / 15:22:07 / Jan Kurs <kurs.jan@post.cz>"
+!
+
+_sun_misc_Signal_handle0: aJavaContext
+
+    <javanative: 'sun/misc/Signal' name: 'handle0'>
+
+        self breakPoint: #libjava.
+    ^ 0.
+
+    "Created: / 11-12-2010 / 16:33:38 / Jan Kurs <kurs.jan@post.cz>"
+!
+
+_sun_misc_Unsafe_addressSize: nativeContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'addressSize()I'>
+
+    ^ExternalAddress pointerSize
+
+    "Modified: / 10-07-2012 / 01:19:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_allocateInstance: nativeContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'allocateInstance'>
+
+        "
+    /** Allocate an instance but do not run any constructor.
+        Initializes the class if it has not yet been. */
+    public native Object allocateInstance(Class cls)
+        throws InstantiationException;
+    "
+    | cls |
+    cls := self reflection classForJavaClassObject: (nativeContext argAt:1).
+    cls classInit.
+    ^cls newCleared
+
+    "Created: / 05-02-2011 / 23:10:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_allocateMemory: aJavaContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'allocateMemory'>
+
+
+    | size |
+    size := aJavaContext argAt: 1.
+    ^SimulatedNativeMemory malloc: size.
+
+    "Created: / 07-12-2010 / 21:04:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 07-12-2010 / 23:46:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_arrayBaseOffset: nativeContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'arrayBaseOffset'>
+    "
+    /**
+    * Report the offset of the first element in the storage allocation of a
+    * given array class.  If {@link #arrayIndexScale} returns a non-zero value
+    * for the same class, you may use that scale factor, together with this
+    * base offset, to form new offsets to access elements of arrays of the
+    * given class.
+    *
+    * @see #getInt(Object, long)
+    * @see #putInt(Object, long, int)
+    */
+    public native int arrayBaseOffset(Class arrayClass);
+    "
+
+    ^ 1
+
+    "Modified (comment): / 10-08-2011 / 01:22:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_arrayIndexScale: nativeContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'arrayIndexScale'>
+
+    "
+      /**
+      * Report the scale factor for addressing elements in the storage
+      * allocation of a given array class.  However, arrays of 'narrow' types
+      * will generally not work properly with accessors like {@link
+      * #getByte(Object, int)}, so the scale factor for such classes is reported
+      * as zero.
+      *
+      * @see #arrayBaseOffset
+      * @see #getInt(Object, long)
+      * @see #putInt(Object, long, int)
+      */
+    public native int arrayIndexScale(Class arrayClass);
+    "
+    ^ 1
+
+    "Modified: / 10-08-2011 / 01:26:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_compareAndSwapInt: aJavaContext
+
+    <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: 'compareAndSwapLong'>
+
+        "
+    /**
+     * Atomically update Java variable to <tt>x</tt> if it is currently
+     * holding <tt>expected</tt>.
+     * @return <tt>true</tt> if successful
+     */
+    public final native boolean compareAndSwapInt(Object o, long offset,
+                                                  long expected,
+                                                  long new);
+    "
+    | o offset expected real new ok |
+    o := aJavaContext argAt:1.
+    offset := aJavaContext argAt:2.
+    "offset is long, so aJavaContext at:3 is dummy nil!!!!!!"
+    expected := aJavaContext argAt:4.
+    new := aJavaContext argAt:6.
+
+    OperatingSystem blockInterrupts.
+    real := o instVarAt: offset.
+    (real == expected)
+            ifTrue:[o instVarAt: offset put: new. ok := 1]
+            ifFalse:[ok := 1].
+    OperatingSystem unblockInterrupts.
+    ^ok
+
+    "Modified: / 18-10-2011 / 21:59:37 / 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
+     * holding <tt>expected</tt>.
+     * @return <tt>true</tt> if successful
+     */
+    public final native boolean compareAndSwapInt(Object o, long offset,
+                                                  int expected,
+                                                  int new);
+    "
+    | o offset expected real new ok |
+    o := aJavaContext argAt:1.
+    offset := aJavaContext argAt:2.
+    "offset is long, so aJavaContext at:3 is dummy nil!!!!!!"
+    expected := aJavaContext argAt:4.
+    new := aJavaContext argAt:5.
+
+    OperatingSystem blockInterrupts.
+    o isArray ifTrue:[
+        real := o at: offset.
+    ] ifFalse:[
+        real := o instVarAt: offset.
+    ].
+    (real == expected) ifTrue:[
+        o isArray ifTrue:[
+            o at: offset put: new.
+        ] ifFalse:[
+            o instVarAt: offset put: new.
+        ].
+        ok := 1
+    ] ifFalse:[
+        ok := 0
+    ].
+    OperatingSystem unblockInterrupts.
+    ^ok
+
+    "Modified: / 03-09-2012 / 19:02:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_copyMemory: nativeContext
+    "
+    /**
+     * Sets all bytes in a given block of memory to a copy of another
+     * block.
+     */
+    public native void copyMemory(long srcAddress, long destAddress,
+                                  long bytes);
+    "
+
+    <javanative: 'sun/misc/Unsafe' name: 'copyMemory(JJJ)V'>
+
+    | srcAddress dstAddress bytes |
+
+    srcAddress := nativeContext argAt:1.
+    dstAddress := nativeContext argAt:3.
+    bytes      := nativeContext argAt:5.
+    SimulatedNativeMemory bcopy: srcAddress to: dstAddress length: bytes.
+
+    "Modified (format): / 11-07-2012 / 10:25:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_defineClass: nativeContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'defineClass'>
+
+        "
+    /**
+     * Tell the VM to define a class, without security checks.  By default, the
+     * class loader and protection domain come from the caller's class.
+     */
+    public native Class defineClass(String name, byte[] b, int off, int len,
+                                    ClassLoader loader,
+                                    ProtectionDomain protectionDomain);
+    "
+    | name b off len loader protectionDomain bs cls |
+    name := nativeContext argAt: 1.
+    b := nativeContext argAt: 2.
+    off := nativeContext argAt: 3.
+    len := nativeContext argAt: 4.
+    loader := nativeContext argAt: 5.
+    protectionDomain := nativeContext argAt: 6.
+
+    bs := (off = 0 and: [len = b size])
+            ifTrue:[b readStream]
+            ifFalse:[(b copyFrom: off + 1 to: off + len) readStream].
+
+    cls := JavaClassReader readStream: bs.
+    cls classLoader: loader.
+
+    ^self reflection javaClassObjectForClass: cls.
+
+    "Created: / 05-02-2011 / 22:57:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_ensureClassInitialized: aJavaContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'ensureClassInitialized'>
+
+        |class|
+
+    class := self reflection classForJavaClassObject:(aJavaContext argAt:1).
+     "Sometimes there is a nil. I don't know why, so I did quickfix"
+    self breakPoint:#libjava.
+    class ifNotNil:[class classInit.].
+
+    "Created: / 11-12-2010 / 15:01:36 / Jan Kurs <kurs.jan@post.cz>"
+    "Modified: / 25-12-2010 / 09:43:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 08-01-2011 / 15:11:21 / Jan Kurs <kurs.jan@post.cz>"
+    "Modified: / 28-01-2011 / 15:19:31 / Marcel Hlopko <hlopik@gmail.com>"
+!
+
+_sun_misc_Unsafe_freeMemory: aJavaContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'freeMemory'>
+
+    | address  |
+    address := aJavaContext argAt: 1.
+    ^SimulatedNativeMemory free: address
+
+    "Created: / 09-12-2010 / 17:56:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_getBoolean: nativeContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'getBoolean(Ljava/lang/Object;J)Z'>
+
+    | o offset |
+    o := nativeContext argAt: 1.
+    offset := nativeContext argAt: 2.
+    ^o instVarAt: offset
+
+    "Modified: / 19-11-2011 / 10:49:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_getByte: nativeContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'getByte(Ljava/lang/ObjectJ)B'>
+    <javanative: 'sun/misc/Unsafe' name: 'getByte(J)B'>
+
+    | object offset address |
+    nativeContext numArgs == 3 ifTrue:[
+        "getByte(Ljava/lang/Object;J)V"
+        object := nativeContext argAt: 1.
+        offset := nativeContext argAt: 2.
+        ^object instVarAt: offset
+    ].
+    nativeContext numArgs == 2 ifTrue:[
+        "getByte(J)V"
+        address := nativeContext argAt: 1.
+        ^SimulatedNativeMemory byteAt: address
+    ].
+
+    self internalError:'Unssuported getByte() variant'
+
+    "Created: / 09-12-2010 / 17:29:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_getChar: nativeContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'getChar(Ljava/lang/Object;J)C'>
+
+    | o offset |
+    o := nativeContext argAt: 1.
+    offset := nativeContext argAt: 2.
+    ^o instVarAt: offset
+
+    "Modified: / 22-11-2011 / 14:51:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_getDouble: nativeContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'getDouble(Ljava/lang/Object;J)D'>
+
+    | o offset |
+    o := nativeContext argAt: 1.
+    offset := nativeContext argAt: 2.
+    ^o instVarAt: offset
+
+    "Modified: / 10-05-2012 / 17:01:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_getFloat: nativeContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'getFloat(Ljava/lang/Object;J)F'>
+
+    | o offset |
+    o := nativeContext argAt: 1.
+    offset := nativeContext argAt: 2.
+    ^o instVarAt: offset
+
+    "Modified: / 22-11-2011 / 14:53:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_getFloatVolatile: nativeContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'getFloatVolatile(Ljava/lang/Object;J)F'>
+
+    | o offset |
+    o := nativeContext argAt: 1.
+    offset := nativeContext argAt: 2.
+    ^o instVarAt: offset
+
+    "Modified: / 10-05-2012 / 17:01:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_getInt: nativeContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'getInt'>
+    "
+    /**
+    * Fetches a integer value from a given Java variable.
+    */
+    public native int getInt(Object o, long offset);
+    "
+    | o offset |
+    o := nativeContext argAt: 1.
+    offset := nativeContext argAt: 2.
+    ^o instVarAt: offset
+
+    "Modified: / 18-10-2011 / 20:33:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_getIntVolatile: nativeContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'getIntVolatile(Ljava/lang/Object;J)I'>
+
+    | o offset |
+    o := nativeContext argAt: 1.
+    offset := nativeContext argAt: 2.
+    ^o instVarAt: offset
+
+    "Modified: / 28-03-2012 / 15:03:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_getLong: nativeContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'getLong(Ljava/lang/Object;J)J'>
+
+    | o offset |
+    o := nativeContext argAt: 1.
+    offset := nativeContext argAt: 2.
+    ^o instVarAt: offset
+
+    "Modified: / 25-08-2012 / 11:15:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_getLongVolatile: nativeContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'getLongVolatile(Ljava/lang/Object;J)J'>
+
+    | o offset |
+    o := nativeContext argAt: 1.
+    offset := nativeContext argAt: 2.
+    ^o instVarAt: offset
+
+    "Modified: / 31-08-2011 / 23:57:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_getObject: nativeContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'getObject'>
+    "
+    /**
+    * Fetches a reference value from a given Java variable.
+    * @see #getInt(Object, long)
+    */
+    public native Object getObject(Object o, long offset);
+    "
+    | o offset |
+    o := nativeContext argAt: 1.
+    offset := nativeContext argAt: 2.
+    ^o isArray ifTrue:[
+        o at: offset
+    ] ifFalse:[
+        o instVarAt: offset
+    ]
+
+    "Modified: / 03-09-2012 / 19:00:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_getObjectVolatile: nativeContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'getObjectVolatile(Ljava/lang/Object;J)Ljava/lang/Object;'>
+    "
+    /**
+    * Fetches a reference value from a given Java variable, with volatile
+    * load semantics. Otherwise identical to {@link #getObject(Object, long)}
+    */
+    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>"
+!
+
+_sun_misc_Unsafe_getShort: nativeContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'getShort(Ljava/lang/Object;J)S'>
+
+    | o offset |
+    o := nativeContext argAt: 1.
+    offset := nativeContext argAt: 2.
+    ^o instVarAt: offset
+
+    "Modified: / 22-11-2011 / 14:52:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_getShortVolatile: nativeContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'getShortVolatile(Ljava/lang/Object;J)S'>
+
+    | o offset |
+    o := nativeContext argAt: 1.
+    offset := nativeContext argAt: 2.
+    ^o instVarAt: offset
+
+    "Modified: / 29-06-2012 / 19:05:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_objectFieldOffset: aJavaContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'objectFieldOffset'>
+
+
+    | javaFieldObject |
+    javaFieldObject := aJavaContext argAt: 1.
+    ^javaFieldObject instVarNamed: #slot
+
+    "Created: / 22-11-2010 / 17:58:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_pageSize: nativeContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'pageSize'>
+
+    ^ 4096"4K is the page size on x86, I think... "
+
+    "Modified: / 25-11-2011 / 19:24:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_park: nativeContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'park(ZJ)V'>
+    "
+    /**
+     * Block current thread, returning when a balancing
+     * <tt>unpark</tt> occurs, or a balancing <tt>unpark</tt> has
+     * already occurred, or the thread is interrupted, or, if not
+     * absolute and time is not zero, the given time nanoseconds have
+     * elapsed, or if absolute, the given deadline in milliseconds
+     * since Epoch has passed, or spuriously (i.e., returning for no
+     * 'reason'). Note: This operation is in the Unsafe class only
+     * because <tt>unpark</tt> is, so it would be strange to place it
+     * elsewhere.
+     */
+    "
+
+    | absolute millis tout process |
+
+    absolute := nativeContext argAt: 1.
+    millis := nativeContext argAt: 2.
+
+    millis ~~ 0 ifTrue:[
+        absolute == 1 ifTrue:[
+            tout := millis - OperatingSystem getOSTime.
+            tout < 1 ifTrue:[
+                tout := nil.
+            ].
+        ] ifFalse:[
+            tout := millis.
+        ]
+    ] ifFalse:[
+        tout := nil.
+    ].
+
+    process := Processor activeProcess.
+    self park: process timeout: tout.
+
+    "Modified: / 16-08-2012 / 21:52:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_putBoolean: nativeContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'putBoolean(Ljava/lang/Object;JZ)V'>
+
+    "Like putInt:, see _sun_misc_Unsafe_putInt:"
+
+    | o offset x |
+
+    o := nativeContext argAt: 1.
+    offset := nativeContext argAt: 2.
+    x := nativeContext argAt: 4.
+    ^o instVarAt: offset put: x.
+
+    "Modified: / 27-10-2011 / 16:23:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_putByte: nativeContext
+
+    <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 := nativeContext argAt: 1.
+        value := nativeContext argAt: 3.
+        SimulatedNativeMemory byteAt: address put: (value bitAnd: 16rFF).
+        ^nil.
+    ].
+
+    nativeContext selector = #'putByte(Ljava/lang/Object;JB)V' ifTrue:[
+        | o offset x |
+        o := nativeContext argAt: 1.
+        offset := nativeContext argAt: 2.
+        x := nativeContext argAt: 4.
+        ^o instVarAt: offset put: x.
+    ].
+
+    self shouldNotImplement
+
+    "Modified: / 31-07-2012 / 11:47:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_putChar: nativeContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'putChar(Ljava/lang/Object;JC)V'>
+
+    | o offset x |
+
+    o := nativeContext argAt: 1.
+    offset := nativeContext argAt: 2.
+    x := nativeContext argAt: 4.
+    ^o instVarAt: offset put: x.
+
+    "Modified: / 22-11-2011 / 14:52:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_putDouble: nativeContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'putDouble(Ljava/lang/Object;JD)V'>
+    <javanative: 'sun/misc/Unsafe' name: 'putDouble(JD)V'>
+
+    | o offset x |
+
+    nativeContext numArgs == 5 ifTrue:[
+        "putDouble(Ljava/lang/Object;JD)V"
+        o := nativeContext argAt: 1.
+        offset := nativeContext argAt: 2.
+        x := nativeContext argAt: 4.
+        o instVarAt: offset put: x.
+        ^nil
+    ].
+    nativeContext numArgs == 4 ifTrue:[
+        "putDouble(JD)V"
+        o := nativeContext argAt: 1.
+        x := nativeContext argAt: 3.
+        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>"
+!
+
+_sun_misc_Unsafe_putFloat: nativeContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'putFloat(Ljava/lang/Object;JF)V'>
+
+    | o offset x |
+
+    o := nativeContext argAt: 1.
+    offset := nativeContext argAt: 2.
+    x := nativeContext argAt: 4.
+    ^o instVarAt: offset put: x.
+
+    "Modified: / 22-11-2011 / 14:53:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_putInt: nativeContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'putInt'>
+    "
+    /**
+     * Stores a value into a given Java variable.
+     * <p>
+     * The first two parameters are interpreted exactly as with
+     * {@link #getInt(Object, long)} to refer to a specific
+     * Java variable (field or array element).  The given value
+     * is stored into that variable.
+     * <p>
+     * The variable must be of the same type as the method
+     * parameter <code>x</code>.
+     *
+     * @param o Java heap object in which the variable resides, if any, else
+     *        null
+     * @param offset indication of where the variable resides in a Java heap
+     *        object, if any, else a memory address locating the variable
+     *        statically
+     * @param x the value to store into the indicated Java variable
+     * @throws RuntimeException No defined exceptions are thrown, not even
+     *         {@link NullPointerException}
+     */
+    public native void putInt(Object o, long offset, int x);
+    "
+
+    | o offset x |
+
+    o := nativeContext argAt: 1.
+    offset := nativeContext argAt: 2.
+    x := nativeContext argAt: 4.
+    ^o instVarAt: offset put: x.
+
+    "Modified: / 30-08-2011 / 15:48:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_putLong: nativeContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'putDouble(Ljava/lang/Object;JJ)V'>
+    <javanative: 'sun/misc/Unsafe' name: 'putDouble(JJ)V'>
+
+    | o offset x |
+
+    nativeContext numArgs == 5 ifTrue:[
+        "putDouble(Ljava/lang/Object;JD)V"
+        o := nativeContext argAt: 1.
+        offset := nativeContext argAt: 2.
+        x := nativeContext argAt: 4.
+        o instVarAt: offset put: x.
+        ^nil
+    ].
+    nativeContext numArgs == 4 ifTrue:[
+        "putDouble(JD)V"
+        o := nativeContext argAt: 1.
+        x := nativeContext argAt: 3.
+        SimulatedNativeMemory sint64At: o put: x.
+        ^nil
+    ].
+    self internalError:'Unknown variant of putLong() native!!'
+
+    "Created: / 07-12-2010 / 23:50:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 16-07-2012 / 16:03:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_putObject: nativeContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'putObject'>
+
+    "
+    /**
+     * Stores a reference value into a given Java variable.
+     * <p>
+     * Unless the reference <code>x</code> being stored is either null
+     * or matches the field type, the results are undefined.
+     * If the reference <code>o</code> is non-null, car marks or
+     * other store barriers for that object (if the VM requires them)
+     * are updated.
+     * @see #putInt(Object, int, int)
+     */
+     public native void putObject(Object o, long offset, Object x);
+     "
+    | o offset x |
+    o := nativeContext argAt: 1.
+    offset := nativeContext argAt: 2.
+    x := nativeContext argAt: 4.
+
+    ^o isArray ifTrue:[
+        o at: offset put: x
+    ] ifFalse:[
+        o instVarAt: offset put: x.
+    ].
+
+    "Modified: / 03-09-2012 / 18:59:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_putObjectVolatile: nativeContext
+
+    <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>"
+!
+
+_sun_misc_Unsafe_putOrderedObject: nativeContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'putOrderedObject(Ljava/lang/Object;JLjava/lang/Object;)V'>
+
+    "
+    /**
+     * Version of {@link #putObjectVolatile(Object, long, Object)}
+     * that does not guarantee immediate visibility of the store to
+     * other threads. This method is generally only useful if the
+     * underlying field is a Java volatile (or if an array cell, one
+     * that is otherwise only accessed using volatile accesses).
+     */
+    "
+
+    ^ self _sun_misc_Unsafe_putObject: nativeContext
+
+    "Modified (comment): / 03-09-2012 / 18:56:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_putShort: nativeContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'putShort(Ljava/lang/Object;JS)V'>
+
+    | o offset x |
+
+    o := nativeContext argAt: 1.
+    offset := nativeContext argAt: 2.
+    x := nativeContext argAt: 4.
+    ^o instVarAt: offset put: x.
+
+    "Modified: / 22-11-2011 / 14:52:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_registerNatives: aJavaContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'registerNatives'>
+
+
+     "Nothing to do, native method are bound lazily"
+
+    "Created: / 25-10-2010 / 16:14:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_setMemory: nativeContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'setMemory(JJB)V'>
+
+    | address bytes value|
+
+    address := nativeContext argAt: 1.
+    bytes := nativeContext argAt: 3.
+    value := nativeContext argAt: 5.
+    SimulatedNativeMemory memset: address value: value length: bytes.
+
+    "Modified (format): / 11-07-2012 / 10:29:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_staticFieldBase: nativeContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'staticFieldBase(Ljava/lang/reflect/Field;)Ljava/lang/Object;'>
+    "
+      /**
+      * Report the location of a given static field, in conjunction with {@link
+      * #staticFieldOffset}.
+      * <p>Fetch the base 'Object', if any, with which static fields of the
+      * given class can be accessed via methods like {@link #getInt(Object,
+      * long)}.  This value may be null.  This value may refer to an object
+      * which is a 'cookie', not guaranteed to be a real Object, and it should
+      * not be used in any way except as argument to the get and put routines in
+      * this class.
+      */
+      public native Object staticFieldBase(Field f);
+    "
+     | javaFieldObject javaClassObject |
+     javaFieldObject := nativeContext argAt: 1.
+     javaClassObject := javaFieldObject instVarNamed: #clazz.
+     ^self classForJavaClassObject: javaClassObject.
+
+    "Modified: / 17-08-2011 / 09:42:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_staticFieldOffset: nativeContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'staticFieldOffset(Ljava/lang/reflect/Field;)J'>
+
+    | javaFieldObject |
+    javaFieldObject := nativeContext argAt: 1.
+    ^javaFieldObject instVarNamed: #slot
+
+    "Modified: / 17-08-2011 / 09:12:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_Unsafe_unpark: nativeContext
+
+    <javanative: 'sun/misc/Unsafe' name: 'unpark(Ljava/lang/Object;)V'>
+    "
+    /**
+     * Unblock the given thread blocked on <tt>park</tt>, or, if it is
+     * not blocked, cause the subsequent call to <tt>park</tt> not to
+     * block.  Note: this operation is 'unsafe' solely because the
+     * caller must somehow ensure that the thread has not been
+     * destroyed. Nothing special is usually required to ensure this
+     * when called from Java (in which there will ordinarily be a live
+     * reference to the thread) but this is not nearly-automatically
+     * so when calling from native code.
+     * @param thread the thread to unpark.
+     *
+     */
+    public native void unpark(Object thread);
+    "
+
+    | thread process |
+
+    thread := nativeContext argAt: 1.
+    process := Java threads at: thread ifAbsent:[
+        self error: 'No process for given thread'.
+    ].
+    self unpark: process.
+
+    "Modified: / 16-08-2012 / 21:52:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_misc_VM_initialize: aJavaContext
+
+    <javanative: 'sun/misc/VM' name: 'initialize'>
+
+
+    "Nothing to do"
+
+    "Created: / 26-11-2010 / 18:43:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - sun.nio.ch'!
+
+_sun_nio_ch_FileChannelImpl_initIDs: nativeContext
+
+    <javanative: 'sun/nio/ch/FileChannelImpl' name: 'initIDs()J'>
+
+    ^ 4096 "/page size, see
+
+    "Modified: / 10-07-2012 / 01:08:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_nio_ch_FileChannelImpl_map0: nativeContext
+
+    <javanative: 'sun/nio/ch/FileChannelImpl' name: 'map0(IJJ)J'>
+
+    ^ JavaVM unimplementedNativeMethodSignal raise
+!
+
+_sun_nio_ch_FileChannelImpl_position0: nativeContext
+
+    <javanative: 'sun/nio/ch/FileChannelImpl' name: 'position0(Ljava/io/FileDescriptor;J)J'>
+
+    | fd position stream |
+
+    fd := nativeContext argAt: 1.
+    position := nativeContext argAt: 2.
+    stream := self validateFileDescriptor: fd.
+    stream isFileStream ifFalse:[
+        self throwIOExceptionWithMessage: 'Not a file stream'.
+        ^nil.
+    ].
+    ^position = -1
+        ifTrue:[stream position0Based]
+        ifFalse:[stream position0Based: position. 0].
+
+    "Modified: / 10-07-2012 / 01:30:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_nio_ch_FileChannelImpl_size0: nativeContext
+
+    <javanative: 'sun/nio/ch/FileChannelImpl' name: 'size0(Ljava/io/FileDescriptor;)J'>
+
+    | fd stream |
+
+    fd := nativeContext argAt: 1.
+    stream := self validateFileDescriptor: fd.
+    stream isFileStream ifFalse:[
+        self throwIOExceptionWithMessage: 'Not a file stream'.
+        ^nil.
+    ].
+    ^stream fileSize max: stream position0Based.
+
+    "Modified: / 10-07-2012 / 01:28:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_nio_ch_FileChannelImpl_truncate0: nativeContext
+
+    <javanative: 'sun/nio/ch/FileChannelImpl' name: 'truncate0(Ljava/io/FileDescriptor;J)I'>
+
+    | fd size stream |
+
+    fd := nativeContext argAt: 1.
+    size := nativeContext argAt: 2.
+    stream := self validateFileDescriptor: fd.
+    stream isFileStream ifFalse:[
+        self throwIOExceptionWithMessage: 'Not a file stream'.
+        ^nil.
+    ].
+    stream truncateTo: size.
+    ^0.
+
+    "Modified: / 10-07-2012 / 01:02:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_nio_ch_FileDispatcher_init: nativeContext
+
+    <javanative: 'sun/nio/ch/FileDispatcher' name: 'init()V'>
+
+    ^ JavaNioSupport _sun_nio_ch_FileDispatcher_init
+
+    "Modified: / 06-07-2012 / 22:35:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_nio_ch_FileDispatcher_preClose0: nativeContext
+
+    <javanative: 'sun/nio/ch/FileDispatcher' name: 'preClose0(Ljava/io/FileDescriptor;)V'>
+
+    "Nothing to do here"
+
+    "Modified: / 10-07-2012 / 00:47:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_nio_ch_FileDispatcher_read0: nativeContext
+
+    <javanative: 'sun/nio/ch/FileDispatcher' name: 'read0(Ljava/io/FileDescriptor;JI)I'>
+
+    | fd address len stream read |
+
+    fd := nativeContext argAt: 1.
+    address := nativeContext argAt: 2.
+    len := nativeContext argAt: 4.
+
+    stream := self validateFileDescriptor: fd.
+    stream atEnd ifTrue:[ ^ -1 ].
+    [
+        self shouldImplement
+        "/WAS: read := stream nextBytes:len into:SimulatedNativeMemory memory startingAt: address
+    ] on: Error do:[:ex|
+        self throwIOExceptionWithMessage: ex description.
+        ^0
+    ].
+    ^read
+
+    "Modified (comment): / 11-07-2012 / 10:38:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_nio_ch_FileDispatcher_write0: nativeContext
+
+    <javanative: 'sun/nio/ch/FileDispatcher' name: 'write0(Ljava/io/FileDescriptor;JI)I'>
+
+    | fd address len stream writtem |
+
+    fd := nativeContext argAt: 1.
+    address := nativeContext argAt: 2.
+    len := nativeContext argAt: 4.
+
+    stream := self validateFileDescriptor: fd.
+    [
+        self shouldImplement.
+        "/WAS: writtem := stream nextPutBytes:len from:SimulatedNativeMemory memory startingAt: address
+    ] on: Error do:[:ex|
+        self throwIOExceptionWithMessage: ex description.
+        ^0
+    ].
+    ^writtem
+
+    "Modified: / 11-07-2012 / 10:38:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_nio_ch_IOUtil_initIDs: nativeContext
+
+    <javanative: 'sun/nio/ch/IOUtil' name: 'initIDs()V'>
+
+    "Nothing to do here"
+
+    "Modified: / 06-07-2012 / 22:10:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_nio_ch_IOUtil_initPipe: nativeContext
+
+    <javanative: 'sun/nio/ch/IOUtil' name: 'initPipe([IZ)V'>
+
+    ^ JavaVM unimplementedNativeMethodSignal raise
+!
+
+_sun_nio_ch_NativeThread_current: nativeContext
+
+    <javanative: 'sun/nio/ch/NativeThread' name: 'current()J'>
+
+    ^ JavaNioSupport _sun_nio_ch_NativeThread_current
+
+    "Modified: / 06-07-2012 / 22:39:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_nio_ch_NativeThread_init: nativeContext
+
+    <javanative: 'sun/nio/ch/NativeThread' name: 'init()V'>
+
+    ^ JavaNioSupport _sun_nio_ch_NativeThread_init
+
+    "Modified: / 06-07-2012 / 22:38:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_nio_ch_Net_initIDs: nativeContext
+
+    <javanative: 'sun/nio/ch/Net' name: 'initIDs()V'>
+
+    "Nothing to do here"
+
+    "Modified: / 10-05-2012 / 17:00:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_nio_ch_Net_socket0: nativeContext
+
+    <javanative: 'sun/nio/ch/Net' name: 'socket0(ZZ)I'>
+
+    ^ JavaVM unimplementedNativeMethodSignal raise
+!
+
+_sun_nio_ch_ServerSocketChannelImpl_initIDs: nativeContext
+
+    <javanative: 'sun/nio/ch/ServerSocketChannelImpl' name: 'initIDs()V'>
+
+    "Nothing to do here"
+
+    "Modified: / 10-05-2012 / 16:58:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - sun.reflect'!
+
+_sun_reflect_ConstantPool_getDoubleAt0: nativeContext
+
+    <javanative: 'sun/reflect/ConstantPool' name: 'getDoubleAt0'>
+
+        | cpool  index  double |
+
+    cpool := self reflection constantPoolFor:(nativeContext receiver).
+    index := nativeContext at:3.
+     "TODO: why 3?"
+    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>"
+!
+
+_sun_reflect_ConstantPool_getIntAt0: nativeContext
+
+    <javanative: 'sun/reflect/ConstantPool' name: 'getIntAt0'>
+
+        | cpool  index  int |
+
+    cpool := self reflection constantPoolFor:(nativeContext receiver).
+    index := nativeContext at:3.
+     "TODO: why 3?"
+    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>"
+!
+
+_sun_reflect_ConstantPool_getLongAt0: nativeContext
+
+    <javanative: 'sun/reflect/ConstantPool' name: 'getLongAt0'>
+
+        | cpool  index  long |
+
+    cpool := self reflection constantPoolFor:(nativeContext receiver).
+    index := nativeContext at:3.
+     "TODO: why 3?"
+    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>"
+!
+
+_sun_reflect_ConstantPool_getUTF8At0: nativeContext
+
+    <javanative: 'sun/reflect/ConstantPool' name: 'getUTF8At0'>
+
+
+    | cpool index string |
+    cpool := self reflection constantPoolFor: (nativeContext receiver).
+    index := nativeContext at: 3.
+    "TODO: why 3?"
+
+    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>"
+!
+
+_sun_reflect_NativeConstructorAccessorImpl_newInstance0: aJavaContext
+
+    <javanative: 'sun/reflect/NativeConstructorAccessorImpl' name: 'newInstance0'>
+
+
+    | ctor args method instance class |
+    ctor := aJavaContext argAt: 1.
+    args := aJavaContext argAt: 2.
+    class := self reflection classForJavaConstructorObject: ctor.
+    method := self reflection methodForJavaConstructorObject: ctor.
+
+    instance := class new.
+    self invoke: ctor receiver: instance arguments: args context: aJavaContext 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>"
+!
+
+_sun_reflect_NativeMethodAccessorImpl_invoke0: nativeContext
+
+    <javanative: 'sun/reflect/NativeMethodAccessorImpl' name: 'invoke0'>
+    "
+    private static native Object invoke0(Method m, Object obj, Object[] args);
+    "
+    | m obj args method |
+    m := nativeContext argAt: 1.
+    obj := nativeContext argAt: 2.
+    args := nativeContext argAt: 3.
+    method := self reflection methodForJavaMethodObject: m.
+
+    ^ self invoke: m receiver: obj arguments: args context: 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>"
+!
+
+_sun_reflect_Reflection_getCallerClass: aJavaContext
+
+    <javanative: 'sun/reflect/Reflection' name: 'getCallerClass'>
+    "
+    /** Returns the class of the method <code>realFramesToSkip</code>
+        frames up the stack (zero-based), ignoring frames associated
+        with java.lang.reflect.Method.invoke() and its implementation.
+        The first frame is that associated with this method, so
+        <code>getCallerClass(0)</code> returns the Class object for
+        sun.reflect.Reflection. Frames associated with
+        java.lang.reflect.Method.invoke() and its implementation are
+        completely ignored and do not count toward the number of 'real'
+        frames skipped. */
+    "
+
+    | framesToSkip framesSkipped frame cls |
+
+
+    framesToSkip := aJavaContext argAt: 1.
+    framesSkipped := 0.
+    frame := aJavaContext.
+    [ framesSkipped == framesToSkip ] whileFalse:[
+        frame := frame sender.
+        "Frames for java,lang.reflect.Method.invoke() does not count, sigh.
+         What a crappy implementation"
+        (frame selector == #'invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;'
+            and:[ frame receiver class name = #'java/lang/reflect/Method']) ifFalse:[
+                framesSkipped := framesSkipped + 1
+            ]
+    ].
+
+    "Returns the __class of the method__, not !!!!!! the class of method's receiver !!!!!!"
+    "                  |                                                            "
+    "                  V                                                            "
+    cls := frame method mclass theNonMetaclass.
+    ^cls isJavaClass
+        ifTrue:[JavaVM javaClassObjectForClass:cls]
+        ifFalse:[nil]
+
+    "Created: / 25-10-2010 / 16:32:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_reflect_Reflection_getClassAccessFlags: aJavaContext
+
+    <javanative: 'sun/reflect/Reflection' name: 'getClassAccessFlags'>
+
+        |class|
+
+    class := self reflection classForJavaClassObject:(aJavaContext argAt:1).
+    ^(class isJavaPrimitiveType or:[class isJavaArrayClass]) ifTrue:[
+        1041"FIXME: make it symbolic"
+    ] ifFalse:[
+        class accessFlags
+    ]
+
+    "Created: / 26-11-2010 / 10:20:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 28-01-2011 / 15:19:28 / Marcel Hlopko <hlopik@gmail.com>"
+    "Modified: / 01-09-2011 / 09:46:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - sun.security.provider'!
+
+_sun_security_provider_NativeSeedGenerator_nativeGenerateSeed: nativeContext
+
+    <javanative: 'sun/security/provider/NativeSeedGenerator' name: 'nativeGenerateSeed([B)Z'>
+
+    ^ JavaVM unimplementedNativeMethodSignal raise
+! !
+
 !JavaNativeMethodImpl_OpenJDK6 class methodsFor:'documentation'!
 
 version_HG