src/JavaClassRef2.st
author hlopkmar
Wed, 19 Oct 2011 16:18:27 +0000
branchjk_new_structure
changeset 1026 5badd1d31864
parent 915 cf0d328465c2
child 1035 712d2090e68b
permissions -rw-r--r--
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
877
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
     1
"
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
     2
 COPYRIGHT (c) 1996-2011 by Claus Gittinger
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
     3
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
     4
                            SWING Research Group, Czech Technical University in Prague
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
     5
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
     6
 Parts of the code written by Claus Gittinger are under following
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
     7
 license:
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
     8
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
     9
 This software is furnished under a license and may be used
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    10
 only in accordance with the terms of that license and with the
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    11
 inclusion of the above copyright notice.   This software may not
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    12
 be provided or otherwise made available to, or used by, any
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    13
 other person.  No title to or ownership of the software is
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    14
 hereby transferred.
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    15
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    16
 Parts of the code written at SWING Reasearch Group [1] are MIT licensed:
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    17
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    18
 Permission is hereby granted, free of charge, to any person
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    19
 obtaining a copy of this software and associated documentation
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    20
 files (the 'Software'), to deal in the Software without
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    21
 restriction, including without limitation the rights to use,
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    22
 copy, modify, merge, publish, distribute, sublicense, and/or sell
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    23
 copies of the Software, and to permit persons to whom the
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    24
 Software is furnished to do so, subject to the following
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    25
 conditions:
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    26
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    27
 The above copyright notice and this permission notice shall be
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    28
 included in all copies or substantial portions of the Software.
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    29
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    30
 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    31
 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    32
 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    33
 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    34
 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    35
 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    36
 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    37
 OTHER DEALINGS IN THE SOFTWARE.
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    38
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    39
 [1] Code written at SWING Research Group contain a signature
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    40
     of one of the above copright owners.
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    41
"
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    42
"{ Package: 'stx:libjava' }"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    43
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    44
JavaRef2 subclass:#JavaClassRef2
778
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    45
	instanceVariableNames:'nameIndex'
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    46
	classVariableNames:''
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    47
	poolDictionaries:''
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    48
	category:'Languages-Java-Reader-Support-new'
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    49
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    50
877
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    51
!JavaClassRef2 class methodsFor:'documentation'!
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    52
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    53
copyright
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    54
"
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    55
 COPYRIGHT (c) 1996-2011 by Claus Gittinger
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    56
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    57
                            SWING Research Group, Czech Technical University in Prague
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    58
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    59
 Parts of the code written by Claus Gittinger are under following
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    60
 license:
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    61
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    62
 This software is furnished under a license and may be used
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    63
 only in accordance with the terms of that license and with the
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    64
 inclusion of the above copyright notice.   This software may not
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    65
 be provided or otherwise made available to, or used by, any
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    66
 other person.  No title to or ownership of the software is
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    67
 hereby transferred.
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    68
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    69
 Parts of the code written at SWING Reasearch Group [1] are MIT licensed:
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    70
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    71
 Permission is hereby granted, free of charge, to any person
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    72
 obtaining a copy of this software and associated documentation
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    73
 files (the 'Software'), to deal in the Software without
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    74
 restriction, including without limitation the rights to use,
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    75
 copy, modify, merge, publish, distribute, sublicense, and/or sell
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    76
 copies of the Software, and to permit persons to whom the
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    77
 Software is furnished to do so, subject to the following
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    78
 conditions:
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    79
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    80
 The above copyright notice and this permission notice shall be
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    81
 included in all copies or substantial portions of the Software.
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    82
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    83
 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    84
 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    85
 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    86
 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    87
 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    88
 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    89
 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    90
 OTHER DEALINGS IN THE SOFTWARE.
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    91
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    92
 [1] Code written at SWING Research Group contain a signature
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    93
     of one of the above copright owners.
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    94
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    95
"
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    96
! !
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    97
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    98
!JavaClassRef2 class methodsFor:'instance creation'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    99
771
fb8026dda011 Merged with /trunk
vranyj1
parents: 761
diff changeset
   100
in: aJavaConstantPool withNameAt: nameIndex
fb8026dda011 Merged with /trunk
vranyj1
parents: 761
diff changeset
   101
   
758
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   102
    
771
fb8026dda011 Merged with /trunk
vranyj1
parents: 761
diff changeset
   103
    ^ self basicNew initializeIn: aJavaConstantPool withNameAt: nameIndex.
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   104
771
fb8026dda011 Merged with /trunk
vranyj1
parents: 761
diff changeset
   105
    "Created: / 10-05-2011 / 14:56:15 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
758
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   106
! !
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   107
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   108
!JavaClassRef2 methodsFor:'accessing'!
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   109
761
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 758
diff changeset
   110
classLoader
777
e6e61412ae43 refactoring tests.. and more needed
hlopkmar
parents: 772
diff changeset
   111
    self owner ifNil: [ ^ nil ] ifNotNil: [ ^ self owner classLoader ].
761
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 758
diff changeset
   112
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 758
diff changeset
   113
    "Created: / 11-04-2011 / 21:52:06 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
777
e6e61412ae43 refactoring tests.. and more needed
hlopkmar
parents: 772
diff changeset
   114
    "Modified: / 12-05-2011 / 18:32:57 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
761
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 758
diff changeset
   115
!
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 758
diff changeset
   116
809
0fd3dbe06abb Few fixes in resolving.
vranyj1
parents: 786
diff changeset
   117
javaClass
0fd3dbe06abb Few fixes in resolving.
vranyj1
parents: 786
diff changeset
   118
0fd3dbe06abb Few fixes in resolving.
vranyj1
parents: 786
diff changeset
   119
    valueCache ifNil:[self resolve].
0fd3dbe06abb Few fixes in resolving.
vranyj1
parents: 786
diff changeset
   120
    ^valueCache
0fd3dbe06abb Few fixes in resolving.
vranyj1
parents: 786
diff changeset
   121
0fd3dbe06abb Few fixes in resolving.
vranyj1
parents: 786
diff changeset
   122
    "Created: / 22-05-2011 / 14:02:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
0fd3dbe06abb Few fixes in resolving.
vranyj1
parents: 786
diff changeset
   123
!
0fd3dbe06abb Few fixes in resolving.
vranyj1
parents: 786
diff changeset
   124
758
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   125
javaClassName
761
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 758
diff changeset
   126
    "return java class name as written in java programs e.g. java.util.String
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 758
diff changeset
   127
     in case of array, return class name without square brackets"
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 758
diff changeset
   128
    
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 758
diff changeset
   129
    | tmp |
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 758
diff changeset
   130
814
68df82c46fb0 finally forced myself to refactor tests.. fieldRef tests are ok now.. methodRef to come..
hlopkmar
parents: 809
diff changeset
   131
    tmp := self name copy.
68df82c46fb0 finally forced myself to refactor tests.. fieldRef tests are ok now.. methodRef to come..
hlopkmar
parents: 809
diff changeset
   132
    [ tmp startsWith: '[' ] whileTrue: [ tmp := tmp copyFrom: 2 ].
786
e3de6a198e63 simple methods are the worst :)
hlopkmar
parents: 785
diff changeset
   133
    tmp := tmp replaceAll: $/ with: $..
785
7811d2e77ca6 aaaargh forgot to delete old code after fixing it.. and wondering why it's not working :)
hlopkmar
parents: 783
diff changeset
   134
    (tmp startsWith: 'L') ifTrue: [ tmp := tmp copyFrom: 2 to: tmp size ].
7811d2e77ca6 aaaargh forgot to delete old code after fixing it.. and wondering why it's not working :)
hlopkmar
parents: 783
diff changeset
   135
    (tmp endsWith: ';') ifTrue: [ tmp := tmp copyFrom: 1 to: tmp size - 1 ].
7811d2e77ca6 aaaargh forgot to delete old code after fixing it.. and wondering why it's not working :)
hlopkmar
parents: 783
diff changeset
   136
    ^ tmp.
758
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   137
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   138
    "Created: / 08-04-2011 / 18:30:44 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
814
68df82c46fb0 finally forced myself to refactor tests.. fieldRef tests are ok now.. methodRef to come..
hlopkmar
parents: 809
diff changeset
   139
    "Modified: / 23-05-2011 / 15:30:01 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
758
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   140
!
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   141
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   142
name
778
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   143
    ^constantPool at: nameIndex.
758
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   144
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   145
    "Created: / 08-04-2011 / 13:48:36 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
778
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   146
    "Modified: / 13-05-2011 / 09:59:58 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
758
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   147
! !
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   148
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   149
!JavaClassRef2 methodsFor:'array support'!
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   150
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   151
arrayDimensions
778
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   152
    ^ self name occurrencesOf: $[.
758
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   153
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   154
    "Created: / 08-04-2011 / 18:42:02 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
778
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   155
    "Modified: / 13-05-2011 / 10:00:15 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
758
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   156
!
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   157
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   158
isJavaArrayClassRef
778
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   159
    ^ self name startsWith: '['.
758
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   160
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   161
    "Created: / 08-04-2011 / 18:40:40 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
778
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   162
    "Modified: / 13-05-2011 / 10:00:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   163
! !
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   164
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   165
!JavaClassRef2 methodsFor:'comparing'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   166
758
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   167
= anotherJavaClassRef 
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   168
    "superclass JavaRef2 says that I am responsible to implement this method"
758
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   169
    
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   170
    anotherJavaClassRef isJavaClassRef ifFalse: [ ^ false ].
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   171
    ^ self name = anotherJavaClassRef name.
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   172
758
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   173
    "Modified: / 08-04-2011 / 13:48:56 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   174
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   175
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   176
hash
778
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   177
    ^ self name hash.
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   178
778
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   179
    "Modified: / 13-05-2011 / 10:00:26 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   180
! !
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   181
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   182
!JavaClassRef2 methodsFor:'initialization'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   183
771
fb8026dda011 Merged with /trunk
vranyj1
parents: 761
diff changeset
   184
initializeIn: aJavaConstantPool withNameAt: nameCPIndex
fb8026dda011 Merged with /trunk
vranyj1
parents: 761
diff changeset
   185
    nameIndex := nameCPIndex.
fb8026dda011 Merged with /trunk
vranyj1
parents: 761
diff changeset
   186
    constantPool := aJavaConstantPool.
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   187
    super initialize.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   188
771
fb8026dda011 Merged with /trunk
vranyj1
parents: 761
diff changeset
   189
    "Modified: / 10-05-2011 / 14:57:38 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
fb8026dda011 Merged with /trunk
vranyj1
parents: 761
diff changeset
   190
! !
fb8026dda011 Merged with /trunk
vranyj1
parents: 761
diff changeset
   191
fb8026dda011 Merged with /trunk
vranyj1
parents: 761
diff changeset
   192
!JavaClassRef2 methodsFor:'printing'!
fb8026dda011 Merged with /trunk
vranyj1
parents: 761
diff changeset
   193
915
vranyj1
parents: 912
diff changeset
   194
displayString
vranyj1
parents: 912
diff changeset
   195
vranyj1
parents: 912
diff changeset
   196
    ^self name
vranyj1
parents: 912
diff changeset
   197
vranyj1
parents: 912
diff changeset
   198
    "Created: / 14-08-2011 / 21:18:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
vranyj1
parents: 912
diff changeset
   199
!
vranyj1
parents: 912
diff changeset
   200
771
fb8026dda011 Merged with /trunk
vranyj1
parents: 761
diff changeset
   201
fullName
fb8026dda011 Merged with /trunk
vranyj1
parents: 761
diff changeset
   202
    ^ self name.
fb8026dda011 Merged with /trunk
vranyj1
parents: 761
diff changeset
   203
fb8026dda011 Merged with /trunk
vranyj1
parents: 761
diff changeset
   204
    "Created: / 10-05-2011 / 14:19:27 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
fb8026dda011 Merged with /trunk
vranyj1
parents: 761
diff changeset
   205
!
fb8026dda011 Merged with /trunk
vranyj1
parents: 761
diff changeset
   206
fb8026dda011 Merged with /trunk
vranyj1
parents: 761
diff changeset
   207
printString
778
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   208
    ^ 'JavaClassRef for: ' , self name printString.
771
fb8026dda011 Merged with /trunk
vranyj1
parents: 761
diff changeset
   209
fb8026dda011 Merged with /trunk
vranyj1
parents: 761
diff changeset
   210
    "Created: / 10-05-2011 / 14:16:50 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
778
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   211
    "Modified: / 13-05-2011 / 10:00:33 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   212
! !
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   213
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   214
!JavaClassRef2 methodsFor:'private - resolving'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   215
761
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 758
diff changeset
   216
findResolvedStaticValue
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 758
diff changeset
   217
    "Resolving static inner classes is not different from resolving any other class, it's only done in different circumstances"
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 758
diff changeset
   218
    
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 758
diff changeset
   219
    ^ self findResolvedValue.
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 758
diff changeset
   220
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 758
diff changeset
   221
    "Created: / 28-04-2011 / 21:57:46 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 758
diff changeset
   222
!
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 758
diff changeset
   223
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   224
findResolvedValue
758
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   225
    "Resolve reference and set valueCache."
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   226
    
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   227
    valueCache := JavaResolver uniqueInstance 
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   228
                resolveClassIndentifiedByRef: self.
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   229
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   230
    "Modified: / 08-04-2011 / 17:39:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
912
e651488f5741 Many fixes in reflection, expecially for generic types support
vranyj1
parents: 877
diff changeset
   231
!
e651488f5741 Many fixes in reflection, expecially for generic types support
vranyj1
parents: 877
diff changeset
   232
e651488f5741 Many fixes in reflection, expecially for generic types support
vranyj1
parents: 877
diff changeset
   233
findResolvedValue: doInit
e651488f5741 Many fixes in reflection, expecially for generic types support
vranyj1
parents: 877
diff changeset
   234
    "Resolve reference and set valueCache."
e651488f5741 Many fixes in reflection, expecially for generic types support
vranyj1
parents: 877
diff changeset
   235
    
e651488f5741 Many fixes in reflection, expecially for generic types support
vranyj1
parents: 877
diff changeset
   236
    valueCache := JavaResolver uniqueInstance 
e651488f5741 Many fixes in reflection, expecially for generic types support
vranyj1
parents: 877
diff changeset
   237
                resolveClassIndentifiedByRef: self init: doInit.
e651488f5741 Many fixes in reflection, expecially for generic types support
vranyj1
parents: 877
diff changeset
   238
e651488f5741 Many fixes in reflection, expecially for generic types support
vranyj1
parents: 877
diff changeset
   239
    "Modified: / 08-04-2011 / 17:39:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e651488f5741 Many fixes in reflection, expecially for generic types support
vranyj1
parents: 877
diff changeset
   240
    "Created: / 12-08-2011 / 22:19:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
758
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   241
! !
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   242
761
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 758
diff changeset
   243
!JavaClassRef2 methodsFor:'queries'!
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 758
diff changeset
   244
1026
5badd1d31864 introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents: 915
diff changeset
   245
isJavaClassOrStringRef
5badd1d31864 introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents: 915
diff changeset
   246
    ^ true.
5badd1d31864 introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents: 915
diff changeset
   247
5badd1d31864 introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents: 915
diff changeset
   248
    "Created: / 11-04-2011 / 19:10:00 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
5badd1d31864 introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents: 915
diff changeset
   249
!
5badd1d31864 introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents: 915
diff changeset
   250
761
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 758
diff changeset
   251
isJavaClassRef
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 758
diff changeset
   252
^true.
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 758
diff changeset
   253
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 758
diff changeset
   254
    "Created: / 11-04-2011 / 19:10:00 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 758
diff changeset
   255
! !
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 758
diff changeset
   256
758
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   257
!JavaClassRef2 methodsFor:'resolving'!
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   258
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   259
invalidateForClass: internalJavaClassName 
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   260
    "Invalidate (means call invalidate) reference if it has something to do with given class (e.g Class named internalJavaClassName was unloaded).
814
68df82c46fb0 finally forced myself to refactor tests.. fieldRef tests are ok now.. methodRef to come..
hlopkmar
parents: 809
diff changeset
   261
     Return true, if reference was invalidated."
68df82c46fb0 finally forced myself to refactor tests.. fieldRef tests are ok now.. methodRef to come..
hlopkmar
parents: 809
diff changeset
   262
    
778
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   263
    self name = internalJavaClassName 
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   264
        ifTrue: 
814
68df82c46fb0 finally forced myself to refactor tests.. fieldRef tests are ok now.. methodRef to come..
hlopkmar
parents: 809
diff changeset
   265
            [ 
68df82c46fb0 finally forced myself to refactor tests.. fieldRef tests are ok now.. methodRef to come..
hlopkmar
parents: 809
diff changeset
   266
            self invalidate.
778
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   267
            ^ true ].
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   268
    ^ false.
758
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   269
814
68df82c46fb0 finally forced myself to refactor tests.. fieldRef tests are ok now.. methodRef to come..
hlopkmar
parents: 809
diff changeset
   270
    "Modified: / 23-05-2011 / 15:21:20 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
912
e651488f5741 Many fixes in reflection, expecially for generic types support
vranyj1
parents: 877
diff changeset
   271
!
e651488f5741 Many fixes in reflection, expecially for generic types support
vranyj1
parents: 877
diff changeset
   272
e651488f5741 Many fixes in reflection, expecially for generic types support
vranyj1
parents: 877
diff changeset
   273
resolve
e651488f5741 Many fixes in reflection, expecially for generic types support
vranyj1
parents: 877
diff changeset
   274
e651488f5741 Many fixes in reflection, expecially for generic types support
vranyj1
parents: 877
diff changeset
   275
    ^self resolve: true
e651488f5741 Many fixes in reflection, expecially for generic types support
vranyj1
parents: 877
diff changeset
   276
e651488f5741 Many fixes in reflection, expecially for generic types support
vranyj1
parents: 877
diff changeset
   277
    "Created: / 08-04-2011 / 11:30:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e651488f5741 Many fixes in reflection, expecially for generic types support
vranyj1
parents: 877
diff changeset
   278
    "Created: / 12-08-2011 / 22:18:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e651488f5741 Many fixes in reflection, expecially for generic types support
vranyj1
parents: 877
diff changeset
   279
!
e651488f5741 Many fixes in reflection, expecially for generic types support
vranyj1
parents: 877
diff changeset
   280
1026
5badd1d31864 introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents: 915
diff changeset
   281
resolve: doInit 
912
e651488f5741 Many fixes in reflection, expecially for generic types support
vranyj1
parents: 877
diff changeset
   282
    "
1026
5badd1d31864 introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents: 915
diff changeset
   283
     Resolves a class. If doInit is true, then the class is initialuzed,
5badd1d31864 introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents: 915
diff changeset
   284
     otherwise not."
912
e651488f5741 Many fixes in reflection, expecially for generic types support
vranyj1
parents: 877
diff changeset
   285
    self isResolved ifFalse: [ self findResolvedValue: doInit ].
e651488f5741 Many fixes in reflection, expecially for generic types support
vranyj1
parents: 877
diff changeset
   286
    ^ valueCache.
e651488f5741 Many fixes in reflection, expecially for generic types support
vranyj1
parents: 877
diff changeset
   287
e651488f5741 Many fixes in reflection, expecially for generic types support
vranyj1
parents: 877
diff changeset
   288
    "Created: / 08-04-2011 / 11:30:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e651488f5741 Many fixes in reflection, expecially for generic types support
vranyj1
parents: 877
diff changeset
   289
    "Created: / 12-08-2011 / 22:18:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   290
! !
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   291
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   292
!JavaClassRef2 class methodsFor:'documentation'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   293
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   294
version_SVN
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   295
    ^ '$Id$'
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   296
! !