--- a/src/JavaVM.st Tue May 31 09:28:43 2011 +0000
+++ b/src/JavaVM.st Tue May 31 09:32:24 2011 +0000
@@ -3384,16 +3384,16 @@
fs := nativeContext receiver.
fd := fs instVarNamed:'fd'.
(fd instVarNamed:'fd') ~~ 0 ifTrue:[
- self halt:'file already open'.
- self internalError:'file already open'.
- ^ self.
+ "/self halt:'file already open'.
+ self internalError:'file already open'.
+ ^ self.
].
name := nativeContext argAt:1.
name := Java as_ST_String:name.
FileOpenTrace ifTrue:[
- ('JAVA: opening ' , name) infoPrintCR.
+ ('JAVA: opening ' , name) infoPrintCR.
].
fn := name asFilename.
@@ -3402,53 +3402,54 @@
readonly := false.
(PermittedDirectories notNil
and:[PermittedDirectories includes:dir]) ifFalse:[
- FileOpenConfirmation ifTrue:[
- answer := Dialog
- confirmWithCancel:('JAVA Security check\\Opening ''' , name , ''' 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 ' , name , ' 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.
- ]
- ]
- ]
+ FileOpenConfirmation ifTrue:[
+ answer := Dialog
+ confirmWithCancel:('JAVA Security check\\Opening ''' , name , ''' 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 ' , name , ' 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.
+ ]
+ ]
+ ]
].
readonly ifTrue:[
- stream := fn readStream.
+ stream := fn readStream.
] ifFalse:[
- forAppend ifTrue:[
- stream := fn appendingWriteStream.
- ] ifFalse:[
- stream := fn writeStream.
- ]
+ forAppend ifTrue:[
+ stream := fn appendingWriteStream.
+ ] ifFalse:[
+ stream := fn writeStream.
+ ]
].
stream isNil ifTrue:[
- self throwIOExceptionWithMessage:('cannot open ' , name , ' for writing').
+ self throwIOExceptionWithMessage:('cannot open ' , name , ' for writing').
].
fileNo := self addOpenFile:stream.
FileOpenTrace ifTrue:[
- ('JAVA: opened ' , name , ' as FD ' , fileNo printString , ' for writing') infoPrintCR.
+ ('JAVA: opened ' , name , ' as FD ' , fileNo printString , ' for writing') infoPrintCR.
].
fd instVarNamed:'fd' put:fileNo.
- "Created: / 7.4.1998 / 19:14:09 / cg"
- "Modified: / 4.1.1999 / 14:34:42 / cg"
+ "Created: / 07-04-1998 / 19:14:09 / cg"
+ "Modified: / 04-01-1999 / 14:34:42 / cg"
+ "Modified: / 31-05-2011 / 09:54:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
fileStreamForReading:name
@@ -3686,6 +3687,63 @@
"Created: / 27.1.1998 / 18:15:51 / cg"
!
+_java_io_FileInputStream_open: nativeContext
+
+ <javanative: 'java/io/FileInputStream' name: 'open'>
+
+ |fs fd fn 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:[
+ FileOpenTrace ifTrue:[
+ ('JAVA: failed to open ''' , name , ''' for reading.') infoPrintCR.
+ ].
+
+ self throwIOExceptionWithMessage:('cannot open ' , name , ' for reading').
+
+ ^ 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.
+
+ "Created: / 4.1.1998 / 16:47:12 / cg"
+ "Modified: / 28.1.1999 / 17:24:07 / cg"
+!
+
_java_io_FileOutputStream_initIDs: nativeContext
<javanative: 'java/io/FileOutputStream' name: 'initIDs'>
@@ -3695,6 +3753,15 @@
"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: / 7.4.1998 / 19:14:31 / cg"
+!
+
_java_io_FileOutputStream_writeBytes: nativeContext
<javanative: 'java/io/FileOutputStream' name: 'writeBytes'>
@@ -3721,6 +3788,20 @@
"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'>
+
+ ^ UnimplementedNativeMethodSignal raise
+!
+
+_java_io_ObjectStreamClass_hasStaticInitializer: nativeContext
+
+ <javanative: 'java/io/ObjectStreamClass' name: 'hasStaticInitializer'>
+
+ ^ UnimplementedNativeMethodSignal raise
+!
+
_java_io_ObjectStreamClass_initNative: aJavaContext
<javanative: 'java/io/ObjectStreamClass' name: 'initNative'>
@@ -3736,6 +3817,13 @@
"Created: / 20-12-2010 / 17:43:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
+_java_io_RandomAccessFile_initIDs: nativeContext
+
+ <javanative: 'java/io/RandomAccessFile' name: 'initIDs'>
+
+ ^ UnimplementedNativeMethodSignal raise
+!
+
_java_io_UnixFileSystem_canonicalize0: aJavaContext
<javanative: 'java/io/UnixFileSystem' name: 'canonicalize0'>
@@ -3749,6 +3837,34 @@
"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'>
+
+ ^ UnimplementedNativeMethodSignal raise
+!
+
+_java_io_UnixFileSystem_createDirectory: nativeContext
+
+ <javanative: 'java/io/UnixFileSystem' name: 'createDirectory'>
+
+ ^ UnimplementedNativeMethodSignal raise
+!
+
+_java_io_UnixFileSystem_createFileExclusively: nativeContext
+
+ <javanative: 'java/io/UnixFileSystem' name: 'createFileExclusively'>
+
+ ^ UnimplementedNativeMethodSignal raise
+!
+
+_java_io_UnixFileSystem_delete0: nativeContext
+
+ <javanative: 'java/io/UnixFileSystem' name: 'delete0'>
+
+ ^ UnimplementedNativeMethodSignal raise
+!
+
_java_io_UnixFileSystem_getBooleanAttributes0: aJavaContext
<javanative: 'java/io/UnixFileSystem' name: 'getBooleanAttributes0'>
@@ -3860,6 +3976,20 @@
"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'>
+
+ ^ UnimplementedNativeMethodSignal raise
+!
+
+_java_lang_ClassLoader_findLoadedClass0: nativeContext
+
+ <javanative: 'java/lang/ClassLoader' name: 'findLoadedClass0'>
+
+ ^ UnimplementedNativeMethodSignal raise
+!
+
_java_lang_ClassLoader_registerNatives: aJavaContext
<javanative: 'java/lang/ClassLoader' name: 'registerNatives'>
@@ -3956,6 +4086,13 @@
"Modified: / 28-02-2011 / 18:05:13 / Marcel Hlopko <hlopik@gmail.com>"
!
+_java_lang_Class_getDeclaredClasses0: nativeContext
+
+ <javanative: 'java/lang/Class' name: 'getDeclaredClasses0'>
+
+ ^ UnimplementedNativeMethodSignal raise
+!
+
_java_lang_Class_getDeclaredConstructors0: aJavaContext
<javanative: 'java/lang/Class' name: 'getDeclaredConstructors0'>
@@ -4034,6 +4171,13 @@
"Modified: / 11-02-2011 / 08:35:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
+_java_lang_Class_getEnclosingMethod0: nativeContext
+
+ <javanative: 'java/lang/Class' name: 'getEnclosingMethod0'>
+
+ ^ UnimplementedNativeMethodSignal raise
+!
+
_java_lang_Class_getInterfaces: nativeContext
<javanative: 'java/lang/Class' name: 'getInterfaces'>
@@ -4103,6 +4247,13 @@
"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'>
+
+ ^ UnimplementedNativeMethodSignal raise
+!
+
_java_lang_Class_getRawAnnotations: aJavaContext
<javanative: 'java/lang/Class' name: 'getRawAnnotations'>
@@ -4201,6 +4352,57 @@
"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'>
@@ -4301,9 +4503,44 @@
(f = 0.0) ifTrue:[^0].
(f = -0.0) ifTrue:[^(1 bitShift: 63)].
- self halt:'Not yet implemented'.
+ self error:'Not yet implemented since I''m lazy'.
"Created: / 10-11-2010 / 14:48:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 31-05-2011 / 10:13:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_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.
+
+ "Created: / 4.1.1998 / 01:45:00 / cg"
!
_java_lang_Float_floatToRawIntBits: aJavaContext
@@ -4352,10 +4589,10 @@
(f = 0.0) ifTrue:[^0].
(f = -0.0) ifTrue:[^(1 bitShift: 31) ].
- self halt.
+ self error: 'Not yet implemented since I''m bit lazy'.
"Created: / 09-11-2010 / 20:59:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 10-11-2010 / 14:47:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 31-05-2011 / 10:13:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
_java_lang_Object_clone: nativeContext
@@ -4406,6 +4643,26 @@
"Created: / 4.1.1998 / 19:40:26 / cg"
!
+_java_lang_Object_notify: nativeContext
+
+ <javanative: 'java/lang/Object' name: 'notify'>
+
+ "wakeup"
+
+ self wakeup:(nativeContext receiver).
+
+ "Created: / 6.1.1998 / 21:09:26 / cg"
+!
+
+_java_lang_Object_notifyAll: nativeContext
+
+ <javanative: 'java/lang/Object' name: 'notifyAll'>
+
+ self wakeupAll:(nativeContext receiver).
+
+ "Created: / 3.1.1998 / 03:06:56 / cg"
+!
+
_java_lang_Object_registerNatives: aJavaContext
<javanative: 'java/lang/Object' name: 'registerNatives'>
@@ -4442,6 +4699,46 @@
"Modified: / 01-05-2011 / 13:26:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
+_java_lang_Package_getSystemPackage0: nativeContext
+
+ <javanative: 'java/lang/Package' name: 'getSystemPackage0'>
+
+ ^ UnimplementedNativeMethodSignal raise
+!
+
+_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'>
+
+ ^ UnimplementedNativeMethodSignal raise
+!
+
+_java_lang_StrictMath_cos: nativeContext
+
+ <javanative: 'java/lang/StrictMath' name: 'cos'>
+
+ ^ UnimplementedNativeMethodSignal raise
+!
+
+_java_lang_StrictMath_sin: nativeContext
+
+ <javanative: 'java/lang/StrictMath' name: 'sin'>
+
+ ^ UnimplementedNativeMethodSignal raise
+!
+
_java_lang_String_intern: nativeContext
<javanative: 'java/lang/String' name: 'intern'>
@@ -4522,6 +4819,19 @@
"Modified: / 23.12.1998 / 21:54:50 / cg"
!
+_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'>
@@ -4716,6 +5026,20 @@
"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.
+ self waitFor:nil state:nil timeOut:(millis max:50)
+
+ "Modified: / 8.1.1999 / 16:42:52 / cg"
+!
+
_java_lang_Thread_start0: nativeContext
<javanative: 'java/lang/Thread' name: 'start0'>
@@ -4821,6 +5145,33 @@
"Created: / 17-12-2010 / 14:49:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 19-12-2010 / 17:54:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 28-01-2011 / 15:18:50 / Marcel Hlopko <hlopik@gmail.com>"
+!
+
+_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 reflection javaClassObjectForClass: cls.
+
+ "Created: / 06-02-2011 / 16:55:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!JavaVM class methodsFor:'native - java.security'!
@@ -4850,6 +5201,15 @@
"Created: / 27.1.1998 / 18:22:15 / cg"
! !
+!JavaVM class methodsFor:'native - java.util.jar'!
+
+_java_util_jar_JarFile_getMetaInfEntryNames: nativeContext
+
+ <javanative: 'java/util/jar/JarFile' name: 'getMetaInfEntryNames'>
+
+ ^ UnimplementedNativeMethodSignal raise
+! !
+
!JavaVM class methodsFor:'native - java.util.zip'!
_java_util_zip_Inflater_inflateBytes: nativeContext
@@ -5789,54 +6149,6 @@
"Created: / 12.11.1998 / 18:55:01 / cg"
!
-_Class_isInstance:nativeContext
- "
- /**
- * 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>"
-!
-
_Class_newInstance:nativeContext
"get an instance for a java.lang.Class"
@@ -5990,37 +6302,6 @@
"Created: / 4.1.1998 / 01:39:12 / cg"
!
-_Double_longBitsToDouble:nativeContext
- |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.
-
- "Created: / 4.1.1998 / 01:45:00 / cg"
-!
-
_Double_valueOf0:nativeContext
|s d|
@@ -6296,60 +6577,6 @@
"Modified: / 4.2.1998 / 15:20:46 / cg"
!
-_FileInputStream_open:nativeContext
- |fs fd fn 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:[
- FileOpenTrace ifTrue:[
- ('JAVA: failed to open ''' , name , ''' for reading.') infoPrintCR.
- ].
-
- self throwIOExceptionWithMessage:('cannot open ' , name , ' for reading').
-
- ^ 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.
-
- "Created: / 4.1.1998 / 16:47:12 / cg"
- "Modified: / 28.1.1999 / 17:24:07 / cg"
-!
-
_FileInputStream_read:nativeContext
|file byte|
@@ -6413,12 +6640,6 @@
"Modified: / 4.2.1998 / 15:20:53 / cg"
!
-_FileOutputStream_open:nativeContext
- ^ self commonOpen:nativeContext forAppend:false
-
- "Modified: / 7.4.1998 / 19:14:31 / cg"
-!
-
_FileOutputStream_openAppend:nativeContext
^ self commonOpen:nativeContext forAppend:true
@@ -8406,20 +8627,6 @@
"Created: / 12.11.1998 / 19:05:53 / cg"
!
-_Object_notify:nativeContext
- "wakeup"
-
- self wakeup:(nativeContext receiver).
-
- "Created: / 6.1.1998 / 21:09:26 / cg"
-!
-
-_Object_notifyAll:nativeContext
- self wakeupAll:(nativeContext receiver).
-
- "Created: / 3.1.1998 / 03:06:56 / cg"
-!
-
_OffScreenImageSource_sendPixels:nativeContext
"/ self halt.
"/ UnimplementedNativeMethodSignal raise
@@ -8875,30 +9082,6 @@
"Created: / 27.1.2000 / 03:00:20 / cg"
!
-_Proxy_defineClass0:nativeContext
- "
- 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 reflection javaClassObjectForClass: cls.
-
- "Created: / 06-02-2011 / 16:55:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
_RandomAccessFile_close:nativeContext
^ self anyStream_close:nativeContext
@@ -9168,15 +9351,6 @@
"Created: / 12.1.1998 / 12:59:53 / cg"
!
-_Runtime_gc:nativeContext
- "Runs the garbage collector.
- Ignored, since the ST-gc runs all the time."
-
- ^ self
-
- "Modified: / 12.1.1998 / 12:58:32 / cg"
-!
-
_Runtime_initializeLinkerInternal:nativeContext
"init sharedLib linker, return searchPath as javaString"
@@ -9579,16 +9753,6 @@
"Modified: / 27.1.1998 / 18:33:13 / cg"
!
-_System_identityHashCode:nativeContext
- |obj|
-
- obj := nativeContext argAt:1.
- ^ obj identityHash
-
- "Modified: / 12.11.1998 / 18:52:07 / cg"
- "Created: / 12.11.1998 / 18:54:00 / cg"
-!
-
_System_validateSecurityManager:nativeContext
"void validateSecurityManager (java.lang.SecurityManager)"
@@ -9670,17 +9834,6 @@
"Modified: / 6.2.1998 / 02:15:08 / cg"
!
-_Thread_sleep:nativeContext
- "sleep for some milliseconds "
-
- |millis|
-
- millis := nativeContext argAt:1.
- self waitFor:nil state:nil timeOut:(millis max:50)
-
- "Modified: / 8.1.1999 / 16:42:52 / cg"
-!
-
_Thread_start:nativeContext
"start the thread"
@@ -10057,51 +10210,6 @@
"Created: / 12.11.1998 / 19:23:43 / cg"
!
-_Unsafe_allocateInstance:nativeContext
- "
- /** 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>"
-!
-
-_Unsafe_defineClass: nativeContext
- "
- /**
- * 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>"
-!
-
_VM_getState:nativeContext
"/ int getState ()
UnimplementedNativeMethodSignal raise
@@ -13355,6 +13463,54 @@
"Modified: / 05-02-2011 / 23:38:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
+_Class_isInstance:nativeContext
+ "
+ /**
+ * 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>"
+!
+
_Class_isInterface:nativeContext
"return true, if this class is an interface"
@@ -13448,6 +13604,37 @@
"Created: / 10-11-2010 / 14:48:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
+_Double_longBitsToDouble:nativeContext
+ |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.
+
+ "Created: / 4.1.1998 / 01:45:00 / cg"
+!
+
_FileDescriptor_initIDs:nativeContext
"/ introduced with jdk1.2 ... (sigh)
@@ -13460,12 +13647,72 @@
"Created: / 27.1.1998 / 18:15:51 / cg"
!
+_FileInputStream_open:nativeContext
+ |fs fd fn 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:[
+ FileOpenTrace ifTrue:[
+ ('JAVA: failed to open ''' , name , ''' for reading.') infoPrintCR.
+ ].
+
+ self throwIOExceptionWithMessage:('cannot open ' , name , ' for reading').
+
+ ^ 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.
+
+ "Created: / 4.1.1998 / 16:47:12 / cg"
+ "Modified: / 28.1.1999 / 17:24:07 / cg"
+!
+
_FileOutputStream_initIDs:nativeContext
"/ introduced with jdk1.2 ... (sigh)
"Created: / 27.1.1998 / 18:16:40 / cg"
!
+_FileOutputStream_open:nativeContext
+ ^ self commonOpen:nativeContext forAppend:false
+
+ "Modified: / 7.4.1998 / 19:14:31 / cg"
+!
+
_FileOutputStream_writeBytes:nativeContext
^ self anyStream_writeBytes:nativeContext
@@ -13647,6 +13894,20 @@
"Created: / 4.1.1998 / 19:40:26 / cg"
!
+_Object_notify:nativeContext
+ "wakeup"
+
+ self wakeup:(nativeContext receiver).
+
+ "Created: / 6.1.1998 / 21:09:26 / cg"
+!
+
+_Object_notifyAll:nativeContext
+ self wakeupAll:(nativeContext receiver).
+
+ "Created: / 3.1.1998 / 03:06:56 / cg"
+!
+
_Object_registerNatives:aJavaContext
"Nothing to do, native method are bound lazily"
@@ -13678,6 +13939,30 @@
"Modified: / 30.12.1998 / 19:20:43 / cg"
!
+_Proxy_defineClass0:nativeContext
+ "
+ 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 reflection javaClassObjectForClass: cls.
+
+ "Created: / 06-02-2011 / 16:55:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
_Reflection_getCallerClass:aJavaContext
| framesToSkip framesSkipped frame |
@@ -13704,6 +13989,15 @@
"Modified: / 28-01-2011 / 15:19:28 / Marcel Hlopko <hlopik@gmail.com>"
!
+_Runtime_gc:nativeContext
+ "Runs the garbage collector.
+ Ignored, since the ST-gc runs all the time."
+
+ ^ self
+
+ "Modified: / 12.1.1998 / 12:58:32 / cg"
+!
+
_Signal_findSignal:aJavaContext
| input signame |
@@ -13792,6 +14086,16 @@
"Modified: / 23.12.1998 / 21:54:50 / cg"
!
+_System_identityHashCode:nativeContext
+ |obj|
+
+ obj := nativeContext argAt:1.
+ ^ obj identityHash
+
+ "Modified: / 12.11.1998 / 18:52:07 / cg"
+ "Created: / 12.11.1998 / 18:54:00 / cg"
+!
+
_System_initProperties:nativeContext
|props stProps|
@@ -13960,6 +14264,17 @@
"Modified: / 6.2.1998 / 02:28:18 / cg"
!
+_Thread_sleep:nativeContext
+ "sleep for some milliseconds "
+
+ |millis|
+
+ millis := nativeContext argAt:1.
+ self waitFor:nil state:nil timeOut:(millis max:50)
+
+ "Modified: / 8.1.1999 / 16:42:52 / cg"
+!
+
_Thread_start0:nativeContext
^self threadStart: nativeContext
@@ -14075,6 +14390,21 @@
"Modified: / 10-12-2010 / 20:58:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
+_Unsafe_allocateInstance:nativeContext
+ "
+ /** 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>"
+!
+
_Unsafe_allocateMemory:aJavaContext
| size |
@@ -14115,6 +14445,36 @@
"Modified: / 06-02-2011 / 12:10:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
+_Unsafe_defineClass: nativeContext
+ "
+ /**
+ * 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>"
+!
+
_Unsafe_ensureClassInitialized:aJavaContext
|class|
@@ -14347,6 +14707,24 @@
"Created: / 11-12-2010 / 16:33:38 / Jan Kurs <kurs.jan@post.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'>
@@ -14393,6 +14771,46 @@
"Modified: / 06-02-2011 / 12:10:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
+_sun_misc_Unsafe_compareAndSwapObject: nativeContext
+
+ <javanative: 'sun/misc/Unsafe' name: 'compareAndSwapObject'>
+
+ ^ UnimplementedNativeMethodSignal raise
+!
+
+_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'>
@@ -14782,12 +15200,13 @@
_ARRAYLENGTH:arr
arr isNil ifTrue:[
- self halt:'should not happen'.
- self throwNullPointerException.
+ "/self halt:'should not happen'.
+ self throwNullPointerException.
].
^ arr size
- "Created: / 8.1.1999 / 14:38:27 / cg"
+ "Created: / 08-01-1999 / 14:38:27 / cg"
+ "Modified: / 31-05-2011 / 10:09:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
_ATHROW:aJavaException