src/JavaVM.st
branchjk_new_structure
changeset 911 efa922d67283
parent 910 74006705243c
child 912 e651488f5741
--- a/src/JavaVM.st	Fri Aug 12 16:36:03 2011 +0000
+++ b/src/JavaVM.st	Fri Aug 12 20:50:02 2011 +0000
@@ -1780,7 +1780,7 @@
     props at: 'java.library.path'   put: self defaultJavaLibraryPath.
     props at: 'sun.boot.library.path' put: self defaultSunBootLibraryPath. 
 
-    props at: 'sun.misc.URLClassPath.debug' put: 'true'. 
+"/    props at: 'sun.misc.URLClassPath.debug' put: 'true'. 
 
     ^ props
 
@@ -1790,7 +1790,7 @@
 
     "Created: / 03-01-1998 / 14:26:39 / cg"
     "Modified: / 27-01-2000 / 02:20:18 / cg"
-    "Modified: / 12-08-2011 / 17:22:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 12-08-2011 / 19:51:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 initializeVM
@@ -3802,6 +3802,53 @@
     "Modified: / 28-02-2011 / 16:58:05 / Marcel Hlopko <hlopik@gmail.com>"
 ! !
 
+!JavaVM 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_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_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_Toolkit_initIDs: nativeContext
+
+    <javanative: 'java/awt/Toolkit' name: 'initIDs'>
+
+        "/ introduced with jdk1.2 ... (sigh)
+
+    "Created: / 27.1.1998 / 19:53:50 / cg"
+! !
+
 !JavaVM class methodsFor:'native - java.io'!
 
 _java_io_FileDescriptor_initIDs: nativeContext
@@ -4539,38 +4586,6 @@
     "Created: / 10-12-2010 / 15:11:33 / Jan Vrany <jan.vrany@fit.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);
-    "
-    | name b off len pd source bs cls |
-    name :=  Java as_ST_String: (nativeContext argAt:1).
-    b := nativeContext argAt:2.
-    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:[(b copyFrom: off + 1 to: off + len) readStream].
-    [
-        cls := JavaClassReader readStream: bs.
-    ] on: JavaClassReader invalidClassFormatSignal do:[
-        self throwClassFormatError.
-        ^self.
-    ].
-    cls classLoader: nativeContext receiver.
-    "FIXME: What to do with source?"
-
-    ^self reflection javaClassObjectForClass: cls.
-
-    "Modified: / 08-08-2011 / 17:57:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
 _java_lang_ClassLoader_findBootstrapClass: nativeContext
 
     <javanative: 'java/lang/ClassLoader' name: 'findBootstrapClass'>
@@ -4596,13 +4611,13 @@
     "        
     |  class |
     class := Java at: (Java as_ST_String: (nativeContext argAt:1)).
-    ^class notNil ifTrue:[
+    ^(class notNil and:[class classLoader == nativeContext receiver]) ifTrue:[
         self reflection javaClassObjectForClass:class
     ] ifFalse:[
         nil
     ]
 
-    "Modified: / 07-08-2011 / 21:19:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 12-08-2011 / 21:32:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_lang_ClassLoader_registerNatives: aJavaContext
@@ -6179,20 +6194,31 @@
     ^ UnimplementedNativeMethodSignal raise
 !
 
+_java_util_zip_Inflater_getBytesWritten: nativeContext
+
+    <javanative: 'java/util/zip/Inflater' name: 'getBytesWritten'>
+
+    ^ UnimplementedNativeMethodSignal raise
+!
+
 _java_util_zip_Inflater_inflateBytes: nativeContext
 
     <javanative: 'java/util/zip/Inflater' name: 'inflateBytes'>
-
-    | inflater inputBuf outputBuf b off len|
-    inflater := nativeContext receiver.
-    inputBuf := inflater instVarNamed: #buf.
+    "
+    private native int inflateBytes(long addr, byte[] b, int off, int len)
+    "
+
+    | addr inputBuf outputBuf b off len inflater |
+    addr := nativeContext argAt: 1.
+    inflater := ZipInflaters at: addr.
+    inputBuf := nativeContext receiver instVarNamed: #buf.
     inputBuf size == 0 ifTrue:[^0].
 
     b := nativeContext argAt: 3.
     off := nativeContext argAt: 4.
     len := nativeContext argAt: 5.
 
-    outputBuf := ByteArray new: (len + 1000"save").
+    outputBuf := ByteArray new: (b size + 1000"save").
 
     ZipArchive basicNew inflate:inputBuf to:outputBuf.
 
@@ -6201,7 +6227,7 @@
     ^len
 
     "Created: / 30-04-2011 / 23:02:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 01-05-2011 / 16:37:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 12-08-2011 / 18:37:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_util_zip_Inflater_init: nativeContext
@@ -6212,12 +6238,12 @@
     | index |
     index := ZipInflaters indexOf: nativeContext receiver.
     index == 0 ifTrue:
-        [ZipInflaters add: nativeContext receiver.
+        [ZipInflaters add: JavaInflater new.
         index := ZipInflaters size].
     ^index
 
     "Created: / 01-02-1998 / 20:14:01 / cg"
-    "Modified: / 30-04-2011 / 23:01:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 12-08-2011 / 18:19:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_util_zip_Inflater_initIDs: aJavaContext
@@ -6233,11 +6259,15 @@
 _java_util_zip_Inflater_reset: nativeContext
 
     <javanative: 'java/util/zip/Inflater' name: 'reset'>
-
-    "Nothing to do here, as we use fresh ZipArchive all the time"
+    "
+    private native static void reset(long addr);
+    "
+    | addr |
+    addr := nativeContext argAt: 1.
+    ZipInflaters at: addr put: nil.
 
     "Created: / 01-02-1998 / 20:14:13 / cg"
-    "Modified: / 12-08-2011 / 17:28:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 12-08-2011 / 18:21:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_util_zip_ZipEntry_initFields: aJavaContext
@@ -7169,12 +7199,6 @@
     "Created: / 28.1.1998 / 22:19:23 / cg"
 !
 
-_Component_initIDs:nativeContext
-    "/ introduced with jdk1.2 ... (sigh)
-
-    "Created: / 27.1.1998 / 19:53:29 / cg"
-!
-
 _Constructor_getModifiers:nativeContext
     "/ int getModifiers ()
 
@@ -10820,12 +10844,6 @@
     "Modified: / 10.11.1998 / 14:19:32 / cg"
 !
 
-_Toolkit_initIDs:nativeContext
-    "/ introduced with jdk1.2 ... (sigh)
-
-    "Created: / 27.1.1998 / 19:53:50 / cg"
-!
-
 _URLConnection_close:nativeContext
     "/ void close ()
     UnimplementedNativeMethodSignal raise
@@ -13811,6 +13829,20 @@
     ^ self _WGraphics_pSetForeground:nativeContext
 ! !
 
+!JavaVM class methodsFor:'native - old-style (converted)'!
+
+_Component_initIDs:nativeContext
+    "/ introduced with jdk1.2 ... (sigh)
+
+    "Created: / 27.1.1998 / 19:53:29 / cg"
+!
+
+_Toolkit_initIDs:nativeContext
+    "/ introduced with jdk1.2 ... (sigh)
+
+    "Created: / 27.1.1998 / 19:53:50 / cg"
+! !
+
 !JavaVM class methodsFor:'native - sun.management'!
 
 _sun_management_VMManagementImpl_getVersion0: nativeContext
@@ -15772,6 +15804,14 @@
 !
 
 javaClassObjectForClass:aClass 
+
+    ^self javaClassObjectForClass:aClass init: true.
+
+    "Modified: / 28-01-2011 / 15:15:44 / Marcel Hlopko <hlopik@gmail.com>"
+    "Modified: / 12-08-2011 / 19:07:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+javaClassObjectForClass:aClass init: init 
     "
         Answers an instance of java.lang.Class for given
         real (Java) class.
@@ -15784,14 +15824,16 @@
 
     javaClasses at: aClass ifPresent:[:javaClassObj|^javaClassObj].
     "/ class must be initialized (with all of its superclasses ?).
-    aClass isJavaClass ifTrue:[aClass classInit].
+    false ifTrue:[
+        aClass isJavaClass ifTrue:[aClass classInit].
+    ].
     javaClassObj := (vm classForName: 'java.lang.Class') new.
     javaClasses at: aClass put: javaClassObj.
     javaClasses at: javaClassObj put: aClass.
     ^javaClassObj
 
     "Modified: / 28-01-2011 / 15:15:44 / Marcel Hlopko <hlopik@gmail.com>"
-    "Modified: / 05-02-2011 / 22:17:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Created: / 12-08-2011 / 19:07:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 javaClassObjectForClassNamed: className