JavaResolver.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 16 Sep 2013 14:09:52 +0100
branchdevelopment
changeset 2734 f56049613ff3
parent 2732 7d1a1fb5b01a
child 2794 cec025d0f359
permissions -rw-r--r--
Initial support for live code checker / lint. JavaLintService parses the code as you type and displays all errors and other problems. This is done by running compiler in check mode in background. This also removes the necessity for JavaCompilerProblemRegistry.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     1
"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     2
 COPYRIGHT (c) 1996-2011 by Claus Gittinger
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
     3
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
     4
 New code and modifications done at SWING Research Group [1]:
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
     5
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     6
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     7
                            SWING Research Group, Czech Technical University in Prague
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     8
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     9
 This software is furnished under a license and may be used
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    10
 only in accordance with the terms of that license and with the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    11
 inclusion of the above copyright notice.   This software may not
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    12
 be provided or otherwise made available to, or used by, any
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    13
 other person.  No title to or ownership of the software is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    14
 hereby transferred.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    15
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
    16
 [1] Code written at SWING Research Group contains a signature
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
    17
     of one of the above copright owners. For exact set of such code,
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
    18
     see the differences between this version and version stx:libjava
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
    19
     as of 1.9.2010
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    20
"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    21
"{ Package: 'stx:libjava' }"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    22
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    23
Object subclass:#JavaResolver
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    24
	instanceVariableNames:'exceptionThrower'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    25
	classVariableNames:'uniqueInstance'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    26
	poolDictionaries:''
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    27
	category:'Languages-Java-Reader-Support-new'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    28
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    29
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    30
!JavaResolver class methodsFor:'documentation'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    31
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    32
copyright
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    33
"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    34
 COPYRIGHT (c) 1996-2011 by Claus Gittinger
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
    35
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
    36
 New code and modifications done at SWING Research Group [1]:
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
    37
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    38
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    39
                            SWING Research Group, Czech Technical University in Prague
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    40
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    41
 This software is furnished under a license and may be used
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    42
 only in accordance with the terms of that license and with the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    43
 inclusion of the above copyright notice.   This software may not
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    44
 be provided or otherwise made available to, or used by, any
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    45
 other person.  No title to or ownership of the software is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    46
 hereby transferred.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    47
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
    48
 [1] Code written at SWING Research Group contains a signature
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
    49
     of one of the above copright owners. For exact set of such code,
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
    50
     see the differences between this version and version stx:libjava
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
    51
     as of 1.9.2010
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    52
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    53
"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    54
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    55
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    56
!JavaResolver class methodsFor:'initialization'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    57
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    58
initialize
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    59
    uniqueInstance := JavaResolver new.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    60
    uniqueInstance exceptionThrower: JavaVM.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    61
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    62
    "/has methods at: and at: put: 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    63
    "/uniqueInstance resolvedClasses: Java.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    64
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    65
    "Modified: / 10-04-2011 / 10:23:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    66
    "Modified: / 13-04-2011 / 14:07:35 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    67
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    68
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    69
!JavaResolver class methodsFor:'instance creation'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    70
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    71
uniqueInstance
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    72
    ^uniqueInstance.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    73
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    74
    "Created: / 08-04-2011 / 17:36:37 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    75
    "Modified: / 11-04-2011 / 19:06:49 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    76
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    77
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    78
!JavaResolver methodsFor:'accessing'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    79
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    80
exceptionThrower
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    81
    ^ exceptionThrower
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    82
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    83
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    84
exceptionThrower:something
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    85
    exceptionThrower := something.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    86
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    87
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    88
!JavaResolver methodsFor:'class resolving'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    89
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    90
checkIfPrimitiveArrayRef: aJavaClassRef andWrap: result 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    91
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    92
    ^ (JavaDescriptor readFromString: aJavaClassRef name) javaClass.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    93
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    94
    "Created: / 23-05-2011 / 21:12:04 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    95
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    96
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    97
resolveClassIndentifiedByRef: aJavaClassRef init: doInit 
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
    98
    "marcel is back working harder then ever :)"
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
    99
    
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   100
    | result |
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   101
    self validateClassRef: aJavaClassRef.
2678
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2396
diff changeset
   102
    result := self 
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2396
diff changeset
   103
         lookupClassIfAlreadyResolved: aJavaClassRef javaClassName
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2396
diff changeset
   104
         definedBy: aJavaClassRef classLoader.
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   105
            
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   106
"/        result notNil ifTrue:[ 
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   107
"/            "/wrap result with array(s) if needed and return it
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   108
"/            "/FIXME: Marcel, can you have a look? Is that correct?
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   109
"/            ^self checkIfArrayRef: aJavaClassRef andWrap: result.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   110
"/        ].
2678
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2396
diff changeset
   111
    "
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   112
     To resolve an unresolved symbolic reference from D to a class or interface C denoted by N,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   113
     the following steps are performed:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   114
     The defining class loader of D is used to create a class or interface denoted by N.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   115
     This class or interface is C. Any exception that can be thrown as a result of failure
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   116
     of class or interface creation can thus be thrown as a result of failure of class and
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   117
     interface resolution. The details of the process are given in Section 5.3.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   118
    "
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   119
    result isNil ifTrue: [
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   120
        JavaClassReader classLoaderQuerySignal answer: (aJavaClassRef classLoader)
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   121
            do: [
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   122
                "#loadUnresolvedClass: wraps the class!!!!!!"
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   123
                result := self loadUnresolvedClass: aJavaClassRef.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   124
                ((aJavaClassRef name first == $[) and: [ result isJavaArrayClass not ]) ifTrue: [
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   125
                    self breakPoint: #jv.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   126
                ]
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   127
            ].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   128
    ] ifFalse: [ result := self checkIfArrayRef: aJavaClassRef andWrap: result. ].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   129
    result isNil ifTrue: [ self breakPoint: #mh ].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   130
    result isJavaPrimitiveType ifTrue: [
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   131
        ^ self checkIfPrimitiveArrayRef: aJavaClassRef andWrap: result
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   132
    ].
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   133
    (doInit and: [ result isJavaClass and: [ result isJavaArrayClass not ] ]) ifTrue: [
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   134
        result classInit
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   135
    ].
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   136
     "
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   137
     If C is an array class and its element type is a reference type, then the symbolic reference
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   138
     to the class or interface representing the element type is resolved by invoking the algorithm
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   139
     in Section 5.4.3.1 recursively.""Finally, access permissions to C are checked:
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   140
     If C is not accessible (5.4.4) to D, class or interface resolution throws an IllegalAccessError.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   141
     This condition can occur, for example, if C is a class that was originally declared to be
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   142
     public but was changed to be non-public after D was compiled.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   143
     
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   144
     If steps 1 and 2 succeed but step 3 fails, C is still valid and usable. Nevertheless, resolution
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   145
     fails, and D is prohibited from accessing C." 
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   146
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   147
    (self checkPermissionsFrom: aJavaClassRef owner to: result) ifFalse: [
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   148
        self throwIllegalAccessError. 
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   149
        ^nil.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   150
    ].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   151
    ^result
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   152
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   153
    "Created: / 11-04-2011 / 19:07:19 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   154
    "Created: / 12-08-2011 / 22:19:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   155
    "Modified (comment): / 03-10-2011 / 23:03:01 / m"
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   156
    "Modified: / 01-12-2012 / 13:44:54 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
2678
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2396
diff changeset
   157
    "Modified: / 02-05-2013 / 01:21:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   158
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   159
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   160
!JavaResolver methodsFor:'class resolving helpers'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   161
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   162
checkIfArrayRef: aJavaClassRef andWrap: nonArrayClass 
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   163
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   164
    "/wrap result with array(s) if needed and return it
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   165
    | class|    
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   166
    class := nonArrayClass.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   167
    aJavaClassRef name do:[:c|
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   168
        c ~~ $[ ifTrue:[ ^ class ].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   169
        class := class javaArrayClass.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   170
    ].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   171
    ^class
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   172
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   173
    "Modified: / 11-04-2011 / 19:31:43 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   174
    "Modified: / 23-10-2011 / 23:46:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   175
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   176
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   177
checkPermissionsFrom: refOwner to: resolvedClass    
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   178
    refOwner hasMagicAccessRights ifTrue: [ ^ true ].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   179
    (JavaDescriptor isJavaPrimitiveArrayName: resolvedClass javaName) ifTrue: [
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   180
        ^ true
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   181
    ].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   182
    resolvedClass isPublic ifTrue: [ ^ true ].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   183
    resolvedClass classLoader = refOwner classLoader ifFalse: [ ^ false. ].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   184
    refOwner javaPackage = resolvedClass javaPackage ifTrue: [ ^ true ].
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   185
    
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   186
    "/a little bit too verbose here just so it's clear what's in query
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   187
    
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   188
    JavaVM privilegedAccessQuery query ifTrue: [ ^ true ] ifFalse: [ ^ false ].
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   189
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   190
    "Created: / 11-04-2011 / 19:35:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   191
    "Modified (comment): / 09-10-2011 / 23:11:54 / Marcel Hlopko <hlopik@gmail.com>"
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   192
    "Modified: / 23-08-2012 / 20:21:40 / m"
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   193
    "Modified: / 30-11-2012 / 20:34:26 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   194
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   195
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   196
loadUnresolvedClass: aJavaClassRef 
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   197
    | nm cls i |
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   198
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   199
    nm := aJavaClassRef name.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   200
    nm size == 1 ifTrue:[ 
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   201
        JavaDescriptor baseTypes at: nm first ifPresent: [:cls | ^ cls ] 
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   202
    ].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   203
    "Note, that JavaVM>>classForName: itself deals with class loaders.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   204
     The caller of me should set one using code like:
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   205
     
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   206
     JavaClassReader classLoaderQuerySignal answer: loader do:[call me]     
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   207
    "
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   208
    cls := JavaVM classForName: nm.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   209
    (nm startsWith:$[) ifTrue:[
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   210
        i := 1.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   211
        [ (nm at:i) == $[ ] whileTrue:[
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   212
            cls := cls javaArrayClass.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   213
            i := i + 1.                                        
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   214
        ].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   215
        self assert: (nm at:i) == $L.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   216
    ].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   217
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   218
    ^cls.
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   219
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   220
    "Created: / 11-04-2011 / 19:27:10 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   221
    "Modified: / 23-05-2011 / 21:06:25 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   222
    "Modified: / 29-02-2012 / 09:20:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   223
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   224
2678
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2396
diff changeset
   225
lookupClassIfAlreadyResolved: javaClassName definedBy: classLoader
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2396
diff changeset
   226
    ^ JavaVM classNamed: javaClassName definedBy: classLoader
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   227
2678
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2396
diff changeset
   228
    "Created: / 02-05-2013 / 01:20:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   229
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   230
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   231
validateClassRef: aJavaClassRef 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   232
    self assert: aJavaClassRef isJavaRef.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   233
    self assert: aJavaClassRef isJavaClassRef .
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   234
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   235
    "Modified: / 23-05-2011 / 21:04:00 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   236
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   237
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   238
!JavaResolver methodsFor:'common helpers'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   239
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   240
checkPermissionsForMethodOrField: aJavaMethodOrField from: accessingJavaClass to: resolvedJavaClass 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   241
    "A class or interface C is accessible to a class or interface D if 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   242
     and only if either of the following conditions are true:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   243
     C is public.
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   244
     C and D are members of the same runtime package (§5.3).
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   245
     A field or method R is accessible to a class or interface D if and only
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   246
     if any of the following conditions is true:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   247
     R is public.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   248
     R is protected and is declared in a class C, and D is either a subclass
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   249
     of C or C itself.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   250
     R is either protected or package private (that is, neither public nor
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   251
     protected nor private), and is declared by a class in the same runtime
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   252
     package as D.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   253
     R is private and is declared in D.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   254
     This discussion of access control omits a related restriction on the target
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   255
     of a protected field access or method invocation (the target must be of class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   256
     D or a subtype of D). That requirement is checked as part of the verification
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   257
     process (§5.4.1); it is not part of link-time access control."
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   258
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   259
    accessingJavaClass hasMagicAccessRights ifTrue: [ ^true ].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   260
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   261
    (self checkPermissionsFrom: accessingJavaClass to: resolvedJavaClass) ifFalse: [
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   262
        JavaVM privilegedAccessQuery query ifTrue: [ ^ true ].
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   263
        ^ false
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   264
    ].
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   265
    aJavaMethodOrField isPublic ifTrue: [ ^ true ].
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   266
    ((aJavaMethodOrField isProtected 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   267
        and: [
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   268
            resolvedJavaClass javaComponentClass 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   269
                equalsOrIsSubclassOf: aJavaMethodOrField javaClass
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   270
        ]) 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   271
            and: [
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   272
                accessingJavaClass javaComponentClass 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   273
                    equalsOrIsSubclassOf: aJavaMethodOrField javaClass
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   274
            ]) 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   275
            ifTrue: [ ^ true ].
2730
272689c14005 Fixed removing of Java classes (issue #40)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2578
diff changeset
   276
    ((
272689c14005 Fixed removing of Java classes (issue #40)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2578
diff changeset
   277
    aJavaMethodOrField isPrivate not 
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   278
        and: [ resolvedJavaClass javaPackage = accessingJavaClass javaPackage ]) 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   279
            and: [ resolvedJavaClass classLoader = accessingJavaClass classLoader ]) 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   280
            ifTrue: [ ^ true ].
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   281
    (aJavaMethodOrField isPrivate 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   282
        and: [ aJavaMethodOrField javaClass name = accessingJavaClass name ]) 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   283
            ifTrue: [ ^ true ].
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   284
    
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   285
    "/a little bit too verbose here just so it's clear what's in query
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   286
    
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   287
    JavaVM privilegedAccessQuery query ifTrue: [ ^ true ] ifFalse: [ ^ false ].
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   288
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   289
    "Created: / 14-04-2011 / 14:19:33 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   290
    "Modified (comment): / 09-10-2011 / 23:12:48 / Marcel Hlopko <hlopik@gmail.com>"
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   291
    "Modified: / 18-11-2012 / 16:24:29 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
2730
272689c14005 Fixed removing of Java classes (issue #40)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2578
diff changeset
   292
    "Modified (format): / 15-09-2013 / 00:09:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   293
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   294
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   295
!JavaResolver methodsFor:'exceptions'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   296
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   297
throwAbstractMethodError
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   298
    exceptionThrower throwAbstractMethodError.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   299
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   300
    "Created: / 11-04-2011 / 20:19:42 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   301
    "Modified: / 13-04-2011 / 14:07:46 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   302
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   303
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   304
throwIllegalAccessError
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   305
    exceptionThrower throwIllegalAccessError.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   306
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   307
    "Created: / 11-04-2011 / 19:39:16 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   308
    "Modified: / 13-04-2011 / 23:06:58 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   309
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   310
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   311
throwIncompatibleClassChangeError
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   312
    exceptionThrower throwIncompatibleClassChangeError.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   313
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   314
    "Created: / 11-04-2011 / 20:02:01 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   315
    "Modified: / 13-04-2011 / 14:07:54 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   316
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   317
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   318
throwNoSuchFieldException
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   319
    exceptionThrower throwNoSuchFieldException.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   320
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   321
    "Created: / 11-04-2011 / 21:35:02 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   322
    "Modified: / 13-04-2011 / 14:07:57 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   323
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   324
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   325
throwNoSuchMethodError
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   326
    exceptionThrower throwNoSuchMethodError.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   327
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   328
    "Created: / 11-04-2011 / 20:19:41 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   329
    "Modified: / 13-04-2011 / 14:08:01 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   330
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   331
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   332
!JavaResolver methodsFor:'field resolving'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   333
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   334
resolveFieldIndentifiedByRef: aJavaFieldRef 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   335
    | result  class |
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   336
    self validateFieldRef: aJavaFieldRef.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   337
    result := self lookupFieldIfAlreadyResolved: aJavaFieldRef.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   338
    result ifNotNil: [ ^ result ].
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   339
    class := aJavaFieldRef classRef resolve: false.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   340
    class ifNil: [ self error: 'should not happen - tell mh' ].
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   341
    result := class lookupFieldByNameAndType: aJavaFieldRef nameAndType.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   342
    result ifNil: [ self throwNoSuchFieldException ].
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   343
    (self 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   344
        checkPermissionsForField: result
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   345
        from: aJavaFieldRef classRef owner
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   346
        to: class) ifFalse: [ self throwIllegalAccessError ].
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   347
    ^ result.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   348
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   349
    "
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   350
     To resolve an unresolved symbolic reference from D to a field in a class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   351
     or interface C, the symbolic reference to C given by the field reference
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   352
     must first be resolved (§5.4.3.1). Therefore, any exception that can be
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   353
     thrown as a result of failure of resolution of a class or interface reference
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   354
     can be thrown as a result of failure of field resolution. If the reference
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   355
     to C can be successfully resolved, an exception relating to the failure of
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   356
     resolution of the field reference itself can be thrown.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   357
     When resolving a field reference, field resolution first attempts to look
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   358
     up the referenced field in C and its superclasses:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   359
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   360
     If C declares a field with the name and descriptor specified by the field
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   361
     reference, field lookup succeeds. The declared field is the result of the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   362
     field lookup.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   363
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   364
     Otherwise, field lookup is applied recursively to the direct superinterfaces
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   365
     of the specified class or interface C.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   366
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   367
     Otherwise, if C has a superclass S, field lookup is applied recursively to S.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   368
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   369
     Otherwise, field lookup fails.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   370
     If field lookup fails, field resolution throws a NoSuchFieldError. Otherwise,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   371
     if field lookup succeeds but the referenced field is not accessible (§5.4.4)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   372
     to D, field resolution throws an IllegalAccessError.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   373
     Otherwise, let <E, L1> be the class or interface in which the referenced
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   374
     field is actually declared and let L2 be the defining loader of D. Let T be
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   375
     the name of the type of the referenced field. The Java virtual machine must
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   376
     impose the loading constraint that TL1=TL2(§5.3.4)."
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   377
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   378
    "Created: / 11-04-2011 / 21:15:20 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   379
    "Modified: / 01-12-2012 / 13:45:41 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   380
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   381
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   382
resolveStaticFieldIndentifiedByRef: aJavaFieldRef 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   383
    | result  class |
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   384
    self validateFieldRef: aJavaFieldRef.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   385
    result := self lookupFieldIfAlreadyResolved: aJavaFieldRef.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   386
    result ifNotNil: [ ^ result ].
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   387
    class := aJavaFieldRef classRef resolve: false.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   388
    class ifNil: [ self error: 'should not happen - tell mh' ].
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   389
    result := class lookupStaticFieldByNameAndType: aJavaFieldRef nameAndType.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   390
    result ifNil: [ self throwNoSuchFieldException ].
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   391
    (self 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   392
        checkPermissionsForField: result
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   393
        from: aJavaFieldRef classRef owner
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   394
        to: class) ifFalse: [ self throwIllegalAccessError ].
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   395
    ^ result.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   396
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   397
    "
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   398
     To resolve an unresolved symbolic reference from D to a field in a class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   399
     or interface C, the symbolic reference to C given by the field reference
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   400
     must first be resolved (§5.4.3.1). Therefore, any exception that can be
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   401
     thrown as a result of failure of resolution of a class or interface reference
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   402
     can be thrown as a result of failure of field resolution. If the reference
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   403
     to C can be successfully resolved, an exception relating to the failure of
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   404
     resolution of the field reference itself can be thrown.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   405
     When resolving a field reference, field resolution first attempts to look
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   406
     up the referenced field in C and its superclasses:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   407
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   408
     If C declares a field with the name and descriptor specified by the field
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   409
     reference, field lookup succeeds. The declared field is the result of the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   410
     field lookup.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   411
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   412
     Otherwise, field lookup is applied recursively to the direct superinterfaces
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   413
     of the specified class or interface C.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   414
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   415
     Otherwise, if C has a superclass S, field lookup is applied recursively to S.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   416
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   417
     Otherwise, field lookup fails.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   418
     If field lookup fails, field resolution throws a NoSuchFieldError. Otherwise,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   419
     if field lookup succeeds but the referenced field is not accessible (§5.4.4)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   420
     to D, field resolution throws an IllegalAccessError.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   421
     Otherwise, let <E, L1> be the class or interface in which the referenced
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   422
     field is actually declared and let L2 be the defining loader of D. Let T be
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   423
     the name of the type of the referenced field. The Java virtual machine must
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   424
     impose the loading constraint that TL1=TL2(§5.3.4)."
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   425
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   426
    "Created: / 28-04-2011 / 22:31:34 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   427
    "Modified: / 01-12-2012 / 13:45:45 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   428
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   429
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   430
!JavaResolver methodsFor:'field resolving helpers'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   431
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   432
checkPermissionsForField: aJavaField from: accessingJavaClass to: resolvedJavaClass     
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   433
    ^ self 
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   434
        checkPermissionsForMethodOrField: aJavaField
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   435
        from: accessingJavaClass
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   436
        to: resolvedJavaClass.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   437
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   438
    "Created: / 11-04-2011 / 21:46:29 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   439
    "Modified: / 01-12-2012 / 13:45:55 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   440
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   441
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   442
lookupFieldIfAlreadyResolved: aJavaFieldRef 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   443
    ^ nil.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   444
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   445
    "Created: / 11-04-2011 / 21:16:45 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   446
    "Modified: / 13-04-2011 / 11:57:13 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   447
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   448
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   449
validateFieldRef: aJavaFieldRef 
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   450
    aJavaFieldRef isJavaRef ifFalse: [ self halt: 'I expected Java Ref' ].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   451
    aJavaFieldRef isJavaFieldRef ifFalse: [
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   452
        self error: 'I expected Java Field Ref'
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   453
    ].
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   454
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   455
    "Created: / 11-04-2011 / 21:16:44 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   456
    "Modified: / 01-12-2012 / 13:46:02 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   457
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   458
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   459
!JavaResolver methodsFor:'interface method resolving'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   460
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   461
resolveInterfaceMethodIdentifiedByRef: aJavaInterfaceMethodRef 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   462
    | result  class |
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   463
    self validateInterfaceMethodRef: aJavaInterfaceMethodRef.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   464
    result := self 
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   465
            lookupInterfaceMethodIfAlreadyResolved: aJavaInterfaceMethodRef.
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   466
    result ifNotNil: [ ^ result ].
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   467
    class := aJavaInterfaceMethodRef classRef resolve: false.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   468
    class ifNil: [ self error: 'should not happen - tell mh' ].
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   469
    class isInterface ifFalse: [ self throwIncompatibleClassChangeError ].
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   470
    result := class 
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   471
            lookupMethodByNameAndType: aJavaInterfaceMethodRef nameAndType.
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   472
    result ifNil: [ self throwNoSuchMethodError ].
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   473
    (self 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   474
        checkPermissionsForMethod: result
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   475
        from: aJavaInterfaceMethodRef classRef owner
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   476
        to: class) ifFalse: [ self throwIllegalAccessError ].
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   477
    ^ result.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   478
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   479
    "
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   480
     To resolve an unresolved symbolic reference from D to an interface method in an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   481
     interface C, the symbolic reference to C given by the interface method reference is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   482
     first resolved (§5.4.3.1). Therefore, any exceptions that can be thrown as a result
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   483
     of failure of resolution of an interface reference can be thrown as a result of
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   484
     failure of interface method resolution. If the reference to C can be successfully
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   485
     resolved, exceptions relating to the resolution of the interface method reference
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   486
     itself can be thrown.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   487
     When resolving an interface method reference:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   488
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   489
     If C is not an interface, interface method resolution throws an IncompatibleClassChangeError."
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   490
    "Otherwise, if the referenced method does not have the same name and descriptor as
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   491
a method in C or in one of the superinterfaces of C, or in class Object, interface
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   492
method resolution throws a NoSuchMethodError.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   493
Otherwise, let <E, L1> be the interface in which the referenced interface method is
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   494
actually declared and let L2 be the defining loader of D. Let T0 be the name of
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   495
the type returned by the referenced method, and let T1, ..., Tn be the names of the
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   496
argument types of the referenced method. The Java virtual machine must impose the
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   497
loading constraints TiL1 = TiL2 for i = 0 to n (§5.3.4)."
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   498
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   499
    "Modified: / 01-12-2012 / 13:46:09 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   500
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   501
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   502
!JavaResolver methodsFor:'interface method resolving helpers'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   503
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   504
lookupInterfaceMethodIfAlreadyResolved: aJavaInterfaceMethodRef 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   505
    ^  nil.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   506
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   507
    "Created: / 13-04-2011 / 11:53:36 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   508
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   509
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   510
validateInterfaceMethodRef: aJavaInterfaceMethodRef 
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   511
    aJavaInterfaceMethodRef isJavaRef ifFalse: [
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   512
        self error: 'I expected JavaRef instance as an argument'
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   513
    ].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   514
    aJavaInterfaceMethodRef isJavaInterfaceMethodRef ifFalse: [
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   515
        self error: 'I expected JavaMethodRef instance as an argument'
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   516
    ].
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   517
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   518
    "Created: / 13-04-2011 / 11:53:34 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   519
    "Modified: / 01-12-2012 / 13:46:20 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   520
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   521
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   522
!JavaResolver methodsFor:'method resolving'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   523
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   524
resolveMethodIndentifiedByRef: aJavaMethodRef 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   525
    | result  class |
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   526
    self validateMethodRef: aJavaMethodRef.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   527
    result := self lookupMethodIfAlreadyResolved: aJavaMethodRef.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   528
    result ifNotNil: [ ^ result ].
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   529
    class := aJavaMethodRef classRef resolve: false.
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   530
    class ifNil: [ self error: 'should not happen - tell mh' ].
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   531
     "Array types responds to all method of class java.lang.Object"
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   532
    class isJavaArrayClass ifTrue: [
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   533
        class := JavaVM classForName: 'java.lang.Object'.
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   534
    ].
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   535
     "
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   536
     To resolve an unresolved symbolic reference from D to a method in
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   537
     a class C, the symbolic reference to C given by the method reference
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   538
     is first resolved (§5.4.3.1). Therefore, any exceptions that can be
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   539
     thrown due to resolution of a class reference can be thrown as a result
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   540
     of method resolution. If the reference to C can be successfully resolved,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   541
     exceptions relating to the resolution of the method reference itself
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   542
     can be thrown.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   543
     When resolving a method reference:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   544
     
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   545
     Method resolution checks whether C is a class or an interface.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   546
     If C is an interface, method resolution throws an IncompatibleClassChangeError."
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   547
    class isInterface ifTrue: [ self throwIncompatibleClassChangeError ].
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   548
     "Method resolution attempts to look up the referenced method in C and its
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   549
     superclasses:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   550
     If C declares a method with the name and descriptor specified by the method
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   551
     reference, method lookup succeeds.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   552
     Otherwise, if C has a superclass, step 2 of method lookup is recursively
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   553
     invoked on the direct superclass of C.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   554
     
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   555
     Otherwise, method lookup attempts to locate the referenced method in any of
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   556
     the superinterfaces of the specified class C.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   557
     If any superinterface of C declares a method with the name and descriptor
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   558
     specified by the method reference, method lookup succeeds.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   559
     Otherwise, method lookup fails.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   560
     If method lookup fails, method resolution throws a NoSuchMethodError. If method
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   561
     lookup succeeds and the method is abstract, but C is not abstract, method resolution
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   562
     throws an AbstractMethodError. Otherwise, if the referenced method is not accessible
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   563
     (§5.4.4) to D, method resolution throws an IllegalAccessError."
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   564
    result := class lookupMethodByNameAndType: aJavaMethodRef nameAndType.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   565
    result ifNil: [ self throwNoSuchMethodError ].
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   566
    (result isAbstract 
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   567
        and: [ result javaClass isInterface not and: [ class isAbstract not ] ]) 
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   568
            ifTrue: [ self throwAbstractMethodError ].
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   569
    (self 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   570
        checkPermissionsForMethod: result
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   571
        from: aJavaMethodRef classRef owner
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   572
        to: class) ifFalse: [ self throwIllegalAccessError ].
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   573
    ^ result.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   574
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   575
    "Otherwise, let <E, L1> be the class or interface in which the referenced method is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   576
     actually declared and let L2 be the defining loader of D. Let T0 be the name of
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   577
     the type returned by the referenced method, and let T1, ..., Tn be the names of
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   578
     the argument types of the referenced method. The Java virtual machine must impose
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   579
     the loading constraints TiL1=TiL2 for i = 0 to n (§5.3.4)."
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   580
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   581
    "Created: / 11-04-2011 / 19:45:34 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   582
    "Modified: / 14-04-2011 / 00:01:34 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   583
    "Modified: / 10-08-2011 / 22:44:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   584
    "Modified (format): / 01-12-2012 / 13:46:25 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   585
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   586
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   587
!JavaResolver methodsFor:'method resolving helpers'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   588
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   589
checkPermissionsForMethod: aJavaMethod from: accessingJavaClass to: resolvedJavaClass    
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   590
    ^ self 
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   591
        checkPermissionsForMethodOrField: aJavaMethod
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   592
        from: accessingJavaClass
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   593
        to: resolvedJavaClass.
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   594
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   595
    "Created: / 11-04-2011 / 20:20:12 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   596
    "Modified: / 24-05-2011 / 14:06:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   597
    "Modified: / 09-02-2012 / 23:15:48 / mh <hlopik@gmail.com>"
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   598
    "Modified: / 01-12-2012 / 13:46:58 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   599
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   600
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   601
lookupMethodIfAlreadyResolved: aJavaMethodRef 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   602
    ^ nil.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   603
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   604
    "Created: / 11-04-2011 / 19:50:38 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   605
    "Modified: / 13-04-2011 / 11:57:00 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   606
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   607
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   608
validateMethodRef: aJavaMethodRef 
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   609
    aJavaMethodRef isJavaRef ifFalse: [
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   610
        self error: 'I expected JavaRef instance as an argument'
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   611
    ].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   612
    aJavaMethodRef isJavaMethodRef ifFalse: [
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   613
        self error: 'I expected JavaMethodRef instance as an argument'
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   614
    ].
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   615
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   616
    "Created: / 11-04-2011 / 19:47:25 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   617
    "Modified: / 01-12-2012 / 13:47:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   618
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   619
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   620
!JavaResolver class methodsFor:'documentation'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   621
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   622
version_CVS
2678
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2396
diff changeset
   623
    ^ '$Header: /cvs/stx/stx/libjava/JavaResolver.st,v 1.6 2013-09-06 00:41:26 vrany Exp $'
2156
a8c5720d1d05 changed: #resolveMethodIndentifiedByRef:
Claus Gittinger <cg@exept.de>
parents: 2152
diff changeset
   624
!
a8c5720d1d05 changed: #resolveMethodIndentifiedByRef:
Claus Gittinger <cg@exept.de>
parents: 2152
diff changeset
   625
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   626
version_HG
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   627
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   628
    ^ '$Changeset: <not expanded> $'
2156
a8c5720d1d05 changed: #resolveMethodIndentifiedByRef:
Claus Gittinger <cg@exept.de>
parents: 2152
diff changeset
   629
!
a8c5720d1d05 changed: #resolveMethodIndentifiedByRef:
Claus Gittinger <cg@exept.de>
parents: 2152
diff changeset
   630
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   631
version_SVN
2731
13f5be2bf83b Merged d87e89dd5276 and fe83a843a7bf (branch default - CVS HEAD)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2711 2678
diff changeset
   632
    ^ 'Id'
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   633
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   634
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2231
diff changeset
   635
2152
1cbdfbcc685c Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 750
diff changeset
   636
JavaResolver initialize!