--- a/JavaResolver.st Fri Feb 14 14:27:26 2014 +0100
+++ b/JavaResolver.st Wed Jan 28 03:12:08 2015 +0100
@@ -1,9 +1,9 @@
"
- COPYRIGHT (c) 1996-2011 by Claus Gittinger
+ COPYRIGHT (c) 1996-2015 by Claus Gittinger
New code and modifications done at SWING Research Group [1]:
- COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
+ COPYRIGHT (c) 2010-2015 by Jan Vrany, Jan Kurs and Marcel Hlopko
SWING Research Group, Czech Technical University in Prague
This software is furnished under a license and may be used
@@ -31,11 +31,11 @@
copyright
"
- COPYRIGHT (c) 1996-2011 by Claus Gittinger
+ COPYRIGHT (c) 1996-2015 by Claus Gittinger
New code and modifications done at SWING Research Group [1]:
- COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
+ COPYRIGHT (c) 2010-2015 by Jan Vrany, Jan Kurs and Marcel Hlopko
SWING Research Group, Czech Technical University in Prague
This software is furnished under a license and may be used
@@ -100,7 +100,7 @@
| result |
self validateClassRef: aJavaClassRef.
result := self
- lookupClassIfAlreadyResolved: aJavaClassRef javaClassName
+ lookupClassIfAlreadyResolved: aJavaClassRef javaClassNameOrPrimitiveTypeId
definedBy: aJavaClassRef classLoader.
"/ result notNil ifTrue:[
@@ -154,7 +154,7 @@
"Created: / 12-08-2011 / 22:19:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified (comment): / 03-10-2011 / 23:03:01 / m"
"Modified: / 01-12-2012 / 13:44:54 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 02-05-2013 / 01:21:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 05-10-2013 / 01:05:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!JavaResolver methodsFor:'class resolving helpers'!
@@ -176,6 +176,7 @@
checkPermissionsFrom: refOwner to: resolvedClass
refOwner hasMagicAccessRights ifTrue: [ ^ true ].
+ resolvedClass isJavaClass ifFalse:[ ^ true ].
(JavaDescriptor isJavaPrimitiveArrayName: resolvedClass javaName) ifTrue: [
^ true
].
@@ -191,6 +192,7 @@
"Modified (comment): / 09-10-2011 / 23:11:54 / Marcel Hlopko <hlopik@gmail.com>"
"Modified: / 23-08-2012 / 20:21:40 / m"
"Modified: / 30-11-2012 / 20:34:26 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 20-11-2013 / 16:07:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
loadUnresolvedClass: aJavaClassRef
@@ -273,7 +275,8 @@
equalsOrIsSubclassOf: aJavaMethodOrField javaClass
])
ifTrue: [ ^ true ].
- ((aJavaMethodOrField isPrivate not
+ ((
+ aJavaMethodOrField isPrivate not
and: [ resolvedJavaClass javaPackage = accessingJavaClass javaPackage ])
and: [ resolvedJavaClass classLoader = accessingJavaClass classLoader ])
ifTrue: [ ^ true ].
@@ -288,6 +291,7 @@
"Created: / 14-04-2011 / 14:19:33 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
"Modified (comment): / 09-10-2011 / 23:12:48 / Marcel Hlopko <hlopik@gmail.com>"
"Modified: / 18-11-2012 / 16:24:29 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified (format): / 15-09-2013 / 00:09:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!JavaResolver methodsFor:'exceptions'!
@@ -329,19 +333,26 @@
!JavaResolver methodsFor:'field resolving'!
-resolveFieldIndentifiedByRef: aJavaFieldRef
+resolveFieldIndentifiedByRef:aJavaFieldRef
| result class |
- self validateFieldRef: aJavaFieldRef.
- result := self lookupFieldIfAlreadyResolved: aJavaFieldRef.
- result ifNotNil: [ ^ result ].
- class := aJavaFieldRef classRef resolve: false.
- class ifNil: [ self error: 'should not happen - tell mh' ].
- result := class lookupFieldByNameAndType: aJavaFieldRef nameAndType.
- result ifNil: [ self throwNoSuchFieldException ].
+
+ self validateFieldRef:aJavaFieldRef.
+ result := self lookupFieldIfAlreadyResolved:aJavaFieldRef.
+ result notNil ifTrue:[
+ ^ result
+ ].
+ class := aJavaFieldRef classRef resolve:false.
+ class isNil ifTrue:[
+ self error:'should not happen - tell mh'
+ ].
+ result := class lookupFieldByNameAndType:aJavaFieldRef nameAndType.
+ result isNil ifTrue:[
+ self throwNoSuchFieldException
+ ].
(self
- checkPermissionsForField: result
- from: aJavaFieldRef classRef owner
- to: class) ifFalse: [ self throwIllegalAccessError ].
+ checkPermissionsForField:result
+ from:aJavaFieldRef classRef owner
+ to:class) ifFalse:[ self throwIllegalAccessError ].
^ result.
"
@@ -375,21 +386,29 @@
"Created: / 11-04-2011 / 21:15:20 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
"Modified: / 01-12-2012 / 13:45:41 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 04-08-2014 / 15:52:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
-resolveStaticFieldIndentifiedByRef: aJavaFieldRef
+resolveStaticFieldIndentifiedByRef:aJavaFieldRef
| result class |
- self validateFieldRef: aJavaFieldRef.
- result := self lookupFieldIfAlreadyResolved: aJavaFieldRef.
- result ifNotNil: [ ^ result ].
- class := aJavaFieldRef classRef resolve: false.
- class ifNil: [ self error: 'should not happen - tell mh' ].
- result := class lookupStaticFieldByNameAndType: aJavaFieldRef nameAndType.
- result ifNil: [ self throwNoSuchFieldException ].
+
+ self validateFieldRef:aJavaFieldRef.
+ result := self lookupFieldIfAlreadyResolved:aJavaFieldRef.
+ result notNil ifTrue:[
+ ^ result
+ ].
+ class := aJavaFieldRef classRef resolve:false.
+ class isNil ifTrue:[
+ self error:'should not happen - tell mh'
+ ].
+ result := class lookupStaticFieldByNameAndType:aJavaFieldRef nameAndType.
+ result isNil ifTrue:[
+ self throwNoSuchFieldException
+ ].
(self
- checkPermissionsForField: result
- from: aJavaFieldRef classRef owner
- to: class) ifFalse: [ self throwIllegalAccessError ].
+ checkPermissionsForField:result
+ from:aJavaFieldRef classRef owner
+ to:class) ifFalse:[ self throwIllegalAccessError ].
^ result.
"
@@ -423,6 +442,7 @@
"Created: / 28-04-2011 / 22:31:34 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
"Modified: / 01-12-2012 / 13:45:45 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 04-08-2014 / 15:52:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!JavaResolver methodsFor:'field resolving helpers'!
@@ -461,13 +481,13 @@
self validateInterfaceMethodRef: aJavaInterfaceMethodRef.
result := self
lookupInterfaceMethodIfAlreadyResolved: aJavaInterfaceMethodRef.
- result ifNotNil: [ ^ result ].
+ result notNil ifTrue: [ ^ result ].
class := aJavaInterfaceMethodRef classRef resolve: false.
- class ifNil: [ self error: 'should not happen - tell mh' ].
+ class isNil ifTrue: [ self error: 'should not happen - tell mh' ].
class isInterface ifFalse: [ self throwIncompatibleClassChangeError ].
result := class
lookupMethodByNameAndType: aJavaInterfaceMethodRef nameAndType.
- result ifNil: [ self throwNoSuchMethodError ].
+ result isNil ifTrue: [ self throwNoSuchMethodError ].
(self
checkPermissionsForMethod: result
from: aJavaInterfaceMethodRef classRef owner
@@ -495,6 +515,7 @@
loading constraints TiL1 = TiL2 for i = 0 to n (§5.3.4)."
"Modified: / 01-12-2012 / 13:46:09 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 09-11-2013 / 00:12:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!JavaResolver methodsFor:'interface method resolving helpers'!
@@ -519,16 +540,21 @@
!JavaResolver methodsFor:'method resolving'!
-resolveMethodIndentifiedByRef: aJavaMethodRef
+resolveMethodIndentifiedByRef:aJavaMethodRef
| result class |
- self validateMethodRef: aJavaMethodRef.
- result := self lookupMethodIfAlreadyResolved: aJavaMethodRef.
- result ifNotNil: [ ^ result ].
- class := aJavaMethodRef classRef resolve: false.
- class ifNil: [ self error: 'should not happen - tell mh' ].
+
+ self validateMethodRef:aJavaMethodRef.
+ result := self lookupMethodIfAlreadyResolved:aJavaMethodRef.
+ result notNil ifTrue:[
+ ^ result
+ ].
+ class := aJavaMethodRef classRef resolve:false.
+ class isNil ifTrue:[
+ self error:'should not happen - tell mh'
+ ].
"Array types responds to all method of class java.lang.Object"
- class isJavaArrayClass ifTrue: [
- class := JavaVM classForName: 'java.lang.Object'.
+ class isJavaArrayClass ifTrue:[
+ class := JavaVM classForName:'java.lang.Object'.
].
"
To resolve an unresolved symbolic reference from D to a method in
@@ -542,7 +568,9 @@
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 ].
+ 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
@@ -559,15 +587,17 @@
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 := class lookupMethodByNameAndType:aJavaMethodRef nameAndType.
+ result isNil ifTrue:[
+ self throwNoSuchMethodError
+ ].
(result isAbstract
- and: [ result javaClass isInterface not and: [ class isAbstract not ] ])
- ifTrue: [ self throwAbstractMethodError ].
+ and:[ result javaClass isInterface not and:[ class isAbstract not ] ])
+ ifTrue:[ self throwAbstractMethodError ].
(self
- checkPermissionsForMethod: result
- from: aJavaMethodRef classRef owner
- to: class) ifFalse: [ self throwIllegalAccessError ].
+ 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
@@ -578,8 +608,8 @@
"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>"
- "Modified: / 10-08-2011 / 22:44:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified (format): / 01-12-2012 / 13:46:25 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 04-08-2014 / 15:55:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!JavaResolver methodsFor:'method resolving helpers'!
@@ -618,7 +648,7 @@
!JavaResolver class methodsFor:'documentation'!
version_CVS
- ^ '$Header: /cvs/stx/stx/libjava/JavaResolver.st,v 1.6 2013-09-06 00:41:26 vrany Exp $'
+ ^ '$Header: /cvs/stx/stx/libjava/JavaResolver.st,v 1.7 2015-01-28 02:10:50 vrany Exp $'
!
version_HG
@@ -627,7 +657,7 @@
!
version_SVN
- ^ '§Id§'
+ ^ 'Id'
! !