--- a/src/JavaClass.st Mon Apr 25 19:32:44 2011 +0000
+++ b/src/JavaClass.st Sun May 01 12:52:23 2011 +0000
@@ -1907,6 +1907,60 @@
"Created: / 05-02-2011 / 23:44:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 11-02-2011 / 09:12:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+isSubclassOf: aJavaClass
+|tmpClass|
+
+tmpClass := self superclass.
+[tmpClass isJavaClass] whileTrue: [tmpClass = aJavaClass ifTrue:[^true]. tmpClass := tmpClass superclass].
+^false.
+
+ "Created: / 13-04-2011 / 23:18:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!JavaClass methodsFor:'reflection'!
+
+lookupFieldByNameAndType: aJavaNameAndType
+ | result |
+
+ result := fields detect:
+ [:each |
+ (each name = aJavaNameAndType name
+ and: [ each signature = aJavaNameAndType descriptor ]) ].
+ result ifNotNil: [ ^ result ].
+ self superclass ~= JavaObject
+ ifTrue: [ ^ self superclass lookupFieldByNameAndType: aJavaNameAndType ]
+ ifFalse: [ ^ nil ].
+
+ "Created: / 11-04-2011 / 21:27:08 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 28-04-2011 / 22:31:05 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+lookupMethodByNameAndType: aJavaNameAndType
+ ^ self lookupMethodFor: aJavaNameAndType selector.
+
+ "Created: / 11-04-2011 / 21:28:34 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+lookupStaticFieldByNameAndType: aJavaNameAndType
+ | result |
+
+ result := staticFields detect:
+ [:each |
+ (each name = aJavaNameAndType name
+ and: [ each signature = aJavaNameAndType descriptor ]) ].
+ result ifNotNil: [ ^ result ].
+ self superclass ~= JavaObject ifTrue: [^ self superclass lookupStaticFieldByNameAndType: aJavaNameAndType]
+ ifFalse: [^nil].
+
+ "Created: / 28-04-2011 / 22:25:39 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+lookupStaticMethodByNameAndType: aJavaNameAndType
+ ^ self lookupMethodFor: aJavaNameAndType selector.
+
+ "Created: / 28-04-2011 / 22:50:31 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !
!JavaClass methodsFor:'special'!
@@ -1985,34 +2039,46 @@
!JavaClass methodsFor:'support - sUnit'!
asTestCase
-
- ^JUnitTestCaseProxy for: self
+ self halt.
+ self isTestletLike
+ ifTrue:
+ [ self halt.
+ ^ TestletTestCaseProxy for: self ].
+ ^ JUnitTestCaseProxy for: self.
"Created: / 04-03-2011 / 08:20:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 29-04-2011 / 17:52:13 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+asTestlet
+ ^ TestletTestCaseProxy for: self
+
+ "Created: / 29-04-2011 / 16:53:18 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
isTestCaseLike
- | junit_framework_TestCase org_junit_Test |
+ | junit_framework_TestCase org_junit_Test |
"try JUnit 4.x"
-
- [ org_junit_Test :=
- JavaVM classForName:'org.junit.Test'
- ] on:Error do:[ "nothing" ].
- (org_junit_Test notNil and:[self containsMethodsAnnotatedWith:org_junit_Test typeName ])
- ifTrue:[^true].
-
- "Try jUnit 3.x"
- [ junit_framework_TestCase :=
- JavaVM classForName:'junit.framework.TestCase'
- ] on:Error do:[ "nothing" ].
-
- junit_framework_TestCase ifNotNil:
- [self == org_junit_Test ifTrue:[ ^ false ].
- (self includesBehavior:junit_framework_TestCase)
- ifTrue:[^true]].
-
- ^false
+ [ org_junit_Test := JavaVM classForName: 'org.junit.Test' ] on: Error
+ do:
+ [ "nothing"
+ ].
+ (org_junit_Test notNil
+ and: [ self containsMethodsAnnotatedWith: org_junit_Test typeName ])
+ ifTrue: [ ^ true ].
+ "Try jUnit 3.x"
+
+ [ junit_framework_TestCase := JavaVM
+ classForName: 'junit.framework.TestCase' ] on: Error
+ do:
+ [ "nothing"
+ ].
+ junit_framework_TestCase ifNotNil:
+ [ self == org_junit_Test ifTrue: [ ^ false ].
+ (self includesBehavior: junit_framework_TestCase) ifTrue: [ ^ true ] ].
+ ^ self isTestletLike.
+
"
JAVA::java::lang::Object isTestCaseLike
JAVA::stx::libjava::tests::junit::JUnit3Tests isTestCaseLike"
@@ -2020,6 +2086,7 @@
"Created: / 28-02-2011 / 21:31:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 02-03-2011 / 23:08:02 / Marcel Hlopko <hlopik@gmail.com>"
"Modified: / 06-03-2011 / 14:27:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 29-04-2011 / 17:52:49 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
isTestSelector: selector
@@ -2038,6 +2105,24 @@
"Modified: / 02-03-2011 / 23:08:02 / Marcel Hlopko <hlopik@gmail.com>"
"Created: / 04-03-2011 / 07:07:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+isTestletLike
+ | testlet |
+
+
+ [ testlet := JavaVM classForName: 'gnu.testlet.Testlet' ] on: Error
+ do:
+ [ "nothing"
+ ].
+ testlet ifNil:[^ false].
+ self == testlet ifTrue: [ ^ false ].
+ (self includesBehavior: testlet) ifTrue: [ ^ true ].
+ ^ false.
+
+ "Modified: / 02-03-2011 / 23:08:02 / Marcel Hlopko <hlopik@gmail.com>"
+ "Modified: / 06-03-2011 / 14:27:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Created: / 29-04-2011 / 17:02:22 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !
!JavaClass class methodsFor:'documentation'!
@@ -2052,3 +2137,4 @@
JavaClass initialize!
+
--- a/src/JavaClassContentRef2.st Mon Apr 25 19:32:44 2011 +0000
+++ b/src/JavaClassContentRef2.st Sun May 01 12:52:23 2011 +0000
@@ -32,6 +32,18 @@
^ nameAndType name.
"Created: / 08-04-2011 / 13:54:28 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+nameAndType
+^ nameAndType.
+
+ "Created: / 11-04-2011 / 19:57:16 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+selector
+ ^ nameAndType selector.
+
+ "Created: / 11-04-2011 / 20:38:54 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !
!JavaClassContentRef2 methodsFor:'comparing'!
@@ -62,6 +74,13 @@
!JavaClassContentRef2 methodsFor:'resolving'!
+invalidate
+classRef invalidate.
+super invalidate.
+
+ "Created: / 13-04-2011 / 12:21:38 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
invalidateForClass: internalJavaClassName
"Invalidate (means call invalidate) reference if it has something to do with given class (e.g Class named internalJavaClassName was unloaded).
Return true, if reference was invalidated."
@@ -79,3 +98,4 @@
^ '$Id$'
! !
+
--- a/src/JavaClassReader.st Mon Apr 25 19:32:44 2011 +0000
+++ b/src/JavaClassReader.st Sun May 01 12:52:23 2011 +0000
@@ -164,10 +164,11 @@
"Modified: / 20.10.1998 / 17:24:54 / cg"
!
-loadClassLazy: internalJavaClassName
- self loadClassLazy: internalJavaClassName ignoring: Set new.
+loadClassLazy: internalJavaClassName
+ ^ self loadClassLazy: internalJavaClassName ignoring: Set new.
"Created: / 08-04-2011 / 18:00:28 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 11-04-2011 / 19:31:04 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
loadClassLazy: aClassName ignoring: classesBeingLoaded
@@ -293,13 +294,12 @@
[ dirString := dir asAbsoluteFilename pathName.
className := filename withoutSuffix pathName.
className := className subString: dirString size + 2 to: className size.
- loadedClasses add: (self loadClass: className).
- ]. ].
- ^ loadedClasses
+ loadedClasses add: (self loadClass: className). ]. ].
+ ^ loadedClasses.
"Created: / 15-03-2011 / 15:39:49 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
"Modified: / 01-04-2011 / 15:44:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 08-04-2011 / 18:09:28 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 29-04-2011 / 17:43:32 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
loadFile:aFilename
@@ -2534,3 +2534,4 @@
JavaClassReader initialize!
+
--- a/src/JavaClassRef2.st Mon Apr 25 19:32:44 2011 +0000
+++ b/src/JavaClassRef2.st Sun May 01 12:52:23 2011 +0000
@@ -20,14 +20,23 @@
!JavaClassRef2 methodsFor:'accessing'!
+classLoader
+owner ifNil:[^nil] ifNotNil:[^owner classLoader].
+
+ "Created: / 11-04-2011 / 21:52:06 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
javaClassName
-"return java class name as written in java programs e.g. java.util.String
-in case of array, return class name without square brackets"
-|tmp|
-tmp := (name replaceAll:'[' with: '').
-^ tmp copyFrom: 2 to: tmp size.
+ "return java class name as written in java programs e.g. java.util.String
+ in case of array, return class name without square brackets"
+
+ | tmp |
+
+ tmp := (name replaceAll: '[' with: '').
+ ^ tmp copyFrom: 2 to: tmp size -1.
"Created: / 08-04-2011 / 18:30:44 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 11-04-2011 / 19:23:49 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
name
@@ -78,6 +87,14 @@
!JavaClassRef2 methodsFor:'private - resolving'!
+findResolvedStaticValue
+ "Resolving static inner classes is not different from resolving any other class, it's only done in different circumstances"
+
+ ^ self findResolvedValue.
+
+ "Created: / 28-04-2011 / 21:57:46 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
findResolvedValue
"Resolve reference and set valueCache."
@@ -87,6 +104,14 @@
"Modified: / 08-04-2011 / 17:39:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !
+!JavaClassRef2 methodsFor:'queries'!
+
+isJavaClassRef
+^true.
+
+ "Created: / 11-04-2011 / 19:10:00 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
!JavaClassRef2 methodsFor:'resolving'!
invalidateForClass: internalJavaClassName
@@ -105,3 +130,4 @@
^ '$Id$'
! !
+
--- a/src/JavaClassRefTests.st Mon Apr 25 19:32:44 2011 +0000
+++ b/src/JavaClassRefTests.st Sun May 01 12:52:23 2011 +0000
@@ -8,7 +8,101 @@
!
-!JavaClassRefTests methodsFor:'javaClassRef tests'!
+!JavaClassRefTests methodsFor:'permissions tests'!
+
+testAccessingNonPublicFromInside
+ | javaClassRef initString throwedException |
+
+ self enableMockedExceptionThrowing.
+
+ [ initString := 'Lstx/libjava/tests/mocks/NonPublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'stx.libjava.tests.mocks.Crate').
+ javaClassRef resolve. ] on: Error
+ do: [:e | throwedException := e ].
+ self assertTrue: ( throwedException isNil ).
+ self disableMockedExceptionThrowing.
+
+ "Created: / 13-04-2011 / 13:42:47 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingNonPublicFromOutside
+ | javaClassRef initString throwedException |
+
+ self enableMockedExceptionThrowing.
+
+ [ initString := 'Lstx/libjava/tests/mocks/NonPublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaClassRef resolve. ] on: Error
+ do: [:e | throwedException := e ].
+ self assertTrue: (throwedException notNil
+ and: [ throwedException messageText = 'IllegalAccessError' ]).
+ self disableMockedExceptionThrowing.
+
+ "Created: / 13-04-2011 / 13:37:41 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 13-04-2011 / 23:06:32 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingPublic
+ | javaClassRef initString |
+
+ self enableMockedExceptionThrowing.
+ self shouldnt: [
+ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaClassRef resolve.] raise: Error.
+ self disableMockedExceptionThrowing.
+
+ "Created: / 13-04-2011 / 13:36:33 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testNonPublicClassPresent
+ | javaClassRef initString |
+
+ self enableMockedExceptionThrowing.
+ initString := 'Lstx/libjava/tests/mocks/NonPublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'stx.libjava.tests.mocks.SubclassOfNonPublicClass').
+ javaClassRef resolve.
+ self assertTrue: (javaClassRef valueCache notNil).
+ self disableMockedExceptionThrowing.
+
+ "Created: / 13-04-2011 / 13:38:49 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testPublicClassPresent
+ | javaClassRef initString |
+
+ self enableMockedExceptionThrowing.
+ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaClassRef resolve.
+ self assertTrue: (javaClassRef valueCache notNil).
+ self disableMockedExceptionThrowing.
+
+ "Created: / 13-04-2011 / 13:39:00 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!JavaClassRefTests methodsFor:'resolving static tests'!
+
+testCorrectStaticResolving
+ | javaClassRef initString result expectedResult |
+
+ initString := 'Lstx/libjava/tests/mocks/ClassWithInnerClasses$InnerStatic;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'stx.libjava.tests.mocks.ClassWithInnerClasses').
+ expectedResult := Java
+ classForName: 'stx.libjava.tests.mocks.ClassWithInnerClasses$InnerStatic'.
+ result := javaClassRef resolveStatic.
+ self assertTrue: (result = expectedResult).
+
+ "Created: / 28-04-2011 / 21:51:26 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!JavaClassRefTests methodsFor:'resolving tests'!
testCorrectInstanceCreation
| javaClassRef initString |
@@ -23,15 +117,17 @@
!
testCorrectResolving
- | javaClassRef initString result expectedResult |
+ | javaClassRef initString result expectedResult |
initString := 'Ljava/lang/String;'.
javaClassRef := JavaClassRef2 for: initString.
- expectedResult := Java classForName: 'java.lang.String'.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ expectedResult := Java classForName: 'java.lang.String'.
result := javaClassRef resolve.
self assertTrue: (result = expectedResult).
"Created: / 08-04-2011 / 14:07:57 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 11-04-2011 / 19:23:18 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
testInvalidation
@@ -39,6 +135,7 @@
initString := 'Ljava/lang/String;'.
javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
self assertTrue: (javaClassRef isResolved not).
javaClassRef resolve.
self assertTrue: (javaClassRef isResolved).
@@ -46,20 +143,23 @@
self assertTrue: (javaClassRef isResolved not).
"Created: / 08-04-2011 / 14:09:06 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 11-04-2011 / 19:41:20 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
testInvalidationForClassNegative
| javaClassRef initString |
- initString := 'Ljava/lang/String;'.
+ initString := 'Ljava/lang/String;'.
javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
self assertTrue: (javaClassRef isResolved not).
javaClassRef resolve.
self assertTrue: (javaClassRef isResolved).
- javaClassRef invalidateForClass:'Ljava/lang/Object;'.
+ javaClassRef invalidateForClass: 'Ljava/lang/Object;'.
self assertTrue: (javaClassRef isResolved).
"Created: / 08-04-2011 / 16:21:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 11-04-2011 / 19:41:40 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
testInvalidationForClassPositive
@@ -67,25 +167,29 @@
initString := 'Ljava/lang/String;'.
javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
self assertTrue: (javaClassRef isResolved not).
javaClassRef resolve.
self assertTrue: (javaClassRef isResolved).
- javaClassRef invalidateForClass:initString.
+ javaClassRef invalidateForClass: initString.
self assertTrue: (javaClassRef isResolved not).
"Created: / 08-04-2011 / 16:21:35 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 11-04-2011 / 19:41:43 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
testResolving
+ | javaClassRef initString |
-| javaClassRef initString |
-initString := 'Ljava/lang/String;'.
-javaClassRef := JavaClassRef2 for: initString.
-self assertTrue: (javaClassRef isResolved not).
-javaClassRef resolve.
-self assertTrue: (javaClassRef isResolved).
+ initString := 'Ljava/lang/String;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ self assertTrue: (javaClassRef isResolved not).
+ javaClassRef resolve.
+ self assertTrue: (javaClassRef isResolved).
"Created: / 08-04-2011 / 14:04:01 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 11-04-2011 / 19:41:48 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !
!JavaClassRefTests class methodsFor:'documentation'!
@@ -93,3 +197,4 @@
version_SVN
^ '$Id$'
! !
+
--- a/src/JavaConstantPool.st Mon Apr 25 19:32:44 2011 +0000
+++ b/src/JavaConstantPool.st Sun May 01 12:52:23 2011 +0000
@@ -50,13 +50,13 @@
new: size
"return an initialized instance"
- ^ ConstantPools add:
- ((super new: size)
- initialize;
- yourself)
+ ^ ConstantPools add: ((super new: size)
+ initialize;
+ yourself).
"Created: / 08-04-2011 / 16:56:18 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
"Modified: / 09-04-2011 / 09:24:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 11-04-2011 / 18:46:54 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !
!JavaConstantPool class methodsFor:'accessing'!
@@ -69,13 +69,14 @@
"Modified: / 09-04-2011 / 09:24:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
-allConstantPools: aLinkedList
+allConstantPools: anOorderedCollection
"linked list of all constant pools in system"
- ConstantPools := aLinkedList.
+ ConstantPools := anOorderedCollection.
"Created: / 08-04-2011 / 17:07:28 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
"Modified: / 09-04-2011 / 09:24:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 11-04-2011 / 18:47:58 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !
!JavaConstantPool class methodsFor:'special'!
@@ -305,3 +306,4 @@
! !
JavaConstantPool initialize!
+
--- a/src/JavaConstantPoolsTests.st Mon Apr 25 19:32:44 2011 +0000
+++ b/src/JavaConstantPoolsTests.st Sun May 01 12:52:23 2011 +0000
@@ -8,13 +8,21 @@
!
+!JavaConstantPoolsTests class methodsFor:'resources'!
+
+resources
+ ^ Array with: JavaInitializedResource with: JavaTestsResource.
+
+ "Created: / 26-04-2011 / 13:03:05 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
!JavaConstantPoolsTests methodsFor:'tests'!
testInvalidateAll
| newConstantPool tmpConstantPoolCache |
tmpConstantPoolCache := JavaConstantPool allConstantPools.
- JavaConstantPool allConstantPools: LinkedList new.
+ JavaConstantPool allConstantPools: OrderedCollection new.
newConstantPool := JavaConstantPool new: 8.
newConstantPool at: 1 put: 6.
newConstantPool at: 2 put: 'hello'.
@@ -33,43 +41,60 @@
put: (JavaInterfaceMethodRef2
namedAndTyped: (JavaNameAndType2 name: 'run' descriptor: '()V')
inClassIdentifiedByRef: (newConstantPool at: 7)).
- JavaConstantPool allConstantPools do: self
- assertTrue: (JavaConstantPool allConstantPools includes: newConstantPool).
- JavaConstantPool allConstantPools:tmpConstantPoolCache.
+ JavaConstantPool allConstantPools do:
+ [ :each | self
+ assertTrue: (JavaConstantPool allConstantPools includes: newConstantPool) ].
+ JavaConstantPool allConstantPools: tmpConstantPoolCache.
"Created: / 08-04-2011 / 17:03:56 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 11-04-2011 / 18:50:24 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
testInvalidateForClass
| newConstantPool tmpConstantPoolCache |
+ "/backup cps
tmpConstantPoolCache := JavaConstantPool allConstantPools.
- JavaConstantPool allConstantPools: LinkedList new.
+ JavaConstantPool allConstantPools: OrderedCollection new.
newConstantPool := JavaConstantPool new: 8.
newConstantPool at: 1 put: 6.
newConstantPool at: 2 put: 'hello'.
- newConstantPool at: 3 put: (JavaClassRef2 for: 'Ljava/lang/Object;').
+ newConstantPool at: 3
+ put: (JavaClassRef2
+ for: 'Lstx/libjava/tests/mocks/ImplementorOfPublicInterface;').
newConstantPool at: 4
- put: (JavaMethodRef2
- namedAndTyped: (JavaNameAndType2 name: '<init>' descriptor: '()V')
+ put: (JavaMethodRef2 namedAndTyped: (JavaNameAndType2 name: 'publicMethod'
+ descriptor: '()Ljava/lang/String;')
inClassIdentifiedByRef: (newConstantPool at: 3)).
- newConstantPool at: 5 put: (JavaClassRef2 for: 'Ljava/lang/String;').
+ newConstantPool at: 5
+ put: (JavaClassRef2 for: 'Lstx/libjava/tests/mocks/PublicClass;').
newConstantPool at: 6
- put: (JavaFieldRef2
- namedAndTyped: (JavaNameAndType2 name: 'value' descriptor: '[C')
+ put: (JavaFieldRef2 namedAndTyped: (JavaNameAndType2 name: 'publicField'
+ descriptor: 'Ljava/lang/String;')
inClassIdentifiedByRef: (newConstantPool at: 5)).
newConstantPool at: 7 put: (JavaClassRef2 for: 'Ljava/lang/Runnable;').
newConstantPool at: 8
put: (JavaInterfaceMethodRef2
namedAndTyped: (JavaNameAndType2 name: 'run' descriptor: '()V')
inClassIdentifiedByRef: (newConstantPool at: 7)).
- JavaConstantPool invalidateReferencesToClass: 'Ljava/lang/String;'.
+
+ "/end of initialization part
+
+ newConstantPool do: [:each | each isJavaRef ifTrue: [ each resolve ] ].
+
+ "/end of resolving part
+
+ JavaConstantPool invalidateReferencesToClass: 'Lstx/libjava/tests/mocks/PublicClass;'.
self assertTrue: (newConstantPool at: 3) isResolved.
self assertTrue: (newConstantPool at: 7) isResolved.
self assertTrue: (newConstantPool at: 5) isResolved not.
+
+ "/and put pack what was there before
+
JavaConstantPool allConstantPools: tmpConstantPoolCache.
"Created: / 08-04-2011 / 17:10:42 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 14-04-2011 / 15:41:35 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
testNewCreatedCPIsInCache
@@ -86,3 +111,4 @@
version_SVN
^ '$Id$'
! !
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/JavaExceptionThrowerMock.st Sun May 01 12:52:23 2011 +0000
@@ -0,0 +1,58 @@
+"{ Package: 'stx:libjava' }"
+
+Object subclass:#JavaExceptionThrowerMock
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Languages-Java-Tests-RuntimeConstantPool'
+!
+
+
+!JavaExceptionThrowerMock methodsFor:'exceptions'!
+
+throwAbstractMethodError
+ self error: 'AbstractMethodError'.
+
+ "Created: / 11-04-2011 / 20:19:42 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 13-04-2011 / 14:09:28 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+throwIllegalAccessError
+ self error: 'IllegalAccessError'.
+
+ "Created: / 11-04-2011 / 19:39:16 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 13-04-2011 / 14:09:39 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+throwIllegalAccessException
+ self error: 'IllegalAccessException'.
+
+ "Created: / 13-04-2011 / 23:02:29 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+throwIncompatibleClassChangeError
+ self error: 'IncompatibleClassChangeError'.
+
+ "Created: / 11-04-2011 / 20:02:01 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 13-04-2011 / 14:09:50 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+throwNoSuchFieldException
+ self error: 'NoSuchFieldException'.
+
+ "Created: / 11-04-2011 / 21:35:02 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 13-04-2011 / 14:10:01 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+throwNoSuchMethodError
+ self error: 'NoSuchMethodError'.
+
+ "Created: / 11-04-2011 / 20:19:41 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 13-04-2011 / 14:10:10 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!JavaExceptionThrowerMock class methodsFor:'documentation'!
+
+version_SVN
+ ^ '$Id$'
+! !
--- a/src/JavaFieldRef2.st Mon Apr 25 19:32:44 2011 +0000
+++ b/src/JavaFieldRef2.st Sun May 01 12:52:23 2011 +0000
@@ -8,12 +8,27 @@
!
+!JavaFieldRef2 methodsFor:'accessing'!
+
+isJavaFieldRef
+^true.
+
+ "Created: / 11-04-2011 / 21:47:51 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
!JavaFieldRef2 methodsFor:'private - resolving'!
+findResolvedStaticValue
+ valueCache := JavaResolver uniqueInstance
+ resolveStaticFieldIndentifiedByRef: self.
+
+ "Created: / 28-04-2011 / 22:05:10 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
findResolvedValue
- "Resolve reference and set valueCache and isResolved."
+valueCache := JavaResolver uniqueInstance resolveFieldIndentifiedByRef: self.
- ^ self shouldImplement
+ "Modified: / 11-04-2011 / 20:43:01 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !
!JavaFieldRef2 class methodsFor:'documentation'!
@@ -22,3 +37,4 @@
^ '$Id$'
! !
+
--- a/src/JavaFieldRefTests.st Mon Apr 25 19:32:44 2011 +0000
+++ b/src/JavaFieldRefTests.st Sun May 01 12:52:23 2011 +0000
@@ -8,13 +8,329 @@
!
-!JavaFieldRefTests methodsFor:'javaFieldRef tests'!
+!JavaFieldRefTests methodsFor:'permission tests'!
+
+testAccessingPPFromOutside
+ | javaClassRef javaFieldRef initString throwedException |
+
+ self enableMockedExceptionThrowing.
+
+ [ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaFieldRef := JavaFieldRef2
+ namedAndTyped: (JavaNameAndType2 name: 'packagePrivateField'
+ descriptor: 'Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaFieldRef resolve. ] on: Error do: [:e | throwedException := e].
+ self assertTrue: (throwedException messageText = 'IllegalAccessError').
+
+ self disableMockedExceptionThrowing.
+
+ "Created: / 14-04-2011 / 15:05:20 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingPPFromPackage
+ | javaClassRef javaFieldRef initString |
+
+ self enableMockedExceptionThrowing.
+ self shouldnt:
+ [ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'stx.libjava.tests.mocks.Crate').
+ javaFieldRef := JavaFieldRef2
+ namedAndTyped: (JavaNameAndType2 name: 'packagePrivateField'
+ descriptor: 'Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaFieldRef resolve. ]
+ raise: Error.
+ self disableMockedExceptionThrowing.
+
+ "Created: / 14-04-2011 / 15:08:11 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingPPFromSubclass
+ | javaClassRef javaFieldRef initString |
+
+ self enableMockedExceptionThrowing.
+ self shouldnt:
+ [ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'stx.libjava.tests.mocks.SubclassOfPublicClass').
+ javaFieldRef := JavaFieldRef2
+ namedAndTyped: (JavaNameAndType2 name: 'packagePrivateField'
+ descriptor: 'Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaFieldRef resolve. ]
+ raise: Error.
+ self disableMockedExceptionThrowing.
+
+ "Created: / 14-04-2011 / 15:08:39 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingPrivateFromOutside
+ | javaClassRef javaFieldRef initString throwedException |
+
+ self enableMockedExceptionThrowing.
+
+ [ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaFieldRef := JavaFieldRef2
+ namedAndTyped: (JavaNameAndType2 name: 'privateField'
+ descriptor: 'Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaFieldRef resolve. ] on: Error
+ do: [:e | throwedException := e ].
+ self assertTrue: (throwedException notNil
+ and: [ throwedException messageText = 'IllegalAccessError' ]).
+ self disableMockedExceptionThrowing.
+
+ "Created: / 13-04-2011 / 14:44:48 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 14-04-2011 / 14:10:28 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingPrivateFromOutsideInNonPublic
+ | javaClassRef javaFieldRef initString throwedException |
+
+ self enableMockedExceptionThrowing.
+
+ [ initString := 'Lstx/libjava/tests/mocks/NonPublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaFieldRef := JavaFieldRef2
+ namedAndTyped: (JavaNameAndType2 name: 'privateField'
+ descriptor: 'Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaFieldRef resolve. ] on: Error
+ do: [:e | throwedException := e ].
+ self assertTrue: (throwedException notNil
+ and: [ throwedException messageText = 'IllegalAccessError' ]).
+ self disableMockedExceptionThrowing.
+
+ "Created: / 13-04-2011 / 14:47:44 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 14-04-2011 / 14:11:00 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingPrivateFromSubclass
+ | javaClassRef javaFieldRef initString throwedException |
+
+ self enableMockedExceptionThrowing.
+
+ [ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.SubclassOfPublicClass').
+ javaFieldRef := JavaFieldRef2
+ namedAndTyped: (JavaNameAndType2 name: 'privateField'
+ descriptor: 'Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaFieldRef resolve. ] on: Error
+ do: [:e | throwedException := e ].
+ self assertTrue: (throwedException notNil
+ and: [ throwedException messageText = 'IllegalAccessError' ]).
+ self disableMockedExceptionThrowing.
+
+ "Created: / 13-04-2011 / 14:49:32 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 14-04-2011 / 14:12:01 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingProtectedFromOutside
+ | javaClassRef javaFieldRef initString throwedException |
+
+ self enableMockedExceptionThrowing.
+
+ [ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaFieldRef := JavaFieldRef2
+ namedAndTyped: (JavaNameAndType2 name: 'protectedField'
+ descriptor: 'Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaFieldRef resolve. ] on: Error
+ do: [:e | throwedException := e ].
+ self assertTrue: (throwedException notNil
+ and: [ throwedException messageText = 'IllegalAccessError' ]).
+ self disableMockedExceptionThrowing.
+
+ "Created: / 13-04-2011 / 14:44:48 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 14-04-2011 / 14:12:23 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingProtectedFromOutsideInNonPublic
+ | javaClassRef javaFieldRef initString throwedException |
+
+ self enableMockedExceptionThrowing.
+
+ [ initString := 'Lstx/libjava/tests/mocks/NonPublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaFieldRef := JavaFieldRef2
+ namedAndTyped: (JavaNameAndType2 name: 'protectedMethod'
+ descriptor: 'Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaFieldRef resolve. ] on: Error
+ do: [:e | throwedException := e ].
+ self assertTrue: (throwedException notNil
+ and: [ throwedException messageText = 'IllegalAccessError' ]).
+ self disableMockedExceptionThrowing.
+
+ "Created: / 13-04-2011 / 14:47:54 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 14-04-2011 / 14:13:05 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingProtectedFromPackage
+ | javaClassRef javaFieldRef initString |
+
+ self enableMockedExceptionThrowing.
+ self shouldnt:
+ [ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'stx.libjava.tests.mocks.Crate').
+ javaFieldRef := JavaFieldRef2
+ namedAndTyped: (JavaNameAndType2 name: 'protectedField'
+ descriptor: 'Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaFieldRef resolve. ]
+ raise: Error.
+ self disableMockedExceptionThrowing.
+
+ "Created: / 14-04-2011 / 15:09:02 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingProtectedFromSubclass
+ | javaClassRef javaFieldRef initString throwedException |
+
+ self enableMockedExceptionThrowing.
+
+ [ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef
+ owner: (Java classForName: 'stx.libjava.tests.mocks.SubclassOfPublicClass').
+ javaFieldRef := JavaFieldRef2
+ namedAndTyped: (JavaNameAndType2 name: 'protectedField'
+ descriptor: 'Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaFieldRef resolve. ] on: Error
+ do: [:e | throwedException := e ].
+ self assertTrue: (throwedException isNil).
+ self disableMockedExceptionThrowing.
+
+ "Created: / 13-04-2011 / 14:49:23 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 14-04-2011 / 14:13:27 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingPublic
+ | javaClassRef javaFieldRef initString |
+
+ self enableMockedExceptionThrowing.
+ self shouldnt:
+ [ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaFieldRef := JavaFieldRef2
+ namedAndTyped: (JavaNameAndType2 name: 'publicField'
+ descriptor: 'Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaFieldRef resolve. ]
+ raise: Error.
+ self disableMockedExceptionThrowing.
+
+ "Created: / 13-04-2011 / 14:44:13 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 14-04-2011 / 14:13:45 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingPublicFromOutside
+ | javaClassRef javaFieldRef initString |
+
+ self enableMockedExceptionThrowing.
+ self shouldnt:
+ [ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaFieldRef := JavaFieldRef2
+ namedAndTyped: (JavaNameAndType2 name: 'publicField'
+ descriptor: 'Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaFieldRef resolve. ]
+ raise: Error.
+ self disableMockedExceptionThrowing.
+
+ "Created: / 13-04-2011 / 14:44:31 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 14-04-2011 / 14:14:12 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingPublicFromOutsideInNonPublic
+ | javaClassRef javaFieldRef initString throwedException |
+
+ self enableMockedExceptionThrowing.
+
+ [ initString := 'Lstx/libjava/tests/mocks/NonPublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaFieldRef := JavaFieldRef2
+ namedAndTyped: (JavaNameAndType2 name: 'publicField'
+ descriptor: 'Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaFieldRef resolve. ] on: Error
+ do: [:e | throwedException := e ].
+ self assertTrue: (throwedException notNil
+ and: [ throwedException messageText = 'IllegalAccessError' ]).
+ self disableMockedExceptionThrowing.
+
+ "Created: / 13-04-2011 / 14:48:05 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 14-04-2011 / 14:14:32 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingPublicFromSubclass
+ | javaClassRef javaFieldRef initString throwedException |
+
+ self enableMockedExceptionThrowing.
+
+ [ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.SubclassOfPublicClass').
+ javaFieldRef := JavaFieldRef2
+ namedAndTyped: (JavaNameAndType2 name: 'publicField'
+ descriptor: 'Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaFieldRef resolve. ] on: Error
+ do: [:e | throwedException := e ].
+ self assertTrue: (throwedException isNil).
+ self disableMockedExceptionThrowing.
+
+ "Created: / 13-04-2011 / 14:49:11 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 14-04-2011 / 14:14:46 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!JavaFieldRefTests methodsFor:'resolving static tests'!
+
+testResolvingStatic
+ | javaClassRef javaFieldRef initString result expectedResult |
+
+ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaFieldRef := JavaFieldRef2
+ namedAndTyped: (JavaNameAndType2 name: 'publicStaticField'
+ descriptor: 'Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ result := javaFieldRef resolveStatic.
+ expectedResult := (Java
+ classForName: 'stx.libjava.tests.mocks.PublicClass') staticFields
+ at: 3.
+ self assertTrue: (result = expectedResult).
+
+ "Created: / 28-04-2011 / 22:00:52 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!JavaFieldRefTests methodsFor:'resolving tests'!
testCorrectInstanceCreation
| javaClassRef initString javaFieldRef |
initString := 'Ljava/lang/String;'.
javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
javaFieldRef := JavaFieldRef2
namedAndTyped: (JavaNameAndType2 name: 'value' descriptor: '[C')
inClassIdentifiedByRef: javaClassRef.
@@ -25,48 +341,58 @@
self assertTrue: (javaFieldRef classRef name = 'Ljava/lang/String;').
"Created: / 08-04-2011 / 14:01:41 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 08-04-2011 / 16:22:34 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 11-04-2011 / 19:59:07 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
testCorrectResolving
| javaClassRef initString javaFieldRef expectedResult result |
- initString := 'Ljava/lang/String;'.
+ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
javaFieldRef := JavaFieldRef2
- namedAndTyped: (JavaNameAndType2 name: 'value' descriptor: '[C')
- inClassIdentifiedByRef: javaClassRef.
+ namedAndTyped: (JavaNameAndType2 name: 'publicField'
+ descriptor: 'Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
result := javaFieldRef resolve.
- expectedResult := (Java classForName: 'java.lang.String') fields at: 1.
+ expectedResult := (Java classForName: 'stx.libjava.tests.mocks.PublicClass') fields at: 3.
self assertTrue: (result = expectedResult).
"Created: / 08-04-2011 / 14:07:57 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 08-04-2011 / 16:28:00 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 14-04-2011 / 15:29:55 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
testInvalidation
- | javaClassRef javaFieldRef |
+ | javaClassRef javaFieldRef initString|
- javaClassRef := JavaClassRef2 for: 'Ljava/lang/String;'.
+ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
javaFieldRef := JavaFieldRef2
- namedAndTyped: (JavaNameAndType2 name: 'value' descriptor: '[C')
- inClassIdentifiedByRef: javaClassRef.
+ namedAndTyped: (JavaNameAndType2 name: 'publicField'
+ descriptor: 'Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
self assertTrue: (javaFieldRef isResolved not).
javaFieldRef resolve.
self assertTrue: (javaFieldRef isResolved).
+ self assertTrue: (javaFieldRef classRef isResolved).
javaFieldRef invalidate.
self assertTrue: (javaFieldRef isResolved not).
+ self assertTrue: (javaFieldRef classRef isResolved not).
"Created: / 08-04-2011 / 14:09:06 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 08-04-2011 / 15:15:18 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 14-04-2011 / 15:30:20 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
testInvalidationForClassNegative
- | javaClassRef javaFieldRef |
+ | javaClassRef javaFieldRef initString |
- javaClassRef := JavaClassRef2 for: 'Ljava/lang/String;'.
+ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
javaFieldRef := JavaFieldRef2
- namedAndTyped: (JavaNameAndType2 name: 'value' descriptor: '[C')
+ namedAndTyped: (JavaNameAndType2 name: 'publicField'
+ descriptor: 'Ljava/lang/String;')
inClassIdentifiedByRef: javaClassRef.
self assertTrue: (javaFieldRef isResolved not).
javaFieldRef resolve.
@@ -75,38 +401,46 @@
self assertTrue: (javaFieldRef isResolved).
"Created: / 08-04-2011 / 16:23:06 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 14-04-2011 / 15:30:33 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
testInvalidationForClassPositive
- | javaClassRef javaFieldRef |
+ | javaClassRef javaFieldRef initString |
- javaClassRef := JavaClassRef2 for: 'Ljava/lang/String;'.
+ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
javaFieldRef := JavaFieldRef2
- namedAndTyped: (JavaNameAndType2 name: 'value' descriptor: '[C')
+ namedAndTyped: (JavaNameAndType2 name: 'publicField'
+ descriptor: 'Ljava/lang/String;')
inClassIdentifiedByRef: javaClassRef.
self assertTrue: (javaFieldRef isResolved not).
javaFieldRef resolve.
self assertTrue: (javaFieldRef isResolved).
- javaFieldRef invalidateForClass: 'Ljava/lang/String;'.
+ javaFieldRef invalidateForClass: 'Lstx/libjava/tests/mocks/PublicClass;'.
self assertTrue: (javaFieldRef isResolved not).
"Created: / 08-04-2011 / 16:23:19 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 14-04-2011 / 15:31:07 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
testResolving
- | javaClassRef javaFieldRef |
+ | javaClassRef javaFieldRef initString|
- javaClassRef := JavaClassRef2 for: 'Ljava/lang/String;'.
+ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
javaFieldRef := JavaFieldRef2
- namedAndTyped: (JavaNameAndType2 name: 'value' descriptor: '[C')
- inClassIdentifiedByRef: javaClassRef.
+ namedAndTyped: (JavaNameAndType2 name: 'publicField'
+ descriptor: 'Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
self assertTrue: (javaFieldRef isResolved not).
javaFieldRef resolve.
self assertTrue: (javaClassRef isResolved).
self assertTrue: (javaFieldRef isResolved).
"Created: / 08-04-2011 / 14:04:01 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 08-04-2011 / 15:14:34 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 14-04-2011 / 15:30:47 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !
!JavaFieldRefTests class methodsFor:'documentation'!
@@ -114,3 +448,4 @@
version_SVN
^ '$Id$'
! !
+
--- a/src/JavaInterfaceMethodRef2.st Mon Apr 25 19:32:44 2011 +0000
+++ b/src/JavaInterfaceMethodRef2.st Sun May 01 12:52:23 2011 +0000
@@ -1,6 +1,6 @@
"{ Package: 'stx:libjava' }"
-JavaClassContentRef2 subclass:#JavaInterfaceMethodRef2
+JavaMethodRef2 subclass:#JavaInterfaceMethodRef2
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
@@ -10,10 +10,37 @@
!JavaInterfaceMethodRef2 methodsFor:'private - resolving'!
+findResolvedStaticValue
+ self halt:'tell mh if you have valid use case for calling me'.
+
+ "Created: / 28-04-2011 / 22:53:16 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
findResolvedValue
- "Resolve reference and set valueCache and isResolved."
+ "Resolve reference and set valueCache."
+
+ valueCache := JavaResolver uniqueInstance
+ resolveInterfaceMethodIdentifiedByRef: self.
+
+ "Modified: / 14-04-2011 / 15:34:56 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!JavaInterfaceMethodRef2 methodsFor:'queries'!
- ^ self shouldImplement
+isJavaInterfaceMethodRef
+ "we will see if this is expected behavior"
+
+ ^ true.
+
+ "Created: / 14-04-2011 / 15:33:46 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+isJavaMethodRef
+"we will see if this is expected behavior"
+ ^ false.
+
+ "Created: / 11-04-2011 / 19:56:35 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 14-04-2011 / 15:33:40 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !
!JavaInterfaceMethodRef2 class methodsFor:'documentation'!
@@ -22,3 +49,4 @@
^ '$Id$'
! !
+
--- a/src/JavaInterfaceMethodRefTests.st Mon Apr 25 19:32:44 2011 +0000
+++ b/src/JavaInterfaceMethodRefTests.st Sun May 01 12:52:23 2011 +0000
@@ -15,7 +15,8 @@
initString := 'Ljava/lang/Runnable;'.
javaClassRef := JavaClassRef2 for: initString.
- javaMethodRef := JavaMethodRef2
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaMethodRef := JavaInterfaceMethodRef2
namedAndTyped: (JavaNameAndType2 name: 'run' descriptor: '()V')
inClassIdentifiedByRef: javaClassRef.
self assertTrue: (javaMethodRef isResolved not).
@@ -25,7 +26,7 @@
self assertTrue: (javaMethodRef classRef name = 'Ljava/lang/Runnable;').
"Created: / 08-04-2011 / 14:01:41 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 08-04-2011 / 16:48:31 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 13-04-2011 / 12:17:46 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
testCorrectResolving
@@ -33,23 +34,25 @@
initString := 'Ljava/lang/Runnable;'.
javaClassRef := JavaClassRef2 for: initString.
- javaMethodRef := JavaMethodRef2
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaMethodRef := JavaInterfaceMethodRef2
namedAndTyped: (JavaNameAndType2 name: 'run' descriptor: '()V')
inClassIdentifiedByRef: javaClassRef.
result := javaMethodRef resolve.
- expectedResult := (Java classForName: 'java.lang.Runnable') methodDictionary
- at: #'run()V'.
+ expectedResult := (Java classForName: 'java.lang.Runnable')
+ methodDictionary at: #'run()V'.
self assertTrue: (result = expectedResult).
"Created: / 08-04-2011 / 14:07:57 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 08-04-2011 / 16:48:48 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 13-04-2011 / 12:17:41 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
testInvalidation
| javaClassRef javaMethodRef |
javaClassRef := JavaClassRef2 for: 'Ljava/lang/Runnable;'.
- javaMethodRef := JavaFieldRef2
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaMethodRef := JavaInterfaceMethodRef2
namedAndTyped: (JavaNameAndType2 name: 'run' descriptor: '()V')
inClassIdentifiedByRef: javaClassRef.
self assertTrue: (javaMethodRef isResolved not).
@@ -61,14 +64,15 @@
self assertTrue: (javaClassRef isResolved not).
"Created: / 08-04-2011 / 14:09:06 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 08-04-2011 / 16:49:50 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 13-04-2011 / 12:17:35 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
testInvalidationForClassNegative
| javaClassRef javaMethodRef |
javaClassRef := JavaClassRef2 for: 'Ljava/lang/Runnable;'.
- javaMethodRef := JavaFieldRef2
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaMethodRef := JavaInterfaceMethodRef2
namedAndTyped: (JavaNameAndType2 name: 'run' descriptor: '()V')
inClassIdentifiedByRef: javaClassRef.
self assertTrue: (javaMethodRef isResolved not).
@@ -80,13 +84,15 @@
self assertTrue: (javaClassRef isResolved).
"Created: / 08-04-2011 / 16:23:06 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 13-04-2011 / 12:17:33 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
testInvalidationForClassPositive
| javaClassRef javaMethodRef |
javaClassRef := JavaClassRef2 for: 'Ljava/lang/Runnable;'.
- javaMethodRef := JavaFieldRef2
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaMethodRef := JavaInterfaceMethodRef2
namedAndTyped: (JavaNameAndType2 name: 'run' descriptor: '()V')
inClassIdentifiedByRef: javaClassRef.
self assertTrue: (javaMethodRef isResolved not).
@@ -98,13 +104,15 @@
self assertTrue: (javaClassRef isResolved not).
"Created: / 08-04-2011 / 16:23:19 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 13-04-2011 / 12:17:30 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
testResolving
| javaClassRef javaMethodRef |
javaClassRef := JavaClassRef2 for: 'Ljava/lang/Runnable;'.
- javaMethodRef := JavaFieldRef2
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaMethodRef := JavaInterfaceMethodRef2
namedAndTyped: (JavaNameAndType2 name: 'run' descriptor: '()V')
inClassIdentifiedByRef: javaClassRef.
self assertTrue: (javaMethodRef isResolved not).
@@ -113,7 +121,218 @@
self assertTrue: (javaMethodRef isResolved).
"Created: / 08-04-2011 / 14:04:01 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 08-04-2011 / 16:47:57 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 13-04-2011 / 12:17:24 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!JavaInterfaceMethodRefTests methodsFor:'permission tests'!
+
+testAccessingPrivateFromOutside
+ | javaClassRef javaMethodRef initString throwedException |
+
+ self enableMockedExceptionThrowing.
+
+ [ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaMethodRef := JavaMethodRef2
+ namedAndTyped: (JavaNameAndType2 name: 'privateMethod'
+ descriptor: '()Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaMethodRef resolve. ] on: Error
+ do: [:e | throwedException := e ].
+ self assertTrue: (throwedException notNil
+ and: [ throwedException messageText = 'IllegalAccessError' ]).
+ self disableMockedExceptionThrowing.
+
+ "Created: / 13-04-2011 / 14:44:48 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 13-04-2011 / 23:09:19 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingPrivateFromOutsideInNonPublic
+ | javaClassRef javaMethodRef initString throwedException |
+
+ self enableMockedExceptionThrowing.
+
+ [ initString := 'Lstx/libjava/tests/mocks/NonPublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaMethodRef := JavaMethodRef2
+ namedAndTyped: (JavaNameAndType2 name: 'privateMethod'
+ descriptor: '()Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaMethodRef resolve. ] on: Error
+ do: [:e | throwedException := e ].
+ self assertTrue: (throwedException notNil
+ and: [ throwedException messageText = 'IllegalAccessError' ]).
+ self disableMockedExceptionThrowing.
+
+ "Created: / 13-04-2011 / 14:47:44 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 14-04-2011 / 14:11:08 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingPrivateFromSubclass
+ | javaClassRef javaMethodRef initString throwedException |
+
+ self enableMockedExceptionThrowing.
+
+ [ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.SubclassOfPublicClass').
+ javaMethodRef := JavaMethodRef2
+ namedAndTyped: (JavaNameAndType2 name: 'privateMethod'
+ descriptor: '()Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaMethodRef resolve. ] on: Error
+ do: [:e | throwedException := e ].
+ self assertTrue: (throwedException notNil
+ and: [ throwedException messageText = 'IllegalAccessError' ]).
+ self disableMockedExceptionThrowing.
+
+ "Created: / 13-04-2011 / 14:49:32 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 14-04-2011 / 00:03:40 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingProtectedFromOutside
+ | javaClassRef javaMethodRef initString throwedException |
+
+ self enableMockedExceptionThrowing.
+
+ [ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaMethodRef := JavaMethodRef2
+ namedAndTyped: (JavaNameAndType2 name: 'protectedMethod'
+ descriptor: '()Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaMethodRef resolve. ] on: Error
+ do: [:e | throwedException := e ].
+ self assertTrue: (throwedException notNil
+ and: [ throwedException messageText = 'IllegalAccessError' ]).
+ self disableMockedExceptionThrowing.
+
+ "Created: / 13-04-2011 / 14:44:48 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 14-04-2011 / 14:12:31 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingProtectedFromOutsideInNonPublic
+ | javaClassRef javaMethodRef initString throwedException |
+
+ self enableMockedExceptionThrowing.
+
+ [ initString := 'Lstx/libjava/tests/mocks/NonPublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaMethodRef := JavaMethodRef2
+ namedAndTyped: (JavaNameAndType2 name: 'protectedMethod'
+ descriptor: '()Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaMethodRef resolve. ] on: Error
+ do: [:e | throwedException := e ].
+ self assertTrue: (throwedException notNil
+ and: [ throwedException messageText = 'IllegalAccessError' ]).
+ self disableMockedExceptionThrowing.
+
+ "Created: / 13-04-2011 / 14:47:54 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 14-04-2011 / 14:11:15 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingProtectedFromSubclass
+ | javaClassRef javaMethodRef initString throwedException |
+
+ self enableMockedExceptionThrowing.
+
+ [ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'stx.libjava.tests.mocks.SubclassOfPublicClass').
+ javaMethodRef := JavaMethodRef2
+ namedAndTyped: (JavaNameAndType2 name: 'protectedMethod'
+ descriptor: '()Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaMethodRef resolve. ] on: Error
+ do: [:e | throwedException := e ].
+ self assertTrue: (throwedException isNil).
+ self disableMockedExceptionThrowing.
+
+ "Created: / 13-04-2011 / 14:49:23 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 13-04-2011 / 23:18:36 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingPublic
+ | javaClassRef javaMethodRef initString |
+
+ self enableMockedExceptionThrowing.
+ self shouldnt:
+ [ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaMethodRef := JavaMethodRef2
+ namedAndTyped: (JavaNameAndType2 name: 'publicMethod' descriptor: '()Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaMethodRef resolve.]
+ raise: Error.
+ self disableMockedExceptionThrowing.
+
+ "Created: / 13-04-2011 / 14:44:13 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingPublicFromOutside
+ | javaClassRef javaMethodRef initString |
+
+ self enableMockedExceptionThrowing.
+ self shouldnt:
+ [ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaMethodRef := JavaMethodRef2
+ namedAndTyped: (JavaNameAndType2 name: 'publicMethod'
+ descriptor: '()Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaMethodRef resolve. ]
+ raise: Error.
+ self disableMockedExceptionThrowing.
+
+ "Created: / 13-04-2011 / 14:44:31 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingPublicFromOutsideInNonPublic
+ | javaClassRef javaMethodRef initString throwedException |
+
+ self enableMockedExceptionThrowing.
+
+ [ initString := 'Lstx/libjava/tests/mocks/NonPublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaMethodRef := JavaMethodRef2
+ namedAndTyped: (JavaNameAndType2 name: 'publicMethod'
+ descriptor: '()Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaMethodRef resolve. ] on: Error
+ do: [:e | throwedException := e ].
+ self assertTrue: (throwedException notNil and:[throwedException messageText = 'IllegalAccessError']).
+ self disableMockedExceptionThrowing.
+
+ "Created: / 13-04-2011 / 14:48:05 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 13-04-2011 / 23:04:57 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingPublicFromSubclass
+ | javaClassRef javaMethodRef initString throwedException |
+
+ self enableMockedExceptionThrowing.
+
+ [ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.SubclassOfPublicClass').
+ javaMethodRef := JavaMethodRef2
+ namedAndTyped: (JavaNameAndType2 name: 'publicMethod'
+ descriptor: '()Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaMethodRef resolve. ] on: Error
+ do: [:e | throwedException := e ].
+ self assertTrue: (throwedException isNil ).
+ self disableMockedExceptionThrowing.
+
+ "Created: / 13-04-2011 / 14:49:11 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !
!JavaInterfaceMethodRefTests class methodsFor:'documentation'!
@@ -121,3 +340,4 @@
version_SVN
^ '$Id$'
! !
+
--- a/src/JavaLookup.st Mon Apr 25 19:32:44 2011 +0000
+++ b/src/JavaLookup.st Sun May 01 12:52:23 2011 +0000
@@ -68,8 +68,9 @@
lookupMethodForSelector:selector directedTo:initialSearchClass for:aReceiver withArguments:argArrayOrNil from:sendingContext
"as a courtesy to the smalltalker, try to map methods"
| m |
- m := self javaLookupMethodForSelector: selector for: aReceiver withArguments: argArrayOrNil.
- m ifNotNil: [ ^ m ] .
+ self halt.
+"/ m := self javaLookupMethodForSelector: selector for: aReceiver withArguments: argArrayOrNil.
+"/ m ifNotNil: [ ^ m ] .
"
I am not sure, if we should invoke builtin lookup. It will search for the Smalltalk-like methods.
For example, if you invoke #isNumber on java.lang.String
@@ -80,7 +81,7 @@
^ self smalltalkLookupMethodForSelector:selector directedTo:initialSearchClass for:aReceiver withArguments:argArrayOrNil from:sendingContext
"Created: / 21-02-2011 / 13:38:55 / kursjan <kursjan@fit.cvut.cz>"
- "Modified: / 25-02-2011 / 20:03:30 / kursjan <kursjan@fit.cvut.cz>"
+ "Modified: / 11-04-2011 / 20:19:50 / kursjan <kursjan@fit.cvut.cz>"
!
smalltalkLookupMethodForSelector:selector directedTo:initialSearchClass for:aReceiver withArguments:argArrayOrNil from:sendingContext
@@ -94,3 +95,4 @@
version_SVN
^ '$Id$'
! !
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/JavaLookupTestsResource.st Sun May 01 12:52:23 2011 +0000
@@ -0,0 +1,121 @@
+"{ Package: 'stx:libjava' }"
+
+TestResource subclass:#JavaLookupTestsResource
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Languages-Java-Lookup-Tests'
+!
+
+JavaLookupTestsResource class instanceVariableNames:'projectDir projectBuilded'
+
+"
+ The following class instance variables are inherited by this class:
+
+ TestResource - current
+ TestAsserter -
+ Object -
+"
+!
+
+
+!JavaLookupTestsResource class methodsFor:'initialization'!
+
+initialize
+ "Invoked at system start or when the class is dynamically loaded."
+
+ "/ please change as required (and remove this comment)
+
+ projectDir :=
+ (Smalltalk packageDirectoryForPackageId: 'stx:libjava') asFilename
+ / 'java' / 'libjava-projects/MethodLookupTests' .
+
+ projectBuilded := false.
+
+ "Modified: / 16-03-2011 / 14:33:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 11-04-2011 / 19:30:29 / kursjan <kursjan@fit.cvut.cz>"
+! !
+
+!JavaLookupTestsResource class methodsFor:'accessing'!
+
+projectBuilded:aBoolean
+
+ "
+ JavaTestsResource projectBuilded: true.
+ JavaTestsResource projectBuilded: false.
+ "
+
+ projectBuilded := aBoolean.
+
+ "Modified: / 16-03-2011 / 15:20:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+projectDir
+ ^ projectDir
+! !
+
+!JavaLookupTestsResource class methodsFor:'running'!
+
+buildProject
+
+ "
+ JavaTestsResource projectBuilded: true.
+ JavaTestsResource projectBuilded: false.
+ "
+
+
+ projectBuilded == true ifFalse:[
+ "Check for ant"
+ self assert: (OperatingSystem canExecuteCommand:'ant')
+ description: 'Cannot execute ant'.
+
+ self assert: (self projectDir / 'build.xml') exists
+ description: 'No build.xml in ' , self projectDir asString.
+
+
+ "Launch ant"
+ Transcript show:'Running ant in '; showCR: self projectDir asString.
+ OperatingSystem
+ executeCommand:'ant -f build.xml'
+ inputFrom:nil
+ outputTo:Stdout
+ errorTo:Stderr
+ inDirectory: self projectDir
+ onError:
+ [:status |
+ Transcript showCR:'ANT FAILED!!!!!!'.
+ self error:'ant failed'.
+ ^self].
+
+ Transcript show:'Ant finished'].
+ ^ projectBuilded
+
+ "Modified: / 16-03-2011 / 15:20:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaLookupTestsResource methodsFor:'running'!
+
+setUp
+ self class buildProject.
+ Java addToClassPath: (self class projectDir / 'bin') asString.
+ JavaObject lookupObject: JavaLookup instance.
+
+ "Created: / 06-03-2011 / 14:50:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 16-03-2011 / 14:38:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 11-04-2011 / 20:15:15 / kursjan <kursjan@fit.cvut.cz>"
+!
+
+tearDown
+ JavaObject lookupObject: nil
+
+ "Modified: / 16-03-2011 / 14:38:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Created: / 11-04-2011 / 20:15:28 / kursjan <kursjan@fit.cvut.cz>"
+! !
+
+!JavaLookupTestsResource class methodsFor:'documentation'!
+
+version_SVN
+ ^ '$Id$'
+! !
+
+JavaLookupTestsResource initialize!
--- a/src/JavaMethodRef2.st Mon Apr 25 19:32:44 2011 +0000
+++ b/src/JavaMethodRef2.st Sun May 01 12:52:23 2011 +0000
@@ -10,10 +10,28 @@
!JavaMethodRef2 methodsFor:'private - resolving'!
+findResolvedStaticValue
+ valueCache := JavaResolver uniqueInstance
+ resolveStaticMethodIndentifiedByRef: self.
+
+ "Created: / 28-04-2011 / 22:45:53 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
findResolvedValue
- "Resolve reference and set valueCache and isResolved."
+ "Resolve reference and set valueCache."
+
+ valueCache := JavaResolver uniqueInstance
+ resolveMethodIndentifiedByRef: self.
- ^ self shouldImplement
+ "Modified: / 11-04-2011 / 19:45:14 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!JavaMethodRef2 methodsFor:'queries'!
+
+isJavaMethodRef
+^ true.
+
+ "Created: / 11-04-2011 / 19:56:35 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !
!JavaMethodRef2 class methodsFor:'documentation'!
@@ -22,3 +40,4 @@
^ '$Id$'
! !
+
--- a/src/JavaMethodRefTests.st Mon Apr 25 19:32:44 2011 +0000
+++ b/src/JavaMethodRefTests.st Sun May 01 12:52:23 2011 +0000
@@ -8,7 +8,302 @@
!
-!JavaMethodRefTests methodsFor:'javaMethodRef tests'!
+!JavaMethodRefTests methodsFor:'permission tests'!
+
+testAccessingPPFromOutside
+ | javaClassRef javaMethodRef initString throwedException |
+
+ self enableMockedExceptionThrowing.
+
+ [ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaMethodRef := JavaMethodRef2
+ namedAndTyped: (JavaNameAndType2 name: 'packagePrivateMethod'
+ descriptor: '()Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaMethodRef resolve. ] on: Error
+ do: [:e | throwedException := e ].
+ self assertTrue: (throwedException notNil
+ and: [ throwedException messageText = 'IllegalAccessError' ]).
+ self disableMockedExceptionThrowing.
+
+ "Created: / 14-04-2011 / 15:10:35 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingPPFromSubclass
+ | javaClassRef javaMethodRef initString throwedException |
+
+ self enableMockedExceptionThrowing.
+
+ [ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef
+ owner: (Java classForName: 'stx.libjava.tests.mocks.SubclassOfPublicClass').
+ javaMethodRef := JavaMethodRef2
+ namedAndTyped: (JavaNameAndType2 name: 'packagePrivateMethod'
+ descriptor: '()Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaMethodRef resolve. ] on: Error
+ do: [:e | throwedException := e ].
+ self assertTrue: (throwedException isNil).
+ self disableMockedExceptionThrowing.
+
+ "Created: / 14-04-2011 / 15:10:55 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingPrivateFromOutside
+ | javaClassRef javaMethodRef initString throwedException |
+
+ self enableMockedExceptionThrowing.
+
+ [ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaMethodRef := JavaMethodRef2
+ namedAndTyped: (JavaNameAndType2 name: 'privateMethod'
+ descriptor: '()Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaMethodRef resolve. ] on: Error
+ do: [:e | throwedException := e ].
+ self assertTrue: (throwedException notNil
+ and: [ throwedException messageText = 'IllegalAccessError' ]).
+ self disableMockedExceptionThrowing.
+
+ "Created: / 13-04-2011 / 14:44:48 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 13-04-2011 / 23:09:19 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingPrivateFromOutsideInNonPublic
+ | javaClassRef javaMethodRef initString throwedException |
+
+ self enableMockedExceptionThrowing.
+
+ [ initString := 'Lstx/libjava/tests/mocks/NonPublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaMethodRef := JavaMethodRef2
+ namedAndTyped: (JavaNameAndType2 name: 'privateMethod'
+ descriptor: '()Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaMethodRef resolve. ] on: Error
+ do: [:e | throwedException := e ].
+ self assertTrue: (throwedException notNil
+ and: [ throwedException messageText = 'IllegalAccessError' ]).
+ self disableMockedExceptionThrowing.
+
+ "Created: / 13-04-2011 / 14:47:44 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 14-04-2011 / 14:11:08 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingPrivateFromSubclass
+ | javaClassRef javaMethodRef initString throwedException |
+
+ self enableMockedExceptionThrowing.
+
+ [ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.SubclassOfPublicClass').
+ javaMethodRef := JavaMethodRef2
+ namedAndTyped: (JavaNameAndType2 name: 'privateMethod'
+ descriptor: '()Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaMethodRef resolve. ] on: Error
+ do: [:e | throwedException := e ].
+ self assertTrue: (throwedException notNil
+ and: [ throwedException messageText = 'IllegalAccessError' ]).
+ self disableMockedExceptionThrowing.
+
+ "Created: / 13-04-2011 / 14:49:32 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 14-04-2011 / 00:03:40 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingProtectedFromOutside
+ | javaClassRef javaMethodRef initString throwedException |
+
+ self enableMockedExceptionThrowing.
+
+ [ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaMethodRef := JavaMethodRef2
+ namedAndTyped: (JavaNameAndType2 name: 'protectedMethod'
+ descriptor: '()Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaMethodRef resolve. ] on: Error
+ do: [:e | throwedException := e ].
+ self assertTrue: (throwedException notNil
+ and: [ throwedException messageText = 'IllegalAccessError' ]).
+ self disableMockedExceptionThrowing.
+
+ "Created: / 13-04-2011 / 14:44:48 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 14-04-2011 / 14:12:31 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingProtectedFromOutsideInNonPublic
+ | javaClassRef javaMethodRef initString throwedException |
+
+ self enableMockedExceptionThrowing.
+
+ [ initString := 'Lstx/libjava/tests/mocks/NonPublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaMethodRef := JavaMethodRef2
+ namedAndTyped: (JavaNameAndType2 name: 'protectedMethod'
+ descriptor: '()Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaMethodRef resolve. ] on: Error
+ do: [:e | throwedException := e ].
+ self assertTrue: (throwedException notNil
+ and: [ throwedException messageText = 'IllegalAccessError' ]).
+ self disableMockedExceptionThrowing.
+
+ "Created: / 13-04-2011 / 14:47:54 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 14-04-2011 / 14:11:15 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingProtectedFromPackage
+ | javaClassRef javaMethodRef initString throwedException |
+
+ self enableMockedExceptionThrowing.
+
+ [ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'stx.libjava.tests.mocks.Crate').
+ javaMethodRef := JavaMethodRef2
+ namedAndTyped: (JavaNameAndType2 name: 'protectedMethod'
+ descriptor: '()Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaMethodRef resolve. ] on: Error
+ do: [:e | throwedException := e ].
+ self assertTrue: (throwedException isNil ).
+
+ self disableMockedExceptionThrowing.
+
+ "Created: / 14-04-2011 / 15:09:41 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingProtectedFromSubclass
+ | javaClassRef javaMethodRef initString throwedException |
+
+ self enableMockedExceptionThrowing.
+
+ [ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'stx.libjava.tests.mocks.SubclassOfPublicClass').
+ javaMethodRef := JavaMethodRef2
+ namedAndTyped: (JavaNameAndType2 name: 'protectedMethod'
+ descriptor: '()Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaMethodRef resolve. ] on: Error
+ do: [:e | throwedException := e ].
+ self assertTrue: (throwedException isNil).
+ self disableMockedExceptionThrowing.
+
+ "Created: / 13-04-2011 / 14:49:23 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 13-04-2011 / 23:18:36 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingPublic
+ | javaClassRef javaMethodRef initString |
+
+ self enableMockedExceptionThrowing.
+ self shouldnt:
+ [ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaMethodRef := JavaMethodRef2
+ namedAndTyped: (JavaNameAndType2 name: 'publicMethod' descriptor: '()Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaMethodRef resolve.]
+ raise: Error.
+ self disableMockedExceptionThrowing.
+
+ "Created: / 13-04-2011 / 14:44:13 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingPublicFromOutside
+ | javaClassRef javaMethodRef initString |
+
+ self enableMockedExceptionThrowing.
+ self shouldnt:
+ [ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaMethodRef := JavaMethodRef2
+ namedAndTyped: (JavaNameAndType2 name: 'publicMethod'
+ descriptor: '()Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaMethodRef resolve. ]
+ raise: Error.
+ self disableMockedExceptionThrowing.
+
+ "Created: / 13-04-2011 / 14:44:31 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingPublicFromOutsideInNonPublic
+ | javaClassRef javaMethodRef initString throwedException |
+
+ self enableMockedExceptionThrowing.
+
+ [ initString := 'Lstx/libjava/tests/mocks/NonPublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaMethodRef := JavaMethodRef2
+ namedAndTyped: (JavaNameAndType2 name: 'publicMethod'
+ descriptor: '()Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaMethodRef resolve. ] on: Error
+ do: [:e | throwedException := e ].
+ self assertTrue: (throwedException notNil and:[throwedException messageText = 'IllegalAccessError']).
+ self disableMockedExceptionThrowing.
+
+ "Created: / 13-04-2011 / 14:48:05 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 13-04-2011 / 23:04:57 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testAccessingPublicFromSubclass
+ | javaClassRef javaMethodRef initString throwedException |
+
+ self enableMockedExceptionThrowing.
+
+ [ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.SubclassOfPublicClass').
+ javaMethodRef := JavaMethodRef2
+ namedAndTyped: (JavaNameAndType2 name: 'publicMethod'
+ descriptor: '()Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ javaMethodRef resolve. ] on: Error
+ do: [:e | throwedException := e ].
+ self assertTrue: (throwedException isNil ).
+ self disableMockedExceptionThrowing.
+
+ "Created: / 13-04-2011 / 14:49:11 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!JavaMethodRefTests methodsFor:'resolving static tests'!
+
+testCorrectStaticResolving
+ | javaClassRef initString javaMethodRef expectedResult result |
+
+ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaMethodRef := JavaMethodRef2
+ namedAndTyped: (JavaNameAndType2 name: 'publicStaticMethod'
+ descriptor: '()Ljava/lang/String;')
+ inClassIdentifiedByRef: javaClassRef.
+ result := javaMethodRef resolveStatic.
+ expectedResult := (Java
+ classForName: 'stx.libjava.tests.mocks.PublicClass') methodDictionary
+ at: #'publicStaticMethod()Ljava/lang/String;'.
+ self assertTrue: (result = expectedResult).
+
+ "Created: / 28-04-2011 / 22:46:53 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!JavaMethodRefTests methodsFor:'resolving tests'!
testCorrectInstanceCreation
| javaClassRef initString javaMethodRef |
@@ -33,41 +328,46 @@
initString := 'Ljava/lang/String;'.
javaClassRef := JavaClassRef2 for: initString.
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
javaMethodRef := JavaMethodRef2
namedAndTyped: (JavaNameAndType2 name: '<init>' descriptor: '()V')
- inClassIdentifiedByRef: javaClassRef.
+ inClassIdentifiedByRef: javaClassRef.
result := javaMethodRef resolve.
- expectedResult := (Java classForName: 'java.lang.String') methodDictionary
- at: #'<init>()V'.
+ expectedResult := (Java classForName: 'java.lang.String') methodDictionary
+ at: #'<init>()V'.
self assertTrue: (result = expectedResult).
"Created: / 08-04-2011 / 14:07:57 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 08-04-2011 / 16:27:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 11-04-2011 / 20:34:42 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
testInvalidation
| javaClassRef javaMethodRef |
javaClassRef := JavaClassRef2 for: 'Ljava/lang/String;'.
- javaMethodRef := JavaFieldRef2
- namedAndTyped: (JavaNameAndType2 name: 'value' descriptor: '[C')
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaMethodRef := JavaMethodRef2
+ namedAndTyped: (JavaNameAndType2 name: '<init>' descriptor: '()V')
inClassIdentifiedByRef: javaClassRef.
self assertTrue: (javaMethodRef isResolved not).
javaMethodRef resolve.
self assertTrue: (javaMethodRef isResolved).
+ self assertTrue: (javaMethodRef classRef isResolved).
javaMethodRef invalidate.
self assertTrue: (javaMethodRef isResolved not).
+ self assertTrue: (javaMethodRef classRef isResolved not).
"Created: / 08-04-2011 / 14:09:06 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 08-04-2011 / 15:15:18 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 13-04-2011 / 12:22:30 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
testInvalidationForClassNegative
| javaClassRef javaMethodRef |
javaClassRef := JavaClassRef2 for: 'Ljava/lang/String;'.
- javaMethodRef := JavaFieldRef2
- namedAndTyped: (JavaNameAndType2 name: 'value' descriptor: '[C')
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaMethodRef := JavaMethodRef2
+ namedAndTyped: (JavaNameAndType2 name: '<init>' descriptor: '()V')
inClassIdentifiedByRef: javaClassRef.
self assertTrue: (javaMethodRef isResolved not).
javaMethodRef resolve.
@@ -76,14 +376,16 @@
self assertTrue: (javaMethodRef isResolved).
"Created: / 08-04-2011 / 16:23:06 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 11-04-2011 / 20:41:52 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
testInvalidationForClassPositive
| javaClassRef javaMethodRef |
javaClassRef := JavaClassRef2 for: 'Ljava/lang/String;'.
- javaMethodRef := JavaFieldRef2
- namedAndTyped: (JavaNameAndType2 name: 'value' descriptor: '[C')
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaMethodRef := JavaMethodRef2
+ namedAndTyped: (JavaNameAndType2 name: '<init>' descriptor: '()V')
inClassIdentifiedByRef: javaClassRef.
self assertTrue: (javaMethodRef isResolved not).
javaMethodRef resolve.
@@ -92,14 +394,16 @@
self assertTrue: (javaMethodRef isResolved not).
"Created: / 08-04-2011 / 16:23:19 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 11-04-2011 / 20:41:49 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
testResolving
| javaClassRef javaMethodRef |
javaClassRef := JavaClassRef2 for: 'Ljava/lang/String;'.
- javaMethodRef := JavaFieldRef2
- namedAndTyped: (JavaNameAndType2 name: 'value' descriptor: '[C')
+ javaClassRef owner: (Java classForName: 'java.lang.Object').
+ javaMethodRef := JavaMethodRef2
+ namedAndTyped: (JavaNameAndType2 name: '<init>' descriptor: '()V')
inClassIdentifiedByRef: javaClassRef.
self assertTrue: (javaMethodRef isResolved not).
javaMethodRef resolve.
@@ -107,7 +411,7 @@
self assertTrue: (javaMethodRef isResolved).
"Created: / 08-04-2011 / 14:04:01 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 08-04-2011 / 15:14:34 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 11-04-2011 / 20:41:45 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !
!JavaMethodRefTests class methodsFor:'documentation'!
@@ -115,3 +419,4 @@
version_SVN
^ '$Id$'
! !
+
--- a/src/JavaNameAndType2.st Mon Apr 25 19:32:44 2011 +0000
+++ b/src/JavaNameAndType2.st Sun May 01 12:52:23 2011 +0000
@@ -47,6 +47,12 @@
^ name.
"Created: / 08-04-2011 / 11:55:23 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+selector
+^ (name , descriptor) asSymbol.
+
+ "Created: / 11-04-2011 / 21:31:27 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !
!JavaNameAndType2 methodsFor:'comparing'!
@@ -80,3 +86,4 @@
^ '$Id$'
! !
+
--- a/src/JavaNativeMethod.st Mon Apr 25 19:32:44 2011 +0000
+++ b/src/JavaNativeMethod.st Sun May 01 12:52:23 2011 +0000
@@ -2,7 +2,7 @@
JavaMethodWithHandler variableSubclass:#JavaNativeMethod
instanceVariableNames:'nativeImplementation'
- classVariableNames:''
+ classVariableNames:'CacheNativeImplementation'
poolDictionaries:''
category:'Languages-Java-Classes'
!
@@ -10,8 +10,35 @@
!JavaNativeMethod class methodsFor:'initialization'!
+cacheNativeImplementation
+
+ "For details, see #cacheNativeImplementation:"
+
+ ^CacheNativeImplementation
+
+ "Created: / 30-04-2011 / 23:38:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+cacheNativeImplementation: aBoolean
+
+ "If set, native implementations are cached, resulting
+ in better performance when calling native methods.
+ Hower, no change in native method implemenetaion will
+ not be visible then, unless #flushAllCachedNativeMethods
+ is explictely called"
+
+ CacheNativeImplementation := aBoolean
+
+ "Created: / 30-04-2011 / 23:38:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
initialize
self flags:(self flags bitOr:Behavior flagJavaMethod).
+
+ "By default, do not cache native impls while developing"
+ CacheNativeImplementation := Smalltalk isStandAloneApp.
+
+ "Modified: / 30-04-2011 / 23:35:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!JavaNativeMethod class methodsFor:'cleanup'!
@@ -64,14 +91,117 @@
"Created: / 17-12-2010 / 10:34:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+!JavaNativeMethod methodsFor:'private'!
+
+compileNativeImplementation: sel dispatchingTo: oldSel
+
+ | src arg converted |
+ src := (JavaVM class compiledMethodAt: oldSel) source.
+ src := src asStringCollection.
+ (src first includesString: 'aJavaContext') ifTrue:[
+ arg := 'aJavaContext'
+ ] ifFalse:[
+ (src first includesString: 'nativeContext') ifTrue:[
+ arg := 'nativeContext'
+ ]
+ ].
+ arg ifNotNil:[
+ src removeFirst asString.
+ converted := true.
+ ] ifNil:[
+ arg := 'nativeContext'.
+ src := ' self breakPoint: #jv info: ''Convert it to new-style natives''.
+
+ ^ self ', oldSel, ' nativeContext'.
+ converted := false.
+ ].
+
+ (JavaVM class
+ compile:
+ (self nativeMethodTemplate bindWith:sel with: arg with: src asString)
+ classified:
+ 'native - ', ((javaClass javaPackage upTo:$$) replaceAll:$/ with:$. ))
+ package: JavaVM package.
+
+ converted ifTrue:[
+ (JavaVM class compiledMethodAt: oldSel) category: 'native - old-style (converted)'
+ ] ifFalse:[
+ (JavaVM class compiledMethodAt: oldSel) category: 'native - old-style (FAILED to convert)'
+ ]
+
+ "Created: / 01-05-2011 / 00:08:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 01-05-2011 / 13:15:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+compileNativeImplementationStub: sel
+
+ (JavaVM class
+ compile:
+ (self nativeMethodTemplate bindWith:sel with: 'nativeContext' with:('^ UnimplementedNativeMethodSignal raise'))
+ classified:
+ 'native - ', ((javaClass javaPackage upTo:$$) replaceAll:$/ with:$.))
+ package: JavaVM package
+
+ "Created: / 01-05-2011 / 00:08:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+nativeMethodTemplate
+
+ ^'%1 %2
+
+ <javanative: ''', javaClass name , ''' name: ''', (selector copyWithoutLast:signature size), '''>
+
+ %3'
+
+ "Created: / 01-05-2011 / 00:12:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+searchNativeImplementation
+
+ "Returns a SELECTOR of native method implementation.
+ For now, two naming schemes are used. The onld one uses
+ just a class name and selector as a name for native method impl.
+ The new one uses fully qualified class name.
+ "
+
+ | nm newStyleSel oldStyleSel |
+ nm := selector copyWithoutLast:signature size.
+ newStyleSel := ('_' , ((javaClass name copyReplaceAll:$/ with:$_) replaceAll:$$ with:$_), '_' , nm , ':') asSymbol.
+ (JavaVM class canUnderstand: newStyleSel) ifTrue:
+ ["Good, a JavaVM understands new style native selectors"
+ ^newStyleSel].
+
+ oldStyleSel := ('_' , (javaClass lastName copyReplaceAll:$$ with:$_) , '_' , nm , ':') asSymbol.
+ (JavaVM class canUnderstand: oldStyleSel) ifTrue:
+ [
+ "Convert method on the fly only if Im Jan Vrany
+ (to avoid confusion of other developers :-)"
+ OperatingSystem getLoginName = 'jv' ifTrue:[
+ "OK, old style method has not yet been converted to a newstyle one.
+ Converts old-style method to a new-style one"
+ self compileNativeImplementation: newStyleSel dispatchingTo: oldStyleSel.
+ ^newStyleSel
+ ] ifFalse:[
+ ^oldStyleSel
+ ]].
+ self compileNativeImplementationStub: newStyleSel.
+ ^newStyleSel
+
+ "Created: / 30-04-2011 / 23:50:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 01-05-2011 / 13:13:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!JavaNativeMethod methodsFor:'vm support'!
nativeMethodInvokation
- |nm sel mthd sender|
+
+ "Called by the VM when a native method is
+ to be executed"
+
+ | sel mthd sender|
(mthd := nativeImplementation) isNil ifTrue:[
- nm := selector copyWithoutLast:signature size.
- sel := ('_' , (javaClass lastName copyReplaceAll:$$ with:$_) , '_' , nm , ':') asSymbol.
+ sel := self searchNativeImplementation.
mthd := (JavaVM class compiledMethodAt:sel).
(mthd isNil or:[mthd isLazyMethod]) ifTrue:[
@@ -85,7 +215,9 @@
perform:sel
with:sender.
].
- nativeImplementation := mthd.
+ CacheNativeImplementation ifTrue:[
+ nativeImplementation := mthd.
+ ]
].
^ mthd
@@ -100,7 +232,7 @@
"
"Modified: / 27-01-2000 / 13:34:53 / cg"
- "Modified: / 10-12-2010 / 15:10:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 30-04-2011 / 23:52:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!JavaNativeMethod class methodsFor:'documentation'!
@@ -114,3 +246,4 @@
! !
JavaNativeMethod initialize!
+
--- a/src/JavaRef2.st Mon Apr 25 19:32:44 2011 +0000
+++ b/src/JavaRef2.st Sun May 01 12:52:23 2011 +0000
@@ -34,9 +34,11 @@
new
"Don't call me directly"
- ^ self halt:'Dont instantiate me like this. Call my custom object creation method'.
+ '[JavaRef] Dont instantiate me with new. Call my custom overriden object creation method'
+ infoPrintCR.
+ ^ self basicNew initialize.
- "Modified: / 08-04-2011 / 17:33:17 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 11-04-2011 / 19:44:01 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !
!JavaRef2 methodsFor:'accessing'!
@@ -94,12 +96,21 @@
!JavaRef2 methodsFor:'private - resolving'!
+findResolvedStaticValue
+ "Resolve reference and set valueCache."
+
+ self subclassResponsibility.
+
+ "Created: / 26-04-2011 / 13:19:15 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
findResolvedValue
- "Resolve reference and set valueCache and isResolved."
+ "Resolve reference and set valueCache."
self subclassResponsibility.
"Created: / 08-04-2011 / 11:33:28 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 26-04-2011 / 13:19:44 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !
!JavaRef2 methodsFor:'queries'!
@@ -141,6 +152,18 @@
^ valueCache.
"Created: / 08-04-2011 / 11:30:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+resolveStatic
+ "
+ Do it all method - resolves current reference and returns expected element (JavaMethod, JavaField etc.)
+ Hides implementation details of the way of dealing with invalidation etc. User should not need to call anything
+ else."
+
+ self isResolved ifFalse: [ self findResolvedStaticValue ].
+ ^ valueCache.
+
+ "Created: / 26-04-2011 / 13:19:15 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !
!JavaRef2 class methodsFor:'documentation'!
@@ -149,3 +172,4 @@
^ '$Id$'
! !
+
--- a/src/JavaRefMock.st Mon Apr 25 19:32:44 2011 +0000
+++ b/src/JavaRefMock.st Sun May 01 12:52:23 2011 +0000
@@ -34,6 +34,14 @@
!JavaRefMock methodsFor:'private - resolving'!
+findResolvedStaticValue
+ "Resolve reference and set valueCache and isResolved."
+
+ valueCache := 'static'.
+
+ "Created: / 26-04-2011 / 13:20:05 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
findResolvedValue
"Resolve reference and set valueCache and isResolved."
@@ -59,3 +67,4 @@
^ '$Id$'
! !
+
--- a/src/JavaRefTests.st Mon Apr 25 19:32:44 2011 +0000
+++ b/src/JavaRefTests.st Sun May 01 12:52:23 2011 +0000
@@ -17,8 +17,10 @@
self assertFalse: (javaRef isResolved).
self assertTrue: (javaRef valueCache isNil).
self should: [ javaRef resolve ] raise: SubclassResponsibilityError.
+ self should: [ javaRef resolveStatic ] raise: SubclassResponsibilityError.
"Created: / 08-04-2011 / 11:40:25 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 26-04-2011 / 13:21:14 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
testMockedInvalidating
@@ -31,9 +33,15 @@
self assertTrue: (javaRefMock isResolved).
javaRefMock invalidate.
self assertFalse: (javaRefMock isResolved).
+ self assertTrue: (javaRefMock valueCache isNil).
+ self assertTrue: (javaRefMock resolveStatic = 'static').
+ self assertTrue: (javaRefMock isResolved).
+ javaRefMock invalidate.
+ self assertFalse: (javaRefMock isResolved).
self assertTrue: (javaRefMock valueCache isNil).
"Created: / 08-04-2011 / 11:50:35 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 26-04-2011 / 13:21:51 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
testMockedInvalidatingForClassNegative
@@ -45,8 +53,15 @@
self assertTrue: (javaRefMock isResolved).
javaRefMock invalidateForClass: 'Ljava/lang/String;'.
self assertTrue: (javaRefMock isResolved).
+ javaRefMock invalidate.
+ self assertTrue: (javaRefMock isResolved not).
+ javaRefMock resolveStatic.
+ self assertTrue: (javaRefMock isResolved).
+ javaRefMock invalidateForClass: 'Ljava/lang/String;'.
+ self assertTrue: (javaRefMock isResolved).
"Created: / 08-04-2011 / 16:19:13 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 26-04-2011 / 13:22:46 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
testMockedInvalidatingForClassPositive
@@ -58,8 +73,13 @@
self assertTrue: (javaRefMock isResolved).
javaRefMock invalidateForClass: 'mock'.
self assertTrue: (javaRefMock isResolved not).
+ javaRefMock resolveStatic.
+ self assertTrue: (javaRefMock isResolved).
+ javaRefMock invalidateForClass: 'mock'.
+ self assertTrue: (javaRefMock isResolved not).
"Created: / 08-04-2011 / 16:19:52 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 26-04-2011 / 13:23:13 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
testMockedResolving
@@ -72,6 +92,18 @@
self assertTrue: (javaRefMock isResolved).
"Created: / 08-04-2011 / 11:47:27 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+testMockedResolvingStatic
+ | javaRefMock |
+
+ javaRefMock := JavaRefMock new.
+ self assertFalse: (javaRefMock isResolved).
+ self assertTrue: (javaRefMock valueCache isNil).
+ self assertTrue: (javaRefMock resolveStatic = 'static').
+ self assertTrue: (javaRefMock isResolved).
+
+ "Created: / 26-04-2011 / 13:23:31 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !
!JavaRefTests class methodsFor:'documentation'!
@@ -79,3 +111,4 @@
version_SVN
^ '$Id$'
! !
+
--- a/src/JavaResolver.st Mon Apr 25 19:32:44 2011 +0000
+++ b/src/JavaResolver.st Sun May 01 12:52:23 2011 +0000
@@ -1,7 +1,7 @@
"{ Package: 'stx:libjava' }"
Object subclass:#JavaResolver
- instanceVariableNames:'resolvedClasses'
+ instanceVariableNames:'exceptionThrower'
classVariableNames:'uniqueInstance'
poolDictionaries:''
category:'Languages-Java-Reader-Support-new'
@@ -12,33 +12,44 @@
initialize
uniqueInstance := JavaResolver new.
+ uniqueInstance exceptionThrower: JavaVM.
+
"/has methods at: and at: put:
"/uniqueInstance resolvedClasses: Java.
- "Modified: / 08-04-2011 / 18:18:56 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
"Modified: / 10-04-2011 / 10:23:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 13-04-2011 / 14:07:35 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !
!JavaResolver class methodsFor:'instance creation'!
uniqueInstance
- self shouldImplement
+ ^uniqueInstance.
"Created: / 08-04-2011 / 17:36:37 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 11-04-2011 / 19:06:49 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!JavaResolver methodsFor:'accessing'!
+
+exceptionThrower
+ ^ exceptionThrower
+!
+
+exceptionThrower:something
+ exceptionThrower := something.
! !
!JavaResolver methodsFor:'class resolving'!
-resolveClassIndentifiedBy: aJavaClassRef
+resolveClassIndentifiedByRef: aJavaClassRef
| classLoader result |
- aJavaClassRef isJavaRef ifFalse: [ self halt: 'Argument type not valid' ].
- aJavaClassRef isJavaClassRef
- ifFalse: [ self halt: 'Only class refs please' ].
- result := resolvedClasses at: aJavaClassRef javaClassName.
+ self validateClassRef: aJavaClassRef.
+ result := self lookupClassIfAlreadyResolved: aJavaClassRef javaClassName.
result ifNotNil:
[ "/wrap result with array(s) if needed and return it
- ^ self wrapJavaClass: result withArrayAsSpecifiedIn: aJavaClassRef ].
+ self checkIfArrayRef: aJavaClassRef andWrap: result ].
"
To resolve an unresolved symbolic reference from D to a class or interface C denoted by N,
the following steps are performed:
@@ -47,36 +58,90 @@
of class or interface creation can thus be thrown as a result of failure of class and
interface resolution. The details of the process are given in Section 5.3.
"
- classLoader := aJavaClassRef owner classLoader.
+ classLoader := aJavaClassRef classLoader.
classLoader isNil
- ifTrue: [ result := JavaClassReader loadClassLazy: aJavaClassRef name. ]
+ ifTrue: [ result := self loadUnresolvedClass: aJavaClassRef ]
ifFalse:
- [ "/ the aquired loader is a javaClassLoader
- "/ which expects an URL as arg.
- result := classLoader perform: #'loadClass(Ljava/lang/String;)Ljava/lang/Class;'
- with: (Java as_String: (aJavaClassRef name)). ].
+ [ result := self loadUnresolvedClass: aJavaClassRef
+ withJavaClassLoader: classLoader. ].
+ result ifNil: [ self halt. "tell mh, he will throw exception instead, for now, he wants to halt." ].
"
If C is an array class and its element type is a reference type, then the symbolic reference
to the class or interface representing the element type is resolved by invoking the algorithm
in Section 5.4.3.1 recursively."
-
-result := self wrapJavaClass: result withArrayAsSpecifiedIn: aJavaClassRef.
-
+ result := self checkIfArrayRef: aJavaClassRef andWrap: result.
"Finally, access permissions to C are checked:
- If C is not accessible (§5.4.4) to D, class or interface resolution throws an IllegalAccessError.
+ If C is not accessible (5.4.4) to D, class or interface resolution throws an IllegalAccessError.
This condition can occur, for example, if C is a class that was originally declared to be
public but was changed to be non-public after D was compiled.
If steps 1 and 2 succeed but step 3 fails, C is still valid and usable. Nevertheless, resolution
fails, and D is prohibited from accessing C."
- self halt.
+ (self checkPermissionsFrom: aJavaClassRef owner to: result)
+ ifTrue: [ ^ result ]
+ ifFalse: [ self throwIllegalAccessError ].
- "Created: / 08-04-2011 / 17:35:15 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 08-04-2011 / 18:48:28 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Created: / 11-04-2011 / 19:07:19 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 26-04-2011 / 13:14:08 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !
!JavaResolver methodsFor:'class resolving helpers'!
+checkIfArrayRef: aJavaClassRef andWrap: result
+ "/wrap result with array(s) if needed and return it
+ ^ aJavaClassRef isJavaArrayClassRef
+ ifFalse: [ result ]
+ ifTrue: [ self wrapJavaClass: result withArrayAsSpecifiedIn: aJavaClassRef ]
+
+ "Modified: / 11-04-2011 / 19:31:43 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+checkPermissionsFrom: refOwner to: resolvedClass
+ "
+ A class or interface C is accessible to a class or interface D if and only if either of the following conditions are true:
+ C is public.
+ C and D are members of the same runtime package (§5.3).
+ Finally, access permissions to C are checked:
+ If C is not accessible (§5.4.4) to D, class or interface resolution throws an IllegalAccessError.
+ This condition can occur, for example, if C is a class that was originally declared to be
+ public but was changed to be non-public after D was compiled.
+ At run time, a class or interface is determined not by its name alone,
+ but by a pair: its fully qualified name and its defining class loader.
+ Each such class or interface belongs to a single runtime package. The runtime
+ package of a class or interface is determined by the package name and
+ defining class loader of the class or interface."
+
+ resolvedClass isPublic ifTrue: [ ^ true ].
+ resolvedClass classLoader = refOwner classLoader ifFalse: [ ^ false ].
+ ^ refOwner javaPackage = resolvedClass javaPackage.
+
+ "Created: / 11-04-2011 / 19:35:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 13-04-2011 / 23:13:39 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+loadUnresolvedClass: aJavaClassRef
+ ^ JavaClassReader loadClassLazy: aJavaClassRef javaClassName.
+
+ "Created: / 11-04-2011 / 19:27:10 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+loadUnresolvedClass: aJavaClassRef withJavaClassLoader: classLoader
+ ^ classLoader perform: #'loadClass(Ljava/lang/String;)Ljava/lang/Class;'
+ with: (Java as_String: (aJavaClassRef name))
+!
+
+lookupClassIfAlreadyResolved: javaClassName
+ ^ nil
+
+ "Modified: / 13-04-2011 / 14:05:25 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+validateClassRef: aJavaClassRef
+ aJavaClassRef isJavaRef ifFalse: [ self halt: 'Argument type not valid' ].
+ aJavaClassRef isJavaClassRef
+ ifFalse: [ self halt: 'Only class refs please' ].
+!
+
wrapJavaClass: aJavaClass withArrayAsSpecifiedIn: aJavaClassRef
"wraps aJavaClass with as many array dimensions as needed (zero means no array)"
@@ -92,6 +157,436 @@
"Created: / 08-04-2011 / 18:40:00 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !
+!JavaResolver methodsFor:'common helpers'!
+
+checkPermissionsForMethodOrField: aJavaMethod from: accessingJavaClass to: resolvedJavaClass
+ "A class or interface C is accessible to a class or interface D if
+ and only if either of the following conditions are true:
+ C is public.
+ C and D are members of the same runtime package (§5.3).
+ A field or method R is accessible to a class or interface D if and only
+ if any of the following conditions is true:
+ R is public.
+ R is protected and is declared in a class C, and D is either a subclass
+ of C or C itself.
+ R is either protected or package private (that is, neither public nor
+ protected nor private), and is declared by a class in the same runtime
+ package as D.
+ R is private and is declared in D.
+ This discussion of access control omits a related restriction on the target
+ of a protected field access or method invocation (the target must be of class
+ D or a subtype of D). That requirement is checked as part of the verification
+ process (§5.4.1); it is not part of link-time access control."
+
+ (self checkPermissionsFrom: accessingJavaClass to: resolvedJavaClass)
+ ifFalse: [ ^ false ].
+ aJavaMethod isPublic ifTrue: [ ^ true ].
+ ((aJavaMethod isProtected
+ and: [ aJavaMethod javaClass = resolvedJavaClass ]) and:
+ [ (accessingJavaClass isSubclassOf: resolvedJavaClass)
+ or: [ accessingJavaClass = resolvedJavaClass ] ])
+ ifTrue: [ ^ true ].
+ ((aJavaMethod isPrivate not
+ and: [ resolvedJavaClass javaPackage = accessingJavaClass javaPackage ])
+ and: [ resolvedJavaClass classLoader = accessingJavaClass classLoader ])
+ ifTrue: [ ^ true ].
+ (aJavaMethod isPrivate and: [ aJavaMethod javaClass = accessingJavaClass ])
+ ifTrue: [ ^ true ].
+ ^ false.
+
+ "Created: / 14-04-2011 / 14:19:33 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 14-04-2011 / 15:42:15 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!JavaResolver methodsFor:'exceptions'!
+
+throwAbstractMethodError
+ exceptionThrower throwAbstractMethodError.
+
+ "Created: / 11-04-2011 / 20:19:42 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 13-04-2011 / 14:07:46 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+throwIllegalAccessError
+ exceptionThrower throwIllegalAccessError.
+
+ "Created: / 11-04-2011 / 19:39:16 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 13-04-2011 / 23:06:58 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+throwIncompatibleClassChangeError
+ exceptionThrower throwIncompatibleClassChangeError.
+
+ "Created: / 11-04-2011 / 20:02:01 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 13-04-2011 / 14:07:54 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+throwNoSuchFieldException
+ exceptionThrower throwNoSuchFieldException.
+
+ "Created: / 11-04-2011 / 21:35:02 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 13-04-2011 / 14:07:57 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+throwNoSuchMethodError
+ exceptionThrower throwNoSuchMethodError.
+
+ "Created: / 11-04-2011 / 20:19:41 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 13-04-2011 / 14:08:01 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!JavaResolver methodsFor:'field resolving'!
+
+resolveFieldIndentifiedByRef: aJavaFieldRef
+ | result class |
+
+ self validateFieldRef: aJavaFieldRef.
+ result := self lookupFieldIfAlreadyResolved: aJavaFieldRef.
+ result ifNotNil: [ ^ result ].
+ class := aJavaFieldRef classRef resolve.
+ class ifNil: [ self halt: 'should not happen - tell mh' ].
+ result := class lookupFieldByNameAndType: aJavaFieldRef nameAndType.
+ result ifNil: [ self throwNoSuchFieldException ].
+ (self
+ checkPermissionsForField: result
+ from: aJavaFieldRef classRef owner
+ to: class) ifFalse: [ self throwIllegalAccessError ].
+ ^ result.
+
+ "
+ To resolve an unresolved symbolic reference from D to a field in a class
+ or interface C, the symbolic reference to C given by the field reference
+ must first be resolved (§5.4.3.1). Therefore, any exception that can be
+ thrown as a result of failure of resolution of a class or interface reference
+ can be thrown as a result of failure of field resolution. If the reference
+ to C can be successfully resolved, an exception relating to the failure of
+ resolution of the field reference itself can be thrown.
+ When resolving a field reference, field resolution first attempts to look
+ up the referenced field in C and its superclasses:
+
+ If C declares a field with the name and descriptor specified by the field
+ reference, field lookup succeeds. The declared field is the result of the
+ field lookup.
+
+ Otherwise, field lookup is applied recursively to the direct superinterfaces
+ of the specified class or interface C.
+
+ Otherwise, if C has a superclass S, field lookup is applied recursively to S.
+
+ Otherwise, field lookup fails.
+ If field lookup fails, field resolution throws a NoSuchFieldError. Otherwise,
+ if field lookup succeeds but the referenced field is not accessible (§5.4.4)
+ to D, field resolution throws an IllegalAccessError.
+ Otherwise, let <E, L1> be the class or interface in which the referenced
+ field is actually declared and let L2 be the defining loader of D. Let T be
+ the name of the type of the referenced field. The Java virtual machine must
+ impose the loading constraint that TL1=TL2(§5.3.4)."
+
+ "Created: / 11-04-2011 / 21:15:20 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 13-04-2011 / 11:57:24 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+resolveStaticFieldIndentifiedByRef: aJavaFieldRef
+ | result class |
+
+ self validateFieldRef: aJavaFieldRef.
+ result := self lookupFieldIfAlreadyResolved: aJavaFieldRef.
+ result ifNotNil: [ ^ result ].
+ class := aJavaFieldRef classRef resolve.
+ class ifNil: [ self halt: 'should not happen - tell mh' ].
+ result := class lookupStaticFieldByNameAndType: aJavaFieldRef nameAndType.
+ result ifNil: [ self throwNoSuchFieldException ].
+ (self
+ checkPermissionsForField: result
+ from: aJavaFieldRef classRef owner
+ to: class) ifFalse: [ self throwIllegalAccessError ].
+ ^ result.
+
+ "
+ To resolve an unresolved symbolic reference from D to a field in a class
+ or interface C, the symbolic reference to C given by the field reference
+ must first be resolved (§5.4.3.1). Therefore, any exception that can be
+ thrown as a result of failure of resolution of a class or interface reference
+ can be thrown as a result of failure of field resolution. If the reference
+ to C can be successfully resolved, an exception relating to the failure of
+ resolution of the field reference itself can be thrown.
+ When resolving a field reference, field resolution first attempts to look
+ up the referenced field in C and its superclasses:
+
+ If C declares a field with the name and descriptor specified by the field
+ reference, field lookup succeeds. The declared field is the result of the
+ field lookup.
+
+ Otherwise, field lookup is applied recursively to the direct superinterfaces
+ of the specified class or interface C.
+
+ Otherwise, if C has a superclass S, field lookup is applied recursively to S.
+
+ Otherwise, field lookup fails.
+ If field lookup fails, field resolution throws a NoSuchFieldError. Otherwise,
+ if field lookup succeeds but the referenced field is not accessible (§5.4.4)
+ to D, field resolution throws an IllegalAccessError.
+ Otherwise, let <E, L1> be the class or interface in which the referenced
+ field is actually declared and let L2 be the defining loader of D. Let T be
+ the name of the type of the referenced field. The Java virtual machine must
+ impose the loading constraint that TL1=TL2(§5.3.4)."
+
+ "Created: / 28-04-2011 / 22:31:34 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!JavaResolver methodsFor:'field resolving helpers'!
+
+checkPermissionsForField: aJavaField from: accessingJavaClass to: resolvedJavaClass
+ "A class or interface C is accessible to a class or interface D if and only
+ if either of the following conditions are true:
+ C is public.
+ C and D are members of the same runtime package (5.3).
+ A field or method R is accessible to a class or interface D if and only
+ if any of the following conditions is true:
+ R is public.
+ R is protected and is declared in a class C, and D is either a subclass of
+ C or C itself.
+ R is either protected or package private (that is, neither public nor protected
+ nor private), and is declared by a class in the same runtime package as D.
+ R is private and is declared in D.
+ This discussion of access control omits a related restriction on the target of
+ a protected field access or method invocation (the target must be of class D or
+ a subtype of D). That requirement is checked as part of the verification process
+ (5.4.1); it is not part of link-time access control."
+
+ ^ self
+ checkPermissionsForMethodOrField: aJavaField from: accessingJavaClass
+ to: resolvedJavaClass.
+
+ "Created: / 11-04-2011 / 21:46:29 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 14-04-2011 / 14:21:05 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+lookupFieldIfAlreadyResolved: aJavaFieldRef
+ ^ nil.
+
+ "Created: / 11-04-2011 / 21:16:45 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 13-04-2011 / 11:57:13 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+validateFieldRef: aJavaFieldRef
+ aJavaFieldRef isJavaRef ifFalse:[self halt:'I expected Java Ref'].
+ aJavaFieldRef isJavaFieldRef ifFalse:[self halt:'I expected Java Field Ref'].
+
+ "Created: / 11-04-2011 / 21:16:44 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!JavaResolver methodsFor:'interface method resolving'!
+
+resolveInterfaceMethodIdentifiedByRef: aJavaInterfaceMethodRef
+ | result class |
+
+ self validateInterfaceMethodRef: aJavaInterfaceMethodRef.
+ result := self
+ lookupInterfaceMethodIfAlreadyResolved: aJavaInterfaceMethodRef.
+ result ifNotNil: [ ^ result ].
+ class := aJavaInterfaceMethodRef classRef resolve.
+ class ifNil: [ self halt: 'should not happen - tell mh' ].
+ class isInterface ifFalse:[self throwIncompatibleClassChangeError].
+ result := class lookupMethodByNameAndType: aJavaInterfaceMethodRef nameAndType.
+ result ifNil:[self throwNoSuchMethodError].
+ ^ result.
+ "
+ To resolve an unresolved symbolic reference from D to an interface method in an
+ interface C, the symbolic reference to C given by the interface method reference is
+ first resolved (§5.4.3.1). Therefore, any exceptions that can be thrown as a result
+ of failure of resolution of an interface reference can be thrown as a result of
+ failure of interface method resolution. If the reference to C can be successfully
+ resolved, exceptions relating to the resolution of the interface method reference
+ itself can be thrown.
+ When resolving an interface method reference:
+
+ If C is not an interface, interface method resolution throws an IncompatibleClassChangeError.
+ Otherwise, if the referenced method does not have the same name and descriptor as
+ a method in C or in one of the superinterfaces of C, or in class Object, interface
+ method resolution throws a NoSuchMethodError.
+ Otherwise, let <E, L1> be the interface in which the referenced interface method is
+ actually declared and let L2 be the defining loader of D. Let T0 be the name of
+ the type returned by the referenced method, and let T1, ..., Tn be the names of the
+ argument types of the referenced method. The Java virtual machine must impose the
+ loading constraints TiL1 = TiL2 for i = 0 to n (§5.3.4)."
+
+ "Modified: / 13-04-2011 / 12:16:01 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!JavaResolver methodsFor:'interface method resolving helpers'!
+
+lookupInterfaceMethodIfAlreadyResolved: aJavaInterfaceMethodRef
+ ^ nil.
+
+ "Created: / 13-04-2011 / 11:53:36 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+validateInterfaceMethodRef: aJavaInterfaceMethodRef
+ aJavaInterfaceMethodRef isJavaRef
+ ifFalse: [ self halt: 'I expected JavaRef instance as an argument' ].
+ aJavaInterfaceMethodRef isJavaInterfaceMethodRef
+ ifFalse: [ self halt: 'I expected JavaMethodRef instance as an argument' ].
+
+ "Created: / 13-04-2011 / 11:53:34 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!JavaResolver methodsFor:'method resolving'!
+
+resolveMethodIndentifiedByRef: aJavaMethodRef
+ | result class |
+
+ self validateMethodRef: aJavaMethodRef.
+ result := self lookupMethodIfAlreadyResolved: aJavaMethodRef.
+ result ifNotNil: [ ^ result ].
+ class := aJavaMethodRef classRef resolve.
+ class ifNil: [ self halt: 'should not happen - tell mh' ].
+ "
+ To resolve an unresolved symbolic reference from D to a method in
+ a class C, the symbolic reference to C given by the method reference
+ is first resolved (§5.4.3.1). Therefore, any exceptions that can be
+ thrown due to resolution of a class reference can be thrown as a result
+ of method resolution. If the reference to C can be successfully resolved,
+ exceptions relating to the resolution of the method reference itself
+ can be thrown.
+ When resolving a method reference:
+
+ Method resolution checks whether C is a class or an interface.
+ If C is an interface, method resolution throws an IncompatibleClassChangeError."
+ class isInterface ifTrue: [ self throwIncompatibleClassChangeError ].
+ "Method resolution attempts to look up the referenced method in C and its
+ superclasses:
+ If C declares a method with the name and descriptor specified by the method
+ reference, method lookup succeeds.
+ Otherwise, if C has a superclass, step 2 of method lookup is recursively
+ invoked on the direct superclass of C.
+
+ Otherwise, method lookup attempts to locate the referenced method in any of
+ the superinterfaces of the specified class C.
+ If any superinterface of C declares a method with the name and descriptor
+ specified by the method reference, method lookup succeeds.
+ Otherwise, method lookup fails.
+ If method lookup fails, method resolution throws a NoSuchMethodError. If method
+ lookup succeeds and the method is abstract, but C is not abstract, method resolution
+ throws an AbstractMethodError. Otherwise, if the referenced method is not accessible
+ (§5.4.4) to D, method resolution throws an IllegalAccessError."
+ result := class lookupMethodByNameAndType: aJavaMethodRef nameAndType.
+ result ifNil: [ self throwNoSuchMethodError ].
+ (result isAbstract and: [ class isAbstract not ])
+ ifTrue: [ self throwAbstractMethodError ].
+ (self
+ checkPermissionsForMethod: result
+ from: aJavaMethodRef classRef owner
+ to: class) ifFalse: [ self throwIllegalAccessError ].
+ ^ result.
+
+ "Otherwise, let <E, L1> be the class or interface in which the referenced method is
+ actually declared and let L2 be the defining loader of D. Let T0 be the name of
+ the type returned by the referenced method, and let T1, ..., Tn be the names of
+ the argument types of the referenced method. The Java virtual machine must impose
+ the loading constraints TiL1=TiL2 for i = 0 to n (§5.3.4)."
+
+ "Created: / 11-04-2011 / 19:45:34 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 14-04-2011 / 00:01:34 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+resolveStaticMethodIndentifiedByRef: aJavaMethodRef
+ | result class |
+
+ self validateMethodRef: aJavaMethodRef.
+ result := self lookupMethodIfAlreadyResolved: aJavaMethodRef.
+ result ifNotNil: [ ^ result ].
+ class := aJavaMethodRef classRef resolve.
+ class ifNil: [ self halt: 'should not happen - tell mh' ].
+ "
+ To resolve an unresolved symbolic reference from D to a method in
+ a class C, the symbolic reference to C given by the method reference
+ is first resolved (§5.4.3.1). Therefore, any exceptions that can be
+ thrown due to resolution of a class reference can be thrown as a result
+ of method resolution. If the reference to C can be successfully resolved,
+ exceptions relating to the resolution of the method reference itself
+ can be thrown.
+ When resolving a method reference:
+
+ Method resolution checks whether C is a class or an interface.
+ If C is an interface, method resolution throws an IncompatibleClassChangeError."
+ class isInterface ifTrue: [ self throwIncompatibleClassChangeError ].
+ "Method resolution attempts to look up the referenced method in C and its
+ superclasses:
+ If C declares a method with the name and descriptor specified by the method
+ reference, method lookup succeeds.
+ Otherwise, if C has a superclass, step 2 of method lookup is recursively
+ invoked on the direct superclass of C.
+
+ Otherwise, method lookup attempts to locate the referenced method in any of
+ the superinterfaces of the specified class C.
+ If any superinterface of C declares a method with the name and descriptor
+ specified by the method reference, method lookup succeeds.
+ Otherwise, method lookup fails.
+ If method lookup fails, method resolution throws a NoSuchMethodError. If method
+ lookup succeeds and the method is abstract, but C is not abstract, method resolution
+ throws an AbstractMethodError. Otherwise, if the referenced method is not accessible
+ (§5.4.4) to D, method resolution throws an IllegalAccessError."
+ result := class lookupStaticMethodByNameAndType: aJavaMethodRef nameAndType.
+ result ifNil: [ self throwNoSuchMethodError ].
+ (result isAbstract and: [ class isAbstract not ])
+ ifTrue: [ self throwAbstractMethodError ].
+ (self
+ checkPermissionsForMethod: result
+ from: aJavaMethodRef classRef owner
+ to: class) ifFalse: [ self throwIllegalAccessError ].
+ ^ result.
+
+ "Otherwise, let <E, L1> be the class or interface in which the referenced method is
+ actually declared and let L2 be the defining loader of D. Let T0 be the name of
+ the type returned by the referenced method, and let T1, ..., Tn be the names of
+ the argument types of the referenced method. The Java virtual machine must impose
+ the loading constraints TiL1=TiL2 for i = 0 to n (§5.3.4)."
+
+ "Created: / 28-04-2011 / 22:50:04 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!JavaResolver methodsFor:'method resolving helpers'!
+
+checkPermissionsForMethod: aJavaMethod from: accessingJavaClass to: resolvedJavaClass
+ "A class or interface C is accessible to a class or interface D if
+ and only if either of the following conditions are true:
+ C is public.
+ C and D are members of the same runtime package (§5.3).
+ A field or method R is accessible to a class or interface D if and only
+ if any of the following conditions is true:
+ R is public.
+ R is protected and is declared in a class C, and D is either a subclass
+ of C or C itself.
+ R is either protected or package private (that is, neither public nor
+ protected nor private), and is declared by a class in the same runtime
+ package as D.
+ R is private and is declared in D.
+ This discussion of access control omits a related restriction on the target
+ of a protected field access or method invocation (the target must be of class
+ D or a subtype of D). That requirement is checked as part of the verification
+ process (§5.4.1); it is not part of link-time access control."
+
+ ^ self checkPermissionsForMethodOrField: aJavaMethod from: accessingJavaClass to: resolvedJavaClass.
+
+ "Created: / 11-04-2011 / 20:20:12 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 14-04-2011 / 14:20:27 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+lookupMethodIfAlreadyResolved: aJavaMethodRef
+ ^ nil.
+
+ "Created: / 11-04-2011 / 19:50:38 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 13-04-2011 / 11:57:00 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+validateMethodRef: aJavaMethodRef
+ aJavaMethodRef isJavaRef ifFalse:[self halt: 'I expected JavaRef instance as an argument'].
+ aJavaMethodRef isJavaMethodRef ifFalse: [self halt: 'I expected JavaMethodRef instance as an argument'].
+
+ "Created: / 11-04-2011 / 19:47:25 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
!JavaResolver class methodsFor:'documentation'!
version_SVN
@@ -99,3 +594,4 @@
! !
JavaResolver initialize!
+
--- a/src/JavaRuntimeConstantPoolTests.st Mon Apr 25 19:32:44 2011 +0000
+++ b/src/JavaRuntimeConstantPoolTests.st Sun May 01 12:52:23 2011 +0000
@@ -1,16 +1,42 @@
"{ Package: 'stx:libjava' }"
TestCase subclass:#JavaRuntimeConstantPoolTests
- instanceVariableNames:''
+ instanceVariableNames:'exceptionThrowerBackup'
classVariableNames:''
poolDictionaries:''
category:'Languages-Java-Tests-RuntimeConstantPool'
!
+!JavaRuntimeConstantPoolTests class methodsFor:'resources'!
+
+resources
+
+
+^ Array with: JavaInitializedResource with: JavaTestsResource.
+
+ "Created: / 13-04-2011 / 22:48:30 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!JavaRuntimeConstantPoolTests methodsFor:'helpers'!
+
+disableMockedExceptionThrowing
+ JavaResolver uniqueInstance exceptionThrower: exceptionThrowerBackup.
+
+ "Created: / 13-04-2011 / 14:11:34 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+enableMockedExceptionThrowing
+ exceptionThrowerBackup := JavaResolver uniqueInstance exceptionThrower.
+ JavaResolver uniqueInstance exceptionThrower: JavaExceptionThrowerMock new.
+
+ "Created: / 13-04-2011 / 14:11:01 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
!JavaRuntimeConstantPoolTests class methodsFor:'documentation'!
version_SVN
^ '$Id$'
! !
+
--- a/src/JavaVM.st Mon Apr 25 19:32:44 2011 +0000
+++ b/src/JavaVM.st Sun May 01 12:52:23 2011 +0000
@@ -37,7 +37,7 @@
DivisionByZeroExceptionDebug IOExceptionDebug
StdinReplacementFileQuerySignal AssertionsEnabled
SimulatedNativeMemory Reflection ZipCache ZipEntryCache
- ZipLastModTimesCache'
+ ZipLastModTimesCache ZipInflaters'
poolDictionaries:''
category:'Languages-Java-Support'
!
@@ -1736,8 +1736,6 @@
updated to reflect changes in jinterpret.c.
Following >>make it working, make it fast<< rule"
- ZipCache := OrderedCollection new.
- ZipEntryCache := OrderedCollection new.
ObjectMemory
javaJustInTimeCompilation: false;
javaNativeCodeOptimization: false.
@@ -1749,6 +1747,10 @@
JavaConsoleStream := Transcript.
Java initAllStaticFields.
Java markAllClassesUninitialized.
+
+ ZipCache := OrderedCollection new.
+ ZipEntryCache := OrderedCollection new.
+ ZipInflaters := OrderedCollection new.
"/ force re-resolving;
"/ otherwise, class-inits would not be called
@@ -1790,8 +1792,8 @@
"Created: / 03-01-1998 / 21:29:09 / cg"
"Modified: / 14-12-1999 / 18:58:56 / cg"
"Modified: / 15-10-2010 / 15:27:45 / Jan Kurs <kurs.jan@post.cz>"
- "Modified: / 21-12-2010 / 19:48:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 01-04-2011 / 15:33:39 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 30-04-2011 / 22:59:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
initializeVMIfNoEventThreadRunning
@@ -2018,752 +2020,6 @@
"Modified: / 6.11.1998 / 00:40:53 / cg"
! !
-!JavaVM class methodsFor:'* As yet uncategorized *'!
-
-_Array_newArray:aJavaContext
- |componentClass size|
-
- componentClass := self reflection
- classForJavaClassObject:(aJavaContext argAt:1).
- size := aJavaContext argAt:2.
- ^ componentClass arrayClass new:size
-
- "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>"
-!
-
-_ClassLoader_registerNatives:aJavaContext
-
- "Nothing to do"
-
- "Created: / 09-11-2010 / 20:55:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-_Class_desiredAssertionStatus0:aJavaContext
-
- ^AssertionsEnabled == true
-
- "Created: / 24-11-2010 / 08:58:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-_Class_forName0:aJavaContext
-
- | name initialize loader class |
- name := Java as_ST_String: (aJavaContext argAt: 1).
- initialize := aJavaContext argAt: 2.
- loader := aJavaContext argAt: 3.
- JavaClassReader classLoaderQuerySignal answer: loader do:
- [class := Java classForName: name].
- class isNil ifTrue:
- [^self throwClassNotFoundException: name].
- initialize ifTrue:
- [[class classInit] on: Error do:[self throwExceptionInInitializerError:name]].
- ^JavaVM javaClassObjectForClass: class.
-
- "Created: / 24-11-2010 / 09:03:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-_Class_getClassLoader0:aJavaContext
- "get a classes loader"
-
- |jClass cls loader|
-
- jClass := aJavaContext receiver.
- cls := self reflection classForJavaClassObject:jClass.
- loader := cls classLoader.
- cls isNil ifTrue:[
- loader := (Java classForName:'java/lang/ClassLoader')
- perform:#'getSystemClassLoader()Ljava/lang/ClassLoader;'.
-
-"/ ('JAVA: getClassLoader - ' , loader printString) infoPrintCR.
- ].
- ^ loader
-
- "Created: / 25-10-2010 / 22:49:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 09-11-2010 / 23:37:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 28-01-2011 / 15:18:54 / Marcel Hlopko <hlopik@gmail.com>"
-!
-
-_Class_getConstantPool:aJavaContext
- | class |
-
- class := self reflection classForJavaClassObject:aJavaContext receiver.
- ^ 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>"
-!
-
-_Class_getDeclaredConstructors0:aJavaContext
- |class publicOnly constructors|
-
- class := self reflection classForJavaClassObject:(aJavaContext receiver).
- publicOnly := (aJavaContext argAt:1) == 1.
- constructors := OrderedCollection new.
- class
- selectorsAndMethodsDo:[:selector :method |
- (method isJavaMethod
- and:[
- (selector at:1) == $<
- and:[
- (selector startsWith:'<init>(') and:[publicOnly not or:[method isPublic]]
- ]
- ])
- ifTrue:[constructors add:(self reflection javaConstructorObjectForMethod:method)]
- ].
- ^ (self classForName: 'java.lang.reflect.Constructor')
- arrayClass withAll: constructors
-
- "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: / 11-02-2011 / 08:55:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-_Class_getDeclaredFields0:aJavaContext
- |javaClassObject class fields publicOnly|
-
- class := self reflection classForJavaClassObject:(javaClassObject := aJavaContext argAt:0).
- publicOnly := (aJavaContext argAt:1) == 1.
- fields := class fields.
- publicOnly ifTrue:
- [fields := fields select:[:f|f isPublic]].
- fields := fields collect:[:f | self javaFieldObjectForField:f in:javaClassObject].
-
- ^ (self classForName: 'java.lang.reflect.Field') arrayClass
- withAll: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: / 16-03-2011 / 15:43:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-_Class_getDeclaredMethods0:aJavaContext
- |class publicOnly methods|
-
- class := self reflection classForJavaClassObject:(aJavaContext receiver).
- publicOnly := (aJavaContext argAt:1) == 1.
- methods := OrderedCollection new.
- class
- selectorsAndMethodsDo:[:selector :method |
- (method isJavaMethod
- and:[
- (selector at:1) ~~ $<
- and:[
- (selector startsWith:'<init>(') not
- and:[publicOnly not or:[method isPublic]]
- ]
- ])
- ifTrue:[methods add:(self javaMethodObjectForMethod:method)]
- ].
- ^ (self classForName: 'java.lang.reflect.Method')
- arrayClass withAll: methods asArray
-
- "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: / 11-02-2011 / 08:35:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-_Class_getName0:aJavaContext
- |class|
-
- class := aJavaContext receiver.
- class := self reflection classForJavaClassObject:aJavaContext receiver.
- ^ self reflection
- javaStringObjectForString:class javaName
- 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: / 25-02-2011 / 19:00:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-_Class_getRawAnnotations:aJavaContext
- |class |
-
- class := self reflection classForJavaClassObject:aJavaContext receiver.
- ^ 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: / 25-02-2011 / 16:48:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-_ConstantPool_getDoubleAt0:nativeContext
- | cpool index double |
-
- cpool := self reflection constantPoolFor:(nativeContext receiver).
- self breakPoint:#mh.
- 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>"
-!
-
-_ConstantPool_getIntAt0:nativeContext
- | 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>"
-!
-
-_ConstantPool_getLongAt0:nativeContext
- | 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>"
-!
-
-_ConstantPool_getUTF8At0: nativeContext
-
- | 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>"
-!
-
-_Double_doubleToRawLongBits:aJavaContext
- "
- /**
- * 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 |
- f := aJavaContext argAt:1.
- (f = 0.0) ifTrue:[^0].
- (f = -0.0) ifTrue:[^(1 bitShift: 63)].
-
- self halt:'Not yet implemented'.
-
- "Created: / 10-11-2010 / 14:48:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-_FileSystem_getFileSystem:aJavaContext
-
- OperatingSystem isUNIXlike ifTrue:
- [^(Java 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>"
-!
-
-_Float_floatToRawIntBits:aJavaContext
- "
- /**
- * 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 exponent mantissa |
- f := aJavaContext argAt:1.
- (f = 0.0) ifTrue:[^0].
- (f = -0.0) ifTrue:[^(1 bitShift: 31) ].
-
- self halt.
-
- "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>"
-!
-
-_NativeConstructorAccessorImpl_newInstance0:aJavaContext
-
- | ctor args method instance |
- ctor := aJavaContext argAt: 1.
- args := aJavaContext argAt: 2.
- args ifNil:[args := #()] ifNotNil:[args := args asArray].
- method := self reflection methodForJavaConstructorObject: ctor.
- instance := method javaClass new.
- method valueWithReceiver:instance arguments:args.
- ^instance
-
- "Created: / 26-11-2010 / 11:41:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 04-02-2011 / 18:47:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 09-02-2011 / 01:12:10 / Marcel Hlopko <hlopik@gmail.com>"
-!
-
-_NativeMethodAccessorImpl_invoke0:nativeContext
- "
- private static native Object invoke0(Method m, Object obj, Object[] args);
- "
- | m obj args |
- m := nativeContext argAt: 1.
- obj := nativeContext argAt: 2.
- args := nativeContext argAt: 3.
-
- ^(self reflection methodForJavaMethodObject: m)
- valueWithReceiver: obj
- arguments: (args ? #()) asArray.
-
- "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: / 16-03-2011 / 15:31:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-_ObjectStreamClass_initNative:aJavaContext
-
- "
- /**
- * Initializes native code.
- */
- "
- "Nothing to do"
-
- "Created: / 20-12-2010 / 17:43:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-_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_getClassAccessFlags:aJavaContext
- |class|
-
- class := self reflection classForJavaClassObject:(aJavaContext argAt:1).
- ^ 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>"
-!
-
-_Signal_findSignal:aJavaContext
- | input signame |
-
- input := Java as_ST_String: (aJavaContext argAt: 1).
- signame := 'SIG', (input asUppercase).
- ^ UnixOperatingSystem signalNamed: signame asSymbol.
-
- "Created: / 11-12-2010 / 15:22:07 / Jan Kurs <kurs.jan@post.cz>"
-!
-
-_Signal_handle0:aJavaContext
- self breakPoint: #libjava.
- ^ 0.
-
- "Created: / 11-12-2010 / 16:33:38 / Jan Kurs <kurs.jan@post.cz>"
-!
-
-_System_mapLibraryName:aJavaContext
-
- | 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>"
-!
-
-_UnixFileSystem_canonicalize0:aJavaContext
-
- | path |
-
- path := Java as_ST_String: (aJavaContext argAt: 1).
- ^(Java as_String: path asFilename asAbsoluteFilename pathName)
-
- "Created: / 10-12-2010 / 14:40:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-_UnixFileSystem_getBooleanAttributes0:aJavaContext
- |file path retval fileSystemClass|
-
- retval := 0.
- file := aJavaContext argAt:1.
- path := Java as_ST_String:(file instVarNamed:#path).
- fileSystemClass := (Java 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>"
-!
-
-_UnixFileSystem_getLastModifiedTime: aJavaContext
- | file path retval |
-
- retval := 0.
- file := aJavaContext argAt: 1.
- path := Java as_ST_String: (file instVarNamed: #path).
- retval := path asFilename modificationTime asMilliseconds.
- ^ retval
-
- "Modified: / 10-12-2010 / 14:43:31 / Jan Kurs <kurs.jan@post.cz>"
- "Modified: / 11-12-2010 / 19:44:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Created: / 27-03-2011 / 15:32:59 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-!
-
-_UnixFileSystem_initIDs:aJavaContext
-
- 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>"
-!
-
-_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 |
- 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>"
-!
-
-_Unsafe_compareAndSwapInt:aJavaContext
- "
- /**
- * 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.
- real := o instVarAt: offset.
- (real == expected)
- ifTrue:[o instVarAt: offset put: new. ok := true]
- ifFalse:[ok := false].
- OperatingSystem unblockInterrupts.
- ^ok
-
- "Created: / 22-11-2010 / 18:40:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "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|
-
- 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>"
-!
-
-_Unsafe_freeMemory:aJavaContext
- | address |
- address := aJavaContext argAt: 1.
- ^SimulatedNativeMemory free: address
-
- "Created: / 09-12-2010 / 17:56:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-_Unsafe_getByte:aJavaContext
-
- | address |
- address := aJavaContext argAt: 1.
- ^SimulatedNativeMemory byteAt: address
-
- "Created: / 09-12-2010 / 17:29:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-_Unsafe_objectFieldOffset:aJavaContext
-
- | javaFieldObject |
- javaFieldObject := aJavaContext argAt: 1.
- ^javaFieldObject instVarNamed: #slot
-
- "Created: / 22-11-2010 / 17:58:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-_Unsafe_putLong:aJavaContext
-
- | address value |
- address := aJavaContext argAt: 1.
- value := aJavaContext argAt: 3.
- "3!!!!!! since at index 2 there is dummy long high word"
- "Ask JV for more details"
-
- SimulatedNativeMemory longAt: address put: value
-
- "Created: / 07-12-2010 / 23:50:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 09-12-2010 / 17:31:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-_VM_initialize:aJavaContext
-
- "Nothing to do"
-
- "Created: / 26-11-2010 / 18:43:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-_WinNTFileSystem_canonicalize0:aJavaContext
-
- | 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>"
-!
-
-_WinNTFileSystem_getBooleanAttributes:aJavaContext
-
- ^ self _UnixFileSystem_getBooleanAttributes0:aJavaContext
-
- "Created: / 01-04-2011 / 18:10:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-_ZipEntry_initFields: aJavaContext
- "hopefully nothing to do"
-
- "Created: / 01-04-2011 / 13:04:24 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-!
-
-_ZipEntry_initIDs: aJavaContext
- "hopefully nothing to do"
-
- "Created: / 01-04-2011 / 13:02:06 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-!
-
-_ZipFile_freeEntry: javaContext
- | zipArchiveIndex zipEntryIndex |
-
-
- zipArchiveIndex := javaContext at: 1.
- zipEntryIndex := javaContext at: 3.
- zipEntryIndex = 0 ifFalse: [ ZipEntryCache at: zipEntryIndex put: nil ].
-
- "Created: / 01-04-2011 / 13:06:19 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 01-04-2011 / 16:02:56 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-!
-
-_ZipFile_getEntry: javaContext
- | zipArchive filename result |
-
- zipArchive := ZipCache at: (javaContext at: 1).
- filename := Java as_ST_String: (javaContext at: 3).
- result := (zipArchive membersMatching: filename).
- result size = 0
- ifTrue: [ ^ 0 ]
- ifFalse: [ ^ ZipEntryCache indexOf: (ZipEntryCache add: result first) ].
-
- "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>"
-!
-
-_ZipFile_getTotal: javaContext
- | zipArchive |
-
- zipArchive := ZipCache at: (javaContext at: 1).
- ^ zipArchive entries size.
-
- "Created: / 27-03-2011 / 16:29:51 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 01-04-2011 / 15:48:46 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-!
-
-_ZipFile_initIDs:aJavaContext
-
- "Nothing to do"
-
- "Created: / 23-03-2011 / 19:37:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-_ZipFile_open: javaContext
- | path mode lastModTime result |
-
- path := Java as_ST_String: (javaContext at: 1).
- mode := javaContext at: 2.
- lastModTime := javaContext at: 3.
- result := path asFilename.
- result ifNil: [ JavaVM throwZipException ].
- ^ ZipCache
- indexOf: ( ZipCache add: (ZipArchive readingFrom: result readStream) ).
-
- "Modified: / 01-04-2011 / 15:35:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-! !
-
!JavaVM class methodsFor:'Signal constants'!
badMessageSignal
@@ -4410,51 +3666,2467 @@
"Modified: / 28-02-2011 / 16:58:05 / Marcel Hlopko <hlopik@gmail.com>"
! !
-!JavaVM class methodsFor:'native - java.awt - ms'!
-
-_SystemColor_GetSysColor:nativeContext
- "/ int GetSysColor (int)
- UnimplementedNativeMethodSignal raise
-
- "Created: / 27.1.2000 / 02:44:41 / cg"
+!JavaVM 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_FileInputStream_initIDs: nativeContext
+
+ <javanative: 'java/io/FileInputStream' name: 'initIDs'>
+
+ "/ introduced with jdk1.2 ... (sigh)
+
+ "Created: / 27.1.1998 / 18:15:51 / cg"
+!
+
+_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_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:
+ [^(Java 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_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_UnixFileSystem_canonicalize0: aJavaContext
+
+ <javanative: 'java/io/UnixFileSystem' name: 'canonicalize0'>
+
+
+ | path |
+
+ path := Java as_ST_String: (aJavaContext argAt: 1).
+ ^(Java as_String: path asFilename asAbsoluteFilename pathName)
+
+ "Created: / 10-12-2010 / 14:40:49 / 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:(file instVarNamed:#path).
+ fileSystemClass := (Java 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>"
+!
+
+_java_io_UnixFileSystem_getLastModifiedTime: aJavaContext
+
+ <javanative: 'java/io/UnixFileSystem' name: 'getLastModifiedTime'>
+
+ | file path retval |
+
+ retval := 0.
+ file := aJavaContext argAt: 1.
+ path := Java as_ST_String: (file instVarNamed: #path).
+ retval := path asFilename modificationTime asMilliseconds.
+ ^ retval
+
+ "Modified: / 10-12-2010 / 14:43:31 / Jan Kurs <kurs.jan@post.cz>"
+ "Modified: / 11-12-2010 / 19:44:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Created: / 27-03-2011 / 15:32:59 / Marcel Hlopko <hlopkmar@fel.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>"
! !
-!JavaVM class methodsFor:'native - java.awt.image'!
+!JavaVM 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>"
+!
+
+_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_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'>
+
+
+ | name initialize loader class |
+ name := Java as_ST_String: (aJavaContext argAt: 1).
+ initialize := aJavaContext argAt: 2.
+ loader := aJavaContext argAt: 3.
+ JavaClassReader classLoaderQuerySignal answer: loader do:
+ [class := Java classForName: name].
+ class isNil ifTrue:
+ [^self throwClassNotFoundException: name].
+ initialize ~~ 0 ifTrue:
+ [[class classInit] on: Error do:[self throwExceptionInInitializerError:name]].
+ ^JavaVM javaClassObjectForClass: class.
+
+ "Created: / 24-11-2010 / 09:03:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 01-05-2011 / 13:27:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Class_getClassLoader0: aJavaContext
+
+ <javanative: 'java/lang/Class' name: 'getClassLoader0'>
+
+ "get a classes loader"
+
+ |jClass cls loader|
+
+ jClass := aJavaContext receiver.
+ cls := self reflection classForJavaClassObject:jClass.
+ loader := cls classLoader.
+ cls isNil ifTrue:[
+ loader := (Java classForName:'java/lang/ClassLoader')
+ perform:#'getSystemClassLoader()Ljava/lang/ClassLoader;'.
+
+"/ ('JAVA: getClassLoader - ' , loader printString) infoPrintCR.
+ ].
+ ^ loader
+
+ "Created: / 25-10-2010 / 22:49:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 09-11-2010 / 23:37:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 28-01-2011 / 15:18:54 / Marcel Hlopko <hlopik@gmail.com>"
+!
+
+_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.
+ ^ 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>"
+!
+
+_java_lang_Class_getDeclaredConstructors0: aJavaContext
+
+ <javanative: 'java/lang/Class' name: 'getDeclaredConstructors0'>
+
+ |class publicOnly constructors|
+
+ class := self reflection classForJavaClassObject:(aJavaContext receiver).
+ publicOnly := (aJavaContext argAt:1) == 1.
+ constructors := OrderedCollection new.
+ class
+ selectorsAndMethodsDo:[:selector :method |
+ (method isJavaMethod
+ and:[
+ (selector at:1) == $<
+ and:[
+ (selector startsWith:'<init>(') and:[publicOnly not or:[method isPublic]]
+ ]
+ ])
+ ifTrue:[constructors add:(self reflection javaConstructorObjectForMethod:method)]
+ ].
+ ^ (self classForName: 'java.lang.reflect.Constructor')
+ arrayClass withAll: constructors
+
+ "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: / 11-02-2011 / 08:55:39 / 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).
+ publicOnly := (aJavaContext argAt:1) == 1.
+ fields := class fields.
+ publicOnly ifTrue:
+ [fields := fields select:[:f|f isPublic]].
+ fields := fields collect:[:f | self javaFieldObjectForField:f in:javaClassObject].
+
+ ^ (self classForName: 'java.lang.reflect.Field') arrayClass
+ withAll: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: / 16-03-2011 / 15:43:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Class_getDeclaredMethods0: aJavaContext
+
+ <javanative: 'java/lang/Class' name: 'getDeclaredMethods0'>
+
+ |class publicOnly methods|
+
+ class := self reflection classForJavaClassObject:(aJavaContext receiver).
+ publicOnly := (aJavaContext argAt:1) == 1.
+ methods := OrderedCollection new.
+ class
+ selectorsAndMethodsDo:[:selector :method |
+ (method isJavaMethod
+ and:[
+ (selector at:1) ~~ $<
+ and:[
+ (selector startsWith:'<init>(') not
+ and:[publicOnly not or:[method isPublic]]
+ ]
+ ])
+ ifTrue:[methods add:(self javaMethodObjectForMethod:method)]
+ ].
+ ^ (self classForName: 'java.lang.reflect.Method')
+ arrayClass withAll: methods asArray
+
+ "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: / 11-02-2011 / 08:35:19 / 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 ifTrue:[
+ ^ (self classForName:'java.lang.Class') arrayClass new
+ ].
+ interfaces := cls interfaces.
+ interfaces ifNil:[^ (self classForName:'java.lang.Class') arrayClass new].
+ jInterfaces := (self classForName:'java.lang.Class') arrayClass 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: / 04-02-2011 / 09:43:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Class_getModifiers: aJavaContext
+
+ <javanative: 'java/lang/Class' name: 'getModifiers'>
+
+ ^ (self reflection classForJavaClassObject:aJavaContext receiver) 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>"
+!
+
+_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 javaName
+ 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: / 25-02-2011 / 19:00:27 / 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_getRawAnnotations: aJavaContext
+
+ <javanative: 'java/lang/Class' name: 'getRawAnnotations'>
+
+ |class |
+
+ class := self reflection classForJavaClassObject:aJavaContext receiver.
+ ^ 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: / 25-02-2011 / 16:48:30 / 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.
+ superCls := cls superclass.
+ superCls == JavaObject ifTrue:[
+ ^ nil.
+ ].
+ ^ 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: / 03-02-2011 / 22:53:55 / 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_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_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 |
+ f := aJavaContext argAt:1.
+ (f = 0.0) ifTrue:[^0].
+ (f = -0.0) ifTrue:[^(1 bitShift: 63)].
+
+ self halt:'Not yet implemented'.
+
+ "Created: / 10-11-2010 / 14:48:46 / 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 exponent mantissa |
+ f := aJavaContext argAt:1.
+ (f = 0.0) ifTrue:[^0].
+ (f = -0.0) ifTrue:[^(1 bitShift: 31) ].
+
+ self halt.
+
+ "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>"
+!
+
+_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_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 sema|
+
+ handle := nativeContext receiver.
+ tmo := nativeContext argAt:1.
+
+ sema := JavaVM semaphoreFor:handle.
+
+ [
+ self waitFor:sema state:#javaWait timeOut:tmo.
+ ] valueOnUnwindDo:[
+ JavaVM releaseSemaphoreFor:handle.
+ ].
+
+ ThreadTrace ifTrue:[
+ '====> thread continues ...' printCR.
+ ]
+
+ "Modified: / 30-12-1998 / 19:20:43 / cg"
+ "Modified: / 01-05-2011 / 13:26:26 / 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 count dstEndIdx|
+
+ srcArray := nativeContext argAt:1.
+ srcArray isNil ifTrue:[
+ ^ self throwNullPointerException
+ ].
+ srcIdx := nativeContext argAt:2.
+ dstArray := nativeContext argAt:3.
+ dstArray isNil ifTrue:[
+ ^ self throwNullPointerException
+ ].
+ dstIdx := nativeContext argAt:4.
+ count := nativeContext argAt:5.
+
+ ((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:[
+ dstArray replaceFrom:dstIdx to:dstEndIdx with:srcArray startingAt:srcIdx.
+ ].
+ ^ nil.
+!
+
+_java_lang_System_currentTimeMillis: nativeContext
+
+ <javanative: 'java/lang/System' name: 'currentTimeMillis'>
+
+ "return the milliseconds since 1.jan.1970"
+
+ |delta|
+
+ "/ workaround win32 bug (use 01:01:01 as base)
+ delta := Timestamp now millisecondDeltaFrom:(AbsoluteTime day:1 month:1 year:1970 hour:1 minutes:1 seconds:1).
+ delta := delta - 3600 - 60 - 1.
+"/ "/ make certain, it fits 64 signed bits
+"/ delta := delta bitAnd:16r7FFFFFFFFFFFFFFF.
+"/ ^ delta max:0
+ ^ delta
+
+ "
+ JavaVM _System_currentTimeMillis:nil
+ "
+
+ "Modified: / 23.12.1998 / 21:54:50 / 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_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.
+ t notNil ifTrue:[
+ ^ t
+ ].
+ t := self newThread:'main'.
+ Java threads at:t put:p.
+ ^ t
+
+ "Modified: / 01-05-2011 / 13:24:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Thread_holdsLock: aJavaContext
+
+ <javanative: 'java/lang/Thread' name: 'holdsLock'>
+
+
+ | obj |
+ obj := aJavaContext argAt: 1.
+
+ ^(self enteredMonitorsOfProcess:Processor activeProcess)
+ includes: obj.
+
+ "Created: / 30-04-2011 / 22:06:29 / Jan Vrany <jan.vrany@fit.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_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_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_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_Throwable_fillInStackTrace: nativeContext
+
+ <javanative: 'java/lang/Throwable' name: 'fillInStackTrace'>
+
+ |exClass exceptionObject list con|
+
+ exClass := Java classNamed:'java.lang.Throwable'.
+
+ exceptionObject := nativeContext receiver.
+
+ "/
+ "/ debugging only
+ "/
+ (exceptionObject isKindOf:(Java classNamed:'java.lang.Throwable')) ifFalse:[
+ self halt
+ ].
+
+ 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: / 4.1.1998 / 14:27:40 / cg"
+ "Modified: / 8.5.1998 / 21:29:53 / cg"
+! !
+
+!JavaVM class methodsFor:'native - java.lang.reflect'!
+
+_java_lang_reflect_Array_newArray: aJavaContext
+
+ <javanative: 'java/lang/reflect/Array' name: 'newArray'>
+
+ |componentClass size|
+
+ componentClass := self reflection
+ classForJavaClassObject:(aJavaContext argAt:1).
+ size := aJavaContext argAt:2.
+ ^ componentClass arrayClass new:size
+
+ "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>"
+! !
+
+!JavaVM class methodsFor:'native - java.security'!
+
+_java_security_AccessController_doPrivileged: aJavaContext
+
+ <javanative: 'java/security/AccessController' name: 'doPrivileged'>
+
+
+ "Don't care about permissions :-)"
+
+ ^(aJavaContext argAt:1) perform: #'run()Ljava/lang/Object;'
+
+ "Created: / 20-10-2010 / 12:31:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_security_AccessController_getStackAccessControlContext: nativeContext
+
+ <javanative: 'java/security/AccessController' name: 'getStackAccessControlContext'>
+
+ "/ introduced with jdk1.2
+
+ "/ supposed to do more here ...
+
+ ^ nil
+
+ "Created: / 27.1.1998 / 18:22:15 / cg"
+! !
+
+!JavaVM class methodsFor:'native - java.util.zip'!
+
+_java_util_zip_Inflater_inflateBytes: aJavaContext
+
+ <javanative: 'java/util/zip/Inflater' name: 'inflateBytes'>
+
+
+ UnimplementedNativeMethodSignal raise
+
+ "Created: / 30-04-2011 / 23:02:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_util_zip_Inflater_init: nativeContext
+
+ <javanative: 'java/util/zip/Inflater' name: 'init'>
+
+
+ | index |
+ index := ZipInflaters indexOf: nativeContext receiver.
+ index == 0 ifTrue:
+ [ZipInflaters add: nativeContext receiver.
+ 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>"
+!
+
+_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_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: #time put: 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: / 29-04-2011 / 20:01:00 / 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_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_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_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 at: 1).
+ ^ zar entries size.
+
+ "Modified: / 01-05-2011 / 13:31:05 / 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).
+ mode := nativeContext at: 2.
+ lastModTime := nativeContext at: 3.
+ result := path asFilename.
+ result ifNil: [ JavaVM throwZipException ].
+ ^ ZipCache
+ indexOf: ( ZipCache add: (ZipArchive readingFrom: result readStream) ).
+
+ "Modified: / 01-04-2011 / 15:35:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 01-05-2011 / 13:29:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaVM 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 := 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.1.1998 / 15:45:30 / cg"
+ "Modified: / 14.10.1998 / 15:20:52 / cg"
+!
+
+_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
+ UnimplementedNativeMethodSignal raiseRequest
+
+ "Modified: / 12.11.1998 / 19:23:00 / cg"
+!
+
+_CMM_cmmGetTagSize:nativeContext
+ "/ public static native synchronized int cmmGetTagSize (long arg1, int arg2, int[] arg3)
+ "/ new with jdk1.2 ...
+
+ UnimplementedNativeMethodSignal raiseRequest.
+ ^ -1.
+
+ "Created: / 27.1.1998 / 21:43:25 / cg"
+!
+
+_CMM_cmmInit:nativeContext
+ "/ new with jdk1.2 ...
+
+ "Created: / 27.1.1998 / 21:43:25 / cg"
+!
+
+_CMM_cmmLoadProfile:nativeContext
+ "/ public static native synchronized int cmmLoadProfile (byte[] arg1, long[] arg2)
+ "/ new with jdk1.2 ...
+
+ UnimplementedNativeMethodSignal raiseRequest.
+ ^ -1.
+
+ "Created: / 27.1.1998 / 21:43:25 / cg"
+!
+
+_CRC32_update1:nativeContext
+ "/ void update1 (int)
+
+UnimplementedNativeMethodSignal raiseRequest.
+
+ "Modified: / 27.1.2000 / 03:08:47 / cg"
+!
+
+_CRC32_update:nativeContext
+ "/ void update (byte[] int int)
+
+UnimplementedNativeMethodSignal raiseRequest.
+
+ "Modified: / 27.1.2000 / 03:08:47 / cg"
+ "Created: / 27.1.2000 / 03:09:20 / cg"
+!
+
+_ClassLoader_createArrayClass:nativeContext
+ "java.lang.Class createArrayClass (java.lang.String java.lang.Class)"
+
+ "resolve a new class as previously created by defineClass0"
+
+ |jClassLoader name elCls|
+
+ jClassLoader := nativeContext receiver.
+ name := nativeContext argAt:1.
+ elCls := nativeContext argAt:2.
+ elCls isNil ifTrue:[
+ self halt.
+ ^ nil
+ ].
+UnimplementedNativeMethodSignal raiseRequest.
+
+ "Modified: / 27.1.2000 / 02:36:01 / cg"
+ "Created: / 27.1.2000 / 02:56:37 / cg"
+!
+
+_ClassLoader_defineClass0:nativeContext
+ "create a new class from a given byteArray.
+ Here, construct a stream on it and pass the work to the
+ JavaClassReader."
+
+ |jClassLoader jName name data offset length inStream newClass
+ loaderStub jClass|
+
+ jClassLoader := nativeContext receiver.
+ jName := nativeContext argAt:1.
+
+ "/ className is now optional ...
+"/ jName isNil ifTrue:[
+"/ self internalError:'nil name in defineClass'.
+"/ ^ nil
+"/ ] ifFalse:[
+"/ name := Java as_ST_String:jName.
+"/ ].
+
+ data := nativeContext argAt:2.
+ offset := nativeContext argAt:3.
+ length := nativeContext argAt:4.
+
+ inStream := data readStream.
+ inStream position:offset + 1.
+ inStream readLimit:(offset + length).
+
+"/ loaderStub := Plug new.
+"/ loaderStub respondTo:#loadClass: with:[:clsName |
+"/ |jName|
+"/
+"/self halt.
+"/ jName := Java as_String:clsName.
+"/ "/ jClassLoader loadClass:jName
+"/ jClassLoader
+"/ perform:#'loadClass(Ljava/lang/String;)Ljava/lang/Class;'
+"/ with:jName.
+"/ ].
+
+"/ ('JAVA [info]: defining class ...') infoPrintCR.
+
+"/ self internalError:'break'.
+
+ newClass := JavaClassReader
+ readStream:inStream
+ loader:jClassLoader "loaderStub"
+ loadUnresolved:false.
+
+ newClass isNil ifTrue:[
+ ('JAVA [info]: defineClass failed') infoPrintCR.
+ ^ nil.
+ ].
+"/ Transcript showCR:('defined class ' , newClass fullName , '.').
+ newClass classLoader:jClassLoader.
+
+"/ ('Java [info]: defined new class: ' , newClass fullName) infoPrintCR.
+
+ jClass := self javaClassObjectForClass:newClass.
+ ^ jClass
+
+ "Created: / 7.1.1998 / 12:35:10 / cg"
+ "Modified: / 24.1.1998 / 15:26:21 / cg"
+!
+
+_ClassLoader_findSystemClass0:nativeContext
+ |loader name class jClass|
+
+ loader := nativeContext receiver.
+ name := nativeContext argAt:1.
+ name := Java as_ST_String:name.
+
+ class := Java at:name.
+ class isNil ifTrue:[
+"/ ('JAVA: findSystemClass0 for ' , name , ' loader is ' , loader displayString) infoPrintCR.
+ loader class == (Java classForName:'java.util.SystemClassLoader') ifTrue:[
+"/ Java classForName:name.
+"/ class := Java at:name.
+ class := JavaClassReader loadSystemClass:name.
+ ] ifFalse:[
+ "/ load using default (ST/X) loader
+ class := JavaClassReader loadSystemClass:name.
+"/ JavaClassReader classLoaderQuerySignal answer:nil do:[
+"/ Java classForName:name.
+"/ ]
+ ].
+ ].
+
+"/ JavaClassReader classLoaderQuerySignal answer:nil "loader"
+"/ do:[
+"/ class := Java classForName:name.
+"/ JavaClassReader postLoadActions:true.
+"/ ].
+
+ (class isNil
+ "or:[class classLoader notNil]") ifTrue:[
+"/ self halt:'class: ' , name , ' not found.'.
+"/ self internalError:'class: ' , name , ' not found.'.
+
+ self
+ throwExceptionClassName:'java.lang.ClassNotFoundException'
+ withMessage:('class: ' , name , ' not found.').
+ ^ nil
+ ].
+
+"/ 'JAVA: findSystemClass0 - loaded: ' infoPrint. class fullName infoPrintCR.
+ jClass := self javaClassObjectForClass:class.
+ ^ jClass
+
+ "Created: / 5.1.1998 / 02:53:04 / cg"
+ "Modified: / 20.10.1998 / 17:28:34 / cg"
+!
+
+_ClassLoader_findSystemClass:nativeContext
+ ^ self _ClassLoader_findSystemClass0:nativeContext
+
+ "Created: / 18.11.1998 / 00:00:14 / cg"
+!
+
+_ClassLoader_getSystemResource:nativeContext asStream0:returnAsStream
+ "common code for
+ getSystemResourceAsStream0
+ getSystemResourceAsName0"
+
+ |jString rString dir file text inStream url|
+
+ jString := nativeContext argAt:1.
+ rString := Java as_ST_String:jString.
+ Java effectiveClassPath keysAndValuesDo:[:classPathIndex :aPath |
+ |f zipFile zar data |
+
+ f := aPath asFilename.
+ ((zipFile := f withSuffix:'jar') exists
+ or:[(zipFile := f withSuffix:'zip') exists]) ifTrue:[
+ zar := ZipArchive oldFileNamed:zipFile.
+ (Array
+ with:rString
+ with:rString asLowercase
+ with:rString asUppercase)
+ do:[:tryName |
+ |entry|
+
+ entry := zar findMember:tryName.
+ entry notNil ifTrue:[
+ returnAsStream ifTrue:[
+ data := zar extract:tryName.
+ inStream := (Java classForName:'java.io.ByteArrayInputStream') newCleared.
+ inStream perform:#'<init>([B)V' with:data.
+ ^ inStream.
+ ].
+ url := 'systemResource:/ZIP' , (classPathIndex-1) printString , '/+/' , tryName.
+ ^ Java as_String:url.
+ ]
+ ]
+ ] ifFalse:[
+ f exists ifTrue:[
+ (file := f construct:rString) exists ifTrue:[
+ (Java isExcludedFromClassPath:file) ifFalse:[
+
+ "/ Copy data from returned buffer into Java byte array.
+
+"/ self halt.
+ returnAsStream ifTrue:[
+ text := file contents asString.
+ data := text asByteArray.
+
+ "/ Create input stream using byte array
+
+ inStream := (Java classForName:'java.io.ByteArrayInputStream') newCleared.
+ inStream perform:#'<init>([B)V' with:data.
+ ^ inStream.
+ ].
+ url := 'systemResource:/FILE/' , file pathName.
+self halt.
+ ^ Java as_String:url
+ ]
+ ]
+ ]
+ ]
+ ].
+ ^ nil
+
+ "Created: / 08-01-1998 / 16:06:56 / cg"
+ "Modified: / 26-12-1998 / 17:14:52 / cg"
+ "Modified: / 22-11-2010 / 13:44:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_ClassLoader_getSystemResourceAsName0:nativeContext
+ "/ java.lang.String getSystemResourceAsName0 (java.lang.String)
+
+ ^ self
+ _ClassLoader_getSystemResource:nativeContext
+ asStream0:false.
+!
+
+_ClassLoader_getSystemResourceAsStream0:nativeContext
+ "/ java.lang.InputStream getSystemResourceAsStream0 (java.lang.String)
+
+ ^ self
+ _ClassLoader_getSystemResource:nativeContext
+ asStream0:true.
+!
+
+_ClassLoader_init:nativeContext
+ ^ nil
+
+ "Created: / 5.1.1998 / 02:04:43 / cg"
+!
+
+_ClassLoader_initIDs:nativeContext
+ "/ introduced with jdk1.2 ... (sigh)
+
+ "Created: / 27.1.1998 / 18:37:08 / cg"
+!
+
+_ClassLoader_resolveClass0:nativeContext
+ "resolve a new class as previously created by defineClass0"
+
+ |jClassLoader jCls cls loaderStub anyUnresolved|
+
+ jClassLoader := nativeContext receiver.
+ jCls := nativeContext argAt:1.
+ jCls isNil ifTrue:[
+ self halt.
+ ^ nil
+ ].
+ cls := self reflection javaClassObjectForClass:jCls.
+ cls isNil ifTrue:[
+ self halt.
+ ^ nil
+ ].
+ ('JavaVM [info]: resolving class ' , cls fullName , ' ...') infoPrintCR.
+ JavaClassReader classLoaderQuerySignal answer:jClassLoader
+ do:[
+ JavaClassReader resolveClass:cls.
+
+"/ JavaClassReader postLoadActions:true.
+
+ anyUnresolved := false.
+ cls constantPool do:[:entry |
+ (entry isMemberOf:JavaUnresolvedClassConstant) ifTrue:[
+ self halt:'debugHalt'.
+ entry preResolve.
+ self halt:'debugHalt'.
+ anyUnresolved := true.
+ ]
+ ]
+ ].
+ anyUnresolved ifTrue:[
+ jClassLoader notNil ifTrue:[
+ "/ any unresolved left -> try resolving with standard loader
+ JavaClassReader classLoaderQuerySignal answer:nil
+ do:[
+ JavaClassReader postLoadActions:true.
+ cls constantPool do:[:entry |
+ (entry isMemberOf:JavaUnresolvedClassConstant) ifTrue:[
+ self halt:'debugHalt'.
+ entry preResolve.
+ self halt:'debugHalt'.
+ ]
+ ]
+ ]
+ ].
+ ].
+
+ "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>"
+!
+
+_ClassLoader_resolveClass:nativeContext
+ "void resolveClass (java.lang.Class)"
+
+ "resolve a new class as previously created by defineClass0"
+
+ |jClassLoader jCls cls loaderStub anyUnresolved|
+
+ jClassLoader := nativeContext receiver.
+ jCls := nativeContext argAt:1.
+ jCls isNil ifTrue:[
+ self halt.
+ ^ nil
+ ].
+UnimplementedNativeMethodSignal raiseRequest.
+
+ "Modified: / 27.1.2000 / 02:36:01 / cg"
+!
+
+_Class_forName:nativeContext
+ "get a java.lang.Class by name"
+
+ |jClassName className cls jClass s m c loader|
+
+ jClassName := nativeContext argAt:1.
+ className := Java as_ST_String:jClassName.
+
+ (s := nativeContext sender) notNil ifTrue:[
+ (s isJavaContext) ifTrue:[
+ c := s method javaClass.
+ loader := c classLoader.
+ loader isNil ifTrue:[
+"/ self halt.
+ ]
+ ]
+ ].
+
+ JavaClassReader classLoaderQuerySignal answer:loader
+ do:[
+ cls := Java classForName:className.
+ ].
+
+"/(className startsWith:'sun.awt') ifTrue:[self halt].
+"/('classForName: ' , className , ' -> ') print.
+"/cls notNil ifTrue:[cls fullName printCR] ifFalse:['nil' printCR].
+
+ cls isNil ifTrue:[
+ ExceptionTrace ifTrue:[
+ ('throwing exception: no such class:' , className) infoPrintCR.
+ ].
+ ExceptionDebug ifTrue:[
+ self halt:'no such class:' , className.
+ ].
+ self throwClassNotFoundException:className.
+ "/ not proceedable
+ AbortSignal raise.
+ "/ not reached
+ ^ self
+ ].
+
+ ^ self javaClassObjectForClass:cls.
+
+ "Modified: / 30.12.1998 / 20:12:53 / cg"
+!
+
+_Class_getClassLoader:nativeContext
+ "get a classes loader"
+
+ |jClass cls loader|
+
+ jClass := nativeContext receiver.
+ cls := self reflection classForJavaClassObject:jClass.
+ loader := cls classLoader.
+ cls isNil ifTrue:[
+ loader := JavaClassReader classLoaderQuerySignal query.
+
+"/ ('JAVA: getClassLoader - ' , loader printString) infoPrintCR.
+ ].
+ ^ loader
+
+ "Created: / 05-01-1998 / 02:51:59 / cg"
+ "Modified: / 04-01-1999 / 17:50:15 / cg"
+ "Modified: / 28-01-2011 / 15:18:57 / Marcel Hlopko <hlopik@gmail.com>"
+!
+
+_Class_getConstructor0:nativeContext
+ UnimplementedNativeMethodSignal raiseRequest
+
+ "Modified: / 12.11.1998 / 18:52:07 / cg"
+ "Created: / 12.11.1998 / 18:55:42 / cg"
+!
+
+_Class_getConstructors0:nativeContext
+ UnimplementedNativeMethodSignal raiseRequest
+
+ "Modified: / 12.11.1998 / 18:52:07 / cg"
+ "Created: / 12.11.1998 / 18:55:26 / cg"
+!
+
+_Class_getField0:nativeContext
+ UnimplementedNativeMethodSignal raiseRequest
+
+ "Modified: / 12.11.1998 / 18:52:07 / cg"
+ "Created: / 12.11.1998 / 18:55:37 / cg"
+!
+
+_Class_getFields0:nativeContext
+ UnimplementedNativeMethodSignal raiseRequest
+
+ "Modified: / 12.11.1998 / 18:52:07 / cg"
+ "Created: / 12.11.1998 / 18:55:18 / cg"
+!
+
+_Class_getMethod0:nativeContext
+ "get a method, given a name and type spec"
+
+ |jClass cls jmName mName mTypes whichAccess argSig sel|
+
+ jClass := nativeContext receiver.
+ cls := self reflection javaClassObjectForClass:jClass.
+ jmName := nativeContext argAt:1.
+ mName := Java as_ST_String:jmName.
+ mTypes := nativeContext argAt:2.
+ whichAccess := nativeContext argAt:3.
+ argSig := JavaMethod argSignatureFromArgTypeArray:mTypes.
+ cls methodDictionary
+ keysAndValuesDo:[:sel :mthd |
+ |i1 i2 jMethod retTypeClass argTypes|
+
+ JavaMethods notNil ifTrue:[
+ (jMethod := JavaMethods at:mthd ifAbsent:nil) notNil ifTrue:[
+ ^ jMethod
+ ]
+ ].
+ mthd name printCR.
+ mName printCR.
+ mthd name = mName ifTrue:[
+ i1 := mthd signature indexOf:$(.
+ i2 := mthd signature indexOf:$) startingAt:(i1 + 1).
+ (mthd signature copyFrom:i1 + 1 to:i2 - 1) = argSig ifTrue:[
+ "/ found it - create a java.lang.reflect.Method for it.
+ jMethod := (Java at:'java.lang.reflect.Method') new.
+ jMethod instVarNamed:'clazz' put:jClass.
+ jMethod instVarNamed:'slot' put:sel.
+ jMethod instVarNamed:'name' put:jmName.
+ retTypeClass := mthd returnTypeClass.
+ retTypeClass isNil ifTrue:[
+ retTypeClass := #void
+ ].
+ argTypes := mthd argSignature.
+ argTypes := argTypes
+ collect:[:s |
+ |c|
+
+ c := Java at:s.
+ self javaClassObjectForClass:(c ? s asSymbol)
+ ].
+ jMethod instVarNamed:'returnType'
+ put:(self javaClassObjectForClass:retTypeClass).
+ jMethod instVarNamed:'parameterTypes' put:argTypes.
+ JavaMethods isNil ifTrue:[
+ JavaMethods := IdentityDictionary new
+ ].
+ JavaMethods at:jMethod put:mthd.
+ JavaMethods at:mthd put:jMethod.
+ ^ jMethod.
+ ].
+ ].
+ ].
+ self halt.
+ self throwExceptionClassName:'java.lang.NoSuchMethodException'
+ withMessage:'not yet implemented'.
+ ^ nil.
+
+ "Modified: / 22-10-1998 / 01:54:38 / cg"
+ "Modified: / 28-01-2011 / 14:36:26 / Marcel Hlopko <hlopik@gmail.com>"
+!
+
+_Class_getMethods0:nativeContext
+ "get a method, given a name and type spec"
+
+ |jClass cls jmName mTypes whichAccess argSig sel methods|
+
+ jClass := nativeContext receiver.
+ cls := self reflection javaClassObjectForClass:jClass.
+
+ "/ 0 = PUBLIC (i.e. includes inherited) / 1 = DECLARED here
+
+ whichAccess := nativeContext argAt:1.
+ methods := OrderedCollection new.
+ [cls isJavaClass] whileTrue:[
+ cls methodDictionary
+ keysAndValuesDo:[:sel :mthd |
+ |i1 i2 jMethod argTypes retTypeClass|
+
+ mthd name printCR.
+ i1 := mthd signature indexOf:$(.
+ i2 := mthd signature indexOf:$) startingAt:(i1 + 1).
+
+ "/ create a java.lang.reflect.Method for it.
+
+ jMethod := (Java at:'java.lang.reflect.Method') new.
+ jMethod instVarNamed:'clazz' put:jClass.
+ jMethod instVarNamed:'slot' put:sel.
+ jMethod instVarNamed:'name' put:(Java as_String:mthd name).
+ retTypeClass := mthd returnTypeClass.
+ retTypeClass isNil ifTrue:[
+ retTypeClass := #void
+ ].
+ argTypes := mthd argSignature.
+ argTypes := argTypes
+ collect:[:s |
+ |c|
+
+ c := Java at:s.
+ self javaClassObjectForClass:(c ? s asSymbol)
+ ].
+ jMethod instVarNamed:'returnType'
+ put:(self javaClassObjectForClass:retTypeClass).
+ jMethod instVarNamed:'parameterTypes' put:argTypes.
+
+"/ (mthd name includesString:'setName') ifTrue:[self halt].
+
+ JavaMethods isNil ifTrue:[
+ JavaMethods := IdentityDictionary new
+ ].
+ JavaMethods at:jMethod put:mthd.
+ JavaMethods at:mthd put:jMethod.
+ methods add:jMethod.
+ ].
+ whichAccess == 1 ifTrue:[
+ "/ local methods only
+ cls := nil
+ ] ifFalse:[
+ cls := cls superclass.
+ ]
+ ].
+ methods := methods asArray.
+ ^ methods.
+
+ "Modified: / 22-10-1998 / 01:53:58 / cg"
+ "Modified: / 28-01-2011 / 14:36:58 / Marcel Hlopko <hlopik@gmail.com>"
+!
+
+_Class_getName:nativeContext
+ "get a classes name"
+
+ |jClass cls nm|
+
+ jClass := nativeContext receiver.
+ cls := self reflection javaClassObjectForClass:jClass.
+ cls isNil ifTrue:[
+ self halt.
+ ].
+ cls isJavaClass ifTrue:[
+ nm := (cls fullName copyReplaceAll:$/ with:$.)
+ ] ifFalse:[
+ cls isSymbol ifTrue:[
+ nm := cls
+ ] ifFalse:[
+ nm := cls name
+ ]
+ ].
+ ^ Java as_String:nm.
+
+ "Modified: / 30-12-1998 / 21:13:50 / cg"
+ "Modified: / 28-01-2011 / 15:30:34 / Marcel Hlopko <hlopik@gmail.com>"
+!
+
+_Class_getSigners:nativeContext
+ UnimplementedNativeMethodSignal raiseRequest
+
+ "Modified: / 12.11.1998 / 18:52:07 / cg"
+ "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"
+
+ |jClass cls newInst|
+
+ jClass := nativeContext receiver.
+ cls := self reflection javaClassObjectForClass:jClass.
+ cls classInit.
+ newInst := cls newCleared.
+ newInst perform:#'<init>()V'.
+ ^ newInst
+
+ "Created: / 02-01-1998 / 22:41:38 / cg"
+ "Modified: / 15-01-1998 / 00:57:37 / cg"
+ "Modified: / 28-01-2011 / 14:12:25 / Marcel Hlopko <hlopik@gmail.com>"
+!
+
+_Class_setSigners:nativeContext
+ UnimplementedNativeMethodSignal raiseRequest
+
+ "Modified: / 12.11.1998 / 18:52:07 / cg"
+ "Created: / 12.11.1998 / 18:55:08 / cg"
+!
_ColorModel_deletepData:nativeContext
"/ void deletepData ()
UnimplementedNativeMethodSignal raiseRequest
"Created: / 12.11.1998 / 19:22:05 / cg"
-! !
-
-!JavaVM class methodsFor:'native - java.beans - ms'!
-
-_Introspector_getMethodDescriptor:nativeContext
- "java.lang.String getMethodDescriptor (java.lang.reflect.Method)"
-
-UnimplementedNativeMethodSignal raise.
-
- "Created: / 27.1.2000 / 02:47:43 / cg"
-!
-
-_Introspector_getMethodParameterCount:nativeContext
- "int getMethodParameterCount (java.lang.reflect.Method)"
-
-UnimplementedNativeMethodSignal raise.
-
- "Created: / 27.1.2000 / 02:49:15 / cg"
-!
-
-_Introspector_getPublicDeclaredMethods0:nativeContext
- "java.lang.reflect.Method[] getPublicDeclaredMethods0 (java.lang.Class)"
-
-UnimplementedNativeMethodSignal raise.
-
- "Created: / 27.1.2000 / 02:48:49 / cg"
-! !
-
-!JavaVM class methodsFor:'native - java.io'!
+!
+
+_ColorModel_initIDs:nativeContext
+ "/ new with jdk1.2 ...
+
+ "Created: / 28.1.1998 / 22:19:23 / cg"
+!
+
+_Color_initIDs:nativeContext
+ "/ new with jdk1.2 ...
+
+ "Created: / 28.1.1998 / 22:19:23 / cg"
+!
+
+_Component_initIDs:nativeContext
+ "/ introduced with jdk1.2 ... (sigh)
+
+ "Created: / 27.1.1998 / 19:53:29 / cg"
+!
+
+_ConstantPool_getDoubleAt0:nativeContext
+ | cpool index double |
+
+ cpool := self reflection constantPoolFor:(nativeContext receiver).
+ self breakPoint:#mh.
+ 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>"
+!
+
+_ConstantPool_getIntAt0:nativeContext
+ | 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>"
+!
+
+_ConstantPool_getLongAt0:nativeContext
+ | 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>"
+!
+
+_ConstantPool_getUTF8At0: nativeContext
+
+ | 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>"
+!
+
+_Constructor_getModifiers:nativeContext
+ "/ int getModifiers ()
+
+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[])
+
+UnimplementedNativeMethodSignal raiseRequest.
+
+ "Modified: / 27.1.2000 / 02:53:55 / cg"
+!
+
+_Double_doubleToLongBits:nativeContext
+ |f i|
+
+ f := nativeContext argAt:1.
+
+ UninterpretedBytes isBigEndian ifTrue:[
+ i := f basicAt:8.
+ i := i bitOr:((f basicAt:7) bitShift:8).
+ i := i bitOr:((f basicAt:6) bitShift:16).
+ i := i bitOr:((f basicAt:5) bitShift:24).
+ i := i bitOr:((f basicAt:4) bitShift:32).
+ i := i bitOr:((f basicAt:3) bitShift:40).
+ i := i bitOr:((f basicAt:2) bitShift:48).
+ i := i bitOr:((f basicAt:1) bitShift:56).
+ ] 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 := i bitOr:((f basicAt:5) bitShift:32).
+ i := i bitOr:((f basicAt:6) bitShift:40).
+ i := i bitOr:((f basicAt:7) bitShift:48).
+ i := i bitOr:((f basicAt:8) bitShift:56).
+ ].
+
+ ^ i.
+
+ "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|
+
+ s := nativeContext argAt:1.
+ s notNil ifTrue:[
+ s := Java as_ST_String:s.
+ d := Float readFrom:s onError:nil.
+ ].
+ d isNil ifTrue:[
+ self throwNumberFormatException.
+ "/ not reached
+ ].
+
+ ^ d
+
+ "Modified: / 8.8.1997 / 12:03:55 / cg"
+ "Created: / 7.1.1998 / 11:09:43 / cg"
+!
+
+_Field_get:nativeContext
+ "/ java.lang.Object get (java.lang.Object)
+
+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)
+
+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)
+
+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)
+
+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)
+
+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)
+
+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)
+
+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)
+
+UnimplementedNativeMethodSignal raiseRequest.
+
+ "Modified: / 27.1.2000 / 02:53:55 / cg"
+ "Created: / 27.1.2000 / 03:05:54 / cg"
+!
+
+_Field_getModifiers:nativeContext
+ "/ int getModifiers ()
+
+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)
+
+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)
+
+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)
+
+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)
+
+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)
+
+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)
+
+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)
+
+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)
+
+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)
+
+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)
+
+UnimplementedNativeMethodSignal raiseRequest.
+
+ "Modified: / 27.1.2000 / 02:53:55 / cg"
+ "Created: / 27.1.2000 / 03:03:23 / cg"
+!
_FileDescriptor_initSystemFD:nativeContext
|descriptor fileNo idx myStream|
@@ -4670,12 +6342,6 @@
"Modified: / 7.4.1998 / 19:13:42 / cg"
!
-_FileOutputStream_writeBytes:nativeContext
- ^ self anyStream_writeBytes:nativeContext
-
- "Modified: / 4.2.1998 / 15:24:20 / cg"
-!
-
_File_canRead0:nativeContext
|file path f|
@@ -4720,6 +6386,23 @@
"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|
@@ -4772,6 +6455,12 @@
"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|
@@ -4976,1220 +6665,6 @@
"Created: / 12.11.1998 / 19:03:52 / cg"
!
-_ObjectInputStream_allocateNewArray:nativeContext
- "/ java.lang.Object allocateNewArray (java.lang.Class int)
- 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)
- 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[])
- UnimplementedNativeMethodSignal raise
-
- "Modified: / 12.11.1998 / 19:01:48 / cg"
- "Created: / 12.11.1998 / 19:02:22 / cg"
-!
-
-_ObjectInputStream_invokeObjectReader:nativeContext
- "/ boolean invokeObjectReader (java.lang.Object java.lang.Class)
- UnimplementedNativeMethodSignal raise
-
- "Modified: / 12.11.1998 / 19:01:48 / cg"
- "Created: / 12.11.1998 / 19:03:06 / cg"
-!
-
-_ObjectInputStream_loadClass0:nativeContext
- "/ java.lang.Class loadClass0 (java.lang.Class java.lang.String)
- UnimplementedNativeMethodSignal raise
-
- "Created: / 12.11.1998 / 19:01:15 / cg"
- "Modified: / 12.11.1998 / 19:01:48 / cg"
-!
-
-_ObjectOutputStream_invokeObjectWriter:nativeContext
- "/ boolean invokeObjectWriter (java.lang.Object java.lang.Class)
- UnimplementedNativeMethodSignal raise
-
- "Created: / 12.11.1998 / 19:00:36 / cg"
- "Modified: / 12.11.1998 / 19:01:45 / cg"
-!
-
-_ObjectOutputStream_outputClassFields:nativeContext
- "/ void outputClassFields (java.lang.Object java.lang.Class int[])
- UnimplementedNativeMethodSignal raise
-
- "Created: / 12.11.1998 / 19:00:09 / cg"
- "Modified: / 12.11.1998 / 19:01:42 / cg"
-!
-
-_ObjectStreamClass_getClassAccess:nativeContext
- "/ int getClassAccess (java.lang.Class)
- UnimplementedNativeMethodSignal raise
-
- "Modified: / 12.11.1998 / 19:01:48 / cg"
- "Created: / 12.11.1998 / 19:04:19 / cg"
-!
-
-_ObjectStreamClass_getFieldAccess:nativeContext
- "/ int getFieldAccess (java.lang.Class java.lang.String)
- 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)
- 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)
- 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)
- 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)
- 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)
- 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)
- UnimplementedNativeMethodSignal raise
-
- "Modified: / 12.11.1998 / 19:01:48 / cg"
- "Created: / 12.11.1998 / 19:05:53 / cg"
-!
-
-_RandomAccessFile_close:nativeContext
- ^ self anyStream_close:nativeContext
-
- "Created: / 4.2.1998 / 13:26:53 / cg"
- "Modified: / 4.2.1998 / 15:21:08 / cg"
-!
-
-_RandomAccessFile_length:nativeContext
- |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"
-!
-
-_RandomAccessFile_open:nativeContext
- |fs fd name dir stream fileNo answer readonly|
-
- readonly := false.
-
- fs := nativeContext receiver.
- fd := fs instVarNamed:'fd'.
- (fd instVarNamed:'fd') ~~ 0 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.
- ].
-
- dir := name asFilename directory pathName.
-
- (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.
- ]
- ]
- ]
- ].
-
- readonly ifTrue:[
- stream := name asFilename readStream.
- ] ifFalse:[
- stream := name asFilename readWriteStream.
- ].
- stream isNil ifTrue:[
- self throwIOExceptionWithMessage:('cannot open ' , name , ' for writing').
- ].
-
- fileNo := self addOpenFile:stream.
-
- FileOpenTrace ifTrue:[
- ('JAVA: opened ' , name , ' as FD ' , fileNo printString , ' for writing') infoPrintCR.
- ].
-
- fd instVarNamed:'fd' put:fileNo.
-
- "Created: / 4.2.1998 / 00:14:48 / cg"
- "Modified: / 12.11.1998 / 21:29:46 / cg"
-!
-
-_RandomAccessFile_read:nativeContext
- |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"
-!
-
-_RandomAccessFile_readBytes:nativeContext
- ^ self anyStream_readBytes:nativeContext
-
- "Modified: / 4.2.1998 / 15:23:27 / cg"
-!
-
-_RandomAccessFile_seek:nativeContext
- |file pos|
-
- file := self validateFile:(nativeContext receiver).
-
- FileIOTrace ifTrue:[
- ('JAVA: seek on ' , file pathName) infoPrintCR.
- ].
-
- pos := nativeContext argAt:1.
- file position:pos+1 "/ ST/X position starts at 1
-
- "Created: / 4.2.1998 / 13:25:38 / cg"
- "Modified: / 4.2.1998 / 13:28:12 / cg"
-!
-
-_RandomAccessFile_writeBytes:nativeContext
- ^ self anyStream_writeBytes:nativeContext
-
- "Modified: / 4.2.1998 / 15:24:20 / cg"
- "Created: / 4.2.1998 / 15:24:35 / cg"
-! !
-
-!JavaVM class methodsFor:'native - java.io - jdk1.2'!
-
-_FileDescriptor_initIDs:nativeContext
- "/ introduced with jdk1.2 ... (sigh)
-
- "Created: / 27.1.1998 / 18:16:29 / cg"
-!
-
-_FileInputStream_initIDs:nativeContext
- "/ introduced with jdk1.2 ... (sigh)
-
- "Created: / 27.1.1998 / 18:15:51 / cg"
-!
-
-_FileOutputStream_initIDs:nativeContext
- "/ introduced with jdk1.2 ... (sigh)
-
- "Created: / 27.1.1998 / 18:16:40 / 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_initIDs:nativeContext
- "/ introduced with jdk1.2 ... (sigh)
-
- "Created: / 27.1.1998 / 18:25:19 / cg"
-! !
-
-!JavaVM class methodsFor:'native - java.io - ms'!
-
-_ObjectInputStream_invokeDefaultReadObject:nativeContext
- "/ void invokeDefaultReadObject (java.lang.Object java.lang.Class)
-
- UnimplementedNativeMethodSignal raise
-
- "Created: / 27.1.2000 / 03:00:47 / cg"
-!
-
-_ObjectInputStream_invokeReadObject:nativeContext
- "/ void invokeReadObject (java.lang.Object java.lang.Class)
-
- UnimplementedNativeMethodSignal raise
-
- "Created: / 27.1.2000 / 03:01:02 / cg"
-!
-
-_ObjectOutputStream_invokeDefaultWriteObject:nativeContext
- "/ void invokeDefaultWriteObject (java.lang.Object java.lang.Class)
-
- UnimplementedNativeMethodSignal raise
-
- "Created: / 27.1.2000 / 03:01:36 / cg"
-!
-
-_ObjectOutputStream_invokeWriteObject:nativeContext
- "/ void invokeWriteObject (java.lang.Object java.lang.Class)
-
- UnimplementedNativeMethodSignal raise
-
- "Created: / 27.1.2000 / 03:01:52 / cg"
-!
-
-_ObjectStreamClass_doMismatchedRead:nativeContext
- "/ void doMismatchedRead (java.io.ObjectInputStream java.lang.Object)
-
- UnimplementedNativeMethodSignal raise
-
- "Created: / 27.1.2000 / 02:50:55 / cg"
-!
-
-_ObjectStreamClass_findObjectMethod0:nativeContext
- "/ boolean findObjectMethod0 (java.lang.Class int)
-
- UnimplementedNativeMethodSignal raise
-
- "Created: / 27.1.2000 / 02:51:50 / cg"
-!
-
-_ObjectStreamClass_getClassDefinedUID:nativeContext
- "/ long getClassDefinedUID (java.lang.Class)
-
- UnimplementedNativeMethodSignal raise
-
- "Created: / 27.1.2000 / 02:51:33 / cg"
-!
-
-_PrintStream_isOutputStreamLocalised:nativeContext
- "/ boolean isOutputStreamLocalised (java.io.DataOutputStream)
-
- UnimplementedNativeMethodSignal raise
-
- "Created: / 27.1.2000 / 03:00:20 / cg"
-! !
-
-!JavaVM class methodsFor:'native - java.lang'!
-
-_ClassLoader_defineClass0:nativeContext
- "create a new class from a given byteArray.
- Here, construct a stream on it and pass the work to the
- JavaClassReader."
-
- |jClassLoader jName name data offset length inStream newClass
- loaderStub jClass|
-
- jClassLoader := nativeContext receiver.
- jName := nativeContext argAt:1.
-
- "/ className is now optional ...
-"/ jName isNil ifTrue:[
-"/ self internalError:'nil name in defineClass'.
-"/ ^ nil
-"/ ] ifFalse:[
-"/ name := Java as_ST_String:jName.
-"/ ].
-
- data := nativeContext argAt:2.
- offset := nativeContext argAt:3.
- length := nativeContext argAt:4.
-
- inStream := data readStream.
- inStream position:offset + 1.
- inStream readLimit:(offset + length).
-
-"/ loaderStub := Plug new.
-"/ loaderStub respondTo:#loadClass: with:[:clsName |
-"/ |jName|
-"/
-"/self halt.
-"/ jName := Java as_String:clsName.
-"/ "/ jClassLoader loadClass:jName
-"/ jClassLoader
-"/ perform:#'loadClass(Ljava/lang/String;)Ljava/lang/Class;'
-"/ with:jName.
-"/ ].
-
-"/ ('JAVA [info]: defining class ...') infoPrintCR.
-
-"/ self internalError:'break'.
-
- newClass := JavaClassReader
- readStream:inStream
- loader:jClassLoader "loaderStub"
- loadUnresolved:false.
-
- newClass isNil ifTrue:[
- ('JAVA [info]: defineClass failed') infoPrintCR.
- ^ nil.
- ].
-"/ Transcript showCR:('defined class ' , newClass fullName , '.').
- newClass classLoader:jClassLoader.
-
-"/ ('Java [info]: defined new class: ' , newClass fullName) infoPrintCR.
-
- jClass := self javaClassObjectForClass:newClass.
- ^ jClass
-
- "Created: / 7.1.1998 / 12:35:10 / cg"
- "Modified: / 24.1.1998 / 15:26:21 / cg"
-!
-
-_ClassLoader_findSystemClass0:nativeContext
- |loader name class jClass|
-
- loader := nativeContext receiver.
- name := nativeContext argAt:1.
- name := Java as_ST_String:name.
-
- class := Java at:name.
- class isNil ifTrue:[
-"/ ('JAVA: findSystemClass0 for ' , name , ' loader is ' , loader displayString) infoPrintCR.
- loader class == (Java classForName:'java.util.SystemClassLoader') ifTrue:[
-"/ Java classForName:name.
-"/ class := Java at:name.
- class := JavaClassReader loadSystemClass:name.
- ] ifFalse:[
- "/ load using default (ST/X) loader
- class := JavaClassReader loadSystemClass:name.
-"/ JavaClassReader classLoaderQuerySignal answer:nil do:[
-"/ Java classForName:name.
-"/ ]
- ].
- ].
-
-"/ JavaClassReader classLoaderQuerySignal answer:nil "loader"
-"/ do:[
-"/ class := Java classForName:name.
-"/ JavaClassReader postLoadActions:true.
-"/ ].
-
- (class isNil
- "or:[class classLoader notNil]") ifTrue:[
-"/ self halt:'class: ' , name , ' not found.'.
-"/ self internalError:'class: ' , name , ' not found.'.
-
- self
- throwExceptionClassName:'java.lang.ClassNotFoundException'
- withMessage:('class: ' , name , ' not found.').
- ^ nil
- ].
-
-"/ 'JAVA: findSystemClass0 - loaded: ' infoPrint. class fullName infoPrintCR.
- jClass := self javaClassObjectForClass:class.
- ^ jClass
-
- "Created: / 5.1.1998 / 02:53:04 / cg"
- "Modified: / 20.10.1998 / 17:28:34 / cg"
-!
-
-_ClassLoader_getSystemResource:nativeContext asStream0:returnAsStream
- "common code for
- getSystemResourceAsStream0
- getSystemResourceAsName0"
-
- |jString rString dir file text inStream url|
-
- jString := nativeContext argAt:1.
- rString := Java as_ST_String:jString.
- Java effectiveClassPath keysAndValuesDo:[:classPathIndex :aPath |
- |f zipFile zar data |
-
- f := aPath asFilename.
- ((zipFile := f withSuffix:'jar') exists
- or:[(zipFile := f withSuffix:'zip') exists]) ifTrue:[
- zar := ZipArchive oldFileNamed:zipFile.
- (Array
- with:rString
- with:rString asLowercase
- with:rString asUppercase)
- do:[:tryName |
- |entry|
-
- entry := zar findMember:tryName.
- entry notNil ifTrue:[
- returnAsStream ifTrue:[
- data := zar extract:tryName.
- inStream := (Java classForName:'java.io.ByteArrayInputStream') newCleared.
- inStream perform:#'<init>([B)V' with:data.
- ^ inStream.
- ].
- url := 'systemResource:/ZIP' , (classPathIndex-1) printString , '/+/' , tryName.
- ^ Java as_String:url.
- ]
- ]
- ] ifFalse:[
- f exists ifTrue:[
- (file := f construct:rString) exists ifTrue:[
- (Java isExcludedFromClassPath:file) ifFalse:[
-
- "/ Copy data from returned buffer into Java byte array.
-
-"/ self halt.
- returnAsStream ifTrue:[
- text := file contents asString.
- data := text asByteArray.
-
- "/ Create input stream using byte array
-
- inStream := (Java classForName:'java.io.ByteArrayInputStream') newCleared.
- inStream perform:#'<init>([B)V' with:data.
- ^ inStream.
- ].
- url := 'systemResource:/FILE/' , file pathName.
-self halt.
- ^ Java as_String:url
- ]
- ]
- ]
- ]
- ].
- ^ nil
-
- "Created: / 08-01-1998 / 16:06:56 / cg"
- "Modified: / 26-12-1998 / 17:14:52 / cg"
- "Modified: / 22-11-2010 / 13:44:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-_ClassLoader_getSystemResourceAsName0:nativeContext
- "/ java.lang.String getSystemResourceAsName0 (java.lang.String)
-
- ^ self
- _ClassLoader_getSystemResource:nativeContext
- asStream0:false.
-!
-
-_ClassLoader_getSystemResourceAsStream0:nativeContext
- "/ java.lang.InputStream getSystemResourceAsStream0 (java.lang.String)
-
- ^ self
- _ClassLoader_getSystemResource:nativeContext
- asStream0:true.
-!
-
-_ClassLoader_init:nativeContext
- ^ nil
-
- "Created: / 5.1.1998 / 02:04:43 / cg"
-!
-
-_ClassLoader_resolveClass0:nativeContext
- "resolve a new class as previously created by defineClass0"
-
- |jClassLoader jCls cls loaderStub anyUnresolved|
-
- jClassLoader := nativeContext receiver.
- jCls := nativeContext argAt:1.
- jCls isNil ifTrue:[
- self halt.
- ^ nil
- ].
- cls := self reflection javaClassObjectForClass:jCls.
- cls isNil ifTrue:[
- self halt.
- ^ nil
- ].
- ('JavaVM [info]: resolving class ' , cls fullName , ' ...') infoPrintCR.
- JavaClassReader classLoaderQuerySignal answer:jClassLoader
- do:[
- JavaClassReader resolveClass:cls.
-
-"/ JavaClassReader postLoadActions:true.
-
- anyUnresolved := false.
- cls constantPool do:[:entry |
- (entry isMemberOf:JavaUnresolvedClassConstant) ifTrue:[
- self halt:'debugHalt'.
- entry preResolve.
- self halt:'debugHalt'.
- anyUnresolved := true.
- ]
- ]
- ].
- anyUnresolved ifTrue:[
- jClassLoader notNil ifTrue:[
- "/ any unresolved left -> try resolving with standard loader
- JavaClassReader classLoaderQuerySignal answer:nil
- do:[
- JavaClassReader postLoadActions:true.
- cls constantPool do:[:entry |
- (entry isMemberOf:JavaUnresolvedClassConstant) ifTrue:[
- self halt:'debugHalt'.
- entry preResolve.
- self halt:'debugHalt'.
- ]
- ]
- ]
- ].
- ].
-
- "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>"
-!
-
-_Class_forName:nativeContext
- "get a java.lang.Class by name"
-
- |jClassName className cls jClass s m c loader|
-
- jClassName := nativeContext argAt:1.
- className := Java as_ST_String:jClassName.
-
- (s := nativeContext sender) notNil ifTrue:[
- (s isJavaContext) ifTrue:[
- c := s method javaClass.
- loader := c classLoader.
- loader isNil ifTrue:[
-"/ self halt.
- ]
- ]
- ].
-
- JavaClassReader classLoaderQuerySignal answer:loader
- do:[
- cls := Java classForName:className.
- ].
-
-"/(className startsWith:'sun.awt') ifTrue:[self halt].
-"/('classForName: ' , className , ' -> ') print.
-"/cls notNil ifTrue:[cls fullName printCR] ifFalse:['nil' printCR].
-
- cls isNil ifTrue:[
- ExceptionTrace ifTrue:[
- ('throwing exception: no such class:' , className) infoPrintCR.
- ].
- ExceptionDebug ifTrue:[
- self halt:'no such class:' , className.
- ].
- self throwClassNotFoundException:className.
- "/ not proceedable
- AbortSignal raise.
- "/ not reached
- ^ self
- ].
-
- ^ self javaClassObjectForClass:cls.
-
- "Modified: / 30.12.1998 / 20:12:53 / cg"
-!
-
-_Class_getClassLoader:nativeContext
- "get a classes loader"
-
- |jClass cls loader|
-
- jClass := nativeContext receiver.
- cls := self reflection classForJavaClassObject:jClass.
- loader := cls classLoader.
- cls isNil ifTrue:[
- loader := JavaClassReader classLoaderQuerySignal query.
-
-"/ ('JAVA: getClassLoader - ' , loader printString) infoPrintCR.
- ].
- ^ loader
-
- "Created: / 05-01-1998 / 02:51:59 / cg"
- "Modified: / 04-01-1999 / 17:50:15 / cg"
- "Modified: / 28-01-2011 / 15:18:57 / Marcel Hlopko <hlopik@gmail.com>"
-!
-
-_Class_getComponentType:nativeContext
- |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>"
-!
-
-_Class_getConstructor0:nativeContext
- UnimplementedNativeMethodSignal raiseRequest
-
- "Modified: / 12.11.1998 / 18:52:07 / cg"
- "Created: / 12.11.1998 / 18:55:42 / cg"
-!
-
-_Class_getConstructors0:nativeContext
- UnimplementedNativeMethodSignal raiseRequest
-
- "Modified: / 12.11.1998 / 18:52:07 / cg"
- "Created: / 12.11.1998 / 18:55:26 / cg"
-!
-
-_Class_getField0:nativeContext
- UnimplementedNativeMethodSignal raiseRequest
-
- "Modified: / 12.11.1998 / 18:52:07 / cg"
- "Created: / 12.11.1998 / 18:55:37 / cg"
-!
-
-_Class_getFields0:nativeContext
- UnimplementedNativeMethodSignal raiseRequest
-
- "Modified: / 12.11.1998 / 18:52:07 / cg"
- "Created: / 12.11.1998 / 18:55:18 / cg"
-!
-
-_Class_getInterfaces:nativeContext
- |jClass cls interfaces jInterfaces|
-
- jClass := nativeContext receiver.
- cls := self reflection classForJavaClassObject:jClass.
- cls isJavaPrimitiveType ifTrue:[
- ^ (self classForName:'java.lang.Class') arrayClass new
- ].
- interfaces := cls interfaces.
- interfaces ifNil:[^ (self classForName:'java.lang.Class') arrayClass new].
- jInterfaces := (self classForName:'java.lang.Class') arrayClass 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: / 04-02-2011 / 09:43:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-_Class_getMethod0:nativeContext
- "get a method, given a name and type spec"
-
- |jClass cls jmName mName mTypes whichAccess argSig sel|
-
- jClass := nativeContext receiver.
- cls := self reflection javaClassObjectForClass:jClass.
- jmName := nativeContext argAt:1.
- mName := Java as_ST_String:jmName.
- mTypes := nativeContext argAt:2.
- whichAccess := nativeContext argAt:3.
- argSig := JavaMethod argSignatureFromArgTypeArray:mTypes.
- cls methodDictionary
- keysAndValuesDo:[:sel :mthd |
- |i1 i2 jMethod retTypeClass argTypes|
-
- JavaMethods notNil ifTrue:[
- (jMethod := JavaMethods at:mthd ifAbsent:nil) notNil ifTrue:[
- ^ jMethod
- ]
- ].
- mthd name printCR.
- mName printCR.
- mthd name = mName ifTrue:[
- i1 := mthd signature indexOf:$(.
- i2 := mthd signature indexOf:$) startingAt:(i1 + 1).
- (mthd signature copyFrom:i1 + 1 to:i2 - 1) = argSig ifTrue:[
- "/ found it - create a java.lang.reflect.Method for it.
- jMethod := (Java at:'java.lang.reflect.Method') new.
- jMethod instVarNamed:'clazz' put:jClass.
- jMethod instVarNamed:'slot' put:sel.
- jMethod instVarNamed:'name' put:jmName.
- retTypeClass := mthd returnTypeClass.
- retTypeClass isNil ifTrue:[
- retTypeClass := #void
- ].
- argTypes := mthd argSignature.
- argTypes := argTypes
- collect:[:s |
- |c|
-
- c := Java at:s.
- self javaClassObjectForClass:(c ? s asSymbol)
- ].
- jMethod instVarNamed:'returnType'
- put:(self javaClassObjectForClass:retTypeClass).
- jMethod instVarNamed:'parameterTypes' put:argTypes.
- JavaMethods isNil ifTrue:[
- JavaMethods := IdentityDictionary new
- ].
- JavaMethods at:jMethod put:mthd.
- JavaMethods at:mthd put:jMethod.
- ^ jMethod.
- ].
- ].
- ].
- self halt.
- self throwExceptionClassName:'java.lang.NoSuchMethodException'
- withMessage:'not yet implemented'.
- ^ nil.
-
- "Modified: / 22-10-1998 / 01:54:38 / cg"
- "Modified: / 28-01-2011 / 14:36:26 / Marcel Hlopko <hlopik@gmail.com>"
-!
-
-_Class_getMethods0:nativeContext
- "get a method, given a name and type spec"
-
- |jClass cls jmName mTypes whichAccess argSig sel methods|
-
- jClass := nativeContext receiver.
- cls := self reflection javaClassObjectForClass:jClass.
-
- "/ 0 = PUBLIC (i.e. includes inherited) / 1 = DECLARED here
-
- whichAccess := nativeContext argAt:1.
- methods := OrderedCollection new.
- [cls isJavaClass] whileTrue:[
- cls methodDictionary
- keysAndValuesDo:[:sel :mthd |
- |i1 i2 jMethod argTypes retTypeClass|
-
- mthd name printCR.
- i1 := mthd signature indexOf:$(.
- i2 := mthd signature indexOf:$) startingAt:(i1 + 1).
-
- "/ create a java.lang.reflect.Method for it.
-
- jMethod := (Java at:'java.lang.reflect.Method') new.
- jMethod instVarNamed:'clazz' put:jClass.
- jMethod instVarNamed:'slot' put:sel.
- jMethod instVarNamed:'name' put:(Java as_String:mthd name).
- retTypeClass := mthd returnTypeClass.
- retTypeClass isNil ifTrue:[
- retTypeClass := #void
- ].
- argTypes := mthd argSignature.
- argTypes := argTypes
- collect:[:s |
- |c|
-
- c := Java at:s.
- self javaClassObjectForClass:(c ? s asSymbol)
- ].
- jMethod instVarNamed:'returnType'
- put:(self javaClassObjectForClass:retTypeClass).
- jMethod instVarNamed:'parameterTypes' put:argTypes.
-
-"/ (mthd name includesString:'setName') ifTrue:[self halt].
-
- JavaMethods isNil ifTrue:[
- JavaMethods := IdentityDictionary new
- ].
- JavaMethods at:jMethod put:mthd.
- JavaMethods at:mthd put:jMethod.
- methods add:jMethod.
- ].
- whichAccess == 1 ifTrue:[
- "/ local methods only
- cls := nil
- ] ifFalse:[
- cls := cls superclass.
- ]
- ].
- methods := methods asArray.
- ^ methods.
-
- "Modified: / 22-10-1998 / 01:53:58 / cg"
- "Modified: / 28-01-2011 / 14:36:58 / Marcel Hlopko <hlopik@gmail.com>"
-!
-
-_Class_getModifiers:aJavaContext
- ^ (self reflection classForJavaClassObject:aJavaContext receiver) 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>"
-!
-
-_Class_getName:nativeContext
- "get a classes name"
-
- |jClass cls nm|
-
- jClass := nativeContext receiver.
- cls := self reflection javaClassObjectForClass:jClass.
- cls isNil ifTrue:[
- self halt.
- ].
- cls isJavaClass ifTrue:[
- nm := (cls fullName copyReplaceAll:$/ with:$.)
- ] ifFalse:[
- cls isSymbol ifTrue:[
- nm := cls
- ] ifFalse:[
- nm := cls name
- ]
- ].
- ^ Java as_String:nm.
-
- "Modified: / 30-12-1998 / 21:13:50 / cg"
- "Modified: / 28-01-2011 / 15:30:34 / Marcel Hlopko <hlopik@gmail.com>"
-!
-
-_Class_getPrimitiveClass:nativeContext
- "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>"
-!
-
-_Class_getSigners:nativeContext
- UnimplementedNativeMethodSignal raiseRequest
-
- "Modified: / 12.11.1998 / 18:52:07 / cg"
- "Created: / 12.11.1998 / 18:55:01 / cg"
-!
-
-_Class_getSuperclass:nativeContext
- "return a classes superclass"
-
- |jClass cls superCls|
-
- jClass := nativeContext receiver.
- cls := self reflection classForJavaClassObject:jClass.
- superCls := cls superclass.
- superCls == JavaObject ifTrue:[
- ^ nil.
- ].
- ^ 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: / 03-02-2011 / 22:53:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-_Class_isArray:nativeContext
- ^ (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>"
-!
-
-_Class_isAssignableFrom:nativeContext
- "
- /**
- * 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>"
-!
-
-_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"
-
- |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>"
-!
-
-_Class_isPrimitive:nativeContext
- "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>"
-!
-
-_Class_newInstance:nativeContext
- "get an instance for a java.lang.Class"
-
- |jClass cls newInst|
-
- jClass := nativeContext receiver.
- cls := self reflection javaClassObjectForClass:jClass.
- cls classInit.
- newInst := cls newCleared.
- newInst perform:#'<init>()V'.
- ^ newInst
-
- "Created: / 02-01-1998 / 22:41:38 / cg"
- "Modified: / 15-01-1998 / 00:57:37 / cg"
- "Modified: / 28-01-2011 / 14:12:25 / Marcel Hlopko <hlopik@gmail.com>"
-!
-
-_Class_registerNatives:aJavaContext
-
- "Nothing to do, native method are bound lazily"
-
- "Created: / 20-10-2010 / 11:13:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-_Class_setSigners:nativeContext
- UnimplementedNativeMethodSignal raiseRequest
-
- "Modified: / 12.11.1998 / 18:52:07 / cg"
- "Created: / 12.11.1998 / 18:55:08 / cg"
-!
-
-_Double_doubleToLongBits:nativeContext
- |f i|
-
- f := nativeContext argAt:1.
-
- UninterpretedBytes isBigEndian ifTrue:[
- i := f basicAt:8.
- i := i bitOr:((f basicAt:7) bitShift:8).
- i := i bitOr:((f basicAt:6) bitShift:16).
- i := i bitOr:((f basicAt:5) bitShift:24).
- i := i bitOr:((f basicAt:4) bitShift:32).
- i := i bitOr:((f basicAt:3) bitShift:40).
- i := i bitOr:((f basicAt:2) bitShift:48).
- i := i bitOr:((f basicAt:1) bitShift:56).
- ] 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 := i bitOr:((f basicAt:5) bitShift:32).
- i := i bitOr:((f basicAt:6) bitShift:40).
- i := i bitOr:((f basicAt:7) bitShift:48).
- i := i bitOr:((f basicAt:8) bitShift:56).
- ].
-
- ^ i.
-
- "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|
-
- s := nativeContext argAt:1.
- s notNil ifTrue:[
- s := Java as_ST_String:s.
- d := Float readFrom:s onError:nil.
- ].
- d isNil ifTrue:[
- self throwNumberFormatException.
- "/ not reached
- ].
-
- ^ d
-
- "Modified: / 8.8.1997 / 12:03:55 / cg"
- "Created: / 7.1.1998 / 11:09:43 / cg"
-!
-
_Float_floatToIntBits:nativeContext
|f i|
@@ -6236,6 +6711,1065 @@
"Modified: / 13.1.1998 / 23:05:01 / 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)
+ 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_init:nativeContext
+ "/ introduced with jdk1.2 ... (sigh)
+
+ "Created: / 27.1.1998 / 18:16:40 / 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)"
+
+UnimplementedNativeMethodSignal raise.
+
+ "Created: / 27.1.2000 / 02:59:22 / cg"
+!
+
+_InetAddress_lookupHostByName:nativeContext
+ "java.lang.Object[] lookupHostByName (java.lang.String)"
+
+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 ()
+
+UnimplementedNativeMethodSignal raise.
+
+ "Modified: / 27.1.2000 / 03:08:47 / cg"
+ "Created: / 27.1.2000 / 03:11:21 / cg"
+!
+
+_Inflater_getAdler0:nativeContext
+ "/ int getAdler0 ()
+
+UnimplementedNativeMethodSignal raise.
+
+ "Modified: / 27.1.2000 / 03:08:47 / cg"
+ "Created: / 27.1.2000 / 03:12:15 / cg"
+!
+
+_Inflater_getTotalIn0:nativeContext
+ "/ int getTotalIn0 ()
+
+UnimplementedNativeMethodSignal raise.
+
+ "Created: / 27.1.2000 / 03:10:50 / cg"
+ "Modified: / 27.1.2000 / 03:11:08 / cg"
+!
+
+_Inflater_getTotalOut0:nativeContext
+ "/ int getTotalOut0 ()
+
+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)
+
+UnimplementedNativeMethodSignal raise.
+
+ "Modified: / 27.1.2000 / 03:08:47 / cg"
+ "Created: / 27.1.2000 / 03:11:39 / cg"
+!
+
+_Inflater_reset0:nativeContext
+ "/ void reset0 ()
+
+UnimplementedNativeMethodSignal raise.
+
+ "Modified: / 27.1.2000 / 03:08:47 / cg"
+ "Created: / 27.1.2000 / 03:11:02 / cg"
+!
+
+_Inflater_reset:nativeContext
+
+ UnimplementedNativeMethodSignal raise.
+
+ "Created: / 01-02-1998 / 20:14:13 / cg"
+ "Modified: / 30-04-2011 / 22:56:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_Inflater_setDictionary0:nativeContext
+ "/ void setDictionary0 (byte[] int int)
+
+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)"
+
+UnimplementedNativeMethodSignal raise.
+
+ "Created: / 27.1.2000 / 02:47:43 / cg"
+!
+
+_Introspector_getMethodParameterCount:nativeContext
+ "int getMethodParameterCount (java.lang.reflect.Method)"
+
+UnimplementedNativeMethodSignal raise.
+
+ "Created: / 27.1.2000 / 02:49:15 / cg"
+!
+
+_Introspector_getPublicDeclaredMethods0:nativeContext
+ "java.lang.reflect.Method[] getPublicDeclaredMethods0 (java.lang.Class)"
+
+UnimplementedNativeMethodSignal raise.
+
+ "Created: / 27.1.2000 / 02:48:49 / cg"
+!
+
+_JPEGImageDecoder_readImage:nativeContext
+ 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 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: / 8.1.1999 / 17:08:35 / cg"
+!
+
+_MToolkit_eventLoop:nativeContext
+ |toolKit|
+
+ (JavaEventThread notNil and:[JavaEventThread isDead not]) ifTrue:[
+ 'JavaVM [warning]: oops - two threads executing eventLoop' errorPrintCR.
+ ].
+
+ toolKit := nativeContext receiver.
+
+ 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: / 8.1.1999 / 17:08:21 / cg"
+!
+
+_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
UnimplementedNativeMethodSignal raise
@@ -6496,6 +8030,12 @@
"Modified: / 11.11.1998 / 15:07:14 / cg"
!
+_MemoryAdvice_register0:nativeContext
+ "private native void register0()"
+
+ "/ UnimplementedNativeMethodSignal raise
+!
+
_Method_getModifiers:nativeContext
|jMethod mthd retVal|
@@ -6550,43 +8090,237 @@
"Modified: / 13.2.1998 / 15:35:54 / cg"
!
-_Object_clone:nativeContext
- "clone an object"
-
- |o rslt|
-
- o := nativeContext receiver.
- rslt := o shallowCopy.
- ^ rslt
-
- "Created: / 4.1.1998 / 19:39:26 / cg"
-!
-
-_Object_getClass:nativeContext
- "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"
-!
-
-_Object_hashCode:nativeContext
- "identityHash"
-
- |o rslt|
-
- o := nativeContext receiver.
- rslt := o identityHash.
- ^ rslt
-
- "Created: / 4.1.1998 / 19:40:26 / 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)
+ UnimplementedNativeMethodSignal raise
+
+ "Created: / 12.11.1998 / 19:23:22 / cg"
+!
+
+_ObjectInputStream_allocateNewArray:nativeContext
+ "/ java.lang.Object allocateNewArray (java.lang.Class int)
+ 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)
+ 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[])
+ 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)
+
+ UnimplementedNativeMethodSignal raise
+
+ "Created: / 27.1.2000 / 03:00:47 / cg"
+!
+
+_ObjectInputStream_invokeObjectReader:nativeContext
+ "/ boolean invokeObjectReader (java.lang.Object java.lang.Class)
+ 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)
+
+ UnimplementedNativeMethodSignal raise
+
+ "Created: / 27.1.2000 / 03:01:02 / cg"
+!
+
+_ObjectInputStream_loadClass0:nativeContext
+ "/ java.lang.Class loadClass0 (java.lang.Class java.lang.String)
+ 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)
+
+ UnimplementedNativeMethodSignal raise
+
+ "Created: / 27.1.2000 / 03:01:36 / cg"
+!
+
+_ObjectOutputStream_invokeObjectWriter:nativeContext
+ "/ boolean invokeObjectWriter (java.lang.Object java.lang.Class)
+ 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)
+
+ UnimplementedNativeMethodSignal raise
+
+ "Created: / 27.1.2000 / 03:01:52 / cg"
+!
+
+_ObjectOutputStream_outputClassFields:nativeContext
+ "/ void outputClassFields (java.lang.Object java.lang.Class int[])
+ 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)
+
+ UnimplementedNativeMethodSignal raise
+
+ "Created: / 27.1.2000 / 02:50:55 / cg"
+!
+
+_ObjectStreamClass_findObjectMethod0:nativeContext
+ "/ boolean findObjectMethod0 (java.lang.Class int)
+
+ UnimplementedNativeMethodSignal raise
+
+ "Created: / 27.1.2000 / 02:51:50 / cg"
+!
+
+_ObjectStreamClass_getClassAccess:nativeContext
+ "/ int getClassAccess (java.lang.Class)
+ 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)
+
+ UnimplementedNativeMethodSignal raise
+
+ "Created: / 27.1.2000 / 02:51:33 / cg"
+!
+
+_ObjectStreamClass_getFieldAccess:nativeContext
+ "/ int getFieldAccess (java.lang.Class java.lang.String)
+ 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)
+ 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)
+ 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)
+ 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)
+ 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)
+ 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)
+ UnimplementedNativeMethodSignal raise
+
+ "Modified: / 12.11.1998 / 19:01:48 / cg"
+ "Created: / 12.11.1998 / 19:05:53 / cg"
!
_Object_notify:nativeContext
@@ -6603,1560 +8337,18 @@
"Created: / 3.1.1998 / 03:06:56 / cg"
!
-_Object_registerNatives:aJavaContext
-
- "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>"
-!
-
-_Object_wait:nativeMethodContext
- "wait"
-
- |tmo handle sema|
-
- handle := nativeMethodContext receiver.
- tmo := nativeMethodContext argAt:1.
-
- sema := JavaVM semaphoreFor:handle.
-
- [
- self waitFor:sema state:#javaWait timeOut:tmo.
- ] valueOnUnwindDo:[
- JavaVM releaseSemaphoreFor:handle.
- ].
-
- ThreadTrace ifTrue:[
- '====> thread continues ...' printCR.
- ]
-
- "Modified: / 30.12.1998 / 19:20:43 / 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 := Java 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_exitInternal:nativeContext
- "exit - here, we only shut down java threads"
-
- |enteredMonitors|
-
- ExitDebug == true ifTrue:[
- self halt:'Java code called exit'.
- ].
-
- self syncMonitorCache.
- (enteredMonitors := self enteredMonitors) size > 0 ifTrue:[
- enteredMonitors do:[:handle |
- | mon |
-
- mon := LockTable at:handle ifAbsent:nil.
- mon isNil ifTrue:[
- self halt:'no monitor in exitInternal'.
- ] ifFalse:[
- mon exit.
-('====> terminateThread - exit monitor for ' , handle displayString , ' in ' , Processor activeProcess name , ' ...') infoPrintCR.
- ].
- ].
- ].
-
- "/ TODO: shut down all threads created by this one ...
-
- AbortSignal raise.
- self halt.
-
- "Created: / 7.1.1998 / 22:48:51 / cg"
- "Modified: / 8.1.1999 / 14:09:36 / cg"
-!
-
-_Runtime_freeMemory:nativeContext
- "free memory - Returns the number of free bytes"
-
- ^ ObjectMemory freeListSpace + ObjectMemory freeSpace
-
- "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"
-
- |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_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_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)
- UnimplementedNativeMethodSignal raise
-
- "Modified: / 12.11.1998 / 18:52:07 / cg"
- "Created: / 12.11.1998 / 18:59:18 / cg"
-!
-
-_Runtime_traceMethodCalls:nativeContext
- "/ void traceMethodCalls (boolean)
- UnimplementedNativeMethodSignal raise
-
- "Modified: / 12.11.1998 / 18:52:07 / cg"
- "Created: / 12.11.1998 / 18:59:37 / cg"
-!
-
-_SecurityManager_classDepth:nativeContext
- 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
- UnimplementedNativeMethodSignal raise
-
- "Modified: / 12.11.1998 / 18:52:07 / cg"
- "Created: / 12.11.1998 / 18:56:41 / cg"
-!
-
-_SecurityManager_getClassContext:nativeContext
- UnimplementedNativeMethodSignal raise
-
- "Modified: / 12.11.1998 / 18:52:07 / cg"
- "Created: / 12.11.1998 / 18:56:06 / cg"
-!
-
-_String_intern:nativeContext
- |jString|
-
- jString := nativeContext receiver.
- ^ Java intern:jString
-!
-
-_System_arraycopy:nativeContext
- |srcArray srcIdx dstArray dstIdx count dstEndIdx|
-
- srcArray := nativeContext argAt:1.
- srcArray isNil ifTrue:[
- ^ self throwNullPointerException
- ].
- srcIdx := nativeContext argAt:2.
- dstArray := nativeContext argAt:3.
- dstArray isNil ifTrue:[
- ^ self throwNullPointerException
- ].
- dstIdx := nativeContext argAt:4.
- count := nativeContext argAt:5.
-
- ((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:[
- dstArray replaceFrom:dstIdx to:dstEndIdx with:srcArray startingAt:srcIdx.
- ].
- ^ nil.
-!
-
-_System_currentTimeMillis:nativeContext
- "return the milliseconds since 1.jan.1970"
-
- |delta|
-
- "/ workaround win32 bug (use 01:01:01 as base)
- delta := Timestamp now millisecondDeltaFrom:(AbsoluteTime day:1 month:1 year:1970 hour:1 minutes:1 seconds:1).
- delta := delta - 3600 - 60 - 1.
-"/ "/ make certain, it fits 64 signed bits
-"/ delta := delta bitAnd:16r7FFFFFFFFFFFFFFF.
-"/ ^ delta max:0
- ^ delta
-
- "
- JavaVM _System_currentTimeMillis:nil
- "
-
- "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|
-
- 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"
-!
-
-_System_registerNatives:aJavaContext
-
- "Nothing to do, native method are bound lazily"
-
- "Created: / 20-10-2010 / 10:56:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-_System_setErr0:nativeContext
- |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"
-!
-
-_System_setIn0:nativeContext
- |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"
-!
-
-_System_setOut0:nativeContext
- |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"
-!
-
-_Thread_countStackFrames:nativeContext
- "/ int countStackFrames ()
- UnimplementedNativeMethodSignal raise
-
- "Created: / 12.11.1998 / 19:06:21 / cg"
-!
-
-_Thread_currentThread:nativeMethodContext
- |t p prio|
-
- p := Processor activeProcess.
- t := self javaThreadForSTProcess:p.
- t notNil ifTrue:[
- ^ t
- ].
- t := self newThread:'main'.
- Java threads at:t put:p.
- ^ t
-
- "Created: / 3.1.1998 / 01:42:28 / cg"
- "Modified: / 4.1.1998 / 14:59:13 / cg"
-!
-
-_Thread_interrupt0:nativeContext
- "ask if a thread is interrupted (clear interruptState if arg is true)"
-
- |jThread stProcess|
-
- jThread := nativeContext receiver.
- stProcess := self stProcessForJavaThread:jThread.
- stProcess isNil ifTrue:[
- self halt.
- ^ 0
- ].
-
- stProcess markInterrupted
-
- "Modified: / 2.1.1998 / 21:49:06 / cg"
- "Created: / 10.4.1998 / 15:21:43 / cg"
-!
-
-_Thread_isAlive:nativeContext
- "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"
-!
-
-_Thread_isInterrupted:nativeContext
- "ask if a thread is interrupted (clear interruptState if arg is true)"
-
- |jThread stProcess clearInterrupt rslt|
-
- jThread := nativeContext receiver.
- stProcess := self stProcessForJavaThread:jThread.
- stProcess isNil ifTrue:[
- self halt.
- ^ 0
- ].
-
- clearInterrupt := nativeContext argAt:1.
- rslt := stProcess isInterrupted ifTrue:[1] ifFalse:[0].
- clearInterrupt ~~ 0 ifTrue:[stProcess clearInterruptActions].
- ^ rslt
-
- "Modified: / 2.1.1998 / 21:49:06 / cg"
- "Created: / 7.1.1998 / 18:50:26 / cg"
-!
-
-_Thread_registerNatives:aJavaContext
-
- "Nothing to do, native method are bound lazily"
-
- "Created: / 20-10-2010 / 11:12:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-_Thread_resume0: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 resume
-
- "Created: / 8.1.1998 / 01:06:27 / cg"
- "Modified: / 6.2.1998 / 02:15:08 / cg"
-!
-
-_Thread_setPriority0:nativeMethodContext
- |t p prio|
-
- t := nativeMethodContext receiver.
- p := JavaVM stProcessForJavaThread:t.
- prio := nativeMethodContext argAt:1.
-
- p isNil ifTrue:[
- ThreadTrace == true ifTrue:[
- 'JAVA [info]: no process yet (in setPriority)' infoPrintCR.
- ].
- ^ nil
- ].
-
- ThreadTrace ifTrue:[
- 'JAVA [info]: setPrio: ' print. t print. ' pri= ' print. prio print. ' p= ' print. p printNL.
- ].
- ^ nil
-
- "Created: / 2.1.1998 / 19:05:55 / cg"
- "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
-
- "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>"
-!
-
-_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 := self monitorFor:obj.
- 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 threads removeKey: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 wakeup:jThread].
-
- stProcess name:'JAVA-' , name.
- stProcess restartable:true.
- stProcess resume.
-
- Java threads at:jThread put:stProcess.
-
- ^ nil
-
- "Created: / 3.1.1998 / 02:05:52 / cg"
- "Modified: / 24.12.1999 / 03:14:33 / cg"
-!
-
-_Thread_stop0:nativeContext
- "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.
- ]
- ].
- stProcess resume.
-
- [stProcess isDead] whileFalse:[
- stProcess resume.
- 'JavaVM: wait for death' infoPrintCR.
- Delay waitForSeconds:0.1
- ].
- stProcess terminate
-
- "Created: / 8.1.1998 / 13:11:17 / cg"
- "Modified: / 24.12.1999 / 02:32:45 / cg"
-!
-
-_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"
-!
-
-_Thread_yield:nativeContext
- "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"
-!
-
-_Throwable_fillInStackTrace:nativeContext
- |exClass exceptionObject list con|
-
- exClass := Java classNamed:'java.lang.Throwable'.
-
- exceptionObject := nativeContext receiver.
-
- "/
- "/ debugging only
- "/
- (exceptionObject isKindOf:(Java classNamed:'java.lang.Throwable')) ifFalse:[
- self halt
- ].
-
- 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: / 4.1.1998 / 14:27:40 / cg"
- "Modified: / 8.5.1998 / 21:29:53 / 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"
-!
-
-_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"
-! !
-
-!JavaVM class methodsFor:'native - java.lang - jdk1.2'!
-
-_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"
-!
-
-_AccessController_getStackAccessControlContext:nativeContext
- "/ introduced with jdk1.2
-
- "/ supposed to do more here ...
-
- ^ nil
-
- "Created: / 27.1.1998 / 18:22:15 / cg"
-!
-
-_ClassLoader_NativeLibrary_load:nativeContext
- "/ 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>"
-!
-
-_ClassLoader_initIDs:nativeContext
- "/ introduced with jdk1.2 ... (sigh)
-
- "Created: / 27.1.1998 / 18:37:08 / cg"
-!
-
-_Component_initIDs:nativeContext
- "/ introduced with jdk1.2 ... (sigh)
-
- "Created: / 27.1.1998 / 19:53:29 / cg"
-!
-
-_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"
-!
-
-_Toolkit_initIDs:nativeContext
- "/ introduced with jdk1.2 ... (sigh)
-
- "Created: / 27.1.1998 / 19:53:50 / cg"
-! !
-
-!JavaVM class methodsFor:'native - java.lang - ms'!
-
-_ClassLoader_createArrayClass:nativeContext
- "java.lang.Class createArrayClass (java.lang.String java.lang.Class)"
-
- "resolve a new class as previously created by defineClass0"
-
- |jClassLoader name elCls|
-
- jClassLoader := nativeContext receiver.
- name := nativeContext argAt:1.
- elCls := nativeContext argAt:2.
- elCls isNil ifTrue:[
- self halt.
- ^ nil
- ].
-UnimplementedNativeMethodSignal raiseRequest.
-
- "Modified: / 27.1.2000 / 02:36:01 / cg"
- "Created: / 27.1.2000 / 02:56:37 / cg"
-!
-
-_ClassLoader_resolveClass:nativeContext
- "void resolveClass (java.lang.Class)"
-
- "resolve a new class as previously created by defineClass0"
-
- |jClassLoader jCls cls loaderStub anyUnresolved|
-
- jClassLoader := nativeContext receiver.
- jCls := nativeContext argAt:1.
- jCls isNil ifTrue:[
- self halt.
- ^ nil
- ].
-UnimplementedNativeMethodSignal raiseRequest.
-
- "Modified: / 27.1.2000 / 02:36:01 / cg"
-!
-
-_Runtime_isInputStreamLocalised:nativeContext
- "/ boolean isInputStreamLocalised (java.io.DataInputStream)
-
-UnimplementedNativeMethodSignal raise.
-
- "Created: / 27.1.2000 / 03:03:01 / cg"
-!
-
-_Runtime_isOutputStreamLocalised:nativeContext
- "/ boolean isOutputStreamLocalised (java.io.DataOutputStream)
-
-UnimplementedNativeMethodSignal raise.
-
- "Created: / 27.1.2000 / 03:02:49 / cg"
-!
-
-_Runtime_setInputStreamLocalised:nativeContext
-
-UnimplementedNativeMethodSignal raise.
-
- "Modified: / 27.1.2000 / 03:02:27 / cg"
-!
-
-_Runtime_setOutputStreamLocalised:nativeContext
-
-UnimplementedNativeMethodSignal raise.
-
- "Modified: / 27.1.2000 / 03:02:32 / cg"
-!
-
-_String_compareTo:nativeContext
- "int compareTo (java.lang.String)"
-
- |jString1 jString2|
-
- jString1 := nativeContext receiver.
- jString2 := nativeContext argAt:1.
-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.
-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.
-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.
-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.
-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.
-UnimplementedNativeMethodSignal raise.
-
- "Created: / 27.1.2000 / 02:31:40 / cg"
-!
-
-_System_validateSecurityManager:nativeContext
- "void validateSecurityManager (java.lang.SecurityManager)"
-
-UnimplementedNativeMethodSignal raise.
-
- "Created: / 27.1.2000 / 02:43:25 / cg"
-!
-
-_ThreadGroup_initMainThreadGroup0:nativeContext
- "void initMainThreadGroup0 (java.lang.ThreadGroup)"
-
-UnimplementedNativeMethodSignal raise.
-
- "Created: / 27.1.2000 / 02:45:52 / cg"
-! !
-
-!JavaVM class methodsFor:'native - java.lang.reflect - ms'!
-
-_Constructor_getModifiers:nativeContext
- "/ int getModifiers ()
-
-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[])
-
-UnimplementedNativeMethodSignal raiseRequest.
-
- "Modified: / 27.1.2000 / 02:53:55 / cg"
-!
-
-_Field_get:nativeContext
- "/ java.lang.Object get (java.lang.Object)
-
-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)
-
-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)
-
-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)
-
-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)
-
-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)
-
-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)
-
-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)
-
-UnimplementedNativeMethodSignal raiseRequest.
-
- "Modified: / 27.1.2000 / 02:53:55 / cg"
- "Created: / 27.1.2000 / 03:05:54 / cg"
-!
-
-_Field_getModifiers:nativeContext
- "/ int getModifiers ()
-
-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)
-
-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)
-
-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)
-
-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)
-
-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)
-
-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)
-
-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)
-
-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)
-
-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)
-
-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)
-
-UnimplementedNativeMethodSignal raiseRequest.
-
- "Modified: / 27.1.2000 / 02:53:55 / cg"
- "Created: / 27.1.2000 / 03:03:23 / cg"
-! !
-
-!JavaVM class methodsFor:'native - java.math'!
-
-_BigInteger_plumbInit:nativeContext
- UnimplementedNativeMethodSignal raiseRequest
-
- "Modified: / 12.11.1998 / 19:23:00 / cg"
-! !
-
-!JavaVM class methodsFor:'native - java.net'!
-
-_InetAddressImpl_getHostByAddr:nativeContext
- "/ java.lang.String getHostByAddr (int)
- 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"
+_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
@@ -8586,217 +8778,183 @@
"Modified: / 30.12.1998 / 20:10:46 / cg"
!
-_SocketInputStream_socketRead:nativeContext
+_PlatformFont_initIDs:nativeContext
+ "/ new with jdk1.2 ...
+
+ "Created: / 28.1.1998 / 22:30:41 / cg"
+!
+
+_PrintStream_isOutputStreamLocalised:nativeContext
+ "/ boolean isOutputStreamLocalised (java.io.DataOutputStream)
+
+ UnimplementedNativeMethodSignal raise
+
+ "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
+
+ "Created: / 4.2.1998 / 13:26:53 / cg"
+ "Modified: / 4.2.1998 / 15:21:08 / cg"
+!
+
+_RandomAccessFile_length:nativeContext
+ |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"
+!
+
+_RandomAccessFile_open:nativeContext
+ |fs fd name dir stream fileNo answer readonly|
+
+ readonly := false.
+
+ fs := nativeContext receiver.
+ fd := fs instVarNamed:'fd'.
+ (fd instVarNamed:'fd') ~~ 0 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.
+ ].
+
+ dir := name asFilename directory pathName.
+
+ (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.
+ ]
+ ]
+ ]
+ ].
+
+ readonly ifTrue:[
+ stream := name asFilename readStream.
+ ] ifFalse:[
+ stream := name asFilename readWriteStream.
+ ].
+ stream isNil ifTrue:[
+ self throwIOExceptionWithMessage:('cannot open ' , name , ' for writing').
+ ].
+
+ fileNo := self addOpenFile:stream.
+
+ FileOpenTrace ifTrue:[
+ ('JAVA: opened ' , name , ' as FD ' , fileNo printString , ' for writing') infoPrintCR.
+ ].
+
+ fd instVarNamed:'fd' put:fileNo.
+
+ "Created: / 4.2.1998 / 00:14:48 / cg"
+ "Modified: / 12.11.1998 / 21:29:46 / cg"
+!
+
+_RandomAccessFile_read:nativeContext
+ |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"
+!
+
+_RandomAccessFile_readBytes:nativeContext
^ self anyStream_readBytes:nativeContext
- "Created: / 25.1.1998 / 20:56:53 / cg"
- "Modified: / 4.2.1998 / 15:52:31 / cg"
-!
-
-_SocketOutputStream_socketWrite:nativeContext
+ "Modified: / 4.2.1998 / 15:23:27 / cg"
+!
+
+_RandomAccessFile_seek:nativeContext
+ |file pos|
+
+ file := self validateFile:(nativeContext receiver).
+
+ FileIOTrace ifTrue:[
+ ('JAVA: seek on ' , file pathName) infoPrintCR.
+ ].
+
+ pos := nativeContext argAt:1.
+ file position:pos+1 "/ ST/X position starts at 1
+
+ "Created: / 4.2.1998 / 13:25:38 / cg"
+ "Modified: / 4.2.1998 / 13:28:12 / cg"
+!
+
+_RandomAccessFile_writeBytes:nativeContext
^ self anyStream_writeBytes:nativeContext
- "Created: / 25.1.1998 / 21:06:55 / cg"
- "Modified: / 4.2.1998 / 15:52:40 / cg"
-! !
-
-!JavaVM class methodsFor:'native - java.net - jdk1.2'!
-
-_InetAddress_init:nativeContext
- "/ introduced with jdk1.2 ... (sigh)
-
- "Created: / 27.1.1998 / 18:16:40 / cg"
-
-
-! !
-
-!JavaVM class methodsFor:'native - java.net - ms'!
-
-_ClassLoader_findSystemClass:nativeContext
- ^ self _ClassLoader_findSystemClass0:nativeContext
-
- "Created: / 18.11.1998 / 00:00:14 / 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)"
-
-UnimplementedNativeMethodSignal raise.
-
- "Created: / 27.1.2000 / 02:59:22 / cg"
-!
-
-_InetAddress_lookupHostByName:nativeContext
- "java.lang.Object[] lookupHostByName (java.lang.String)"
-
-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"
-! !
-
-!JavaVM class methodsFor:'native - java.security'!
-
-_AccessController_doPrivileged:aJavaContext
-
- "Don't care about permissions :-)"
-
- ^(aJavaContext argAt:1) perform: #'run()Ljava/lang/Object;'
-
- "Created: / 20-10-2010 / 12:31:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-
-!JavaVM class methodsFor:'native - java.util.zip - ms'!
-
-_CRC32_update1:nativeContext
- "/ void update1 (int)
-
-UnimplementedNativeMethodSignal raiseRequest.
-
- "Modified: / 27.1.2000 / 03:08:47 / cg"
-!
-
-_CRC32_update:nativeContext
- "/ void update (byte[] int int)
-
-UnimplementedNativeMethodSignal raiseRequest.
-
- "Modified: / 27.1.2000 / 03:08:47 / cg"
- "Created: / 27.1.2000 / 03:09:20 / cg"
-!
-
-_Inflater_end0:nativeContext
- "/ void end0 ()
-
-UnimplementedNativeMethodSignal raise.
-
- "Modified: / 27.1.2000 / 03:08:47 / cg"
- "Created: / 27.1.2000 / 03:11:21 / cg"
-!
-
-_Inflater_getAdler0:nativeContext
- "/ int getAdler0 ()
-
-UnimplementedNativeMethodSignal raise.
-
- "Modified: / 27.1.2000 / 03:08:47 / cg"
- "Created: / 27.1.2000 / 03:12:15 / cg"
-!
-
-_Inflater_getTotalIn0:nativeContext
- "/ int getTotalIn0 ()
-
-UnimplementedNativeMethodSignal raise.
-
- "Created: / 27.1.2000 / 03:10:50 / cg"
- "Modified: / 27.1.2000 / 03:11:08 / cg"
-!
-
-_Inflater_getTotalOut0:nativeContext
- "/ int getTotalOut0 ()
-
-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)
-
-UnimplementedNativeMethodSignal raise.
-
- "Modified: / 27.1.2000 / 03:08:47 / cg"
- "Created: / 27.1.2000 / 03:11:39 / cg"
-!
-
-_Inflater_reset0:nativeContext
- "/ void reset0 ()
-
-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)
-
-UnimplementedNativeMethodSignal raise.
-
- "Modified: / 27.1.2000 / 03:08:47 / cg"
- "Created: / 27.1.2000 / 03:10:33 / cg"
-! !
-
-!JavaVM class methodsFor:'native - java.utils'!
+ "Modified: / 4.2.1998 / 15:24:20 / cg"
+ "Created: / 4.2.1998 / 15:24:35 / cg"
+!
_ResourceBundle_getClassContext:nativeContext
"returns an array filled with the contextChain receivers classes.
@@ -8831,103 +8989,885 @@
"Modified: / 24-12-1998 / 00:34:57 / cg"
"Modified: / 28-01-2011 / 15:31:28 / Marcel Hlopko <hlopik@gmail.com>"
"Modified: / 03-02-2011 / 21:31:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-
-!JavaVM class methodsFor:'native - java.utils.zip'!
-
-_Inflater_inflate:nativeContext
- "public native synchronized int inflate (byte[] arg1, int arg2, int arg3)"
-
- |inBytes in outBytes len offs|
-
- inBytes := nativeContext argAt:1.
- offs := nativeContext argAt:2.
- len := nativeContext argAt:3.
-
- outBytes := ByteArray new:16*1024.
- in := inBytes copyFrom:offs+1 to:offs+len.
-
- UnimplementedNativeMethodSignal raise
-
- "Created: / 27.1.1999 / 20:57:37 / cg"
- "Modified: / 27.1.1999 / 21:10:13 / cg"
-!
-
-_Inflater_init:nativeContext
-
- "Created: / 1.2.1998 / 20:14:01 / cg"
-!
-
-_Inflater_reset:nativeContext
-
- "Created: / 1.2.1998 / 20:14:13 / cg"
-! !
-
-!JavaVM class methodsFor:'native - kaffe.lang'!
-
-_MemoryAdvice_register0:nativeContext
- "private native void register0()"
-
- "/ UnimplementedNativeMethodSignal raise
-! !
-
-!JavaVM class methodsFor:'native - netscape'!
-
-_MozillaAppletContext_pMochaOnLoad:nativeContext
- |id|
-
- id := nativeContext argAt:1.
-"/ 'JAVA: MozillaAppletContext_pMochaOnLoad: ' print. id printNL.
+!
+
+_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 := Java 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: / 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.
+ "Created: / 15.1.1998 / 01:50:31 / cg"
+ "Modified: / 11.12.1998 / 13:09:36 / cg"
+!
+
+_Runtime_exitInternal:nativeContext
+ "exit - here, we only shut down java threads"
+
+ |enteredMonitors|
+
+ ExitDebug == true ifTrue:[
+ self halt:'Java code called exit'.
+ ].
+
+ self syncMonitorCache.
+ (enteredMonitors := self enteredMonitors) size > 0 ifTrue:[
+ enteredMonitors do:[:handle |
+ | mon |
+
+ mon := LockTable at:handle ifAbsent:nil.
+ mon isNil ifTrue:[
+ self halt:'no monitor in exitInternal'.
+ ] ifFalse:[
+ mon exit.
+('====> terminateThread - exit monitor for ' , handle displayString , ' in ' , Processor activeProcess name , ' ...') infoPrintCR.
+ ].
+ ].
+ ].
+
+ "/ TODO: shut down all threads created by this one ...
+
+ AbortSignal raise.
+ self halt.
+
+ "Created: / 7.1.1998 / 22:48:51 / cg"
+ "Modified: / 8.1.1999 / 14:09:36 / cg"
+!
+
+_Runtime_freeMemory:nativeContext
+ "free memory - Returns the number of free bytes"
+
+ ^ ObjectMemory freeListSpace + ObjectMemory freeSpace
+
+ "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"
+
+ |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)
+
+UnimplementedNativeMethodSignal raise.
+
+ "Created: / 27.1.2000 / 03:03:01 / cg"
+!
+
+_Runtime_isOutputStreamLocalised:nativeContext
+ "/ boolean isOutputStreamLocalised (java.io.DataOutputStream)
+
+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
+
+UnimplementedNativeMethodSignal raise.
+
+ "Modified: / 27.1.2000 / 03:02:27 / cg"
+!
+
+_Runtime_setOutputStreamLocalised:nativeContext
+
+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)
+ UnimplementedNativeMethodSignal raise
+
+ "Modified: / 12.11.1998 / 18:52:07 / cg"
+ "Created: / 12.11.1998 / 18:59:18 / cg"
+!
+
+_Runtime_traceMethodCalls:nativeContext
+ "/ void traceMethodCalls (boolean)
+ 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
+ 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
+ UnimplementedNativeMethodSignal raise
+
+ "Modified: / 12.11.1998 / 18:52:07 / cg"
+ "Created: / 12.11.1998 / 18:56:41 / cg"
+!
+
+_SecurityManager_getClassContext:nativeContext
+ UnimplementedNativeMethodSignal raise
+
+ "Modified: / 12.11.1998 / 18:52:07 / cg"
+ "Created: / 12.11.1998 / 18:56:06 / 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.
+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.
+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.
+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.
+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.
+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.
+UnimplementedNativeMethodSignal raise.
+
+ "Created: / 27.1.2000 / 02:31:40 / cg"
+!
+
+_SystemColor_GetSysColor:nativeContext
+ "/ int GetSysColor (int)
+ 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_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)"
+
+UnimplementedNativeMethodSignal raise.
+
+ "Created: / 27.1.2000 / 02:43:25 / cg"
+!
+
+_ThreadGroup_initMainThreadGroup0:nativeContext
+ "void initMainThreadGroup0 (java.lang.ThreadGroup)"
+
+UnimplementedNativeMethodSignal raise.
+
+ "Created: / 27.1.2000 / 02:45:52 / cg"
+!
+
+_Thread_countStackFrames:nativeContext
+ "/ int countStackFrames ()
+ UnimplementedNativeMethodSignal raise
+
+ "Created: / 12.11.1998 / 19:06:21 / cg"
+!
+
+_Thread_interrupt0:nativeContext
+ "ask if a thread is interrupted (clear interruptState if arg is true)"
+
+ |jThread stProcess|
+
+ jThread := nativeContext receiver.
+ stProcess := self stProcessForJavaThread:jThread.
+ stProcess isNil ifTrue:[
+ self halt.
+ ^ 0
+ ].
+
+ stProcess markInterrupted
+
+ "Modified: / 2.1.1998 / 21:49:06 / cg"
+ "Created: / 10.4.1998 / 15:21:43 / cg"
+!
+
+_Thread_isInterrupted:nativeContext
+ "ask if a thread is interrupted (clear interruptState if arg is true)"
+
+ |jThread stProcess clearInterrupt rslt|
+
+ jThread := nativeContext receiver.
+ stProcess := self stProcessForJavaThread:jThread.
+ stProcess isNil ifTrue:[
+ self halt.
+ ^ 0
+ ].
+
+ clearInterrupt := nativeContext argAt:1.
+ rslt := stProcess isInterrupted ifTrue:[1] ifFalse:[0].
+ clearInterrupt ~~ 0 ifTrue:[stProcess clearInterruptActions].
+ ^ rslt
+
+ "Modified: / 2.1.1998 / 21:49:06 / cg"
+ "Created: / 7.1.1998 / 18:50:26 / cg"
+!
+
+_Thread_resume0: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 resume
+
+ "Created: / 8.1.1998 / 01:06:27 / cg"
+ "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"
+
+ |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 := self monitorFor:obj.
+ 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 threads removeKey: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 wakeup:jThread].
+
+ stProcess name:'JAVA-' , name.
+ stProcess restartable:true.
+ stProcess resume.
+
+ Java threads at:jThread put:stProcess.
^ 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)
- UnimplementedNativeMethodSignal raise
-
- "Created: / 12.11.1998 / 19:23:22 / cg"
+ "Created: / 3.1.1998 / 02:05:52 / cg"
+ "Modified: / 24.12.1999 / 03:14:33 / cg"
+!
+
+_Thread_stop0:nativeContext
+ "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.
+ ]
+ ].
+ stProcess resume.
+
+ [stProcess isDead] whileFalse:[
+ stProcess resume.
+ 'JavaVM: wait for death' infoPrintCR.
+ Delay waitForSeconds:0.1
+ ].
+ stProcess terminate
+
+ "Created: / 8.1.1998 / 13:11:17 / cg"
+ "Modified: / 24.12.1999 / 02:32:45 / cg"
+!
+
+_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"
+!
+
+_Thread_yield:nativeContext
+ "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"
+!
+
+_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"
+!
+
+_Toolkit_initIDs:nativeContext
+ "/ introduced with jdk1.2 ... (sigh)
+
+ "Created: / 27.1.1998 / 19:53:50 / cg"
!
_URLConnection_close:nativeContext
@@ -9032,868 +9972,108 @@
UnimplementedNativeMethodSignal raise
"Created: / 12.11.1998 / 19:23:43 / cg"
-! !
-
-!JavaVM class methodsFor:'native - sun.audio'!
-
-_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 := 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.1.1998 / 15:45:30 / cg"
- "Modified: / 14.10.1998 / 15:20:52 / cg"
-!
-
-_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"
-! !
-
-!JavaVM class methodsFor:'native - sun.awt'!
-
-_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"
-!
-
-_JPEGImageDecoder_readImage:nativeContext
- UnimplementedNativeMethodSignal raise
-
- "Created: / 12.11.1998 / 18:53:30 / cg"
- "Modified: / 12.11.1998 / 18:53:40 / cg"
-!
-
-_OffScreenImageSource_sendPixels:nativeContext
- "/ self halt.
- "/ UnimplementedNativeMethodSignal raise
-
- "Modified: / 16.1.1998 / 18:22:23 / cg"
- "Created: / 17.1.1998 / 12:36:25 / cg"
-! !
-
-!JavaVM class methodsFor:'native - sun.awt - jdk1.2'!
-
-_CMM_cmmGetTagSize:nativeContext
- "/ public static native synchronized int cmmGetTagSize (long arg1, int arg2, int[] arg3)
- "/ new with jdk1.2 ...
-
- UnimplementedNativeMethodSignal raiseRequest.
- ^ -1.
-
- "Created: / 27.1.1998 / 21:43:25 / cg"
-!
-
-_CMM_cmmInit:nativeContext
- "/ new with jdk1.2 ...
-
- "Created: / 27.1.1998 / 21:43:25 / cg"
-!
-
-_CMM_cmmLoadProfile:nativeContext
- "/ public static native synchronized int cmmLoadProfile (byte[] arg1, long[] arg2)
- "/ new with jdk1.2 ...
-
- UnimplementedNativeMethodSignal raiseRequest.
- ^ -1.
-
- "Created: / 27.1.1998 / 21:43:25 / cg"
-!
-
-_ColorModel_initIDs:nativeContext
- "/ new with jdk1.2 ...
-
- "Created: / 28.1.1998 / 22:19:23 / cg"
-!
-
-_Color_initIDs:nativeContext
- "/ new with jdk1.2 ...
-
- "Created: / 28.1.1998 / 22:19:23 / 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"
-!
-
-_PackedColorModel_initIDs:nativeContext
- "/ new with jdk1.2 ...
-
- "Created: / 28.1.1998 / 22:19:35 / cg"
-!
-
-_PlatformFont_initIDs:nativeContext
- "/ new with jdk1.2 ...
-
- "Created: / 28.1.1998 / 22:30:41 / cg"
-!
-
-_ScrollPane_initIDs:nativeContext
- "/ new with jdk1.2 ...
-
- "Created: / 28.1.1998 / 22:19:23 / cg"
-!
-
-_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"
-! !
-
-!JavaVM class methodsFor:'native - sun.awt.motif'!
-
-_MButtonPeer_create:nativeContext
- ^ self _WButtonPeer_create:nativeContext
-!
-
-_MComponentPeer_handleEvent:nativeContext
- ^ self _WComponentPeer_handleEvent:nativeContext
-
- "Created: / 18.11.1998 / 00:21:17 / cg"
-!
-
-_MComponentPeer_nativeHandleEvent:nativeContext
- ^ self _WComponentPeer_nativeHandleEvent:nativeContext
-!
-
-_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"
-!
-
-_MToolkit_loadSystemColors:nativeContext
- ^ self _WToolkit_loadSystemColors:nativeContext
-!
-
-_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
-!
-
-_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
-! !
-
-!JavaVM class methodsFor:'native - sun.awt.motif - jdk1.2'!
-
-_InputThread_run:nativeContext
- self _WToolkit_eventLoop:nativeContext.
-
- "Created: / 28.1.1998 / 22:34:47 / cg"
- "Modified: / 28.1.1998 / 22:35:16 / cg"
-!
-
-_MComponentPeer_cacheInit:nativeContext
-
- "Created: / 28.1.1998 / 22:22:30 / cg"
-!
-
-_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_setCursor:nativeContext
-
- "Created: / 28.1.1998 / 22:27:35 / cg"
-!
-
-_MFramePeer_create:nativeContext
- ^ self _WFramePeer_create:nativeContext
-
- "Created: / 28.1.1998 / 22:25:44 / 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"
-!
-
-_MToolkit_init:nativeContext
-
- "Created: / 28.1.1998 / 22:21:54 / cg"
-!
-
-_MToolkit_run:nativeContext
-
- "Created: / 28.1.1998 / 22:22:10 / cg"
-! !
-
-!JavaVM class methodsFor:'native - sun.awt.windows'!
+!
+
+_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
+
+ "Created: / 12.11.1998 / 19:06:44 / cg"
+!
+
+_VM_resetJavaMonitor:nativeContext
+ "/ void resetJavaMonitor ()
+ UnimplementedNativeMethodSignal raise
+
+ "Created: / 14.11.1998 / 10:43:23 / cg"
+!
+
+_VM_resumeJavaMonitor:nativeContext
+ "/ void resumeJavaMonitor ()
+ UnimplementedNativeMethodSignal raise
+
+ "Created: / 14.11.1998 / 10:42:49 / cg"
+!
+
+_VM_suspendJavaMonitor:nativeContext
+ "/ void suspendJavaMonitor ()
+ UnimplementedNativeMethodSignal raise
+
+ "Created: / 14.11.1998 / 10:43:07 / cg"
+!
+
+_VM_threadsSuspended:nativeContext
+ "/ boolean threadsSuspended ()
+ UnimplementedNativeMethodSignal raise
+
+ "Created: / 12.11.1998 / 19:07:10 / cg"
+!
+
+_VM_unsuspendSomeThreads:nativeContext
+ "/ void unsuspendSomeThreads ()
+ UnimplementedNativeMethodSignal raise
+
+ "Created: / 12.11.1998 / 19:07:29 / cg"
+!
+
+_VM_unsuspendThreads:nativeContext
+ "/ void unsuspendThreads ()
+ UnimplementedNativeMethodSignal raise
+
+ "Created: / 12.11.1998 / 19:07:20 / cg"
+!
+
+_VM_writeJavaMonitorReport:nativeContext
+ "/ void writeJavaMonitorReport ()
+ UnimplementedNativeMethodSignal raise
+
+ "Created: / 14.11.1998 / 10:43:37 / cg"
+!
_WButtonPeer_create:nativeContext
|jButtonPeer jButton jFrame frame button
@@ -10423,6 +10603,39 @@
"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|
@@ -10443,6 +10656,28 @@
"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|
@@ -10485,6 +10720,12 @@
"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
@@ -10873,6 +11114,51 @@
"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()
UnimplementedNativeMethodSignal raise
@@ -11896,6 +12182,12 @@
"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)
UnimplementedNativeMethodSignal raise
@@ -12452,396 +12744,877 @@
"Modified: / 18.3.1997 / 18:43:18 / cg"
"Created: / 4.1.1998 / 18:09:04 / cg"
-! !
-
-!JavaVM class methodsFor:'native - sun.awt.windows - jdk1.2'!
-
-_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"
-!
-
-_WPanelPeer_calculateInsets:nativeContext
+!
+
+_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"
+!
+
+_WinNTFileSystem_canonicalize0:aJavaContext
+
+ | 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>"
+!
+
+_WinNTFileSystem_getBooleanAttributes:aJavaContext
+
+ ^ self _UnixFileSystem_getBooleanAttributes0:aJavaContext
+
+ "Created: / 01-04-2011 / 18:10:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_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 ...
- "Created: / 27.1.1998 / 21:40:00 / cg"
+ |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
+!
+
+_ZipFile_read:aJavaContext
+
+ | jzfile jzentry pos b off len zar zmember data nread |
+ 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.
+
+ data := zar extract: zmember fileName.
+ nread := len min: (data size - pos).
+ b replaceFrom: off to: off + len with: data startingAt: nread.
+ ^nread.
+
+ "Created: / 30-04-2011 / 22:15:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
-!JavaVM class methodsFor:'native - sun.awt.windows - ms'!
-
-_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_pReshape:nativeContext
- self commonReshapeComponent:nativeContext
-
- "Created: / 18.11.1998 / 00:18:17 / 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_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_getWindowBackgroundColor:nativeContext
- ^ View defaultViewBackgroundColor rgbValue.
-
- "Created: / 17.11.1998 / 23:55:42 / 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.
+!JavaVM class methodsFor:'native - old-style (converted)'!
+
+_AccessController_doPrivileged:aJavaContext
+
+ "Don't care about permissions :-)"
+
+ ^(aJavaContext argAt:1) perform: #'run()Ljava/lang/Object;'
+
+ "Created: / 20-10-2010 / 12:31:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_AccessController_getStackAccessControlContext:nativeContext
+ "/ introduced with jdk1.2
+
+ "/ supposed to do more here ...
^ 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 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: / 8.1.1999 / 17:08:35 / cg"
-!
-
-_MToolkit_eventLoop:nativeContext
- |toolKit|
-
- (JavaEventThread notNil and:[JavaEventThread isDead not]) ifTrue:[
- 'JavaVM [warning]: oops - two threads executing eventLoop' errorPrintCR.
- ].
-
- toolKit := nativeContext receiver.
-
- self wakeup:toolKit.
+ "Created: / 27.1.1998 / 18:22:15 / cg"
+!
+
+_Array_newArray:aJavaContext
+ |componentClass size|
+
+ componentClass := self reflection
+ classForJavaClassObject:(aJavaContext argAt:1).
+ size := aJavaContext argAt:2.
+ ^ componentClass arrayClass new:size
+
+ "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>"
+!
+
+_ClassLoader_NativeLibrary_load:nativeContext
+ "/ 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.
- 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: / 8.1.1999 / 17:08:21 / cg"
-! !
-
-!JavaVM class methodsFor:'native - sun.awt.windows - ns4.0'!
-
-_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_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"
-!
-
-_WContainerPeer_calculateInsets:nativeContext
- "/ new with ns4.0 ...
-
- "Created: / 16.10.1998 / 02:12:59 / 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"
-! !
-
-!JavaVM class methodsFor:'native - sun.misc'!
-
-_Unsafe_registerNatives:aJavaContext
+ 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>"
+!
+
+_ClassLoader_registerNatives:aJavaContext
+
+ "Nothing to do"
+
+ "Created: / 09-11-2010 / 20:55:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_Class_desiredAssertionStatus0:aJavaContext
+
+ ^AssertionsEnabled == true
+
+ "Created: / 24-11-2010 / 08:58:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_Class_forName0:aJavaContext
+
+ | name initialize loader class |
+ name := Java as_ST_String: (aJavaContext argAt: 1).
+ initialize := aJavaContext argAt: 2.
+ loader := aJavaContext argAt: 3.
+ JavaClassReader classLoaderQuerySignal answer: loader do:
+ [class := Java classForName: name].
+ class isNil ifTrue:
+ [^self throwClassNotFoundException: name].
+ initialize ifTrue:
+ [[class classInit] on: Error do:[self throwExceptionInInitializerError:name]].
+ ^JavaVM javaClassObjectForClass: class.
+
+ "Created: / 24-11-2010 / 09:03:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_Class_getClassLoader0:aJavaContext
+ "get a classes loader"
+
+ |jClass cls loader|
+
+ jClass := aJavaContext receiver.
+ cls := self reflection classForJavaClassObject:jClass.
+ loader := cls classLoader.
+ cls isNil ifTrue:[
+ loader := (Java classForName:'java/lang/ClassLoader')
+ perform:#'getSystemClassLoader()Ljava/lang/ClassLoader;'.
+
+"/ ('JAVA: getClassLoader - ' , loader printString) infoPrintCR.
+ ].
+ ^ loader
+
+ "Created: / 25-10-2010 / 22:49:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 09-11-2010 / 23:37:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 28-01-2011 / 15:18:54 / Marcel Hlopko <hlopik@gmail.com>"
+!
+
+_Class_getComponentType:nativeContext
+ |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>"
+!
+
+_Class_getConstantPool:aJavaContext
+ | class |
+
+ class := self reflection classForJavaClassObject:aJavaContext receiver.
+ ^ 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>"
+!
+
+_Class_getDeclaredConstructors0:aJavaContext
+ |class publicOnly constructors|
+
+ class := self reflection classForJavaClassObject:(aJavaContext receiver).
+ publicOnly := (aJavaContext argAt:1) == 1.
+ constructors := OrderedCollection new.
+ class
+ selectorsAndMethodsDo:[:selector :method |
+ (method isJavaMethod
+ and:[
+ (selector at:1) == $<
+ and:[
+ (selector startsWith:'<init>(') and:[publicOnly not or:[method isPublic]]
+ ]
+ ])
+ ifTrue:[constructors add:(self reflection javaConstructorObjectForMethod:method)]
+ ].
+ ^ (self classForName: 'java.lang.reflect.Constructor')
+ arrayClass withAll: constructors
+
+ "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: / 11-02-2011 / 08:55:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_Class_getDeclaredFields0:aJavaContext
+ |javaClassObject class fields publicOnly|
+
+ class := self reflection classForJavaClassObject:(javaClassObject := aJavaContext argAt:0).
+ publicOnly := (aJavaContext argAt:1) == 1.
+ fields := class fields.
+ publicOnly ifTrue:
+ [fields := fields select:[:f|f isPublic]].
+ fields := fields collect:[:f | self javaFieldObjectForField:f in:javaClassObject].
+
+ ^ (self classForName: 'java.lang.reflect.Field') arrayClass
+ withAll: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: / 16-03-2011 / 15:43:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_Class_getDeclaredMethods0:aJavaContext
+ |class publicOnly methods|
+
+ class := self reflection classForJavaClassObject:(aJavaContext receiver).
+ publicOnly := (aJavaContext argAt:1) == 1.
+ methods := OrderedCollection new.
+ class
+ selectorsAndMethodsDo:[:selector :method |
+ (method isJavaMethod
+ and:[
+ (selector at:1) ~~ $<
+ and:[
+ (selector startsWith:'<init>(') not
+ and:[publicOnly not or:[method isPublic]]
+ ]
+ ])
+ ifTrue:[methods add:(self javaMethodObjectForMethod:method)]
+ ].
+ ^ (self classForName: 'java.lang.reflect.Method')
+ arrayClass withAll: methods asArray
+
+ "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: / 11-02-2011 / 08:35:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_Class_getInterfaces:nativeContext
+ |jClass cls interfaces jInterfaces|
+
+ jClass := nativeContext receiver.
+ cls := self reflection classForJavaClassObject:jClass.
+ cls isJavaPrimitiveType ifTrue:[
+ ^ (self classForName:'java.lang.Class') arrayClass new
+ ].
+ interfaces := cls interfaces.
+ interfaces ifNil:[^ (self classForName:'java.lang.Class') arrayClass new].
+ jInterfaces := (self classForName:'java.lang.Class') arrayClass 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: / 04-02-2011 / 09:43:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_Class_getModifiers:aJavaContext
+ ^ (self reflection classForJavaClassObject:aJavaContext receiver) 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>"
+!
+
+_Class_getName0:aJavaContext
+ |class|
+
+ class := aJavaContext receiver.
+ class := self reflection classForJavaClassObject:aJavaContext receiver.
+ ^ self reflection
+ javaStringObjectForString:class javaName
+ 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: / 25-02-2011 / 19:00:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_Class_getPrimitiveClass:nativeContext
+ "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>"
+!
+
+_Class_getRawAnnotations:aJavaContext
+ |class |
+
+ class := self reflection classForJavaClassObject:aJavaContext receiver.
+ ^ 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: / 25-02-2011 / 16:48:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_Class_getSuperclass:nativeContext
+ "return a classes superclass"
+
+ |jClass cls superCls|
+
+ jClass := nativeContext receiver.
+ cls := self reflection classForJavaClassObject:jClass.
+ superCls := cls superclass.
+ superCls == JavaObject ifTrue:[
+ ^ nil.
+ ].
+ ^ 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: / 03-02-2011 / 22:53:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_Class_isArray:nativeContext
+ ^ (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>"
+!
+
+_Class_isAssignableFrom:nativeContext
+ "
+ /**
+ * 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>"
+!
+
+_Class_isInterface:nativeContext
+ "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>"
+!
+
+_Class_isPrimitive:nativeContext
+ "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>"
+!
+
+_Class_registerNatives:aJavaContext
"Nothing to do, native method are bound lazily"
- "Created: / 25-10-2010 / 16:14:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-_VM_getState:nativeContext
- "/ int getState ()
- UnimplementedNativeMethodSignal raise
-
- "Created: / 12.11.1998 / 19:06:44 / cg"
-!
-
-_VM_resetJavaMonitor:nativeContext
- "/ void resetJavaMonitor ()
- UnimplementedNativeMethodSignal raise
-
- "Created: / 14.11.1998 / 10:43:23 / cg"
-!
-
-_VM_resumeJavaMonitor:nativeContext
- "/ void resumeJavaMonitor ()
- UnimplementedNativeMethodSignal raise
-
- "Created: / 14.11.1998 / 10:42:49 / cg"
-!
-
-_VM_suspendJavaMonitor:nativeContext
- "/ void suspendJavaMonitor ()
- UnimplementedNativeMethodSignal raise
-
- "Created: / 14.11.1998 / 10:43:07 / cg"
-!
-
-_VM_threadsSuspended:nativeContext
- "/ boolean threadsSuspended ()
- UnimplementedNativeMethodSignal raise
-
- "Created: / 12.11.1998 / 19:07:10 / cg"
-!
-
-_VM_unsuspendSomeThreads:nativeContext
- "/ void unsuspendSomeThreads ()
- UnimplementedNativeMethodSignal raise
-
- "Created: / 12.11.1998 / 19:07:29 / cg"
-!
-
-_VM_unsuspendThreads:nativeContext
- "/ void unsuspendThreads ()
- UnimplementedNativeMethodSignal raise
-
- "Created: / 12.11.1998 / 19:07:20 / cg"
-!
-
-_VM_writeJavaMonitorReport:nativeContext
- "/ void writeJavaMonitorReport ()
- UnimplementedNativeMethodSignal raise
-
- "Created: / 14.11.1998 / 10:43:37 / cg"
-! !
-
-!JavaVM class methodsFor:'native - sun.reflect'!
+ "Created: / 20-10-2010 / 11:13:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_Double_doubleToRawLongBits:aJavaContext
+ "
+ /**
+ * 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 |
+ f := aJavaContext argAt:1.
+ (f = 0.0) ifTrue:[^0].
+ (f = -0.0) ifTrue:[^(1 bitShift: 63)].
+
+ self halt:'Not yet implemented'.
+
+ "Created: / 10-11-2010 / 14:48:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_FileDescriptor_initIDs:nativeContext
+ "/ introduced with jdk1.2 ... (sigh)
+
+ "Created: / 27.1.1998 / 18:16:29 / cg"
+!
+
+_FileInputStream_initIDs:nativeContext
+ "/ introduced with jdk1.2 ... (sigh)
+
+ "Created: / 27.1.1998 / 18:15:51 / cg"
+!
+
+_FileOutputStream_initIDs:nativeContext
+ "/ introduced with jdk1.2 ... (sigh)
+
+ "Created: / 27.1.1998 / 18:16:40 / cg"
+!
+
+_FileOutputStream_writeBytes:nativeContext
+ ^ self anyStream_writeBytes:nativeContext
+
+ "Modified: / 4.2.1998 / 15:24:20 / cg"
+!
+
+_FileSystem_getFileSystem:aJavaContext
+
+ OperatingSystem isUNIXlike ifTrue:
+ [^(Java 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>"
+!
+
+_Float_floatToRawIntBits:aJavaContext
+ "
+ /**
+ * 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 exponent mantissa |
+ f := aJavaContext argAt:1.
+ (f = 0.0) ifTrue:[^0].
+ (f = -0.0) ifTrue:[^(1 bitShift: 31) ].
+
+ self halt.
+
+ "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>"
+!
+
+_Inflater_inflateBytes:aJavaContext
+
+ UnimplementedNativeMethodSignal raise
+
+ "Created: / 30-04-2011 / 23:02:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_Inflater_init:nativeContext
+
+ | index |
+ index := ZipInflaters indexOf: nativeContext receiver.
+ index == 0 ifTrue:
+ [ZipInflaters add: nativeContext receiver.
+ 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>"
+!
+
+_Inflater_initIDs:aJavaContext
+
+ "Nothing to do, used only to register natives"
+
+ "Created: / 30-04-2011 / 21:55:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_NativeConstructorAccessorImpl_newInstance0:aJavaContext
+
+ | ctor args method instance |
+ ctor := aJavaContext argAt: 1.
+ args := aJavaContext argAt: 2.
+ args ifNil:[args := #()] ifNotNil:[args := args asArray].
+ method := self reflection methodForJavaConstructorObject: ctor.
+ instance := method javaClass new.
+ method valueWithReceiver:instance arguments:args.
+ ^instance
+
+ "Created: / 26-11-2010 / 11:41:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 04-02-2011 / 18:47:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 09-02-2011 / 01:12:10 / Marcel Hlopko <hlopik@gmail.com>"
+!
+
+_NativeMethodAccessorImpl_invoke0:nativeContext
+ "
+ private static native Object invoke0(Method m, Object obj, Object[] args);
+ "
+ | m obj args |
+ m := nativeContext argAt: 1.
+ obj := nativeContext argAt: 2.
+ args := nativeContext argAt: 3.
+
+ ^(self reflection methodForJavaMethodObject: m)
+ valueWithReceiver: obj
+ arguments: (args ? #()) asArray.
+
+ "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: / 16-03-2011 / 15:31:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_ObjectStreamClass_initNative:aJavaContext
+
+ "
+ /**
+ * Initializes native code.
+ */
+ "
+ "Nothing to do"
+
+ "Created: / 20-12-2010 / 17:43:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_Object_clone:nativeContext
+ "clone an object"
+
+ |o rslt|
+
+ o := nativeContext receiver.
+ rslt := o shallowCopy.
+ ^ rslt
+
+ "Created: / 4.1.1998 / 19:39:26 / cg"
+!
+
+_Object_getClass:nativeContext
+ "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"
+!
+
+_Object_hashCode:nativeContext
+ "identityHash"
+
+ |o rslt|
+
+ o := nativeContext receiver.
+ rslt := o identityHash.
+ ^ rslt
+
+ "Created: / 4.1.1998 / 19:40:26 / cg"
+!
+
+_Object_registerNatives:aJavaContext
+
+ "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>"
+!
+
+_Object_wait:nativeMethodContext
+ "wait"
+
+ |tmo handle sema|
+
+ handle := nativeMethodContext receiver.
+ tmo := nativeMethodContext argAt:1.
+
+ sema := JavaVM semaphoreFor:handle.
+
+ [
+ self waitFor:sema state:#javaWait timeOut:tmo.
+ ] valueOnUnwindDo:[
+ JavaVM releaseSemaphoreFor:handle.
+ ].
+
+ ThreadTrace ifTrue:[
+ '====> thread continues ...' printCR.
+ ]
+
+ "Modified: / 30.12.1998 / 19:20:43 / cg"
+!
_Reflection_getCallerClass:aJavaContext
@@ -12857,33 +13630,847 @@
(frame receiver class theNonMetaclass)
"Created: / 25-10-2010 / 16:32:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_Reflection_getClassAccessFlags:aJavaContext
+ |class|
+
+ class := self reflection classForJavaClassObject:(aJavaContext argAt:1).
+ ^ 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>"
+!
+
+_Signal_findSignal:aJavaContext
+ | input signame |
+
+ input := Java as_ST_String: (aJavaContext argAt: 1).
+ signame := 'SIG', (input asUppercase).
+ ^ UnixOperatingSystem signalNamed: signame asSymbol.
+
+ "Created: / 11-12-2010 / 15:22:07 / Jan Kurs <kurs.jan@post.cz>"
+!
+
+_Signal_handle0:aJavaContext
+ self breakPoint: #libjava.
+ ^ 0.
+
+ "Created: / 11-12-2010 / 16:33:38 / Jan Kurs <kurs.jan@post.cz>"
+!
+
+_String_intern:nativeContext
+ |jString|
+
+ jString := nativeContext receiver.
+ ^ Java intern:jString
+!
+
+_System_arraycopy:nativeContext
+ |srcArray srcIdx dstArray dstIdx count dstEndIdx|
+
+ srcArray := nativeContext argAt:1.
+ srcArray isNil ifTrue:[
+ ^ self throwNullPointerException
+ ].
+ srcIdx := nativeContext argAt:2.
+ dstArray := nativeContext argAt:3.
+ dstArray isNil ifTrue:[
+ ^ self throwNullPointerException
+ ].
+ dstIdx := nativeContext argAt:4.
+ count := nativeContext argAt:5.
+
+ ((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:[
+ dstArray replaceFrom:dstIdx to:dstEndIdx with:srcArray startingAt:srcIdx.
+ ].
+ ^ nil.
+!
+
+_System_currentTimeMillis:nativeContext
+ "return the milliseconds since 1.jan.1970"
+
+ |delta|
+
+ "/ workaround win32 bug (use 01:01:01 as base)
+ delta := Timestamp now millisecondDeltaFrom:(AbsoluteTime day:1 month:1 year:1970 hour:1 minutes:1 seconds:1).
+ delta := delta - 3600 - 60 - 1.
+"/ "/ make certain, it fits 64 signed bits
+"/ delta := delta bitAnd:16r7FFFFFFFFFFFFFFF.
+"/ ^ delta max:0
+ ^ delta
+
+ "
+ JavaVM _System_currentTimeMillis:nil
+ "
+
+ "Modified: / 23.12.1998 / 21:54:50 / cg"
+!
+
+_System_initProperties:nativeContext
+ |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"
+!
+
+_System_mapLibraryName:aJavaContext
+
+ | 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>"
+!
+
+_System_registerNatives:aJavaContext
+
+ "Nothing to do, native method are bound lazily"
+
+ "Created: / 20-10-2010 / 10:56:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_System_setErr0:nativeContext
+ |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"
+!
+
+_System_setIn0:nativeContext
+ |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"
+!
+
+_System_setOut0:nativeContext
+ |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"
+!
+
+_Thread_currentThread:nativeMethodContext
+ |t p prio|
+
+ p := Processor activeProcess.
+ t := self javaThreadForSTProcess:p.
+ t notNil ifTrue:[
+ ^ t
+ ].
+ t := self newThread:'main'.
+ Java threads at:t put:p.
+ ^ t
+
+ "Created: / 3.1.1998 / 01:42:28 / cg"
+ "Modified: / 4.1.1998 / 14:59:13 / cg"
+!
+
+_Thread_holdsLock:aJavaContext
+
+ | obj |
+ obj := aJavaContext argAt: 1.
+
+ ^(self enteredMonitorsOfProcess:Processor activeProcess)
+ includes: obj.
+
+ "Created: / 30-04-2011 / 22:06:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_Thread_isAlive:nativeContext
+ "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"
+!
+
+_Thread_registerNatives:aJavaContext
+
+ "Nothing to do, native method are bound lazily"
+
+ "Created: / 20-10-2010 / 11:12:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_Thread_setPriority0:nativeMethodContext
+ |t p prio|
+
+ t := nativeMethodContext receiver.
+ p := JavaVM stProcessForJavaThread:t.
+ prio := nativeMethodContext argAt:1.
+
+ p isNil ifTrue:[
+ ThreadTrace == true ifTrue:[
+ 'JAVA [info]: no process yet (in setPriority)' infoPrintCR.
+ ].
+ ^ nil
+ ].
+
+ ThreadTrace ifTrue:[
+ 'JAVA [info]: setPrio: ' print. t print. ' pri= ' print. prio print. ' p= ' print. p printNL.
+ ].
+ ^ nil
+
+ "Created: / 2.1.1998 / 19:05:55 / cg"
+ "Modified: / 6.2.1998 / 02:28:18 / cg"
+!
+
+_Thread_start0:nativeContext
+
+ ^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>"
+!
+
+_Throwable_fillInStackTrace:nativeContext
+ |exClass exceptionObject list con|
+
+ exClass := Java classNamed:'java.lang.Throwable'.
+
+ exceptionObject := nativeContext receiver.
+
+ "/
+ "/ debugging only
+ "/
+ (exceptionObject isKindOf:(Java classNamed:'java.lang.Throwable')) ifFalse:[
+ self halt
+ ].
+
+ 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: / 4.1.1998 / 14:27:40 / cg"
+ "Modified: / 8.5.1998 / 21:29:53 / cg"
+!
+
+_UnixFileSystem_canonicalize0:aJavaContext
+
+ | path |
+
+ path := Java as_ST_String: (aJavaContext argAt: 1).
+ ^(Java as_String: path asFilename asAbsoluteFilename pathName)
+
+ "Created: / 10-12-2010 / 14:40:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_UnixFileSystem_getBooleanAttributes0:aJavaContext
+ |file path retval fileSystemClass|
+
+ retval := 0.
+ file := aJavaContext argAt:1.
+ path := Java as_ST_String:(file instVarNamed:#path).
+ fileSystemClass := (Java 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>"
+!
+
+_UnixFileSystem_getLastModifiedTime: aJavaContext
+ | file path retval |
+
+ retval := 0.
+ file := aJavaContext argAt: 1.
+ path := Java as_ST_String: (file instVarNamed: #path).
+ retval := path asFilename modificationTime asMilliseconds.
+ ^ retval
+
+ "Modified: / 10-12-2010 / 14:43:31 / Jan Kurs <kurs.jan@post.cz>"
+ "Modified: / 11-12-2010 / 19:44:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Created: / 27-03-2011 / 15:32:59 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+_UnixFileSystem_initIDs:aJavaContext
+
+ 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>"
+!
+
+_Unsafe_allocateMemory:aJavaContext
+
+ | 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>"
+!
+
+_Unsafe_compareAndSwapInt:aJavaContext
+ "
+ /**
+ * 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.
+ real := o instVarAt: offset.
+ (real == expected)
+ ifTrue:[o instVarAt: offset put: new. ok := true]
+ ifFalse:[ok := false].
+ OperatingSystem unblockInterrupts.
+ ^ok
+
+ "Created: / 22-11-2010 / 18:40:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 06-02-2011 / 12:10:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_Unsafe_ensureClassInitialized:aJavaContext
+ |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>"
+!
+
+_Unsafe_freeMemory:aJavaContext
+ | address |
+ address := aJavaContext argAt: 1.
+ ^SimulatedNativeMemory free: address
+
+ "Created: / 09-12-2010 / 17:56:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_Unsafe_getByte:aJavaContext
+
+ | address |
+ address := aJavaContext argAt: 1.
+ ^SimulatedNativeMemory byteAt: address
+
+ "Created: / 09-12-2010 / 17:29:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_Unsafe_objectFieldOffset:aJavaContext
+
+ | javaFieldObject |
+ javaFieldObject := aJavaContext argAt: 1.
+ ^javaFieldObject instVarNamed: #slot
+
+ "Created: / 22-11-2010 / 17:58:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_Unsafe_putLong:aJavaContext
+
+ | address value |
+ address := aJavaContext argAt: 1.
+ value := aJavaContext argAt: 3.
+ "3!!!!!! since at index 2 there is dummy long high word"
+ "Ask JV for more details"
+
+ SimulatedNativeMemory longAt: address put: value
+
+ "Created: / 07-12-2010 / 23:50:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 09-12-2010 / 17:31:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_Unsafe_registerNatives:aJavaContext
+
+ "Nothing to do, native method are bound lazily"
+
+ "Created: / 25-10-2010 / 16:14:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_VM_initialize:aJavaContext
+
+ "Nothing to do"
+
+ "Created: / 26-11-2010 / 18:43:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_ZipEntry_initFields: aJavaContext
+ | entry jzentry zmember |
+
+ entry := aJavaContext receiver.
+ jzentry := aJavaContext argAt: 1.
+ zmember := ZipEntryCache at: jzentry.
+
+ entry
+ instVarNamed: #time put: 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: / 29-04-2011 / 20:01:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_ZipEntry_initIDs: aJavaContext
+ "hopefully nothing to do"
+
+ "Created: / 01-04-2011 / 13:02:06 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+_ZipFile_freeEntry: javaContext
+ | zipArchiveIndex zipEntryIndex |
+
+
+ zipArchiveIndex := javaContext at: 1.
+ zipEntryIndex := javaContext at: 3.
+ zipEntryIndex = 0 ifFalse: [ ZipEntryCache at: zipEntryIndex put: nil ].
+
+ "Created: / 01-04-2011 / 13:06:19 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 01-04-2011 / 16:02:56 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+_ZipFile_getCSize:aJavaContext
+
+ | 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>"
+!
+
+_ZipFile_getEntry: javaContext
+ | zipArchive filename result |
+
+ zipArchive := ZipCache at: (javaContext at: 1).
+ filename := Java as_ST_String: (javaContext at: 3).
+ result := (zipArchive membersMatching: filename).
+ result size = 0
+ ifTrue: [ ^ 0 ]
+ ifFalse: [ ^ ZipEntryCache indexOf: (ZipEntryCache add: result first) ].
+
+ "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>"
+!
+
+_ZipFile_getMethod:aJavaContext
+
+ | 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>"
+!
+
+_ZipFile_getSize:aJavaContext
+
+ | 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>"
+!
+
+_ZipFile_getTotal: javaContext
+ | zipArchive |
+
+ zipArchive := ZipCache at: (javaContext at: 1).
+ ^ zipArchive entries size.
+
+ "Created: / 27-03-2011 / 16:29:51 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 01-04-2011 / 15:48:46 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+_ZipFile_initIDs:aJavaContext
+
+ "Nothing to do"
+
+ "Created: / 23-03-2011 / 19:37:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_ZipFile_open: javaContext
+ | path mode lastModTime result |
+
+ path := Java as_ST_String: (javaContext at: 1).
+ mode := javaContext at: 2.
+ lastModTime := javaContext at: 3.
+ result := path asFilename.
+ result ifNil: [ JavaVM throwZipException ].
+ ^ ZipCache
+ indexOf: ( ZipCache add: (ZipArchive readingFrom: result readStream) ).
+
+ "Modified: / 01-04-2011 / 15:35:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !
-!JavaVM class methodsFor:'native - sysresource'!
-
-_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
+!JavaVM class methodsFor:'native - sun.misc'!
+
+_sun_misc_Signal_findSignal: aJavaContext
+
+ <javanative: 'sun/misc/Signal' name: 'findSignal'>
+
+ | input signame |
+
+ input := Java as_ST_String: (aJavaContext argAt: 1).
+ signame := 'SIG', (input asUppercase).
+ ^ UnixOperatingSystem signalNamed: signame asSymbol.
+
+ "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_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_compareAndSwapInt: 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.
+ real := o instVarAt: offset.
+ (real == expected)
+ ifTrue:[o instVarAt: offset put: new. ok := true]
+ ifFalse:[ok := false].
+ OperatingSystem unblockInterrupts.
+ ^ok
+
+ "Created: / 22-11-2010 / 18:40:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 06-02-2011 / 12:10:34 / 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_getByte: aJavaContext
+
+ <javanative: 'sun/misc/Unsafe' name: 'getByte'>
+
+
+ | address |
+ address := aJavaContext argAt: 1.
+ ^SimulatedNativeMemory byteAt: address
+
+ "Created: / 09-12-2010 / 17:29:27 / 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_putLong: aJavaContext
+
+ <javanative: 'sun/misc/Unsafe' name: 'putLong'>
+
+
+ | address value |
+ address := aJavaContext argAt: 1.
+ value := aJavaContext argAt: 3.
+ "3!!!!!! since at index 2 there is dummy long high word"
+ "Ask JV for more details"
+
+ SimulatedNativeMemory longAt: address put: value
+
+ "Created: / 07-12-2010 / 23:50:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 09-12-2010 / 17:31:45 / 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_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>"
+! !
+
+!JavaVM class methodsFor:'native - sun.reflect'!
+
+_sun_reflect_NativeConstructorAccessorImpl_newInstance0: aJavaContext
+
+ <javanative: 'sun/reflect/NativeConstructorAccessorImpl' name: 'newInstance0'>
+
+
+ | ctor args method instance |
+ ctor := aJavaContext argAt: 1.
+ args := aJavaContext argAt: 2.
+ args ifNil:[args := #()] ifNotNil:[args := args asArray].
+ method := self reflection methodForJavaConstructorObject: ctor.
+ instance := method javaClass new.
+ method valueWithReceiver:instance arguments:args.
+ ^instance
+
+ "Created: / 26-11-2010 / 11:41:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 04-02-2011 / 18:47:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 09-02-2011 / 01:12:10 / Marcel Hlopko <hlopik@gmail.com>"
+!
+
+_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 |
+ m := nativeContext argAt: 1.
+ obj := nativeContext argAt: 2.
+ args := nativeContext argAt: 3.
+
+ ^(self reflection methodForJavaMethodObject: m)
+ valueWithReceiver: obj
+ arguments: (args ? #()) asArray.
+
+ "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: / 16-03-2011 / 15:31:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_sun_reflect_Reflection_getCallerClass: aJavaContext
+
+ <javanative: 'sun/reflect/Reflection' name: 'getCallerClass'>
+
+
+ | framesToSkip framesSkipped frame |
+ framesToSkip := aJavaContext argAt: 1.
+ framesSkipped := 0.
+ frame := aJavaContext.
+ [ framesSkipped == framesToSkip ] whileFalse:
+ [frame := frame sender.
+ framesSkipped := framesSkipped + 1].
+
+ ^JavaVM javaClassObjectForClass:
+ (frame receiver class theNonMetaclass)
+
+ "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 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>"
! !
!JavaVM class methodsFor:'semaphores & monitors'!
@@ -13127,6 +14714,10 @@
class := classOrClassRef javaClass.
+ | class |
+
+ class := classOrClassRef javaClass.
+
"
Java VM Spec, 3rd edition, p 280:
@@ -14425,3 +16016,4 @@
! !
JavaVM initialize!
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/LookupTests.st Sun May 01 12:52:23 2011 +0000
@@ -0,0 +1,63 @@
+"{ Package: 'stx:libjava' }"
+
+TestCase subclass:#LookupTests
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Languages-Java-Lookup-Tests'
+!
+
+
+!LookupTests class methodsFor:'resources'!
+
+resources
+ ^ Array with: JavaLookupTestsResource.
+
+ "Created: / 11-04-2011 / 19:38:11 / kursjan <kursjan@fit.cvut.cz>"
+! !
+
+!LookupTests methodsFor:'running'!
+
+test1
+ self shouldnt: [(Java classForName: 'java.lang.Object') new hash] raise: Exception.
+ self shouldnt: [(Java classForName: 'java.lang.Object') new toString] raise: Exception.
+
+ "Created: / 11-04-2011 / 19:22:07 / kursjan <kursjan@fit.cvut.cz>"
+!
+
+test2
+ self assert: (Java classForName: 'cz.cvut.fit.swing.methodLookup.Object') staticSayHello = 'static hello'.
+ self assert: (Java classForName: 'cz.cvut.fit.swing.methodLookup.Object') new sayHello = 'hello'.
+
+ "Created: / 11-04-2011 / 19:32:51 / kursjan <kursjan@fit.cvut.cz>"
+!
+
+test3
+ "I am not sure with this test :)"
+ self shouldnt: [(Java classForName: 'cz.cvut.fit.swing.methodLookup.Object') new isNumber] raise: Exception.
+ self assert: (Java classForName: 'cz.cvut.fit.swing.methodLookup.Object') new isNumber = false.
+
+ "Created: / 11-04-2011 / 19:43:37 / kursjan <kursjan@fit.cvut.cz>"
+!
+
+test4
+ "test multiple parameters"
+ self assert: ((Java classForName: 'cz.cvut.fit.swing.methodLookup.Object') new sayHello: 'Pepo' with: 10) = 'hello Pepo in age 10'.
+
+ "Created: / 11-04-2011 / 19:48:54 / kursjan <kursjan@fit.cvut.cz>"
+!
+
+test5
+ "test type overloading"
+ self assert: ((Java classForName: 'cz.cvut.fit.swing.methodLookup.Object') new sayHello: 'Pepo' with: 10) = 'hello Pepo in age 10'.
+ self shouldnt: [(Java classForName: 'cz.cvut.fit.swing.methodLookup.Object') new sayHello: 'Pepo' with: 'Tyno'] raise: Exception.
+ self assert: ((Java classForName: 'cz.cvut.fit.swing.methodLookup.Object') new sayHello: 'Pepo' with: 'Tyno') = 'hello Pepo and Tyno'.
+
+ "Created: / 11-04-2011 / 20:02:54 / kursjan <kursjan@fit.cvut.cz>"
+! !
+
+!LookupTests class methodsFor:'documentation'!
+
+version_SVN
+ ^ '$Id$'
+! !
--- a/src/Make.proto Mon Apr 25 19:32:44 2011 +0000
+++ b/src/Make.proto Sun May 01 12:52:23 2011 +0000
@@ -95,11 +95,13 @@
cd ../libview2 && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
cd ../libboss && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
cd ../goodies/sunit && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
+ cd ../goodies/xml/stx && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
cd ../libui && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
cd $(TOP)/../squeak/petitparser && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
cd ../libwidg && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
cd ../libhtml && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
cd ../libwidg2 && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
+ cd ../libwidg3 && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
cd ../libtool && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
cd ../librun && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
@@ -192,7 +194,6 @@
$(OUTDIR)JavaMethodWithException.$(O) JavaMethodWithException.$(H): JavaMethodWithException.st $(INCLUDE_TOP)/stx/libjava/JavaMethod.$(H) $(INCLUDE_TOP)/stx/libbasic/CompiledCode.$(H) $(INCLUDE_TOP)/stx/libbasic/ExecutableFunction.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
$(OUTDIR)JavaMethodref.$(O) JavaMethodref.$(H): JavaMethodref.st $(INCLUDE_TOP)/stx/libjava/JavaRef.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
$(OUTDIR)JavaParser.$(O) JavaParser.$(H): JavaParser.st $(INCLUDE_TOP)/squeak/petitparser/PPCompositeParser.$(H) $(INCLUDE_TOP)/squeak/petitparser/PPDelegateParser.$(H) $(INCLUDE_TOP)/squeak/petitparser/PPParser.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libjava/PPJavaNode.$(H) $(INCLUDE_TOP)/stx/libbasic/ReadStream.$(H) $(INCLUDE_TOP)/stx/libbasic/PositionableStream.$(H) $(INCLUDE_TOP)/stx/libbasic/PeekableStream.$(H) $(INCLUDE_TOP)/stx/libbasic/Stream.$(H) $(STCHDR)
-$(OUTDIR)JavaRefMock.$(O) JavaRefMock.$(H): JavaRefMock.st $(INCLUDE_TOP)/stx/libjava/JavaRef2.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
$(OUTDIR)JavaTypeNode.$(O) JavaTypeNode.$(H): JavaTypeNode.st $(INCLUDE_TOP)/stx/libjava/JavaNode.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
$(OUTDIR)JavaUnhandledExceptionError.$(O) JavaUnhandledExceptionError.$(H): JavaUnhandledExceptionError.st $(INCLUDE_TOP)/stx/libjava/JavaError.$(H) $(INCLUDE_TOP)/stx/libbasic/Error.$(H) $(INCLUDE_TOP)/stx/libbasic/Exception.$(H) $(INCLUDE_TOP)/stx/libbasic/GenericException.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
$(OUTDIR)JavaUnresolvedClassConstant.$(O) JavaUnresolvedClassConstant.$(H): JavaUnresolvedClassConstant.st $(INCLUDE_TOP)/stx/libjava/JavaUnresolvedConstant.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
@@ -211,7 +212,6 @@
$(OUTDIR)JavaFieldRef2.$(O) JavaFieldRef2.$(H): JavaFieldRef2.st $(INCLUDE_TOP)/stx/libjava/JavaClassContentRef2.$(H) $(INCLUDE_TOP)/stx/libjava/JavaRef2.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
$(OUTDIR)JavaFloatTypeNode.$(O) JavaFloatTypeNode.$(H): JavaFloatTypeNode.st $(INCLUDE_TOP)/stx/libjava/JavaTypeNode.$(H) $(INCLUDE_TOP)/stx/libjava/JavaNode.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
$(OUTDIR)JavaIntTypeNode.$(O) JavaIntTypeNode.$(H): JavaIntTypeNode.st $(INCLUDE_TOP)/stx/libjava/JavaTypeNode.$(H) $(INCLUDE_TOP)/stx/libjava/JavaNode.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
-$(OUTDIR)JavaInterfaceMethodRef2.$(O) JavaInterfaceMethodRef2.$(H): JavaInterfaceMethodRef2.st $(INCLUDE_TOP)/stx/libjava/JavaClassContentRef2.$(H) $(INCLUDE_TOP)/stx/libjava/JavaRef2.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
$(OUTDIR)JavaInterfaceMethodref.$(O) JavaInterfaceMethodref.$(H): JavaInterfaceMethodref.st $(INCLUDE_TOP)/stx/libjava/JavaMethodref.$(H) $(INCLUDE_TOP)/stx/libjava/JavaRef.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
$(OUTDIR)JavaLongTypeNode.$(O) JavaLongTypeNode.$(H): JavaLongTypeNode.st $(INCLUDE_TOP)/stx/libjava/JavaTypeNode.$(H) $(INCLUDE_TOP)/stx/libjava/JavaNode.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
$(OUTDIR)JavaMethodRef2.$(O) JavaMethodRef2.$(H): JavaMethodRef2.st $(INCLUDE_TOP)/stx/libjava/JavaClassContentRef2.$(H) $(INCLUDE_TOP)/stx/libjava/JavaRef2.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
@@ -220,6 +220,7 @@
$(OUTDIR)JavaUnresolvedMethodrefConstant.$(O) JavaUnresolvedMethodrefConstant.$(H): JavaUnresolvedMethodrefConstant.st $(INCLUDE_TOP)/stx/libjava/JavaUnresolvedRefConstant.$(H) $(INCLUDE_TOP)/stx/libjava/JavaUnresolvedConstant.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
$(OUTDIR)JavaVoidTypeNode.$(O) JavaVoidTypeNode.$(H): JavaVoidTypeNode.st $(INCLUDE_TOP)/stx/libjava/JavaTypeNode.$(H) $(INCLUDE_TOP)/stx/libjava/JavaNode.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
$(OUTDIR)JavaArrayClassPointerRef.$(O) JavaArrayClassPointerRef.$(H): JavaArrayClassPointerRef.st $(INCLUDE_TOP)/stx/libjava/JavaClassPointerRef.$(H) $(INCLUDE_TOP)/stx/libjava/JavaClassRef.$(H) $(INCLUDE_TOP)/stx/libjava/JavaRef.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
+$(OUTDIR)JavaInterfaceMethodRef2.$(O) JavaInterfaceMethodRef2.$(H): JavaInterfaceMethodRef2.st $(INCLUDE_TOP)/stx/libjava/JavaMethodRef2.$(H) $(INCLUDE_TOP)/stx/libjava/JavaClassContentRef2.$(H) $(INCLUDE_TOP)/stx/libjava/JavaRef2.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
$(OUTDIR)JavaNativeMethod.$(O) JavaNativeMethod.$(H): JavaNativeMethod.st $(INCLUDE_TOP)/stx/libjava/JavaMethodWithHandler.$(H) $(INCLUDE_TOP)/stx/libjava/JavaMethodWithException.$(H) $(INCLUDE_TOP)/stx/libjava/JavaMethod.$(H) $(INCLUDE_TOP)/stx/libbasic/CompiledCode.$(H) $(INCLUDE_TOP)/stx/libbasic/ExecutableFunction.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
$(OUTDIR)JavaUnresolvedInterfaceMethodrefConstant.$(O) JavaUnresolvedInterfaceMethodrefConstant.$(H): JavaUnresolvedInterfaceMethodrefConstant.st $(INCLUDE_TOP)/stx/libjava/JavaUnresolvedMethodrefConstant.$(H) $(INCLUDE_TOP)/stx/libjava/JavaUnresolvedRefConstant.$(H) $(INCLUDE_TOP)/stx/libjava/JavaUnresolvedConstant.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
$(OUTDIR)extensions.$(O): extensions.st $(INCLUDE_TOP)/stx/libbasic2/BooleanArray.$(H) $(INCLUDE_TOP)/stx/libbasic2/BitArray.$(H) $(INCLUDE_TOP)/stx/libbasic/ArrayedCollection.$(H) $(INCLUDE_TOP)/stx/libbasic/SequenceableCollection.$(H) $(INCLUDE_TOP)/stx/libbasic/Collection.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libbasic/ByteArray.$(H) $(INCLUDE_TOP)/stx/libbasic/UninterpretedBytes.$(H) $(INCLUDE_TOP)/stx/libbasic/DoubleArray.$(H) $(INCLUDE_TOP)/stx/libbasic/FloatArray.$(H) $(INCLUDE_TOP)/stx/libbasic/String.$(H) $(INCLUDE_TOP)/stx/libbasic/CharacterArray.$(H) $(INCLUDE_TOP)/stx/libbasic2/ZipArchive.$(H) $(INCLUDE_TOP)/stx/libbasic/Boolean.$(H) $(INCLUDE_TOP)/stx/libbasic/Character.$(H) $(INCLUDE_TOP)/stx/libbasic/Magnitude.$(H) $(INCLUDE_TOP)/stx/libbasic/Float.$(H) $(INCLUDE_TOP)/stx/libbasic/LimitedPrecisionReal.$(H) $(INCLUDE_TOP)/stx/libbasic/Number.$(H) $(INCLUDE_TOP)/stx/libbasic/ArithmeticValue.$(H) $(INCLUDE_TOP)/stx/libwidg/GenericToolbarIconLibrary.$(H) $(INCLUDE_TOP)/stx/libbasic/Integer.$(H) $(INCLUDE_TOP)/stx/libbasic2/IntegerArray.$(H) $(INCLUDE_TOP)/stx/libbasic2/UnboxedIntegerArray.$(H) $(INCLUDE_TOP)/stx/libbasic/LargeInteger.$(H) $(INCLUDE_TOP)/stx/libbasic2/LongIntegerArray.$(H) $(INCLUDE_TOP)/stx/libbasic/ShortFloat.$(H) $(INCLUDE_TOP)/stx/libbasic/UndefinedObject.$(H) $(INCLUDE_TOP)/stx/libbasic2/WordArray.$(H) $(STCHDR)
@@ -227,3 +228,4 @@
# ENDMAKEDEPEND --- do not remove this line
+
--- a/src/Make.spec Mon Apr 25 19:32:44 2011 +0000
+++ b/src/Make.spec Sun May 01 12:52:23 2011 +0000
@@ -127,7 +127,6 @@
JavaMethodWithException \
JavaMethodref \
JavaParser \
- JavaRefMock \
JavaTypeNode \
JavaUnhandledExceptionError \
JavaUnresolvedClassConstant \
@@ -146,7 +145,6 @@
JavaFieldRef2 \
JavaFloatTypeNode \
JavaIntTypeNode \
- JavaInterfaceMethodRef2 \
JavaInterfaceMethodref \
JavaLongTypeNode \
JavaMethodRef2 \
@@ -155,6 +153,7 @@
JavaUnresolvedMethodrefConstant \
JavaVoidTypeNode \
JavaArrayClassPointerRef \
+ JavaInterfaceMethodRef2 \
JavaNativeMethod \
JavaUnresolvedInterfaceMethodrefConstant \
@@ -239,7 +238,6 @@
$(OUTDIR)JavaMethodWithException.$(O) \
$(OUTDIR)JavaMethodref.$(O) \
$(OUTDIR)JavaParser.$(O) \
- $(OUTDIR)JavaRefMock.$(O) \
$(OUTDIR)JavaTypeNode.$(O) \
$(OUTDIR)JavaUnhandledExceptionError.$(O) \
$(OUTDIR)JavaUnresolvedClassConstant.$(O) \
@@ -258,7 +256,6 @@
$(OUTDIR)JavaFieldRef2.$(O) \
$(OUTDIR)JavaFloatTypeNode.$(O) \
$(OUTDIR)JavaIntTypeNode.$(O) \
- $(OUTDIR)JavaInterfaceMethodRef2.$(O) \
$(OUTDIR)JavaInterfaceMethodref.$(O) \
$(OUTDIR)JavaLongTypeNode.$(O) \
$(OUTDIR)JavaMethodRef2.$(O) \
@@ -267,6 +264,7 @@
$(OUTDIR)JavaUnresolvedMethodrefConstant.$(O) \
$(OUTDIR)JavaVoidTypeNode.$(O) \
$(OUTDIR)JavaArrayClassPointerRef.$(O) \
+ $(OUTDIR)JavaInterfaceMethodRef2.$(O) \
$(OUTDIR)JavaNativeMethod.$(O) \
$(OUTDIR)JavaUnresolvedInterfaceMethodrefConstant.$(O) \
$(OUTDIR)extensions.$(O) \
@@ -274,3 +272,4 @@
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/TestletTestCaseProxy.st Sun May 01 12:52:23 2011 +0000
@@ -0,0 +1,191 @@
+"{ Package: 'stx:libjava' }"
+
+TestCase subclass:#TestletTestCaseProxy
+ instanceVariableNames:''
+ classVariableNames:'TestCases'
+ poolDictionaries:''
+ category:'Languages-Java-JUnit'
+!
+
+TestletTestCaseProxy class instanceVariableNames:'javaClassName'
+
+"
+ The following class instance variables are inherited by this class:
+
+ TestCase - lastTestRunResultOrNil lastTestRunsPassedTests lastTestRunsFailedTests lastTestRunsErrorTests
+ TestAsserter -
+ Object -
+"
+!
+
+
+!TestletTestCaseProxy class methodsFor:'initialization'!
+
+initialize
+
+ TestCases := Dictionary new.
+
+ "Created: / 01-03-2011 / 10:43:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+setJavaClassName: aSymbol
+
+ javaClassName ifNotNil:
+ [self error: 'Attempting to set java class name twice'].
+ javaClassName := aSymbol.
+
+ "Created: / 01-03-2011 / 10:43:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!TestletTestCaseProxy class methodsFor:'accessing'!
+
+javaClass
+
+ ^Java at: javaClassName
+
+ "Created: / 01-03-2011 / 11:30:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 01-03-2011 / 14:48:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+javaClassName
+
+ ^javaClassName
+
+ "Created: / 01-03-2011 / 11:30:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+lookupHierarchyRoot
+ ^ TestletTestCaseProxy
+
+ "Created: / 01-03-2011 / 11:41:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 01-03-2011 / 14:54:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 29-04-2011 / 10:25:26 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+nameForHDTestReport
+
+ ^javaClassName copyReplaceAll:$/ with: $.
+
+ "Created: / 01-04-2011 / 16:10:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+selector: aSymbol
+
+ ^super selector: aSymbol
+
+ "Created: / 01-03-2011 / 11:55:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!TestletTestCaseProxy class methodsFor:'private'!
+
+testSelectors
+ "testlet always has only one test method, but maybe for the future.."
+ | javaClass |
+
+ self == TestletTestCaseProxy ifTrue: [ ^ #() ].
+ javaClass := self javaClass.
+ (javaClass includesBehavior: (JavaVM classForName: 'gnu.testlet.Testlet'))
+ ifTrue: [ ^ javaClass selectors select: [:sel | sel startsWith: 'test' ]. ]
+ ifFalse: [ ^ #() ].
+
+ "Created: / 01-03-2011 / 10:49:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 03-03-2011 / 00:34:39 / Marcel Hlopko <hlopik@gmail.com>"
+ "Modified: / 04-03-2011 / 00:05:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 29-04-2011 / 10:24:50 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!TestletTestCaseProxy class methodsFor:'queries'!
+
+isAbstract
+ ^ self == TestletTestCaseProxy
+
+ "Created: / 28-02-2011 / 22:32:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 01-03-2011 / 14:54:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 29-04-2011 / 10:21:51 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!TestletTestCaseProxy class methodsFor:'subclass creation'!
+
+for: javaClass
+ "Answers a new (anonymous) testcase proxy for
+ given javaClass"
+
+ | meta cls name |
+
+ self assert: javaClass isJavaClass description: 'Not a java class'.
+ self assert: javaClass isTestletLike
+ description: 'Not a testcase-like class'.
+ name := javaClass name.
+ TestCases at: name ifPresent: [:c | ^ c ].
+ meta := Metaclass new.
+ meta setSuperclass: TestletTestCaseProxy class.
+ meta instSize: TestletTestCaseProxy class instSize.
+ cls := meta new.
+ cls setSuperclass: TestletTestCaseProxy.
+ cls flags: TestletTestCaseProxy flags.
+ cls instSize: TestletTestCaseProxy instSize.
+ cls setJavaClassName: name.
+ cls
+ setName: ('TestletTestCase for: (Java classForName: ' , name storeString
+ , ')') asSymbol.
+ cls setCategory: javaClass category.
+ TestCases at: name put: cls.
+ ^ cls
+
+ "Created: / 01-03-2011 / 10:30:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 03-03-2011 / 00:20:49 / Marcel Hlopko <hlopik@gmail.com>"
+ "Modified: / 01-04-2011 / 16:02:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 29-04-2011 / 10:21:39 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!TestletTestCaseProxy methodsFor:'accessing'!
+
+javaClass
+
+ | javaClass |
+
+ self
+ assert: (javaClass := self class javaClass) isJavaClass
+ description: 'java class does not exists'.
+ ^javaClass
+
+ "Created: / 01-03-2011 / 14:48:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!TestletTestCaseProxy methodsFor:'private'!
+
+harnessMock
+ ^ (Java classForName: 'stx.libjava.tests.mocks.TestletHarnessMock') new.
+
+ "Modified: / 29-04-2011 / 10:52:53 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+performTest
+ | harnessMock |
+
+ harnessMock := self harnessMock.
+ [ self javaClass new perform: 'test(Lgnu/testlet/TestHarness;)V' sunitAsSymbol with: harnessMock ]
+ on: JavaError
+ do:
+ [:ex |
+ "This is the tricky part. We have to auto-magically convert
+ jUnit's AssertionFailedError to sUnits TestFailure's"
+ "Bad, bad, I know..."
+ (ex parameter class name == #'junit/framework/AssertionFailedError')
+ ifTrue: [ TestResult failure sunitSignalWith: ex description ]
+ ifFalse: [ ex pass ] ].
+ harnessMock instVarNamed: 'passed' = 0
+ ifTrue: [ TestResult failure sunitSignalWith: 'Test failed' ].
+
+ "Created: / 01-03-2011 / 14:50:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 04-03-2011 / 00:07:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 29-04-2011 / 17:39:41 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!TestletTestCaseProxy class methodsFor:'documentation'!
+
+version_SVN
+ ^ '$Id$'
+! !
+
+TestletTestCaseProxy initialize!
--- a/src/abbrev.stc Mon Apr 25 19:32:44 2011 +0000
+++ b/src/abbrev.stc Sun May 01 12:52:23 2011 +0000
@@ -14,15 +14,19 @@
JavaByteCodeProcessorTests JavaByteCodeProcessorTests stx:libjava 'Languages-Java-Tests' 4
JavaClassReader JavaClassReader stx:libjava 'Languages-Java-Support' 0
JavaClassReaderTests JavaClassReaderTests stx:libjava 'Languages-Java-Tests' 4
+JavaClassRefTests JavaClassRefTests stx:libjava 'Languages-Java-Tests-RuntimeConstantPool' 0
JavaConstantPool JavaConstantPool stx:libjava 'Languages-Java-Reader-Support' 0
-JavaConstantPoolsTests JavaConstantPoolsTests stx:libjava 'Languages-Java-Tests-RuntimeConstantPool' 4
+JavaConstantPoolsTests JavaConstantPoolsTests stx:libjava 'Languages-Java-Tests-RuntimeConstantPool' 0
JavaContext JavaContext stx:libjava 'Languages-Java-Support' 0
JavaDecompiler JavaDecompiler stx:libjava 'Languages-Java-Support-Decompiling' 0
JavaDescriptor JavaDescriptor stx:libjava 'Languages-Java-Support' 0
JavaError JavaError stx:libjava 'Languages-Java-Support' 1
JavaExceptionTableEntry JavaExceptionTableEntry stx:libjava 'Languages-Java-Support' 0
-JavaInitializedResource JavaInitializedResource stx:libjava 'Languages-Java-Tests' 1
-JavaJUnitTests JavaJUnitTests stx:libjava 'Languages-Java-Tests' 4
+JavaExceptionThrowerMock JavaExceptionThrowerMock stx:libjava 'Languages-Java-Tests-RuntimeConstantPool' 0
+JavaFieldRefTests JavaFieldRefTests stx:libjava 'Languages-Java-Tests-RuntimeConstantPool' 0
+JavaInitializedResource JavaInitializedResource stx:libjava 'Languages-Java-Tests' 0
+JavaInterfaceMethodRefTests JavaInterfaceMethodRefTests stx:libjava 'Languages-Java-Tests-RuntimeConstantPool' 0
+JavaJUnitTests JavaJUnitTests stx:libjava 'Languages-Java-Tests' 0
JavaJavadocNode JavaJavadocNode stx:libjava 'Languages-Java-AST' 0
JavaLanguage JavaLanguage stx:libjava 'Languages-Java-Support' 1
JavaLibraries JavaLibraries stx:libjava 'Languages-Java-Support' 0
@@ -30,7 +34,9 @@
JavaLocalVariableTable JavaLocalVariableTable stx:libjava 'Languages-Java-Support' 0
JavaLocalVariableTableEntry JavaLocalVariableTableEntry stx:libjava 'Languages-Java-Support' 0
JavaLookup JavaLookup stx:libjava 'Languages-Java-Lookup' 0
+JavaLookupTestsResource JavaLookupTestsResource stx:libjava 'Languages-Java-Lookup-Tests' 0
JavaMethod JavaMethod stx:libjava 'Languages-Java-Classes' 0
+JavaMethodRefTests JavaMethodRefTests stx:libjava 'Languages-Java-Tests-RuntimeConstantPool' 0
JavaNameAndType2 JavaNameAndType2 stx:libjava 'Languages-Java-Reader-Support-new' 0
JavaNameandType JavaNameandType stx:libjava 'Languages-Java-Reader-Support' 0
JavaNativeMemory JavaNativeMemory stx:libjava 'Languages-Java-Support' 0
@@ -38,31 +44,35 @@
JavaObject JavaObject stx:libjava 'Languages-Java-Classes' 0
JavaObjectDictionary JavaObjectDictionary stx:libjava 'Languages-Java-Support' 0
JavaParseResult JavaParseResult stx:libjava 'Languages-Java-Parser' 0
-JavaParserNavigationTests JavaParserNavigationTests stx:libjava 'Languages-Java-Tests' 4
-JavaParserTestCase JavaParserTestCase stx:libjava 'Languages-Java-Tests' 4
-JavaParserTests JavaParserTests stx:libjava 'Languages-Java-Tests' 4
+JavaParserNavigationTests JavaParserNavigationTests stx:libjava 'Languages-Java-Tests' 0
+JavaParserTestCase JavaParserTestCase stx:libjava 'Languages-Java-Tests' 0
+JavaParserTests JavaParserTests stx:libjava 'Languages-Java-Tests' 0
JavaPopUpView JavaPopUpView stx:libjava 'Languages-Java-Views-Support' 2
JavaProcess JavaProcess stx:libjava 'Languages-Java-Classes' 0
JavaRef JavaRef stx:libjava 'Languages-Java-Reader-Support' 0
JavaRef2 JavaRef2 stx:libjava 'Languages-Java-Reader-Support-new' 0
+JavaRefMock JavaRefMock stx:libjava 'Languages-Java-Tests-RuntimeConstantPool' 0
+JavaRefTests JavaRefTests stx:libjava 'Languages-Java-Tests-RuntimeConstantPool' 0
JavaRelease JavaRelease stx:libjava 'Languages-Java-Support' 0
JavaResolver JavaResolver stx:libjava 'Languages-Java-Reader-Support-new' 0
-JavaResolverTests JavaResolverTests stx:libjava 'Languages-Java-Tests-RuntimeConstantPool' 4
-JavaRuntimeConstantPoolTests JavaRuntimeConstantPoolTests stx:libjava 'Languages-Java-Tests-RuntimeConstantPool' 4
+JavaResolverTests JavaResolverTests stx:libjava 'Languages-Java-Tests-RuntimeConstantPool' 0
+JavaRuntimeConstantPoolTests JavaRuntimeConstantPoolTests stx:libjava 'Languages-Java-Tests-RuntimeConstantPool' 0
JavaSlotIndexCache JavaSlotIndexCache stx:libjava 'Languages-Java-Support' 0
JavaSourceCodeCache JavaSourceCodeCache stx:libjava 'Languages-Java-Support' 1
JavaSourceFileWriter JavaSourceFileWriter stx:libjava 'Languages-Java-Support' 0
JavaStartup JavaStartup stx:libjava 'Languages-Java-Support' 1
-JavaTestsResource JavaTestsResource stx:libjava 'Languages-Java-Tests' 3
+JavaTestsResource JavaTestsResource stx:libjava 'Languages-Java-Tests' 0
JavaTopView JavaTopView stx:libjava 'Languages-Java-Views-Support' 2
-JavaUTF8Tests JavaUTF8Tests stx:libjava 'Languages-Java-Tests' 4
+JavaUTF8Tests JavaUTF8Tests stx:libjava 'Languages-Java-Tests' 0
JavaUnresolvedConstant JavaUnresolvedConstant stx:libjava 'Languages-Java-Reader-Support' 0
JavaVM JavaVM stx:libjava 'Languages-Java-Support' 0
JavaView JavaView stx:libjava 'Languages-Java-Views-Support' 2
+LookupTests LookupTests stx:libjava 'Languages-Java-Lookup-Tests' 0
PPJavaNode PPJavaNode stx:libjava 'Languages-Java-AST' 0
Short Short stx:libjava 'Magnitude-Numbers' 0
SmalltalkAppletContext SmalltalkAppletContext stx:libjava 'Languages-Java-Views-Support' 0
SmalltalkAppletStub SmalltalkAppletStub stx:libjava 'Languages-Java-Views-Support' 0
+TestletTestCaseProxy TestletTestCaseProxy stx:libjava 'Languages-Java-JUnit' 5
stx_libjava stx_libjava stx:libjava '* Projects & Packages *' 4
JavaAnnotationArrayValue JavaAnnotationArrayValue stx:libjava 'Languages-Java-Reader-Support' 0
JavaAnnotationClassValue JavaAnnotationClassValue stx:libjava 'Languages-Java-Reader-Support' 0
@@ -77,26 +87,20 @@
JavaClassContentRef2 JavaClassContentRef2 stx:libjava 'Languages-Java-Reader-Support-new' 0
JavaClassRef JavaClassRef stx:libjava 'Languages-Java-Reader-Support' 0
JavaClassRef2 JavaClassRef2 stx:libjava 'Languages-Java-Reader-Support-new' 0
-JavaClassRefTests JavaClassRefTests stx:libjava 'Languages-Java-Tests-RuntimeConstantPool' 4
JavaEmbeddedFrameView JavaEmbeddedFrameView stx:libjava 'Languages-Java-Views-Support' 2
JavaField JavaField stx:libjava 'Languages-Java-Reader-Support' 0
JavaFieldAnnotationContainer JavaFieldAnnotationContainer stx:libjava 'Languages-Java-Annotations' 1
JavaFieldDescriptor JavaFieldDescriptor stx:libjava 'Languages-Java-Support' 0
-JavaFieldRefTests JavaFieldRefTests stx:libjava 'Languages-Java-Tests-RuntimeConstantPool' 4
JavaFieldref JavaFieldref stx:libjava 'Languages-Java-Reader-Support' 0
JavaFormalParameterNode JavaFormalParameterNode stx:libjava 'Languages-Java-AST' 0
-JavaInterfaceMethodRefTests JavaInterfaceMethodRefTests stx:libjava 'Languages-Java-Tests-RuntimeConstantPool' 4
JavaMethodAnnotationContainer JavaMethodAnnotationContainer stx:libjava 'Languages-Java-Annotations' 1
JavaMethodDeclarationNode JavaMethodDeclarationNode stx:libjava 'Languages-Java-AST' 0
JavaMethodDeclaratorNode JavaMethodDeclaratorNode stx:libjava 'Languages-Java-AST' 0
JavaMethodDescriptor JavaMethodDescriptor stx:libjava 'Languages-Java-Support' 0
JavaMethodNode JavaMethodNode stx:libjava 'Languages-Java-AST' 0
-JavaMethodRefTests JavaMethodRefTests stx:libjava 'Languages-Java-Tests-RuntimeConstantPool' 4
JavaMethodWithException JavaMethodWithException stx:libjava 'Languages-Java-Classes' 0
JavaMethodref JavaMethodref stx:libjava 'Languages-Java-Reader-Support' 0
JavaParser JavaParser stx:libjava 'Languages-Java-Parser' 0
-JavaRefMock JavaRefMock stx:libjava 'Languages-Java-Tests-RuntimeConstantPool' 0
-JavaRefTests JavaRefTests stx:libjava 'Languages-Java-Tests-RuntimeConstantPool' 4
JavaTypeNode JavaTypeNode stx:libjava 'Languages-Java-AST' 0
JavaUnhandledExceptionError JavaUnhandledExceptionError stx:libjava 'Languages-Java-Support' 1
JavaUnresolvedClassConstant JavaUnresolvedClassConstant stx:libjava 'Languages-Java-Reader-Support' 0
@@ -115,7 +119,6 @@
JavaFieldRef2 JavaFieldRef2 stx:libjava 'Languages-Java-Reader-Support-new' 0
JavaFloatTypeNode JavaFloatTypeNode stx:libjava 'Languages-Java-AST' 0
JavaIntTypeNode JavaIntTypeNode stx:libjava 'Languages-Java-AST' 0
-JavaInterfaceMethodRef2 JavaInterfaceMethodRef2 stx:libjava 'Languages-Java-Reader-Support-new' 0
JavaInterfaceMethodref JavaInterfaceMethodref stx:libjava 'Languages-Java-Reader-Support' 0
JavaLongTypeNode JavaLongTypeNode stx:libjava 'Languages-Java-AST' 0
JavaMethodRef2 JavaMethodRef2 stx:libjava 'Languages-Java-Reader-Support-new' 0
@@ -124,6 +127,8 @@
JavaUnresolvedMethodrefConstant JavaUnresolvedMethodrefConstant stx:libjava 'Languages-Java-Reader-Support' 0
JavaVoidTypeNode JavaVoidTypeNode stx:libjava 'Languages-Java-AST' 0
JavaArrayClassPointerRef JavaArrayClassPointerRef stx:libjava 'Languages-Java-Reader-Support' 0
+JavaInterfaceMethodRef2 JavaInterfaceMethodRef2 stx:libjava 'Languages-Java-Reader-Support-new' 0
JavaNativeMethod JavaNativeMethod stx:libjava 'Languages-Java-Classes' 0
JavaUnresolvedInterfaceMethodrefConstant JavaUnresolvedInterfaceMethodrefConstant stx:libjava 'Languages-Java-Reader-Support' 0
+
--- a/src/bc.mak Mon Apr 25 19:32:44 2011 +0000
+++ b/src/bc.mak Sun May 01 12:52:23 2011 +0000
@@ -53,11 +53,13 @@
pushd ..\libview2 & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
pushd ..\libboss & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
pushd ..\goodies\sunit & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
+ pushd ..\goodies\xml\stx & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
pushd ..\libui & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
pushd ..\..\squeak\petitparser & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
pushd ..\libwidg & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
pushd ..\libhtml & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
pushd ..\libwidg2 & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
+ pushd ..\libwidg3 & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
pushd ..\libtool & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
pushd ..\librun & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
@@ -142,7 +144,6 @@
$(OUTDIR)JavaMethodWithException.$(O) JavaMethodWithException.$(H): JavaMethodWithException.st $(INCLUDE_TOP)\stx\libjava\JavaMethod.$(H) $(INCLUDE_TOP)\stx\libbasic\CompiledCode.$(H) $(INCLUDE_TOP)\stx\libbasic\ExecutableFunction.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
$(OUTDIR)JavaMethodref.$(O) JavaMethodref.$(H): JavaMethodref.st $(INCLUDE_TOP)\stx\libjava\JavaRef.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
$(OUTDIR)JavaParser.$(O) JavaParser.$(H): JavaParser.st $(INCLUDE_TOP)\squeak\petitparser\PPCompositeParser.$(H) $(INCLUDE_TOP)\squeak\petitparser\PPDelegateParser.$(H) $(INCLUDE_TOP)\squeak\petitparser\PPParser.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libjava\PPJavaNode.$(H) $(INCLUDE_TOP)\stx\libbasic\ReadStream.$(H) $(INCLUDE_TOP)\stx\libbasic\PositionableStream.$(H) $(INCLUDE_TOP)\stx\libbasic\PeekableStream.$(H) $(INCLUDE_TOP)\stx\libbasic\Stream.$(H) $(STCHDR)
-$(OUTDIR)JavaRefMock.$(O) JavaRefMock.$(H): JavaRefMock.st $(INCLUDE_TOP)\stx\libjava\JavaRef2.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
$(OUTDIR)JavaTypeNode.$(O) JavaTypeNode.$(H): JavaTypeNode.st $(INCLUDE_TOP)\stx\libjava\JavaNode.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
$(OUTDIR)JavaUnhandledExceptionError.$(O) JavaUnhandledExceptionError.$(H): JavaUnhandledExceptionError.st $(INCLUDE_TOP)\stx\libjava\JavaError.$(H) $(INCLUDE_TOP)\stx\libbasic\Error.$(H) $(INCLUDE_TOP)\stx\libbasic\Exception.$(H) $(INCLUDE_TOP)\stx\libbasic\GenericException.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
$(OUTDIR)JavaUnresolvedClassConstant.$(O) JavaUnresolvedClassConstant.$(H): JavaUnresolvedClassConstant.st $(INCLUDE_TOP)\stx\libjava\JavaUnresolvedConstant.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
@@ -161,7 +162,6 @@
$(OUTDIR)JavaFieldRef2.$(O) JavaFieldRef2.$(H): JavaFieldRef2.st $(INCLUDE_TOP)\stx\libjava\JavaClassContentRef2.$(H) $(INCLUDE_TOP)\stx\libjava\JavaRef2.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
$(OUTDIR)JavaFloatTypeNode.$(O) JavaFloatTypeNode.$(H): JavaFloatTypeNode.st $(INCLUDE_TOP)\stx\libjava\JavaTypeNode.$(H) $(INCLUDE_TOP)\stx\libjava\JavaNode.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
$(OUTDIR)JavaIntTypeNode.$(O) JavaIntTypeNode.$(H): JavaIntTypeNode.st $(INCLUDE_TOP)\stx\libjava\JavaTypeNode.$(H) $(INCLUDE_TOP)\stx\libjava\JavaNode.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
-$(OUTDIR)JavaInterfaceMethodRef2.$(O) JavaInterfaceMethodRef2.$(H): JavaInterfaceMethodRef2.st $(INCLUDE_TOP)\stx\libjava\JavaClassContentRef2.$(H) $(INCLUDE_TOP)\stx\libjava\JavaRef2.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
$(OUTDIR)JavaInterfaceMethodref.$(O) JavaInterfaceMethodref.$(H): JavaInterfaceMethodref.st $(INCLUDE_TOP)\stx\libjava\JavaMethodref.$(H) $(INCLUDE_TOP)\stx\libjava\JavaRef.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
$(OUTDIR)JavaLongTypeNode.$(O) JavaLongTypeNode.$(H): JavaLongTypeNode.st $(INCLUDE_TOP)\stx\libjava\JavaTypeNode.$(H) $(INCLUDE_TOP)\stx\libjava\JavaNode.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
$(OUTDIR)JavaMethodRef2.$(O) JavaMethodRef2.$(H): JavaMethodRef2.st $(INCLUDE_TOP)\stx\libjava\JavaClassContentRef2.$(H) $(INCLUDE_TOP)\stx\libjava\JavaRef2.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
@@ -170,9 +170,11 @@
$(OUTDIR)JavaUnresolvedMethodrefConstant.$(O) JavaUnresolvedMethodrefConstant.$(H): JavaUnresolvedMethodrefConstant.st $(INCLUDE_TOP)\stx\libjava\JavaUnresolvedRefConstant.$(H) $(INCLUDE_TOP)\stx\libjava\JavaUnresolvedConstant.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
$(OUTDIR)JavaVoidTypeNode.$(O) JavaVoidTypeNode.$(H): JavaVoidTypeNode.st $(INCLUDE_TOP)\stx\libjava\JavaTypeNode.$(H) $(INCLUDE_TOP)\stx\libjava\JavaNode.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
$(OUTDIR)JavaArrayClassPointerRef.$(O) JavaArrayClassPointerRef.$(H): JavaArrayClassPointerRef.st $(INCLUDE_TOP)\stx\libjava\JavaClassPointerRef.$(H) $(INCLUDE_TOP)\stx\libjava\JavaClassRef.$(H) $(INCLUDE_TOP)\stx\libjava\JavaRef.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
+$(OUTDIR)JavaInterfaceMethodRef2.$(O) JavaInterfaceMethodRef2.$(H): JavaInterfaceMethodRef2.st $(INCLUDE_TOP)\stx\libjava\JavaMethodRef2.$(H) $(INCLUDE_TOP)\stx\libjava\JavaClassContentRef2.$(H) $(INCLUDE_TOP)\stx\libjava\JavaRef2.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
$(OUTDIR)JavaNativeMethod.$(O) JavaNativeMethod.$(H): JavaNativeMethod.st $(INCLUDE_TOP)\stx\libjava\JavaMethodWithHandler.$(H) $(INCLUDE_TOP)\stx\libjava\JavaMethodWithException.$(H) $(INCLUDE_TOP)\stx\libjava\JavaMethod.$(H) $(INCLUDE_TOP)\stx\libbasic\CompiledCode.$(H) $(INCLUDE_TOP)\stx\libbasic\ExecutableFunction.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
$(OUTDIR)JavaUnresolvedInterfaceMethodrefConstant.$(O) JavaUnresolvedInterfaceMethodrefConstant.$(H): JavaUnresolvedInterfaceMethodrefConstant.st $(INCLUDE_TOP)\stx\libjava\JavaUnresolvedMethodrefConstant.$(H) $(INCLUDE_TOP)\stx\libjava\JavaUnresolvedRefConstant.$(H) $(INCLUDE_TOP)\stx\libjava\JavaUnresolvedConstant.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
$(OUTDIR)extensions.$(O): extensions.st $(INCLUDE_TOP)\stx\libbasic2\BooleanArray.$(H) $(INCLUDE_TOP)\stx\libbasic2\BitArray.$(H) $(INCLUDE_TOP)\stx\libbasic\ArrayedCollection.$(H) $(INCLUDE_TOP)\stx\libbasic\SequenceableCollection.$(H) $(INCLUDE_TOP)\stx\libbasic\Collection.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libbasic\ByteArray.$(H) $(INCLUDE_TOP)\stx\libbasic\UninterpretedBytes.$(H) $(INCLUDE_TOP)\stx\libbasic\DoubleArray.$(H) $(INCLUDE_TOP)\stx\libbasic\FloatArray.$(H) $(INCLUDE_TOP)\stx\libbasic\String.$(H) $(INCLUDE_TOP)\stx\libbasic\CharacterArray.$(H) $(INCLUDE_TOP)\stx\libbasic2\ZipArchive.$(H) $(INCLUDE_TOP)\stx\libbasic\Boolean.$(H) $(INCLUDE_TOP)\stx\libbasic\Character.$(H) $(INCLUDE_TOP)\stx\libbasic\Magnitude.$(H) $(INCLUDE_TOP)\stx\libbasic\Float.$(H) $(INCLUDE_TOP)\stx\libbasic\LimitedPrecisionReal.$(H) $(INCLUDE_TOP)\stx\libbasic\Number.$(H) $(INCLUDE_TOP)\stx\libbasic\ArithmeticValue.$(H) $(INCLUDE_TOP)\stx\libwidg\GenericToolbarIconLibrary.$(H) $(INCLUDE_TOP)\stx\libbasic\Integer.$(H) $(INCLUDE_TOP)\stx\libbasic2\IntegerArray.$(H) $(INCLUDE_TOP)\stx\libbasic2\UnboxedIntegerArray.$(H) $(INCLUDE_TOP)\stx\libbasic\LargeInteger.$(H) $(INCLUDE_TOP)\stx\libbasic2\LongIntegerArray.$(H) $(INCLUDE_TOP)\stx\libbasic\ShortFloat.$(H) $(INCLUDE_TOP)\stx\libbasic\UndefinedObject.$(H) $(INCLUDE_TOP)\stx\libbasic2\WordArray.$(H) $(STCHDR)
# ENDMAKEDEPEND --- do not remove this line
+
--- a/src/builder/package.deps.rake Mon Apr 25 19:32:44 2011 +0000
+++ b/src/builder/package.deps.rake Sun May 01 12:52:23 2011 +0000
@@ -2,6 +2,14 @@
# Package dependencies.
# Automatically generated by project defintion.
+task "stx:libwidg3" => "stx:libview"
+task "stx:libwidg3" => "stx:libui"
+task "stx:libwidg3" => "stx:libview2"
+task "stx:libwidg3" => "stx:libwidg"
+task "stx:libwidg3" => "stx:libbasic2"
+task "stx:libwidg3" => "stx:libwidg2"
+task "stx:libwidg3" => "stx:libbasic"
+
task "stx:goodies/refactoryBrowser/parser" => "stx:libbasic"
@@ -32,17 +40,20 @@
task "stx:libhtml" => "stx:libview"
task "stx:libhtml" => "stx:libbasic"
+
+task "stx:libtool" => "stx:libwidg2"
+task "stx:libtool" => "stx:libbasic3"
task "stx:libtool" => "stx:goodies/refactoryBrowser/parser"
-task "stx:libtool" => "stx:libui"
-task "stx:libtool" => "stx:libview"
-task "stx:libtool" => "stx:libview2"
-task "stx:libtool" => "stx:libwidg"
+task "stx:libtool" => "stx:libcomp"
task "stx:libtool" => "stx:libbasic2"
-task "stx:libtool" => "stx:libwidg2"
+task "stx:libtool" => "stx:libui"
+task "stx:libtool" => "stx:libview2"
+task "stx:libtool" => "stx:libboss"
+task "stx:libtool" => "stx:goodies/xml/stx"
+task "stx:libtool" => "stx:libwidg"
task "stx:libtool" => "stx:libbasic"
-task "stx:libtool" => "stx:libbasic3"
-task "stx:libtool" => "stx:libboss"
-task "stx:libtool" => "stx:libcomp"
+task "stx:libtool" => "stx:libview"
+task "stx:libtool" => "stx:libwidg3"
task "stx:libcomp" => "stx:libbasic"
@@ -77,3 +88,4 @@
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java/libjava-projects/MethodLookupTests/.classpath Sun May 01 12:52:23 2011 +0000
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java/libjava-projects/MethodLookupTests/.project Sun May 01 12:52:23 2011 +0000
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>MethodLookupTests</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java/libjava-projects/MethodLookupTests/.settings/org.eclipse.jdt.core.prefs Sun May 01 12:52:23 2011 +0000
@@ -0,0 +1,12 @@
+#Mon Apr 11 19:26:01 CEST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java/libjava-projects/MethodLookupTests/build.xml Sun May 01 12:52:23 2011 +0000
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- WARNING: Eclipse auto-generated file.
+ Any modifications will be overwritten.
+ To include a user specific buildfile here, simply create one in the same
+ directory with the processing instruction <?eclipse.ant.import?>
+ as the first entry and export the buildfile again. -->
+<project basedir="." default="build" name="MethodLookupTests">
+ <property environment="env"/>
+ <property name="ECLIPSE_HOME" value="../../../../opt/eclipse_3_6"/>
+ <property name="debuglevel" value="source,lines,vars"/>
+ <property name="target" value="1.6"/>
+ <property name="source" value="1.6"/>
+ <path id="MethodLookupTests.classpath">
+ <pathelement location="bin"/>
+ </path>
+ <target name="init">
+ <mkdir dir="bin"/>
+ <copy includeemptydirs="false" todir="bin">
+ <fileset dir="src">
+ <exclude name="**/*.launch"/>
+ <exclude name="**/*.java"/>
+ </fileset>
+ </copy>
+ </target>
+ <target name="clean">
+ <delete dir="bin"/>
+ </target>
+ <target depends="clean" name="cleanall"/>
+ <target depends="build-subprojects,build-project" name="build"/>
+ <target name="build-subprojects"/>
+ <target depends="init" name="build-project">
+ <echo message="${ant.project.name}: ${ant.file}"/>
+ <javac debug="true" debuglevel="${debuglevel}" destdir="bin" source="${source}" target="${target}">
+ <src path="src"/>
+ <classpath refid="MethodLookupTests.classpath"/>
+ </javac>
+ </target>
+ <target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
+ <target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
+ <copy todir="${ant.library.dir}">
+ <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
+ </copy>
+ <unzip dest="${ant.library.dir}">
+ <patternset includes="jdtCompilerAdapter.jar"/>
+ <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
+ </unzip>
+ </target>
+ <target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
+ <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
+ <antcall target="build"/>
+ </target>
+</project>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java/libjava-projects/MethodLookupTests/src/cz/cvut/fit/swing/methodLookup/Object.java Sun May 01 12:52:23 2011 +0000
@@ -0,0 +1,19 @@
+package cz.cvut.fit.swing.methodLookup;
+
+public class Object
+{
+ public String sayHello()
+ {
+ return "hello";
+ }
+
+ public static String staticSayHello()
+ {
+ return "static hello";
+ }
+
+ public String sayHello(String name, Integer age)
+ {
+ return "hello " + name + " in age " + age;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java/libjava-tests/src/gnu/testlet/TestHarness.java Sun May 01 12:52:23 2011 +0000
@@ -0,0 +1,335 @@
+// Copyright (c) 1998, 1999, 2001 Cygnus Solutions
+// Written by Tom Tromey <tromey@cygnus.com>
+// Copyright (c) 2005 Mark J. Wielaard <mark@klomp.org>
+
+// This file is part of Mauve.
+
+// Mauve is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// Mauve is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Mauve; see the file COPYING. If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+package gnu.testlet;
+
+import java.awt.AWTException;
+import java.awt.Robot;
+
+import java.io.File;
+import java.io.Reader;
+import java.io.InputStream;
+
+/**
+ * This base class defines the API that test cases can report against. This
+ * code has been lifted from the Mauve project (and reformatted and
+ * commented).
+ */
+public abstract class TestHarness
+{
+ /**
+ * Records the result of a boolean check.
+ *
+ * @param result the result.
+ */
+ public abstract void check (boolean result);
+
+ /**
+ * Checks the two objects for equality and records the result of
+ * the check.
+ *
+ * @param result the actual result.
+ * @param expected the expected result.
+ */
+ public void check(Object result, Object expected)
+ {
+ boolean ok = (result == null ? expected == null : result.equals(expected));
+ check(ok);
+ // This debug message may be misleading, depending on whether
+ // string conversion produces same results for unequal objects.
+ if (! ok)
+ debug("got " + result + " but expected " + expected);
+ }
+
+ /**
+ * Checks two booleans for equality and records the result of the check.
+ *
+ * @param result the actual result.
+ * @param expected the expected result.
+ */
+ public void check(boolean result, boolean expected)
+ {
+ boolean ok = (result == expected);
+ check(ok);
+ if (! ok)
+ debug("got " + result + " but expected " + expected);
+ }
+
+ /**
+ * Checks two ints for equality and records the result of the check.
+ *
+ * @param result the actual result.
+ * @param expected the expected result.
+ */
+ public void check(int result, int expected)
+ {
+ boolean ok = (result == expected);
+ check(ok);
+ if (! ok)
+ debug("got " + result + " but expected " + expected);
+ }
+
+ /**
+ * Checks two longs for equality and records the result of the check.
+ *
+ * @param result the actual result.
+ * @param expected the expected result.
+ */
+ public void check(long result, long expected)
+ {
+ boolean ok = (result == expected);
+ check(ok);
+ if (! ok)
+ debug("got " + result + " but expected " + expected);
+ }
+
+ /**
+ * Checks two doubles for equality and records the result of the check.
+ *
+ * @param result the actual result.
+ * @param expected the expected result.
+ */
+ public void check(double result, double expected)
+ {
+ // This triple check overcomes the fact that == does not
+ // compare NaNs, and cannot tell between 0.0 and -0.0;
+ // and all without relying on java.lang.Double (which may
+ // itself be buggy - else why would we be testing it? ;)
+ // For 0, we switch to infinities, and for NaN, we rely
+ // on the identity in JLS 15.21.1 that NaN != NaN is true.
+ boolean ok = (result == expected ? (result != 0)
+ || (1 / result == 1 / expected)
+ : (result != result)
+ && (expected != expected));
+ check(ok);
+ if (! ok)
+ // If Double.toString() is buggy, this debug statement may
+ // accidentally show the same string for two different doubles!
+ debug("got " + result + " but expected " + expected);
+ }
+
+ /**
+ * Checks if <code>result</code> is equal to <code>expected</code> and
+ * take a rounding delta into account.
+ *
+ * @param result the actual result
+ * @param expected the expected value
+ * @param delta the rounding delta
+ */
+ public void check(double result, double expected, double delta)
+ {
+ boolean ok = true;
+ if (Double.isInfinite(expected))
+ {
+ if (result != expected)
+ ok = false;
+ }
+ else if (! (Math.abs(expected - result) <= delta))
+ ok = false;
+
+ check(ok);
+ if (! ok)
+ // If Double.toString() is buggy, this debug statement may
+ // accidentally show the same string for two different doubles!
+ debug("got " + result + " but expected " + expected);
+ }
+
+ // These methods are like the above, but checkpoint first.
+ public void check(boolean result, String name)
+ {
+ checkPoint(name);
+ check(result);
+ }
+
+ public void check(Object result, Object expected, String name)
+ {
+ checkPoint(name);
+ check(result, expected);
+ }
+
+ public void check(boolean result, boolean expected, String name)
+ {
+ checkPoint(name);
+ check(result, expected);
+ }
+
+ public void check(int result, int expected, String name)
+ {
+ checkPoint(name);
+ check(result, expected);
+ }
+
+ public void check(long result, long expected, String name)
+ {
+ checkPoint(name);
+ check(result, expected);
+ }
+
+ public void check(double result, double expected, String name)
+ {
+ checkPoint(name);
+ check(result, expected);
+ }
+
+ public Robot createRobot()
+ {
+ Robot r = null;
+
+ try
+ {
+ r = new Robot();
+ }
+ catch (AWTException e)
+ {
+ fail("TestHarness: couldn't create Robot: " + e.getMessage());
+ }
+
+ return r;
+ }
+
+ /**
+ * A convenience method that sets a checkpoint with the specified name
+ * then records a failed check.
+ *
+ * @param name the checkpoint name.
+ */
+ public void fail(String name)
+ {
+ checkPoint(name);
+ check(false);
+ }
+
+ // Given a resource name, return a Reader on it. Resource names are
+ // just like file names. They are relative to the top level Mauve
+ // directory, but '#' characters are used in place of directory
+ // separators.
+ public abstract Reader getResourceReader (String name);
+
+ public abstract InputStream getResourceStream (String name);
+
+ public abstract File getResourceFile (String name);
+
+ /**
+ * Records a check point. This can be used to mark a known place in a
+ * testlet. It is useful if you have a large number of tests -- it makes
+ * it easier to find a failing test in the source code.
+ *
+ * @param name the check point name.
+ */
+ public abstract void checkPoint (String name);
+
+ /**
+ * This will print a message when in verbose mode.
+ *
+ * @param message the message.
+ */
+ public abstract void verbose (String message);
+
+ /**
+ * Writes a message to the debug log.
+ *
+ * @param message the message.
+ */
+ public abstract void debug (String message);
+
+ /**
+ * Writes a message to the debug log with or without a newline.
+ *
+ * @param message the message.
+ * @param newline a flag to control whether or not a newline is added.
+ */
+ public abstract void debug (String message, boolean newline);
+ /**
+ * Writes a stack trace for the specified exception to a log.
+ *
+ * @param ex the exception.
+ */
+ public abstract void debug (Throwable ex);
+
+ /**
+ * Writes the contents of an array to the log.
+ *
+ * @param o the array of objects.
+ * @param desc the description.
+ */
+ public abstract void debug (Object[] o, String desc);
+
+ // Default config interface methods.
+ public String getSourceDirectory ()
+ {
+ return null;
+ }
+
+ public String getBuildDirectory ()
+ {
+ return null;
+ }
+
+ /**
+ * Provide a directory name for writing temporary files.
+ *
+ * @return The temporary directory name.
+ */
+
+ public String getTempDirectory ()
+ {
+ return null;
+ }
+
+ public String getPathSeparator ()
+ {
+ return null;
+ }
+
+ public String getSeparator ()
+ {
+ return null;
+ }
+
+ public String getMailHost ()
+ {
+ return null;
+ }
+ public String getAutoCompile()
+ {
+ return null;
+ }
+
+ public String getCpInstallDir()
+ {
+ return null;
+ }
+
+ public String getEcjJar()
+ {
+ return null;
+ }
+
+ public String getEmmaString()
+ {
+ return null;
+ }
+
+ public String getTestJava()
+ {
+ return null;
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java/libjava-tests/src/gnu/testlet/Testlet.java Sun May 01 12:52:23 2011 +0000
@@ -0,0 +1,7 @@
+package gnu.testlet;
+
+public interface Testlet
+{
+ // This runs the test.
+ public abstract void test (TestHarness harness);
+}
\ No newline at end of file
--- a/src/java/libjava-tests/src/stx/libjava/tests/Log4JTests.java Mon Apr 25 19:32:44 2011 +0000
+++ b/src/java/libjava-tests/src/stx/libjava/tests/Log4JTests.java Sun May 01 12:52:23 2011 +0000
@@ -14,14 +14,14 @@
public class Log4JTests extends TestCase {
public void testLoadAndLogSomething() {
- assertTrue("Test disabled since it crashes the VM (#9 bug)", false);
- /*
+ //assertTrue("Test disabled since it crashes the VM (#9 bug)", false);
+ /**/
BasicConfigurator.configure();
Logger logger = Logger.getRootLogger();
logger.debug("Sample debug message");
logger.error("Sample error message");
logger.fatal("Sample fatal message");
- */
+ /**/
}
@@ -40,3 +40,4 @@
}
}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java/libjava-tests/src/stx/libjava/tests/mocks/ClassWithInnerClasses.java Sun May 01 12:52:23 2011 +0000
@@ -0,0 +1,24 @@
+package stx.libjava.tests.mocks;
+
+public class ClassWithInnerClasses {
+
+ class Inner {
+ public String helloWorldFromInner() {
+ return "hello world from inner";
+ }
+ };
+
+ static class InnerStatic {
+ public String helloWorldFromInnerStatic() {
+ return "hello world from inner static";
+ }
+ };
+
+ public static InnerStatic getInnerStatic() {
+ return new InnerStatic();
+ }
+
+ public Inner getInner() {
+ return new Inner();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java/libjava-tests/src/stx/libjava/tests/mocks/ImplementorOfNonPublicInterface.java Sun May 01 12:52:23 2011 +0000
@@ -0,0 +1,27 @@
+package stx.libjava.tests.mocks;
+
+public class ImplementorOfNonPublicInterface implements NonPublicInterface{
+ @Override
+ public String publicMethod() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String abstractMethod() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String publicAbstractMethod() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String packagePrivateMethod() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java/libjava-tests/src/stx/libjava/tests/mocks/ImplementorOfPublicInterface.java Sun May 01 12:52:23 2011 +0000
@@ -0,0 +1,29 @@
+package stx.libjava.tests.mocks;
+
+public class ImplementorOfPublicInterface implements PublicInterface {
+
+ @Override
+ public String publicMethod() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String abstractMethod() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String publicAbstractMethod() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String packagePrivateMethod() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java/libjava-tests/src/stx/libjava/tests/mocks/NonPublicClass.java Sun May 01 12:52:23 2011 +0000
@@ -0,0 +1,36 @@
+package stx.libjava.tests.mocks;
+
+class NonPublicClass {
+
+ private String privateField;
+ protected String protectedField;
+ public String publicField;
+
+ private static String privateStaticField;
+ protected static String protectedStaticField;
+ public static String publicStaticField;
+
+ private static String privateStaticMethod() {
+ return "privateStatic";
+ }
+
+ protected static String protectedStaticMethod() {
+ return "protectedStatic";
+ }
+
+ public static String publicStaticMethod() {
+ return "publicStatic";
+ }
+
+ private String privateMethod() {
+ return "private";
+ }
+
+ protected String protectedMethod() {
+ return "protected";
+ }
+
+ public String publicMethod() {
+ return "public";
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java/libjava-tests/src/stx/libjava/tests/mocks/NonPublicInterface.java Sun May 01 12:52:23 2011 +0000
@@ -0,0 +1,13 @@
+package stx.libjava.tests.mocks;
+
+interface NonPublicInterface {
+
+
+ public String publicMethod();
+
+ abstract String abstractMethod();
+
+ public abstract String publicAbstractMethod();
+
+ String packagePrivateMethod();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java/libjava-tests/src/stx/libjava/tests/mocks/PublicClass.java Sun May 01 12:52:23 2011 +0000
@@ -0,0 +1,47 @@
+package stx.libjava.tests.mocks;
+
+
+public class PublicClass {
+
+ private String privateField;
+ protected String protectedField;
+ public String publicField;
+ String packagePrivateField;
+
+ private static String privateStaticField;
+ protected static String protectedStaticField;
+ public static String publicStaticField;
+ static String packagePrivateStaticField;
+
+ private static String privateStaticMethod() {
+ return "privateStatic";
+ }
+
+ protected static String protectedStaticMethod() {
+ return "protectedStatic";
+ }
+
+ public static String publicStaticMethod() {
+ return "publicStatic";
+ }
+
+ static String packagePrivateStaticMethod() {
+ return "packagePrivateStatic";
+ }
+
+ private String privateMethod() {
+ return "private";
+ }
+
+ protected String protectedMethod() {
+ return "protected";
+ }
+
+ public String publicMethod() {
+ return "public";
+ }
+
+ String packagePrivateMethod() {
+ return "packagePrivate";
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java/libjava-tests/src/stx/libjava/tests/mocks/PublicInterface.java Sun May 01 12:52:23 2011 +0000
@@ -0,0 +1,12 @@
+package stx.libjava.tests.mocks;
+
+public interface PublicInterface {
+
+ public String publicMethod();
+
+ abstract String abstractMethod();
+
+ public abstract String publicAbstractMethod();
+
+ String packagePrivateMethod();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java/libjava-tests/src/stx/libjava/tests/mocks/SubclassOfNonPublicClass.java Sun May 01 12:52:23 2011 +0000
@@ -0,0 +1,6 @@
+package stx.libjava.tests.mocks;
+
+
+public class SubclassOfNonPublicClass extends NonPublicClass {
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java/libjava-tests/src/stx/libjava/tests/mocks/SubclassOfPublicClass.java Sun May 01 12:52:23 2011 +0000
@@ -0,0 +1,5 @@
+package stx.libjava.tests.mocks;
+
+public class SubclassOfPublicClass extends PublicClass {
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java/libjava-tests/src/stx/libjava/tests/mocks/TestletHarnessMock.java Sun May 01 12:52:23 2011 +0000
@@ -0,0 +1,84 @@
+package stx.libjava.tests.mocks;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.Reader;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class TestletHarnessMock extends TestHarness {
+
+ private boolean passed;
+ private Testlet testlet;
+
+ public TestletHarnessMock(Testlet t, boolean verbose)
+ {
+ super();
+ testlet = t;
+ }
+
+ public void check(boolean result)
+ {
+ passed = result;
+ }
+
+ public boolean passed() {
+ return passed;
+ }
+
+ @Override
+ public Reader getResourceReader(String name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public InputStream getResourceStream(String name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public File getResourceFile(String name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void checkPoint(String name) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void verbose(String message) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void debug(String message) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void debug(String message, boolean newline) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void debug(Throwable ex) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void debug(Object[] o, String desc) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
--- a/src/libInit.cc Mon Apr 25 19:32:44 2011 +0000
+++ b/src/libInit.cc Sun May 01 12:52:23 2011 +0000
@@ -104,7 +104,6 @@
_JavaMethodWithException_Init(pass,__pRT__,snd);
_JavaMethodref_Init(pass,__pRT__,snd);
_JavaParser_Init(pass,__pRT__,snd);
-_JavaRefMock_Init(pass,__pRT__,snd);
_JavaTypeNode_Init(pass,__pRT__,snd);
_JavaUnhandledExceptionError_Init(pass,__pRT__,snd);
_JavaUnresolvedClassConstant_Init(pass,__pRT__,snd);
@@ -123,7 +122,6 @@
_JavaFieldRef2_Init(pass,__pRT__,snd);
_JavaFloatTypeNode_Init(pass,__pRT__,snd);
_JavaIntTypeNode_Init(pass,__pRT__,snd);
-_JavaInterfaceMethodRef2_Init(pass,__pRT__,snd);
_JavaInterfaceMethodref_Init(pass,__pRT__,snd);
_JavaLongTypeNode_Init(pass,__pRT__,snd);
_JavaMethodRef2_Init(pass,__pRT__,snd);
@@ -132,6 +130,7 @@
_JavaUnresolvedMethodrefConstant_Init(pass,__pRT__,snd);
_JavaVoidTypeNode_Init(pass,__pRT__,snd);
_JavaArrayClassPointerRef_Init(pass,__pRT__,snd);
+_JavaInterfaceMethodRef2_Init(pass,__pRT__,snd);
_JavaNativeMethod_Init(pass,__pRT__,snd);
_JavaUnresolvedInterfaceMethodrefConstant_Init(pass,__pRT__,snd);
@@ -139,3 +138,4 @@
__END_PACKAGE__();
}
+
--- a/src/libjava.rc Mon Apr 25 19:32:44 2011 +0000
+++ b/src/libjava.rc Sun May 01 12:52:23 2011 +0000
@@ -3,7 +3,7 @@
// automagically generated from the projectDefinition: stx_libjava.
//
VS_VERSION_INFO VERSIONINFO
- FILEVERSION 6,1,1053,1053
+ FILEVERSION 6,1,0,1
PRODUCTVERSION 6,1,2,1
FILEFLAGSMASK VS_FF_DEBUG | VS_FF_PRERELEASE
FILEFLAGS VS_FF_PRERELEASE | VS_FF_SPECIALBUILD
@@ -18,12 +18,12 @@
BEGIN
VALUE "CompanyName", "eXept Software AG\0"
VALUE "FileDescription", "Smalltalk/X Class library (LIB)\0"
- VALUE "FileVersion", "6.1.1053.1053\0"
+ VALUE "FileVersion", "6.1.0.1\0"
VALUE "InternalName", "stx:libjava\0"
VALUE "LegalCopyright", "Copyright Claus Gittinger 1988-2010\nCopyright eXept Software AG 1998-2010\0"
VALUE "ProductName", "Smalltalk/X\0"
VALUE "ProductVersion", "6.1.2.1\0"
- VALUE "ProductDate", "Fri, 08 Apr 2011 18:30:49 GMT\0"
+ VALUE "ProductDate", "Fri, 29 Apr 2011 15:57:34 GMT\0"
END
END
@@ -34,3 +34,4 @@
END
END
+
--- a/src/stx_libjava.st Mon Apr 25 19:32:44 2011 +0000
+++ b/src/stx_libjava.st Sun May 01 12:52:23 2011 +0000
@@ -69,6 +69,7 @@
^ #(
#'squeak:petitparser' "PPParser - superclass of JavaParser::BlockParser "
+ #'stx:goodies/sunit' "TestAsserter - superclass of JUnitTestCaseProxy "
#'stx:libbasic' "Object - superclass of JavaUnresolvedFieldrefConstant "
#'stx:libbasic2' "ZipArchive - referenced by Java class>>classSource:package:in: "
#'stx:libbasic3' "MessageTracer - referenced by JavaMethod>>setBreakPoint "
@@ -108,6 +109,7 @@
(JavaByteCodeProcessorTests autoload)
JavaClassReader
(JavaClassReaderTests autoload)
+ (JavaClassRefTests autoload)
JavaConstantPool
(JavaConstantPoolsTests autoload)
JavaContext
@@ -115,7 +117,10 @@
JavaDescriptor
JavaError
JavaExceptionTableEntry
+ (JavaExceptionThrowerMock autoload)
+ (JavaFieldRefTests autoload)
(JavaInitializedResource autoload)
+ (JavaInterfaceMethodRefTests autoload)
(JavaJUnitTests autoload)
JavaJavadocNode
JavaLanguage
@@ -124,7 +129,9 @@
JavaLocalVariableTable
JavaLocalVariableTableEntry
JavaLookup
+ (JavaLookupTestsResource autoload)
JavaMethod
+ (JavaMethodRefTests autoload)
JavaNameAndType2
JavaNameandType
JavaNativeMemory
@@ -139,6 +146,8 @@
JavaProcess
JavaRef
JavaRef2
+ (JavaRefMock autoload)
+ (JavaRefTests autoload)
JavaRelease
JavaResolver
(JavaResolverTests autoload)
@@ -153,10 +162,12 @@
JavaUnresolvedConstant
JavaVM
JavaView
+ (LookupTests autoload)
PPJavaNode
Short
SmalltalkAppletContext
SmalltalkAppletStub
+ (TestletTestCaseProxy autoload)
#'stx_libjava'
JavaAnnotationArrayValue
JavaAnnotationClassValue
@@ -171,26 +182,20 @@
JavaClassContentRef2
JavaClassRef
JavaClassRef2
- (JavaClassRefTests autoload)
JavaEmbeddedFrameView
JavaField
JavaFieldAnnotationContainer
JavaFieldDescriptor
- (JavaFieldRefTests autoload)
JavaFieldref
JavaFormalParameterNode
- (JavaInterfaceMethodRefTests autoload)
JavaMethodAnnotationContainer
JavaMethodDeclarationNode
JavaMethodDeclaratorNode
JavaMethodDescriptor
JavaMethodNode
- (JavaMethodRefTests autoload)
JavaMethodWithException
JavaMethodref
JavaParser
- JavaRefMock
- (JavaRefTests autoload)
JavaTypeNode
JavaUnhandledExceptionError
JavaUnresolvedClassConstant
@@ -209,7 +214,6 @@
JavaFieldRef2
JavaFloatTypeNode
JavaIntTypeNode
- JavaInterfaceMethodRef2
JavaInterfaceMethodref
JavaLongTypeNode
JavaMethodRef2
@@ -218,6 +222,7 @@
JavaUnresolvedMethodrefConstant
JavaVoidTypeNode
JavaArrayClassPointerRef
+ JavaInterfaceMethodRef2
JavaNativeMethod
JavaUnresolvedInterfaceMethodrefConstant
)
@@ -339,7 +344,7 @@
"Return a SVN revision number of myself.
This number is updated after a commit"
- ^ "$SVN-Revision:"'1063M'"$"
+ ^ "$SVN-Revision:"'1091M'"$"
! !
!stx_libjava class methodsFor:'file generation'!
@@ -366,3 +371,4 @@
^ '$Id$'
! !
+