--- a/src/JavaVM.st Fri Aug 12 20:50:02 2011 +0000
+++ b/src/JavaVM.st Sat Aug 13 01:26:52 2011 +0000
@@ -2225,6 +2225,9 @@
exceptionDebugPatterns
^ ExceptionDebugPatterns
+ "
+ ExceptionDebugPatterns add: 'java/lang/ArrayIndex*'
+ "
"Created: / 25-02-2011 / 08:08:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
@@ -3260,7 +3263,7 @@
!
throwNullPointerException
- NullPointerExceptionDebug := true ifTrue:[
+ NullPointerExceptionDebug == true ifTrue:[
self halt:'Null Pointer exception'.
].
@@ -3270,7 +3273,7 @@
"Created: / 09-01-1998 / 02:26:08 / cg"
"Modified: / 28-01-1998 / 02:30:09 / cg"
- "Modified: / 11-08-2011 / 23:13:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 13-08-2011 / 01:10:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
throwNumberFormatException
@@ -4586,6 +4589,38 @@
"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'>
@@ -4786,6 +4821,36 @@
"Modified: / 04-06-2011 / 17:07:04 / Marcel Hlopko <hlopkmar@fel.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 := Java 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'>
@@ -4793,13 +4858,31 @@
^ UnimplementedNativeMethodSignal raise
!
+_java_lang_Class_getGenericSignature: nativeContext
+
+ <javanative: 'java/lang/Class' name: 'getGenericSignature'>
+
+ |cls sig |
+
+ cls := self reflection classForJavaClassObject:(nativeContext receiver).
+ (cls isJavaPrimitiveType or:[cls isJavaArrayClass]) ifTrue:[^nil].
+ sig := cls signatureJ.
+ ^sig notNil ifTrue:[
+ Java as_String: sig
+ ] ifFalse:[
+ nil
+ ]
+
+ "Modified: / 13-08-2011 / 02:19:21 / 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.
- cls isJavaPrimitiveType
+ (cls isJavaPrimitiveType or:[cls isJavaArrayClass])
ifTrue:[ ^ (self classForName:'java.lang.Class') javaArrayClass new ].
interfaces := cls interfaces.
interfaces
@@ -4811,18 +4894,25 @@
^ jInterfaces
"Modified: / 28-01-2011 / 15:19:11 / Marcel Hlopko <hlopik@gmail.com>"
- "Modified: / 04-02-2011 / 09:43:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 12-08-2011 / 22:27:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
_java_lang_Class_getModifiers: aJavaContext
<javanative: 'java/lang/Class' name: 'getModifiers'>
- ^ (self reflection classForJavaClassObject:aJavaContext receiver) accessFlags
+ | cls |
+
+ cls := (self reflection classForJavaClassObject:aJavaContext receiver).
+ ^(cls isJavaPrimitiveType or:[cls isJavaArrayClass]) ifTrue:[
+ 1041"FIXME: make it symbolic"
+ ] ifFalse:[
+ cls accessFlags
+ ]
"Created: / 12-11-1998 / 18:54:53 / cg"
- "Modified: / 26-11-2010 / 10:25:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 28-01-2011 / 15:19:14 / Marcel Hlopko <hlopik@gmail.com>"
+ "Modified: / 12-08-2011 / 22:34:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
_java_lang_Class_getName0: aJavaContext
@@ -4895,6 +4985,9 @@
jClass := nativeContext receiver.
cls := self reflection classForJavaClassObject:jClass.
+ cls isJavaPrimitiveType ifTrue:[^nil].
+ cls isJavaArrayClass ifTrue:[^self javaClassObjectForClass:(Java at:'java.lang.Object')].
+
superCls := cls superclass.
superCls == JavaObject ifTrue:[
^ nil.
@@ -4904,7 +4997,7 @@
"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: / 03-02-2011 / 22:53:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 12-08-2011 / 22:41:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
_java_lang_Class_isArray: nativeContext
@@ -14611,18 +14704,20 @@
aJavaClassRef isJavaRef
ifTrue: [ class := aJavaClassRef resolve ]
ifFalse: [ self halt: 'I expected classRefs only - maybe I was wrong' ].
- "(object isNil or: [ (self canCast: object class to: class) not ])
+ (object isNil or: [ (self canCast: object class to: class) not ])
ifTrue:
[ self throwClassCastException.
- ^ false ]."
-
+ ^ false ].
+ "
(self canCast: object class to: class) not
ifTrue:
[ self throwClassCastException.
^ false ].
+ "
^ true.
"Created: / 19-05-2011 / 10:12:23 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 13-08-2011 / 01:33:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
_CHECKCAST:object _: classOrClassRef