--- a/src/JavaVM.st Sun Oct 30 17:30:47 2011 +0000
+++ b/src/JavaVM.st Sun Oct 30 21:13:43 2011 +0000
@@ -2339,7 +2339,7 @@
^ (JavaDescriptor fromString: className) javaClass.
].
result := ClassRegistry
- classForName: className asInternalJavaClassName
+ classForName: className asSlashedJavaClassName
loader: classLoader
ifAbsentPut: aBlock.
result notNil ifTrue:[
@@ -2348,7 +2348,7 @@
^result.
"Created: / 21-10-2011 / 12:13:08 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 23-10-2011 / 22:29:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 30-10-2011 / 22:04:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
classNamed: className
@@ -2445,7 +2445,10 @@
^ ExceptionDebugPatterns
"
- ExceptionDebugPatterns add: 'java/lang/ArrayIndex*'
+ ExceptionDebug must be set in order to ExceptionDebugPatterns work
+
+ ExceptionDebug := true.
+ ExceptionDebugPatterns add: 'java.lang.SecurityException*'
"
"Created: / 25-02-2011 / 08:08:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -2469,21 +2472,18 @@
|s|
s := '' writeStream.
- Java classPath do:[:p |
- s size == 0 ifFalse:[
- s nextPut: OperatingSystem pathSeparator
- ].
- s nextPutAll:p.
- ].
+ Java classPath
+ do:[:p | s nextPutAll:p ]
+ separatedBy: [s nextPut: OperatingSystem pathSeparator].
^ s contents
"
- self defaultCLASSPATH
+ self defaultCLASSPATH
"
"Created: / 03-01-1998 / 14:27:21 / cg"
- "Modified: / 01-09-2011 / 22:04:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 30-10-2011 / 21:21:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
defaultExtDirs
@@ -5052,25 +5052,32 @@
self breakPoint: #mh.
className := 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 := JavaVM classRegistry loadStream: bs loader: nativeContext receiver.
- ] on: JavaClassReader invalidClassFormatSignal do: [:ex|
- self throwClassFormatError: ex description.
- ^ self.
- ].
- self assert: cls classLoader == nativeContext receiver.
- "FIXME: What to do with source?"
+ 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.
+ ].
^ self reflection javaClassObjectForClass: cls.
- "Modified: / 27-10-2011 / 16:21:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 30-10-2011 / 21:46:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
_java_lang_ClassLoader_findBootstrapClass: nativeContext
@@ -5083,12 +5090,14 @@
| nm class |
nm := Java as_ST_String: (nativeContext argAt: 1).
- class := JavaVM classRegistry classNamed: nm loader: nil.
+ class := ClassRegistry classForName: nm asSlashedJavaClassName loader: nil ifAbsentPut:[
+ JavaClassReader readClass: nm asSlashedJavaClassName classPath: Java release classPath
+ ].
^ class notNil
ifTrue: [ self reflection javaClassObjectForClass: class ]
ifFalse: [ self throwClassNotFoundException: nm ].
- "Modified: / 27-10-2011 / 16:09:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 30-10-2011 / 21:45:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
_java_lang_ClassLoader_findLoadedClass0: nativeContext
@@ -5105,7 +5114,7 @@
"
| nm class |
nm := Java as_ST_String: (nativeContext argAt:1).
- class := ClassRegistry classNamed: nm loader: nativeContext receiver.
+ class := ClassRegistry classNamed: nm asSlashedJavaClassName loader: nativeContext receiver.
^class notNil ifTrue: [
self reflection javaClassObjectForClass:class
@@ -5113,7 +5122,7 @@
nil
]
- "Modified: / 27-10-2011 / 16:18:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 30-10-2011 / 21:48:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
_java_lang_ClassLoader_registerNatives: aJavaContext
@@ -5200,6 +5209,15 @@
| nm initialize loader class descriptor |
nm := Java as_ST_String: (aJavaContext argAt: 1).
+
+ "Using Class.forName() to get a primitive type is not allowed"
+ (JavaDescriptor baseTypes includesKey: nm) ifTrue: [
+ ^ self throwClassNotFoundException: nm .
+ ].
+ (JavaDescriptor baseTypesByTypeName includesKey: nm) ifTrue: [
+ ^ self throwClassNotFoundException: nm .
+ ].
+
initialize := aJavaContext argAt: 2.
loader := aJavaContext argAt: 3.
JavaClassReader classLoaderQuerySignal answer: loader
@@ -5212,14 +5230,14 @@
] ifFalse: [ class := self classForName: nm ]
].
class isNil ifTrue: [ ^ self throwClassNotFoundException: nm ].
- ((initialize ~~ 0) and: [ class isJavaArrayClass not ]) ifTrue: [
+ ((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: / 24-10-2011 / 10:12:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 30-10-2011 / 20:13:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
_java_lang_Class_getClassLoader0: aJavaContext
@@ -5437,8 +5455,14 @@
jClass := nativeContext receiver.
cls := self reflection classForJavaClassObject:jClass.
- (cls isJavaPrimitiveType or:[cls isJavaArrayClass])
- ifTrue:[ ^ (self classForName:'java.lang.Class') javaArrayClass new ].
+ cls isJavaPrimitiveType ifTrue:[
+ ^ (self classForName:'java.lang.Class') javaArrayClass new
+ ].
+ cls isJavaArrayClass ifTrue:[
+ ^ (self classForName:'java.lang.Class') javaArrayClass
+ with:(self javaClassObjectForClass:(self classForName: 'java.lang.Cloneable'))
+ with:(self javaClassObjectForClass:(self classForName: 'java.io.Serializable'))
+ ].
interfaces := cls interfaces.
interfaces
ifNil:[ ^ (self classForName:'java.lang.Class') javaArrayClass new ].
@@ -5449,7 +5473,7 @@
^ jInterfaces
"Modified: / 28-01-2011 / 15:19:11 / Marcel Hlopko <hlopik@gmail.com>"
- "Modified: / 12-08-2011 / 22:27:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 30-10-2011 / 20:04:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
_java_lang_Class_getModifiers: aJavaContext
@@ -16595,21 +16619,6 @@
"Modified: / 10.12.1998 / 19:36:59 / cg"
! !
-!JavaVM methodsFor:'initialization'!
-
-systemProperties
- |props|
-
- (props := SystemProperties) isNil ifTrue:[
- props := SystemProperties := Dictionary new.
- self initializeSystemPropertiesInto:props.
- ].
- ^ props
-
- "Modified: / 3.1.1998 / 14:32:38 / cg"
- "Created: / 9.1.1999 / 14:48:22 / cg"
-! !
-
!JavaVM::Reflection class methodsFor:'documentation'!
documentation