JavaClassReader.st
author cg
Mon, 29 Mar 1999 11:39:19 +0000
changeset 548 063963638b8d
parent 547 38870f6447d0
child 583 c859797c4e8c
permissions -rw-r--r--
raise -> query
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
454
38f590639d65 *** empty log message ***
cg
parents: 443
diff changeset
     1
"
38f590639d65 *** empty log message ***
cg
parents: 443
diff changeset
     2
 COPYRIGHT (c) 1997 by eXept Software AG
38f590639d65 *** empty log message ***
cg
parents: 443
diff changeset
     3
              All Rights Reserved
38f590639d65 *** empty log message ***
cg
parents: 443
diff changeset
     4
38f590639d65 *** empty log message ***
cg
parents: 443
diff changeset
     5
 This software is furnished under a license and may be used
38f590639d65 *** empty log message ***
cg
parents: 443
diff changeset
     6
 only in accordance with the terms of that license and with the
38f590639d65 *** empty log message ***
cg
parents: 443
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
38f590639d65 *** empty log message ***
cg
parents: 443
diff changeset
     8
 be provided or otherwise made available to, or used by, any
38f590639d65 *** empty log message ***
cg
parents: 443
diff changeset
     9
 other person.  No title to or ownership of the software is
38f590639d65 *** empty log message ***
cg
parents: 443
diff changeset
    10
 hereby transferred.
38f590639d65 *** empty log message ***
cg
parents: 443
diff changeset
    11
"
38f590639d65 *** empty log message ***
cg
parents: 443
diff changeset
    12
38f590639d65 *** empty log message ***
cg
parents: 443
diff changeset
    13
38f590639d65 *** empty log message ***
cg
parents: 443
diff changeset
    14
1
083530508d9c intitial checkin
cg
parents:
diff changeset
    15
Object subclass:#JavaClassReader
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
    16
	instanceVariableNames:'inStream msb constants majorVsn minorVsn constNeeds2Slots
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
    17
		constSlot'
198
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
    18
	classVariableNames:'Verbose Silent AbsolutelySilent LazyClassLoading
275
92b7ebb0b54c *** empty log message ***
cg
parents: 273
diff changeset
    19
		InvalidClassFormatSignal ClassLoaderQuerySignal'
1
083530508d9c intitial checkin
cg
parents:
diff changeset
    20
	poolDictionaries:''
083530508d9c intitial checkin
cg
parents:
diff changeset
    21
	category:'Java-Support'
083530508d9c intitial checkin
cg
parents:
diff changeset
    22
!
083530508d9c intitial checkin
cg
parents:
diff changeset
    23
454
38f590639d65 *** empty log message ***
cg
parents: 443
diff changeset
    24
!JavaClassReader class methodsFor:'documentation'!
38f590639d65 *** empty log message ***
cg
parents: 443
diff changeset
    25
38f590639d65 *** empty log message ***
cg
parents: 443
diff changeset
    26
copyright
38f590639d65 *** empty log message ***
cg
parents: 443
diff changeset
    27
"
38f590639d65 *** empty log message ***
cg
parents: 443
diff changeset
    28
 COPYRIGHT (c) 1997 by eXept Software AG
38f590639d65 *** empty log message ***
cg
parents: 443
diff changeset
    29
              All Rights Reserved
38f590639d65 *** empty log message ***
cg
parents: 443
diff changeset
    30
38f590639d65 *** empty log message ***
cg
parents: 443
diff changeset
    31
 This software is furnished under a license and may be used
38f590639d65 *** empty log message ***
cg
parents: 443
diff changeset
    32
 only in accordance with the terms of that license and with the
38f590639d65 *** empty log message ***
cg
parents: 443
diff changeset
    33
 inclusion of the above copyright notice.   This software may not
38f590639d65 *** empty log message ***
cg
parents: 443
diff changeset
    34
 be provided or otherwise made available to, or used by, any
38f590639d65 *** empty log message ***
cg
parents: 443
diff changeset
    35
 other person.  No title to or ownership of the software is
38f590639d65 *** empty log message ***
cg
parents: 443
diff changeset
    36
 hereby transferred.
38f590639d65 *** empty log message ***
cg
parents: 443
diff changeset
    37
"
38f590639d65 *** empty log message ***
cg
parents: 443
diff changeset
    38
38f590639d65 *** empty log message ***
cg
parents: 443
diff changeset
    39
38f590639d65 *** empty log message ***
cg
parents: 443
diff changeset
    40
! !
1
083530508d9c intitial checkin
cg
parents:
diff changeset
    41
135
098936234135 *** empty log message ***
cg
parents: 128
diff changeset
    42
!JavaClassReader class methodsFor:'initialization'!
1
083530508d9c intitial checkin
cg
parents:
diff changeset
    43
083530508d9c intitial checkin
cg
parents:
diff changeset
    44
initialize
198
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
    45
    InvalidClassFormatSignal := Signal new mayProceed:true.
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
    46
    InvalidClassFormatSignal notifierString:'class load failure'.
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
    47
    InvalidClassFormatSignal nameClass:self message:#invalidClassFormatSignal.
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
    48
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
    49
    Verbose := false. 
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
    50
    Silent := true.
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
    51
    AbsolutelySilent := false.
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
    52
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
    53
    LazyClassLoading := false. "/ true.
223
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
    54
    ClassLoaderQuerySignal := QuerySignal new
29
eb3367f8fb9b checkin from browser
cg
parents: 27
diff changeset
    55
eb3367f8fb9b checkin from browser
cg
parents: 27
diff changeset
    56
    "
eb3367f8fb9b checkin from browser
cg
parents: 27
diff changeset
    57
     JavaClassReader initialize
eb3367f8fb9b checkin from browser
cg
parents: 27
diff changeset
    58
    "
eb3367f8fb9b checkin from browser
cg
parents: 27
diff changeset
    59
275
92b7ebb0b54c *** empty log message ***
cg
parents: 273
diff changeset
    60
    "Modified: / 27.1.1998 / 17:54:23 / cg"
198
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
    61
! !
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
    62
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
    63
!JavaClassReader class methodsFor:'Signal constants'!
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
    64
223
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
    65
classLoaderQuerySignal
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
    66
    ^ ClassLoaderQuerySignal
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
    67
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
    68
    "Created: 14.8.1997 / 19:56:03 / cg"
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
    69
!
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
    70
198
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
    71
invalidClassFormatSignal
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
    72
    ^ InvalidClassFormatSignal
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
    73
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
    74
    "Created: 3.8.1997 / 18:17:21 / cg"
1
083530508d9c intitial checkin
cg
parents:
diff changeset
    75
! !
083530508d9c intitial checkin
cg
parents:
diff changeset
    76
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    77
!JavaClassReader class methodsFor:'constants'!
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    78
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    79
fileMajorVersion
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    80
    ^ 45
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    81
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    82
    "Modified: / 7.5.1998 / 13:14:27 / cg"
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    83
    "Created: / 7.5.1998 / 13:16:35 / cg"
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    84
!
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    85
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    86
fileMinorVersion
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    87
    ^ 3
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    88
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    89
    "Modified: / 7.5.1998 / 13:14:27 / cg"
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    90
    "Created: / 7.5.1998 / 13:16:40 / cg"
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    91
!
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    92
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    93
magic_LSB
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    94
    ^ 16rBEBAFECA
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    95
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    96
    "Modified: / 7.5.1998 / 13:14:27 / cg"
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    97
    "Created: / 7.5.1998 / 13:15:05 / cg"
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    98
!
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    99
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
   100
magic_MSB
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
   101
    ^ 16rCAFEBABE
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
   102
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
   103
    "Modified: / 7.5.1998 / 13:14:27 / cg"
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
   104
! !
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
   105
135
098936234135 *** empty log message ***
cg
parents: 128
diff changeset
   106
!JavaClassReader class methodsFor:'debugging'!
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   107
083530508d9c intitial checkin
cg
parents:
diff changeset
   108
verbose:aBoolean
083530508d9c intitial checkin
cg
parents:
diff changeset
   109
    Verbose := aBoolean
083530508d9c intitial checkin
cg
parents:
diff changeset
   110
083530508d9c intitial checkin
cg
parents:
diff changeset
   111
    "
67
a72c949d86dd *** empty log message ***
cg
parents: 62
diff changeset
   112
     Java flushClasses.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   113
     JavaClassReader verbose:true
083530508d9c intitial checkin
cg
parents:
diff changeset
   114
     JavaClassReader verbose:false
083530508d9c intitial checkin
cg
parents:
diff changeset
   115
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
   116
! !
083530508d9c intitial checkin
cg
parents:
diff changeset
   117
135
098936234135 *** empty log message ***
cg
parents: 128
diff changeset
   118
!JavaClassReader class methodsFor:'file reading'!
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   119
21
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
   120
loadClass:aClassName
43
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   121
    "reads a class, installs and returns it.
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   122
     The classes string constants are resolved & <clinit> is called,
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   123
     if it implements it."
21
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
   124
223
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   125
    |rslt loader|
21
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
   126
548
063963638b8d raise -> query
cg
parents: 547
diff changeset
   127
    loader := ClassLoaderQuerySignal query.
223
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   128
    loader isNil ifTrue:[
399
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   129
        ^ self loadSystemClass:aClassName
223
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   130
    ].
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   131
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   132
    ^ loader loadClass:aClassName
21
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
   133
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
   134
    "
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
   135
     JavaClassReader loadClass:'awt/Component'
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
   136
     JavaClassReader loadClass:'awt/Button'
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
   137
     JavaClassReader loadClass:'browser/AddButton'
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
   138
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
   139
     JavaClassReader loadClass:'java/lang/Object'
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
   140
     JavaClassReader loadClass:'java/lang/AbstractMethodError'
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
   141
     JavaClassReader loadClass:'java/lang/Thread'
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
   142
    "
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
   143
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
   144
    "Created: / 15.4.1996 / 14:58:53 / cg"
399
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   145
    "Modified: / 20.10.1998 / 17:24:54 / cg"
21
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
   146
!
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
   147
54
f37bcefb7091 avoid loading classes twice
cg
parents: 52
diff changeset
   148
loadClassLazy:aClassName ignoring:classesBeingLoaded
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
   149
    "private helper:
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
   150
      reads a class, installs and returns it.
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
   151
      The class is searched along the ClassPath.
43
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   152
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   153
     This is a partial load (to load other classes):
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   154
     - The classes stringConstants are not fixed to be JavaStrings 
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   155
       (i.e they are still ST-Strings).
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
   156
     - The class is NOT initialized."
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
   157
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   158
    |rslt clsName cls loadedClass|
50
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
   159
52
1dc41619b6f8 checkin from browser
cg
parents: 50
diff changeset
   160
    (aClassName endsWith:';') ifTrue:[
278
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   161
        ('oops - loading of ' , aClassName , ' attempted') printNL.
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   162
        self halt:'should not happen'.
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   163
        ^ nil
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   164
    ].
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   165
    (aClassName endsWith:'[]') ifTrue:[
278
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   166
        ('oops - loading of ' , aClassName , ' attempted') printNL.
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   167
        self halt:'should not happen'.
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   168
        ^ nil
52
1dc41619b6f8 checkin from browser
cg
parents: 50
diff changeset
   169
    ].
1dc41619b6f8 checkin from browser
cg
parents: 50
diff changeset
   170
50
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
   171
    clsName := aClassName.
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
   172
    (clsName includes:$.) ifTrue:[
360
e3df9401df00 use #copyReplaceAll:with:
cg
parents: 357
diff changeset
   173
        clsName := clsName asString copyReplaceAll:$. with:$/
50
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
   174
    ].
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
   175
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   176
    (classesBeingLoaded notNil and:[classesBeingLoaded includes:clsName]) ifTrue:[
278
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   177
        ('oops - recursive load of ' , clsName , ' attempted') printNL.
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   178
        self halt:'should not happen'.
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   179
        ^ JavaUnresolvedClassConstant fullName:clsName
54
f37bcefb7091 avoid loading classes twice
cg
parents: 52
diff changeset
   180
    ].
f37bcefb7091 avoid loading classes twice
cg
parents: 52
diff changeset
   181
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   182
    (cls := Java at:clsName) notNil ifTrue:[
278
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   183
        ('oops - ' , clsName , ' is already loaded') printNL.
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   184
        self halt:clsName , ' is already loaded - should not happen'.
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   185
        ^ cls
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   186
    ].
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   187
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   188
    classesBeingLoaded isNil ifTrue:[
278
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   189
        loadedClass := Set with:clsName
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   190
    ] ifFalse:[
278
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   191
        loadedClass := Set withAll:classesBeingLoaded.
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   192
        loadedClass add:clsName.
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   193
    ].
54
f37bcefb7091 avoid loading classes twice
cg
parents: 52
diff changeset
   194
135
098936234135 *** empty log message ***
cg
parents: 128
diff changeset
   195
    Java classPath do:[:path |
365
568f3a4e4e1c checkin from browser
cg
parents: 360
diff changeset
   196
        |nm p zar entry zipFile|
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   197
278
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   198
        p := path.
327
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   199
        p asFilename isDirectory ifTrue:[
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   200
            (p endsWith:Filename separator) ifFalse:[
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   201
                p := p , (Filename separator asString)
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   202
            ].
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   203
            (Array 
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   204
                with:clsName
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   205
                with:clsName asLowercase
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   206
                with:clsName asUppercase) 
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   207
            do:[:tryName |
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   208
                (nm := p , tryName , '.class') asFilename exists ifTrue:[
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   209
                    (Java isExcludedFromClassPath:nm) ifFalse:[
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   210
                        rslt := self loadFileLazy:nm ignoring:loadedClass.
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   211
                        rslt notNil ifTrue:[^ rslt].
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   212
                    ]
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   213
                ].
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   214
            ]
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   215
        ] ifFalse:[
370
2a2e5914ee22 also look for zar suffix files.
cg
parents: 366
diff changeset
   216
            ((zipFile := p asFilename withSuffix:'jar') exists 
2a2e5914ee22 also look for zar suffix files.
cg
parents: 366
diff changeset
   217
            or:[(zipFile := p asFilename withSuffix:'zip') exists]) ifTrue:[
365
568f3a4e4e1c checkin from browser
cg
parents: 360
diff changeset
   218
                zar := ZipArchive oldFileNamed:zipFile.
327
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   219
                (Array 
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   220
                    with:clsName
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   221
                    with:clsName asLowercase
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   222
                    with:clsName asUppercase) 
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   223
                do:[:tryName |
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   224
                    nm := tryName , '.class'.
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   225
                    entry := zar extract:nm.
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   226
                    entry notNil ifTrue:[
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   227
                        (Java isExcludedFromClassPath:nm) ifFalse:[
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   228
                            rslt := self loadStreamLazy:(entry readStream) ignoring:loadedClass.
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   229
                            rslt notNil ifTrue:[^ rslt].
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   230
                        ]
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   231
                    ]
278
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   232
                ]
327
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   233
            ]
278
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   234
        ]
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
   235
    ].
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
   236
318
8720093188f7 debugPrints
cg
parents: 278
diff changeset
   237
    ('JAVA [info]: no file found for: ' , clsName) infoPrintCR.
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   238
    ^ nil
135
098936234135 *** empty log message ***
cg
parents: 128
diff changeset
   239
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
   240
    "Modified: / 14.8.1997 / 11:38:42 / stefan"
370
2a2e5914ee22 also look for zar suffix files.
cg
parents: 366
diff changeset
   241
    "Modified: / 17.9.1998 / 20:51:25 / cg"
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
   242
!
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
   243
7
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   244
loadFile:aFilename
43
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   245
    "reads a class from aFilename, installs and returns it.
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   246
     The classes strings are fixed and its class-init function is called."
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   247
54
f37bcefb7091 avoid loading classes twice
cg
parents: 52
diff changeset
   248
    self loadFileLazy:aFilename ignoring:(Set new).
43
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   249
    self postLoadActions
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   250
!
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   251
54
f37bcefb7091 avoid loading classes twice
cg
parents: 52
diff changeset
   252
loadFileLazy:aFilename ignoring:classesBeingLoaded
43
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   253
    "reads a class from aFilename, installs and returns it.
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   254
     Strings are fixed and classrefs are fixed, 
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   255
     but NO no class-init functions are called."
7
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   256
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   257
    |aClass pool|
7
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   258
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   259
    aClass := self readFile:aFilename ignoring:classesBeingLoaded.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   260
    aClass notNil ifTrue:[
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   261
        aClass isJavaClass ifTrue:[
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   262
            "/ a java class
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   263
            Java at:(aClass fullName asSymbol) put:aClass.
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   264
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   265
            classesBeingLoaded remove:aClass fullName ifAbsent:nil.
21
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
   266
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   267
            JavaUnresolvedConstant resolveFor:aClass.
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   268
        ] ifFalse:[    
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   269
            "/ a smalltalk class
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   270
            "/ self halt.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   271
aClass inspect.
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   272
        ]
7
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   273
    ].
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   274
    ^ aClass
7
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   275
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   276
    "
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   277
     JavaClassReader loadFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   278
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   279
     '/phys/ibm3/java/lib/java/lang' asFilename
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   280
        directoryContents do:[:nm |
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   281
            (nm endsWith:'.class') ifTrue:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   282
                ('/phys/ibm3/java/lib/java/lang/' , nm) printNL.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   283
                JavaClassReader loadFile:'/phys/ibm3/java/lib/java/lang/' , nm
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   284
            ]
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   285
        ].
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   286
14
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
   287
     '/phys/ibm3/java/lib/java/io' asFilename
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   288
        directoryContents do:[:nm |
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   289
            (nm endsWith:'.class') ifTrue:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   290
                ('/phys/ibm3/java/lib/java/io/' , nm) printNL.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   291
                JavaClassReader loadFile:'/phys/ibm3/java/lib/java/io/' , nm
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   292
            ]
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   293
        ].
14
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
   294
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
   295
     '/phys/ibm3/java/lib/java/net' asFilename
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   296
        directoryContents do:[:nm |
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   297
            (nm endsWith:'.class') ifTrue:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   298
                ('/phys/ibm3/java/lib/java/net/' , nm) printNL.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   299
                JavaClassReader loadFile:'/phys/ibm3/java/lib/java/net/' , nm
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   300
            ]
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   301
        ].
14
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
   302
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
   303
     '/phys/ibm3/java/lib/java/util' asFilename
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   304
        directoryContents do:[:nm |
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   305
            (nm endsWith:'.class') ifTrue:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   306
                ('/phys/ibm3/java/lib/java/util/' , nm) printNL.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   307
                JavaClassReader loadFile:'/phys/ibm3/java/lib/java/util/' , nm
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   308
            ]
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   309
        ].
14
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
   310
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
   311
     '/phys/ibm3/java/lib/java/awt' asFilename
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   312
        directoryContents do:[:nm |
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   313
            (nm endsWith:'.class') ifTrue:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   314
                ('/phys/ibm3/java/lib/java/awt/' , nm) printNL.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   315
                JavaClassReader loadFile:'/phys/ibm3/java/lib/java/awt/' , nm
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   316
            ]
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   317
        ].
14
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
   318
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
   319
     '/phys/ibm3/java/lib/java/applet' asFilename
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   320
        directoryContents do:[:nm |
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   321
            (nm endsWith:'.class') ifTrue:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   322
                ('/phys/ibm3/java/lib/java/applet/' , nm) printNL.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   323
                JavaClassReader loadFile:'/phys/ibm3/java/lib/java/applet/' , nm
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   324
            ]
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   325
        ].
14
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
   326
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   327
     JavaClassReader loadFile:'/phys/ibm3/java/lib/java/lang/AbstractMethodError.class'
14
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
   328
     JavaClassReader loadFile:'/phys/ibm3/java/lib/java/lang/Thread.class'
7
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   329
    "
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   330
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   331
    "Created: / 15.4.1996 / 14:58:53 / cg"
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   332
    "Modified: / 12.5.1998 / 22:06:52 / cg"
7
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   333
!
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   334
327
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   335
loadStreamLazy:aStream ignoring:classesBeingLoaded
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   336
    "reads a class from aStream, installs and returns it.
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   337
     Strings are fixed and classrefs are fixed, 
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   338
     but NO no class-init functions are called."
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   339
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   340
    |javaClass pool|
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   341
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   342
    javaClass := self readStream:aStream ignoring:classesBeingLoaded.
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   343
    javaClass notNil ifTrue:[
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   344
        Java at:(javaClass fullName asSymbol) put:javaClass.
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   345
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   346
        classesBeingLoaded remove:javaClass fullName ifAbsent:nil.
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   347
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   348
        JavaUnresolvedConstant resolveFor:javaClass.
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   349
    ].
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   350
    ^ javaClass
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   351
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   352
    "Created: / 30.3.1998 / 17:59:02 / cg"
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   353
!
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   354
399
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   355
loadSystemClass:aClassName
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   356
    "reads a class, installs and returns it.
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   357
     The classes string constants are resolved & <clinit> is called,
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   358
     if it implements it.
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   359
     This only loads local classes (i.e. any Java classReader is not used)"
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   360
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   361
    |rslt|
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   362
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   363
    rslt := self loadClassLazy:aClassName ignoring:(Set new).
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   364
    rslt notNil ifTrue:[self postLoadActions].
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   365
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   366
    ^ rslt
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   367
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   368
    "
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   369
     JavaClassReader loadSystemClass:'awt/Component'
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   370
     JavaClassReader loadSystemClass:'awt/Button'
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   371
     JavaClassReader loadSystemClass:'browser/AddButton'
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   372
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   373
     JavaClassReader loadSystemClass:'java/lang/Object'
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   374
     JavaClassReader loadSystemClass:'java/lang/AbstractMethodError'
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   375
     JavaClassReader loadSystemClass:'java/lang/Thread'
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   376
    "
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   377
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   378
    "Modified: / 3.1.1998 / 22:36:13 / cg"
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   379
    "Created: / 20.10.1998 / 17:24:40 / cg"
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   380
!
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   381
43
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   382
postLoadActions
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   383
    "Resolve all classes' string constants.
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   384
     Perform all class initialization functions (of those which are not
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   385
     yet initialized)."
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   386
225
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   387
    ^ self postLoadActions:true
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   388
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   389
    "Modified: 15.8.1997 / 01:02:17 / cg"
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   390
!
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   391
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   392
postLoadActions:loadUnresolved
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   393
    "Resolve all classes' string constants.
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
   394
     Perform all class initialization functions 
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
   395
     (of those which are not yet initialized)."
225
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   396
223
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   397
    |classes prevUnresolved newUnresolved loader|
43
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   398
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   399
    "/ need at least java.lang.String, for valid constants
167
77dcbc4b2201 *** empty log message ***
cg
parents: 135
diff changeset
   400
    Java java_lang_String isNil ifTrue:[
255
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   401
        self loadClassLazy:'java.lang.String' ignoring:(Set new).
54
f37bcefb7091 avoid loading classes twice
cg
parents: 52
diff changeset
   402
    ].
f37bcefb7091 avoid loading classes twice
cg
parents: 52
diff changeset
   403
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   404
    LazyClassLoading ifFalse:[
547
38870f6447d0 raise -> query
cg
parents: 475
diff changeset
   405
        loader := ClassLoaderQuerySignal query.
255
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   406
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   407
        prevUnresolved := nil.
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   408
        newUnresolved := JavaUnresolvedConstant unresolvedClassNames asArray.
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   409
        loadUnresolved ifTrue:[
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   410
            [prevUnresolved ~= newUnresolved] whileTrue:[
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   411
                newUnresolved do:[:nextUnresolved |
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   412
                    |classURL|
223
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   413
255
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   414
                    (Java at:nextUnresolved) isNil ifTrue:[ "/ could have been loaded in the meantime
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   415
                        Silent ifFalse:[
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   416
                            'loading unresolved: ' print. nextUnresolved printCR.
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   417
                        ].
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   418
                        loader isNil ifTrue:[
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   419
                            self
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   420
                                loadClassLazy:nextUnresolved
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   421
                                ignoring:(Set new).
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   422
                        ] ifFalse:[
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   423
                            "/
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   424
                            "/ the aquired loader is a javaClassLoader
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   425
                            "/ which expects an URL as arg.
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   426
                            "/
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   427
                            "/ classURL := Java as_URL:('file:' , nextUnresolved asString , '.class').
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   428
                            "/ loader loadClass:classURL
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   429
                            loader
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   430
                                perform:#'loadClass(Ljava/lang/String;)Ljava/lang/Class;'
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   431
                                with:(Java as_String:(nextUnresolved asString)).
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   432
                        ]
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   433
                    ]
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   434
                ].
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   435
                prevUnresolved := newUnresolved.
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   436
                newUnresolved := JavaUnresolvedConstant unresolvedClassNames asArray.
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   437
            ].
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   438
        ].
407
568d64f6d7d6 checkin from browser
cg
parents: 399
diff changeset
   439
false ifTrue:[
255
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   440
        newUnresolved size == 0 ifTrue:[
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   441
            "/ nothing unresolved
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   442
255
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   443
            (classes := Java allClasses) notNil ifTrue:[
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   444
                "/ init all new classes
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   445
                "/ fetch again - there could be new ones ...
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   446
255
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   447
                classes := Java allClasses.
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   448
                classes do:[:aJavaClass |
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   449
                    aJavaClass isInitialized ifFalse:[
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   450
                        Silent ifFalse:[
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   451
                            'performing class initialization of ' print. aJavaClass fullName printCR.
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   452
                        ].
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   453
                        aJavaClass classInit
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   454
                    ]
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   455
                ]
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   456
            ]
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   457
        ].
407
568d64f6d7d6 checkin from browser
cg
parents: 399
diff changeset
   458
].
43
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   459
    ]
167
77dcbc4b2201 *** empty log message ***
cg
parents: 135
diff changeset
   460
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
   461
    "Created: / 15.8.1997 / 01:01:44 / cg"
407
568d64f6d7d6 checkin from browser
cg
parents: 399
diff changeset
   462
    "Modified: / 21.10.1998 / 01:18:35 / cg"
43
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   463
!
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   464
54
f37bcefb7091 avoid loading classes twice
cg
parents: 52
diff changeset
   465
readFile:aFilename ignoring:classesBeingLoaded
7
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   466
    "reads a class from aFilename and returns it.
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   467
     The JavaClass is NOT installed as global and unresolved
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   468
     refs are NOT patched."
7
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   469
73
a1268823f1a4 *** empty log message ***
cg
parents: 72
diff changeset
   470
    |inStream javaClass|
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   471
43
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   472
    Silent ifFalse:[
318
8720093188f7 debugPrints
cg
parents: 278
diff changeset
   473
        'reading ' print. aFilename print. ' ...' printNL.
43
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   474
    ].
21
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
   475
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   476
    inStream := aFilename asFilename readStream.
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   477
    inStream isNil ifTrue:[
318
8720093188f7 debugPrints
cg
parents: 278
diff changeset
   478
        ('JAVA [info]: no file: ' , aFilename) printCR.
8720093188f7 debugPrints
cg
parents: 278
diff changeset
   479
        self halt.
8720093188f7 debugPrints
cg
parents: 278
diff changeset
   480
        ^ nil
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   481
    ].
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   482
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   483
    javaClass := self new readStream:inStream ignoring:classesBeingLoaded.
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   484
    (javaClass notNil and:[javaClass isJavaClass]) ifTrue:[
318
8720093188f7 debugPrints
cg
parents: 278
diff changeset
   485
        javaClass setBinaryFilePath:(inStream pathName).
73
a1268823f1a4 *** empty log message ***
cg
parents: 72
diff changeset
   486
    ].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   487
    inStream close.
27
4560bb77bb36 checkin from browser
cg
parents: 21
diff changeset
   488
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   489
    AbsolutelySilent ifFalse:[
318
8720093188f7 debugPrints
cg
parents: 278
diff changeset
   490
        '  ... loaded ' print. javaClass displayString printNL.
43
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   491
    ].
27
4560bb77bb36 checkin from browser
cg
parents: 21
diff changeset
   492
73
a1268823f1a4 *** empty log message ***
cg
parents: 72
diff changeset
   493
    ^ javaClass
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   494
318
8720093188f7 debugPrints
cg
parents: 278
diff changeset
   495
    "Created: / 15.4.1996 / 14:58:53 / cg"
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   496
    "Modified: / 9.5.1998 / 01:44:24 / cg"
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   497
!
083530508d9c intitial checkin
cg
parents:
diff changeset
   498
198
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
   499
readStream:aStream
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
   500
    "reads a class from aStream and returns it.
223
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   501
     The JavaClass is installed as global.
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   502
     If new classes are required to be loaded, a new standard loader
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   503
     is created."
198
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
   504
223
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   505
    ^ self readStream:aStream loader:nil
198
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
   506
223
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   507
    "Modified: 14.8.1997 / 19:51:50 / cg"
198
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
   508
!
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
   509
54
f37bcefb7091 avoid loading classes twice
cg
parents: 52
diff changeset
   510
readStream:aStream ignoring:classesBeingLoaded
7
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   511
    "reads a class from aStream and returns it.
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   512
     The JavaClass is not installed as global"
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   513
327
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   514
    |javaClass|
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   515
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   516
    javaClass :=  self new readStream:aStream ignoring:classesBeingLoaded.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   517
327
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   518
    AbsolutelySilent ifFalse:[
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   519
        '  ... loaded ' print. javaClass displayString printNL.
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   520
    ].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   521
327
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   522
    ^ javaClass
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   523
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   524
    "Modified: / 30.3.1998 / 18:14:40 / cg"
223
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   525
!
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   526
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   527
readStream:aStream loader:aClassLoader
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   528
    "reads a class from aStream and returns it.
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   529
     The JavaClass is installed as global.
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   530
     If new classes are required to be loaded, aClassLoader is
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   531
     asked to do it. If aClassLoader is nil, a new standard loader
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   532
     is created."
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   533
225
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   534
    ^ self
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
   535
	readStream:aStream 
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
   536
	loader:aClassLoader 
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
   537
	loadUnresolved:true
225
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   538
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   539
    "Modified: 15.8.1997 / 01:00:35 / cg"
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   540
!
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   541
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   542
readStream:aStream loader:aClassLoader loadUnresolved:loadUnresolved
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   543
    "reads a class from aStream and returns it.
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   544
     The JavaClass is installed as global.
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   545
     If new classes are required to be loaded, aClassLoader is
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   546
     asked to do it. If aClassLoader is nil, a new standard loader
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   547
     is created."
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   548
223
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   549
    |javaClass|
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   550
269
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   551
    ClassLoaderQuerySignal answer:aClassLoader
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   552
    do:[
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   553
        javaClass := self readStream:aStream ignoring:(Set new).
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   554
        javaClass notNil ifTrue:[
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   555
            self postLoadActions:loadUnresolved.
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   556
            Java at:(javaClass fullName asSymbol) put:javaClass.
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   557
            JavaUnresolvedConstant resolveFor:javaClass.
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   558
        ].
223
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   559
    ].
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   560
    ^ javaClass
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   561
269
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   562
    "Created: / 15.8.1997 / 00:59:24 / cg"
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   563
    "Modified: / 23.1.1998 / 17:14:09 / cg"
399
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   564
!
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   565
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   566
resolveClass:aJavaClass
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   567
    "Resolve a particular classes' constants.
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   568
     Perform all class initialization functions 
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   569
     (of those which are not yet initialized)."
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   570
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   571
    |loader classToLoad|
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   572
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   573
    LazyClassLoading ifFalse:[
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   574
        loader := (aJavaClass classLoader). "/ ? (ClassLoaderQuerySignal raise).
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   575
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   576
        [
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   577
            classToLoad := nil.
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   578
            aJavaClass constantPool do:[:item |
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   579
                |itemClass |
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   580
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   581
                itemClass := item class.
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   582
                itemClass == JavaUnresolvedClassConstant ifTrue:[
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   583
                    classToLoad := item className.
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   584
"/                ] ifFalse:[
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   585
"/                    itemClass == JavaUnresolvedMethodrefConstant ifTrue:[
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   586
"/self halt.
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   587
"/                    ] ifFalse:[
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   588
"/                        itemClass == JavaUnresolvedInterfaceMethodrefConstant ifTrue:[
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   589
"/self halt.
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   590
"/                        ]
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   591
"/                    ]
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   592
                ].
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   593
            ].
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   594
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   595
            classToLoad notNil ifTrue:[
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   596
                loader isNil ifTrue:[
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   597
                    self
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   598
                        loadClassLazy:classToLoad
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   599
                        ignoring:(Set new).
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   600
                ] ifFalse:[
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   601
                    "/
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   602
                    "/ the aquired loader is a javaClassLoader
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   603
                    "/ which expects an URL as arg.
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   604
                    "/
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   605
                    "/ classURL := Java as_URL:('file:' , nextUnresolved asString , '.class').
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   606
                    "/ loader loadClass:classURL
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   607
                    loader
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   608
                        perform:#'loadClass(Ljava/lang/String;)Ljava/lang/Class;'
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   609
                        with:(Java as_String:(classToLoad asString)).
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   610
                ]
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   611
            ].
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   612
            classToLoad notNil.
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   613
        ] whileTrue.
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   614
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   615
        aJavaClass isInitialized ifFalse:[
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   616
            Silent ifFalse:[
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   617
                'performing class initialization of ' print. aJavaClass fullName printCR.
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   618
            ].
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   619
            aJavaClass classInit
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   620
        ].
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   621
    ]
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   622
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   623
    "Created: / 20.10.1998 / 17:53:22 / cg"
94d37f2032a1 classloader fixes.
cg
parents: 386
diff changeset
   624
    "Modified: / 20.10.1998 / 17:59:09 / cg"
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   625
! !
083530508d9c intitial checkin
cg
parents:
diff changeset
   626
083530508d9c intitial checkin
cg
parents:
diff changeset
   627
!JavaClassReader methodsFor:'file reading'!
083530508d9c intitial checkin
cg
parents:
diff changeset
   628
54
f37bcefb7091 avoid loading classes twice
cg
parents: 52
diff changeset
   629
readClassFileIgnoring:classesbeingLoaded
7
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   630
    "reads a class from inStream and returns it.
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
   631
     The JavaClass is not installed as global and its constants
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
   632
     (especially strings) may not be fully resolved."
7
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   633
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   634
    |magic 
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
   635
     access_flags this_class this_class_index super_class super_class_index
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
   636
     realSuperClass this_class_ref existingSuperClass
269
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   637
     fields interfaces staticFields nStatic
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   638
     jSuperClass loader superClassName thisClassName existing_class
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   639
     thisMetaClass|
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   640
083530508d9c intitial checkin
cg
parents:
diff changeset
   641
    "/
083530508d9c intitial checkin
cg
parents:
diff changeset
   642
    "/ read magic, determine byte order
083530508d9c intitial checkin
cg
parents:
diff changeset
   643
    "/
083530508d9c intitial checkin
cg
parents:
diff changeset
   644
    msb := true.
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
   645
    magic := inStream nextUnsignedLongMSB:true.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
   646
    magic = (self class magic_MSB) ifFalse:[
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
   647
        magic = (self class magic_LSB) ifFalse:[
269
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   648
            InvalidClassFormatSignal raiseErrorString:'not a java class file'.
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   649
            ^ nil
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   650
        ].
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   651
        msb := false.
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   652
        Verbose ifTrue:[Transcript showCR:'file is lsb'].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   653
    ] ifTrue:[
269
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   654
        Verbose ifTrue:[Transcript showCR:'file is msb'].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   655
    ].
083530508d9c intitial checkin
cg
parents:
diff changeset
   656
083530508d9c intitial checkin
cg
parents:
diff changeset
   657
    "/
083530508d9c intitial checkin
cg
parents:
diff changeset
   658
    "/ get version
083530508d9c intitial checkin
cg
parents:
diff changeset
   659
    "/
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
   660
    minorVsn := inStream nextUnsignedShortMSB:msb.
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
   661
    majorVsn := inStream nextUnsignedShortMSB:msb.
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   662
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
   663
    (majorVsn ~~ (self class fileMajorVersion) 
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
   664
    or:[minorVsn ~~ (self class fileMinorVersion)]) ifTrue:[
269
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   665
        Transcript show:'warning this file has version '; show:majorVsn; show:'.'; showCR:minorVsn. 
99
d1248315f589 support vsn 45.2 AND 45.3 classFile formats
cg
parents: 97
diff changeset
   666
    ].
d1248315f589 support vsn 45.2 AND 45.3 classFile formats
cg
parents: 97
diff changeset
   667
d1248315f589 support vsn 45.2 AND 45.3 classFile formats
cg
parents: 97
diff changeset
   668
    Verbose ifTrue:[
269
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   669
        Transcript show:'version = '; 
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   670
                   show:(majorVsn printString); 
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   671
                   show:'.';
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   672
                   showCR:(minorVsn printString).
99
d1248315f589 support vsn 45.2 AND 45.3 classFile formats
cg
parents: 97
diff changeset
   673
    ].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   674
083530508d9c intitial checkin
cg
parents:
diff changeset
   675
    "/
083530508d9c intitial checkin
cg
parents:
diff changeset
   676
    "/ get constant pool
083530508d9c intitial checkin
cg
parents:
diff changeset
   677
    "/
083530508d9c intitial checkin
cg
parents:
diff changeset
   678
    self readConstantPool.
083530508d9c intitial checkin
cg
parents:
diff changeset
   679
083530508d9c intitial checkin
cg
parents:
diff changeset
   680
    "/
083530508d9c intitial checkin
cg
parents:
diff changeset
   681
    "/ access flags
083530508d9c intitial checkin
cg
parents:
diff changeset
   682
    "/
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
   683
    access_flags := inStream nextUnsignedShortMSB:msb.
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
   684
    this_class_index := inStream nextUnsignedShortMSB:msb.
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
   685
    super_class_index := inStream nextUnsignedShortMSB:msb.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   686
14
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
   687
    super_class_index == 0 ifTrue:[
269
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   688
        super_class := nil
14
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
   689
    ] ifFalse:[
269
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   690
        super_class := constants at:super_class_index.
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   691
        superClassName := super_class fullName.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   692
        
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   693
        "/ special for ST-classes
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   694
        (superClassName startsWith:'smalltalk.') ifTrue:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   695
            "/ a Smalltalk class
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   696
            superClassName := superClassName copyFrom:11.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   697
            existingSuperClass := Smalltalk at:superClassName asSymbol.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   698
            existingSuperClass notNil ifTrue:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   699
                super_class := existingSuperClass
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   700
            ] ifFalse:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   701
                "/ self halt - must load superclass ...
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   702
            ]
269
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   703
        ] ifFalse:[
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   704
            "/ a JAVA class
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   705
            existingSuperClass := Java classNamed:superClassName.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   706
            existingSuperClass notNil ifTrue:[
269
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   707
                super_class := existingSuperClass
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   708
            ] ifFalse:[
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   709
                (super_class isMemberOf:JavaUnresolvedClassConstant) ifTrue:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   710
                    Silent ifFalse:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   711
                        'load superClass: ' print. superClassName printCR.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   712
                    ].
547
38870f6447d0 raise -> query
cg
parents: 475
diff changeset
   713
                    loader := ClassLoaderQuerySignal query.
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   714
                    loader isNil ifTrue:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   715
                        existingSuperClass := self class 
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   716
                                            loadClassLazy:superClassName
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   717
                                            ignoring:classesbeingLoaded.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   718
                    ] ifFalse:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   719
                        jSuperClass := loader
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   720
                                    perform:#'loadClass(Ljava/lang/String;)Ljava/lang/Class;'
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   721
                                    with:(Java as_String:superClassName).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   722
                        existingSuperClass := JavaVM classForJavaClassObject:jSuperClass.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   723
                    ].
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   724
                    existingSuperClass isNil ifTrue:[
443
f5c1f55d8bdb *** empty log message ***
cg
parents: 433
diff changeset
   725
                        ('JAVA: cannot find superclass: ' , superClassName) infoPrintCR.
f5c1f55d8bdb *** empty log message ***
cg
parents: 433
diff changeset
   726
                        "/ self halt:('cannot find superclass: ' , superClassName).
f5c1f55d8bdb *** empty log message ***
cg
parents: 433
diff changeset
   727
                        ^ nil.
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   728
                    ].
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   729
                    super_class := existingSuperClass
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   730
                ] ifFalse:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   731
                    self halt:'oops - superclass ?'
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   732
                ]
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   733
            ].
269
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   734
        ].
14
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
   735
    ].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   736
083530508d9c intitial checkin
cg
parents:
diff changeset
   737
    "/
083530508d9c intitial checkin
cg
parents:
diff changeset
   738
    "/ get interfaces
083530508d9c intitial checkin
cg
parents:
diff changeset
   739
    "/
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
   740
    interfaces := self readInterfaces.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   741
083530508d9c intitial checkin
cg
parents:
diff changeset
   742
    "/
083530508d9c intitial checkin
cg
parents:
diff changeset
   743
    "/ get fields
083530508d9c intitial checkin
cg
parents:
diff changeset
   744
    "/
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
   745
    fields := self readFieldInfofields.
40
7f332a95e015 checkin from browser
cg
parents: 39
diff changeset
   746
7f332a95e015 checkin from browser
cg
parents: 39
diff changeset
   747
    "/
7f332a95e015 checkin from browser
cg
parents: 39
diff changeset
   748
    "/ create the fields as instVars
7f332a95e015 checkin from browser
cg
parents: 39
diff changeset
   749
    "/ static fields are created as class-InstVars
7f332a95e015 checkin from browser
cg
parents: 39
diff changeset
   750
    "/
7f332a95e015 checkin from browser
cg
parents: 39
diff changeset
   751
    staticFields := fields select:[:f | f isStatic].
7f332a95e015 checkin from browser
cg
parents: 39
diff changeset
   752
    nStatic := staticFields size.
7f332a95e015 checkin from browser
cg
parents: 39
diff changeset
   753
7f332a95e015 checkin from browser
cg
parents: 39
diff changeset
   754
    this_class_ref := constants at:this_class_index.
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   755
    thisClassName := this_class_ref fullName.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   756
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   757
    "/ care for smalltalk classes ...
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   758
    (thisClassName startsWith:'smalltalk.') ifTrue:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   759
        thisClassName := thisClassName copyFrom:11.
182
5f85fd0fec56 checkin from browser
cg
parents: 177
diff changeset
   760
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   761
        existing_class := Smalltalk at:thisClassName asSymbol.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   762
        existing_class notNil ifTrue:[
355
9452f8876652 *** empty log message ***
cg
parents: 353
diff changeset
   763
            self halt:('overloading existing class: ', thisClassName).
9452f8876652 *** empty log message ***
cg
parents: 353
diff changeset
   764
            thisClassName := (thisClassName , '_new') asSymbol.
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   765
        ].
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   766
        thisMetaClass := Metaclass new.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   767
        thisMetaClass setSuperclass:super_class class.
355
9452f8876652 *** empty log message ***
cg
parents: 353
diff changeset
   768
        thisMetaClass instSize:(super_class class instSize + nStatic).
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   769
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   770
        this_class := thisMetaClass new.
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   771
        this_class setSuperclass:super_class.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   772
        this_class setName:thisClassName asSymbol.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   773
    ] ifFalse:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   774
        "/ a java class
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   775
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   776
        this_class := JavaClass fullName:thisClassName numStatic:nStatic.
40
7f332a95e015 checkin from browser
cg
parents: 39
diff changeset
   777
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   778
        nStatic ~~ 0 ifTrue:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   779
            fields := fields select:[:f | f isStatic not].
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   780
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   781
            JavaClass setInstanceVariableStringFromFields:staticFields in:this_class class.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   782
            this_class setStaticFields:staticFields.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   783
            this_class initializeStaticFields.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   784
        ].
40
7f332a95e015 checkin from browser
cg
parents: 39
diff changeset
   785
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   786
        this_class setAccessFlags:access_flags.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   787
        this_class setSuperclass:super_class.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   788
        this_class setConstantPool:constants.
40
7f332a95e015 checkin from browser
cg
parents: 39
diff changeset
   789
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   790
        this_class setFields:fields.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   791
        this_class setInterfaces:interfaces.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   792
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   793
        constants owner:this_class.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   794
    ].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   795
083530508d9c intitial checkin
cg
parents:
diff changeset
   796
    "/
083530508d9c intitial checkin
cg
parents:
diff changeset
   797
    "/ get methods
083530508d9c intitial checkin
cg
parents:
diff changeset
   798
    "/
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
   799
    self readMethodsFor:this_class.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   800
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   801
    self readAttributesFor:this_class.
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   802
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   803
    ^ this_class
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   804
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   805
    "
355
9452f8876652 *** empty log message ***
cg
parents: 353
diff changeset
   806
     JavaClassReader loadFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
9452f8876652 *** empty log message ***
cg
parents: 353
diff changeset
   807
     JavaClassReader loadFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class'
9452f8876652 *** empty log message ***
cg
parents: 353
diff changeset
   808
     JavaClassReader loadFile:'foo.cls'
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   809
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   810
     JavaClassReader verbose:true.
355
9452f8876652 *** empty log message ***
cg
parents: 353
diff changeset
   811
     JavaClassReader loadFile:'/phys/ibm3/hotjava/classes/java/lang/ArithmeticException.class'
9452f8876652 *** empty log message ***
cg
parents: 353
diff changeset
   812
     JavaClassReader loadFile:'/phys/ibm3/java/lib/java/lang/ArithmeticException.class'
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   813
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
   814
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
   815
    "Created: / 15.4.1996 / 15:02:47 / cg"
443
f5c1f55d8bdb *** empty log message ***
cg
parents: 433
diff changeset
   816
    "Modified: / 12.11.1998 / 21:14:45 / cg"
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   817
!
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   818
54
f37bcefb7091 avoid loading classes twice
cg
parents: 52
diff changeset
   819
readStream:aStream ignoring:classesBeingLoaded
7
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   820
    "reads a class from aStream and returns it.
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   821
     The JavaClass is not installed as global"
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   822
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   823
    inStream := aStream.
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   824
    inStream binary.
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
   825
54
f37bcefb7091 avoid loading classes twice
cg
parents: 52
diff changeset
   826
    ^ self readClassFileIgnoring:classesBeingLoaded
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   827
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   828
    "
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   829
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   830
    "
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   831
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   832
    "Created: 15.4.1996 / 15:00:55 / cg"
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   833
    "Modified: 15.4.1996 / 15:06:18 / cg"
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   834
! !
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   835
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   836
!JavaClassReader methodsFor:'file reading - attributes'!
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   837
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   838
readAttribute:attributeName for:something
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
   839
    "/ implemented ST attributes
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
   840
    (attributeName = 'STLiterals') ifTrue:[
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
   841
        self readSTLiteralsAttributeFor:something.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
   842
        ^ self.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
   843
    ].
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   844
    (attributeName = 'ClassRevision') ifTrue:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   845
        self readSTClassRevisionAttributeFor:something.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   846
        ^ self.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   847
    ].
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   848
    (attributeName = 'ClassPackage') ifTrue:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   849
        self readSTClassPackageAttributeFor:something.
348
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
   850
        ^ self.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
   851
    ].
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   852
    (attributeName = 'ClassCategory') ifTrue:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   853
        self readSTClassCategoryAttributeFor:something.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   854
        ^ self.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   855
    ].
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   856
    (attributeName = 'ClassVarNames') ifTrue:[
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   857
        self readSTClassVarNamesAttributeFor:something.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   858
        ^ self.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   859
    ].
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   860
    (attributeName = 'ClassInstVarNames') ifTrue:[
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   861
        self readSTClassInstVarNamesAttributeFor:something.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   862
        ^ self.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   863
    ].
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   864
    (attributeName = 'InstVarNames') ifTrue:[
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   865
        self readSTInstVarNamesAttributeFor:something.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   866
        ^ self.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   867
    ].
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   868
    (attributeName = 'STCode') ifTrue:[
357
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
   869
        self readSTCodeAttributeFor:something.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
   870
        ^ self.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
   871
    ].
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
   872
    (attributeName = 'MethodCategory') ifTrue:[
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
   873
        self readSTMethodCategoryAttributeFor:something.
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   874
        ^ self.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   875
    ].
83
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
   876
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
   877
    "/ implemented JAVA attributes
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   878
    (attributeName = 'Code') ifTrue:[
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   879
        self readCodeAttributeFor:something.
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   880
        ^ self.
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   881
    ].
83
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
   882
    (attributeName = 'Exceptions') ifTrue:[
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   883
        self readExceptionsAttributeFor:something.
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   884
        ^ self.
83
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
   885
    ].
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   886
    (attributeName = 'LineNumberTable') ifTrue:[
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   887
        self readLineNumberTableAttributeFor:something.
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   888
        ^ self.
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   889
    ].
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   890
    (attributeName = 'LocalVariableTable') ifTrue:[
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   891
        self readLocalVariableTableAttributeFor:something.
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   892
        ^ self.
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   893
    ].
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   894
    (attributeName = 'ConstantValue') ifTrue:[
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   895
        self readConstantValueAttributeFor:something.
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   896
        ^ self.
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   897
    ].
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   898
    (attributeName = 'SourceFile') ifTrue:[
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   899
        self readSourceFileAttributeFor:something.
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   900
        ^ self.
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   901
    ].
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   902
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
   903
    "/ ignored JAVA attributes
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   904
    (attributeName = 'Deprecated') ifTrue:[
366
42a5f6d73925 checkin from browser
cg
parents: 365
diff changeset
   905
"/        ('JAVA [info]: unhandled attribute: ' , attributeName) infoPrintCR.
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   906
        self skipAttribute:attributeName.
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   907
        ^ self.
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
   908
    ].
475
9f72432385fc checkin from browser
cg
parents: 470
diff changeset
   909
    (attributeName = 'FastJavac1.0') ifTrue:[
9f72432385fc checkin from browser
cg
parents: 470
diff changeset
   910
"/        ('JAVA [info]: unhandled attribute: ' , attributeName) infoPrintCR.
9f72432385fc checkin from browser
cg
parents: 470
diff changeset
   911
        self skipAttribute:attributeName.
9f72432385fc checkin from browser
cg
parents: 470
diff changeset
   912
        ^ self.
9f72432385fc checkin from browser
cg
parents: 470
diff changeset
   913
    ].
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   914
    (attributeName = 'AbsoluteSourcePath') ifTrue:[
335
5309d0a795b1 checkin from browser
cg
parents: 333
diff changeset
   915
        ('JAVA [info]: unhandled attribute: ' , attributeName) infoPrintCR.
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   916
        self skipAttribute:attributeName.
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   917
        ^ self.
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   918
    ].
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   919
    (attributeName = 'Synthetic') ifTrue:[
475
9f72432385fc checkin from browser
cg
parents: 470
diff changeset
   920
"/        ('JAVA [info]: unhandled attribute: ' , attributeName) infoPrintCR.
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   921
        self skipAttribute:attributeName.
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   922
        ^ self.
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   923
    ].
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   924
    (attributeName = 'InnerClasses') ifTrue:[
475
9f72432385fc checkin from browser
cg
parents: 470
diff changeset
   925
"/        ('JAVA [info]: unhandled attribute: ' , attributeName) infoPrintCR.
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   926
        self skipAttribute:attributeName.
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   927
        ^ self.
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   928
    ].
83
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
   929
386
ed3f417b7d02 checkin from browser
cg
parents: 376
diff changeset
   930
    (attributeName startsWith:((Character value:13) asString , 'WARNING:')) ifTrue:[
ed3f417b7d02 checkin from browser
cg
parents: 376
diff changeset
   931
"/        ('JAVA [info]: unhandled attribute: ' , attributeName) infoPrintCR.
ed3f417b7d02 checkin from browser
cg
parents: 376
diff changeset
   932
        self skipAttribute:attributeName.
ed3f417b7d02 checkin from browser
cg
parents: 376
diff changeset
   933
        ^ self.
ed3f417b7d02 checkin from browser
cg
parents: 376
diff changeset
   934
    ].
ed3f417b7d02 checkin from browser
cg
parents: 376
diff changeset
   935
355
9452f8876652 *** empty log message ***
cg
parents: 353
diff changeset
   936
    "/ unknown attributes
335
5309d0a795b1 checkin from browser
cg
parents: 333
diff changeset
   937
    ('JAVA [warning]: unrecognized attribute: ' , attributeName) infoPrintCR.
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   938
    self skipAttribute:attributeName.
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   939
475
9f72432385fc checkin from browser
cg
parents: 470
diff changeset
   940
    "Modified: / 3.12.1998 / 13:13:42 / cg"
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   941
!
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   942
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   943
readAttributeFor:something
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   944
    |attribute_name_index attribute_name attribute_length attribute_info|
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   945
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
   946
    Verbose ifTrue:[Transcript show:'attrib at pos: '; showCR:inStream position].
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   947
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
   948
    attribute_name_index := inStream nextUnsignedShortMSB:msb.
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   949
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   950
    "/
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   951
    "/ UNDOC feature ?
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   952
    "/
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   953
    attribute_name_index > constants size ifTrue:[
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   954
        attribute_name_index == 16rb700 ifTrue:[
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   955
            self halt.
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   956
        ]
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   957
    ].
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   958
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   959
    attribute_name := constants at:attribute_name_index.
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   960
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
   961
    Verbose ifTrue:[Transcript show:'attrib name: '; showCR:attribute_name].
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   962
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   963
    self readAttribute:attribute_name for:something.
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   964
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   965
    "
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   966
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   967
    "
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   968
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   969
    "Created: / 15.4.1996 / 15:40:17 / cg"
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   970
    "Modified: / 9.4.1998 / 18:13:34 / cg"
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   971
!
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   972
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   973
readAttributesFor:something
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   974
    |attributes_count|
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   975
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
   976
    attributes_count := inStream nextUnsignedShortMSB:msb.
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   977
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   978
    1 to:attributes_count do:[:i |
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
   979
	self readAttributeFor:something.
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   980
    ].
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   981
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   982
    "Modified: 15.4.1996 / 15:33:28 / cg"
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   983
    "Created: 15.4.1996 / 15:40:17 / cg"
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   984
!
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   985
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   986
readSourceFileAttributeFor:aClass
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   987
    |attribute_length sourceFile_index sourceFile|
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   988
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   989
    attribute_length := inStream nextUnsignedLongMSB:msb.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   990
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   991
    sourceFile_index := inStream nextUnsignedShortMSB:msb.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   992
    sourceFile := constants at:sourceFile_index.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   993
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   994
    aClass isJavaClass ifTrue:[
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   995
        aClass setSourceFile:sourceFile.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   996
    ] ifFalse:[
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   997
        aClass setClassFilename:sourceFile
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   998
    ].
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   999
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1000
    Verbose ifTrue:[Transcript show:'sourceFile: '; showCR:sourceFile].
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1001
    ^ true
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1002
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1003
    "
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1004
     JavaClassReader loadFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1005
     JavaClassReader loadFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class'
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1006
     JavaClassReader loadFile:'foo.cls'
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1007
    "
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1008
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1009
    "Created: / 15.4.1996 / 15:40:17 / cg"
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1010
    "Modified: / 12.5.1998 / 22:01:07 / cg"
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1011
!
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1012
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
  1013
skipAttribute:attributeName
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
  1014
    "dont know about this attribute - skip it here"
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
  1015
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
  1016
    |attribute_length attribute_info|
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
  1017
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
  1018
    attribute_length := inStream nextUnsignedLongMSB:msb.
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
  1019
    attribute_info := ByteArray new:(attribute_length).
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
  1020
    inStream nextBytes:attribute_length into:attribute_info startingAt:1.
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
  1021
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
  1022
    Verbose ifTrue:[Transcript show:'skipped '; show:attributeName; showCR:'-attribute'].
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
  1023
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
  1024
    "Created: / 9.4.1998 / 18:12:46 / cg"
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
  1025
    "Modified: / 9.4.1998 / 18:13:20 / cg"
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1026
! !
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1027
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1028
!JavaClassReader methodsFor:'file reading - attributes-ST'!
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1029
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1030
readSTClassCategoryAttributeFor:aClass
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1031
    |attribute_length categoryString_index categoryString|
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1032
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1033
    attribute_length := inStream nextUnsignedLongMSB:msb.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1034
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1035
    categoryString_index := inStream nextUnsignedShortMSB:msb.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1036
    categoryString := constants at:categoryString_index.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1037
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1038
    aClass category:categoryString.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1039
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1040
    Verbose ifTrue:[Transcript show:'categoryString: '; showCR:categoryString].
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1041
    ^ true
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1042
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1043
    "
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1044
     JavaClassReader loadFile:'foo.cls'
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1045
    "
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1046
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1047
    "Created: / 9.5.1998 / 02:33:13 / cg"
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1048
    "Modified: / 9.5.1998 / 02:36:55 / cg"
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1049
!
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1050
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1051
readSTClassInstVarNamesAttributeFor:aClass
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1052
    |attribute_length nameString_index nameString|
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1053
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1054
    attribute_length := inStream nextUnsignedLongMSB:msb.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1055
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1056
    nameString_index := inStream nextUnsignedShortMSB:msb.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1057
    nameString := constants at:nameString_index.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1058
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1059
    aClass class instanceVariableString:nameString.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1060
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1061
    Verbose ifTrue:[Transcript show:'nameString: '; showCR:nameString].
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1062
    ^ true
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1063
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1064
    "
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1065
     JavaClassReader loadFile:'foo.cls'
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1066
    "
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1067
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1068
    "Modified: / 12.5.1998 / 22:18:03 / cg"
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1069
    "Created: / 12.5.1998 / 22:18:24 / cg"
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1070
!
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1071
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1072
readSTClassPackageAttributeFor:aClass
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1073
    |attribute_length packageString_index packageString|
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1074
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1075
    attribute_length := inStream nextUnsignedLongMSB:msb.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1076
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1077
    packageString_index := inStream nextUnsignedShortMSB:msb.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1078
    packageString := constants at:packageString_index.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1079
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1080
    aClass package:packageString asSymbol.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1081
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1082
    Verbose ifTrue:[Transcript show:'packageString: '; showCR:packageString].
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1083
    ^ true
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1084
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1085
    "
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1086
     JavaClassReader loadFile:'foo.cls'
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1087
    "
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1088
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1089
    "Modified: / 9.5.1998 / 02:32:38 / cg"
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1090
    "Created: / 9.5.1998 / 02:33:44 / cg"
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1091
!
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1092
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1093
readSTClassRevisionAttributeFor:aClass
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1094
    |attribute_length revisionString_index revisionString|
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1095
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1096
    attribute_length := inStream nextUnsignedLongMSB:msb.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1097
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1098
    revisionString_index := inStream nextUnsignedShortMSB:msb.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1099
    revisionString := constants at:revisionString_index.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1100
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1101
    aClass setBinaryRevision:revisionString.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1102
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1103
    Verbose ifTrue:[Transcript show:'revisionString: '; showCR:revisionString].
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1104
    ^ true
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1105
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1106
    "
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1107
     JavaClassReader loadFile:'foo.cls'
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1108
    "
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1109
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1110
    "Created: / 9.5.1998 / 02:33:13 / cg"
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1111
    "Modified: / 9.5.1998 / 02:35:01 / cg"
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1112
!
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1113
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1114
readSTClassVarNamesAttributeFor:aClass
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1115
    |attribute_length nameString_index nameString|
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1116
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1117
    attribute_length := inStream nextUnsignedLongMSB:msb.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1118
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1119
    nameString_index := inStream nextUnsignedShortMSB:msb.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1120
    nameString := constants at:nameString_index.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1121
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1122
    aClass classVariableString:nameString.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1123
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1124
    Verbose ifTrue:[Transcript show:'nameString: '; showCR:nameString].
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1125
    ^ true
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1126
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1127
    "
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1128
     JavaClassReader loadFile:'foo.cls'
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1129
    "
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1130
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1131
    "Created: / 9.5.1998 / 02:33:13 / cg"
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1132
    "Modified: / 12.5.1998 / 22:18:03 / cg"
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1133
!
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1134
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1135
readSTInstVarNamesAttributeFor:aClass
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1136
    |attribute_length nameString_index nameString|
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1137
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1138
    attribute_length := inStream nextUnsignedLongMSB:msb.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1139
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1140
    nameString_index := inStream nextUnsignedShortMSB:msb.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1141
    nameString := constants at:nameString_index.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1142
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1143
    aClass setInstanceVariableString:nameString.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1144
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1145
    Verbose ifTrue:[Transcript show:'nameString: '; showCR:nameString].
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1146
    ^ true
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1147
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1148
    "
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1149
     JavaClassReader loadFile:'foo.cls'
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1150
    "
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1151
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1152
    "Created: / 12.5.1998 / 22:18:14 / cg"
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1153
    "Modified: / 12.5.1998 / 22:21:10 / cg"
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1154
! !
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1155
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1156
!JavaClassReader methodsFor:'file reading - constants'!
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1157
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1158
readConstant
083530508d9c intitial checkin
cg
parents:
diff changeset
  1159
    |tag constReader const|
083530508d9c intitial checkin
cg
parents:
diff changeset
  1160
083530508d9c intitial checkin
cg
parents:
diff changeset
  1161
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1162
    constNeeds2Slots := false.
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1163
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1164
    "/
083530508d9c intitial checkin
cg
parents:
diff changeset
  1165
    "/ get tag
083530508d9c intitial checkin
cg
parents:
diff changeset
  1166
    "/
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1167
    tag := inStream nextByte.
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1168
    Verbose ifTrue:[Transcript show:'tag = '; showCR:tag].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1169
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1170
    tag >= 250 ifTrue:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1171
        constReader := #(
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1172
                        "/ ST types
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1173
                        readConstant_ST_Large           "/ 249
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1174
                        readConstant_ST_Special         "/ 250
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1175
                        readConstant_ST_Character       "/ 251
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1176
                        readConstant_ST_ByteArray       "/ 252
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1177
                        readConstant_ST_Array           "/ 253
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1178
                        readConstant_ST_Symbol          "/ 254
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1179
                        readConstant_ST_Reserved        "/ 255
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1180
                    ) at:tag-249+1.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1181
    ] ifFalse:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1182
        constReader := #(
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1183
                        "/ JAVA types
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1184
                        readConstant_Asciz              "/ 1  - now called Utf8
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1185
                        readConstant_Unicode            "/ 2
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1186
                        readConstant_Integer            "/ 3
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1187
                        readConstant_Float              "/ 4
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1188
                        readConstant_Long               "/ 5
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1189
                        readConstant_Double             "/ 6
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1190
                        readConstant_Class              "/ 7
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1191
                        readConstant_String             "/ 8
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1192
                        readConstant_Fieldref           "/ 9
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1193
                        readConstant_Methodref          "/ 10
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1194
                        readConstant_InterfaceMethodref "/ 11
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1195
                        readConstant_NameAndType        "/ 12
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1196
                    ) at:tag ifAbsent:[#readConstant_Undef].
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1197
    ].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1198
    ^ self perform:constReader.
083530508d9c intitial checkin
cg
parents:
diff changeset
  1199
083530508d9c intitial checkin
cg
parents:
diff changeset
  1200
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1201
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
083530508d9c intitial checkin
cg
parents:
diff changeset
  1202
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1203
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1204
    "Created: / 15.4.1996 / 15:46:32 / cg"
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1205
    "Modified: / 9.5.1998 / 01:26:05 / cg"
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1206
!
083530508d9c intitial checkin
cg
parents:
diff changeset
  1207
083530508d9c intitial checkin
cg
parents:
diff changeset
  1208
readConstantPool
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1209
    |constantPoolCount const i|
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1210
083530508d9c intitial checkin
cg
parents:
diff changeset
  1211
    "/
083530508d9c intitial checkin
cg
parents:
diff changeset
  1212
    "/ get constant pool
083530508d9c intitial checkin
cg
parents:
diff changeset
  1213
    "/
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1214
    constantPoolCount := inStream nextUnsignedShortMSB:msb.
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1215
    Verbose ifTrue:[Transcript show:'constantPoolCount = '; showCR:constantPoolCount].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1216
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
  1217
    constants := JavaConstantPool "Array" new:constantPoolCount-1.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1218
21
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
  1219
    constSlot := 1.
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
  1220
    [constSlot < constantPoolCount] whileTrue:[
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1221
        Verbose ifTrue:[Transcript show:'const: '; showCR:constSlot].
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1222
        const := self readConstant.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1223
        constants at:constSlot put:const.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1224
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1225
        "/ long & double consts take 2 slots
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1226
        "/ (only first is used)
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1227
        constNeeds2Slots ifTrue:[
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1228
            constSlot := constSlot + 2.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1229
        ] ifFalse:[
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1230
            constSlot := constSlot + 1.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1231
        ]
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1232
    ].
083530508d9c intitial checkin
cg
parents:
diff changeset
  1233
52
1dc41619b6f8 checkin from browser
cg
parents: 50
diff changeset
  1234
    constSlot := -1.
1dc41619b6f8 checkin from browser
cg
parents: 50
diff changeset
  1235
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
  1236
    "/ preresolve what can be (especially, strings are resolved here)
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
  1237
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1238
    1 to:constantPoolCount-1 do:[:i |
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1239
        |const value|
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1240
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1241
        const := constants at:i.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1242
        const notNil ifTrue:[   "/ kludge for 2-slot constants (which only take 1 slot in ST/X)
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1243
            (const isKindOf:JavaUnresolvedConstant) ifTrue:[
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1244
                value := const preResolve.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1245
                value ~~ const ifTrue:[
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1246
                    constants at:i put:value.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1247
                ]
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1248
            ]
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1249
        ]
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1250
    ].
083530508d9c intitial checkin
cg
parents:
diff changeset
  1251
083530508d9c intitial checkin
cg
parents:
diff changeset
  1252
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1253
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
083530508d9c intitial checkin
cg
parents:
diff changeset
  1254
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class'
083530508d9c intitial checkin
cg
parents:
diff changeset
  1255
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1256
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1257
    "Created: / 15.4.1996 / 15:14:11 / cg"
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1258
    "Modified: / 7.5.1998 / 11:44:06 / cg"
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1259
!
083530508d9c intitial checkin
cg
parents:
diff changeset
  1260
083530508d9c intitial checkin
cg
parents:
diff changeset
  1261
readConstant_Asciz
083530508d9c intitial checkin
cg
parents:
diff changeset
  1262
    |len string|
083530508d9c intitial checkin
cg
parents:
diff changeset
  1263
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1264
    len := inStream nextUnsignedShortMSB:msb.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1265
    string := String new:len.
083530508d9c intitial checkin
cg
parents:
diff changeset
  1266
    inStream nextBytes:len into:string startingAt:1.
083530508d9c intitial checkin
cg
parents:
diff changeset
  1267
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1268
    Verbose ifTrue:[Transcript show:'asciz; string= ';     showCR:string].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1269
083530508d9c intitial checkin
cg
parents:
diff changeset
  1270
    ^ string
083530508d9c intitial checkin
cg
parents:
diff changeset
  1271
083530508d9c intitial checkin
cg
parents:
diff changeset
  1272
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1273
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
083530508d9c intitial checkin
cg
parents:
diff changeset
  1274
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class'
083530508d9c intitial checkin
cg
parents:
diff changeset
  1275
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1276
083530508d9c intitial checkin
cg
parents:
diff changeset
  1277
    "Created: 15.4.1996 / 15:15:35 / cg"
083530508d9c intitial checkin
cg
parents:
diff changeset
  1278
    "Modified: 15.4.1996 / 16:33:45 / cg"
083530508d9c intitial checkin
cg
parents:
diff changeset
  1279
!
083530508d9c intitial checkin
cg
parents:
diff changeset
  1280
083530508d9c intitial checkin
cg
parents:
diff changeset
  1281
readConstant_Class
52
1dc41619b6f8 checkin from browser
cg
parents: 50
diff changeset
  1282
    |name_index name|
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1283
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1284
    name_index := inStream nextUnsignedShortMSB:msb.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1285
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1286
    Verbose ifTrue:[Transcript show:'class; index= '; showCR:name_index].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1287
52
1dc41619b6f8 checkin from browser
cg
parents: 50
diff changeset
  1288
    name := constants at:name_index.
1dc41619b6f8 checkin from browser
cg
parents: 50
diff changeset
  1289
    name notNil ifTrue:[
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1290
        Verbose ifTrue:[Transcript showCR:'name in constant_class already resolved'].
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1291
        "/ self halt
52
1dc41619b6f8 checkin from browser
cg
parents: 50
diff changeset
  1292
    ].
1dc41619b6f8 checkin from browser
cg
parents: 50
diff changeset
  1293
21
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
  1294
    ^ JavaUnresolvedClassConstant 
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1295
        pool:constants
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1296
        poolIndex:constSlot
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1297
        nameIndex:name_index
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
  1298
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1299
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1300
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
083530508d9c intitial checkin
cg
parents:
diff changeset
  1301
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1302
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1303
    "Created: / 15.4.1996 / 15:21:13 / cg"
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1304
    "Modified: / 8.5.1998 / 21:53:16 / cg"
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1305
!
083530508d9c intitial checkin
cg
parents:
diff changeset
  1306
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1307
readConstant_Double
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1308
    |high low aFloat bytes|
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1309
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1310
"/ new code - to be tested
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1311
"/    bytes := ByteArray new:8.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1312
"/
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1313
"/    inStream nextBytes:8 into:bytes startingAt:1.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1314
"/    msb ~~ UninterpretedBytes isBigEndian ifTrue:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1315
"/        bytes reverse
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1316
"/    ].
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1317
"/    aFloat := bytes doubleAt:1.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1318
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1319
"/ old code
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1320
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1321
    high := inStream nextUnsignedLongMSB:msb.
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1322
    low := inStream nextUnsignedLongMSB:msb.
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1323
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1324
    aFloat := Float new.
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1325
    UninterpretedBytes isBigEndian ifTrue:[
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1326
        aFloat basicAt:1 put:((high bitShift:-24) bitAnd:16rFF).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1327
        aFloat basicAt:2 put:((high bitShift:-16) bitAnd:16rFF).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1328
        aFloat basicAt:3 put:((high bitShift:-8) bitAnd:16rFF).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1329
        aFloat basicAt:4 put:(high bitAnd:16rFF).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1330
        aFloat basicAt:5 put:((low bitShift:-24) bitAnd:16rFF).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1331
        aFloat basicAt:6 put:((low bitShift:-16) bitAnd:16rFF).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1332
        aFloat basicAt:7 put:((low bitShift:-8) bitAnd:16rFF).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1333
        aFloat basicAt:8 put:(low bitAnd:16rFF).
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1334
    ] ifFalse:[
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1335
        aFloat basicAt:1 put:(low bitAnd:16rFF).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1336
        aFloat basicAt:2 put:((low bitShift:-8) bitAnd:16rFF).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1337
        aFloat basicAt:3 put:((low bitShift:-16) bitAnd:16rFF).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1338
        aFloat basicAt:4 put:((low bitShift:-24) bitAnd:16rFF).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1339
        aFloat basicAt:5 put:(high bitAnd:16rFF).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1340
        aFloat basicAt:6 put:((high bitShift:-8) bitAnd:16rFF).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1341
        aFloat basicAt:7 put:((high bitShift:-16) bitAnd:16rFF).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1342
        aFloat basicAt:8 put:((high bitShift:-24) bitAnd:16rFF).
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1343
    ].
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1344
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1345
    constNeeds2Slots := true.
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1346
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1347
    Verbose ifTrue:[Transcript show:'double; value= ';     showCR:aFloat].
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1348
    ^ aFloat
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1349
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1350
    "
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1351
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1352
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class'
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1353
    "
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1354
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1355
    "Created: / 15.4.1996 / 16:34:42 / cg"
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1356
    "Modified: / 8.5.1998 / 22:06:07 / cg"
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1357
!
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1358
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1359
readConstant_Fieldref
083530508d9c intitial checkin
cg
parents:
diff changeset
  1360
    |class_index name_and_type_index|
083530508d9c intitial checkin
cg
parents:
diff changeset
  1361
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1362
    class_index := inStream nextUnsignedShortMSB:msb.
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1363
    name_and_type_index := inStream nextUnsignedShortMSB:msb.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1364
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1365
    Verbose ifTrue:[Transcript show:'fieldref; classindex= ';     showCR:class_index].
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1366
    Verbose ifTrue:[Transcript show:'fieldref; name&typeindex= '; showCR:name_and_type_index].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1367
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
  1368
    ^ JavaUnresolvedFieldrefConstant
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1369
		pool:constants
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1370
		poolIndex:constSlot
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1371
		classIndex:class_index
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1372
		nameandTypeIndex:name_and_type_index
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1373
083530508d9c intitial checkin
cg
parents:
diff changeset
  1374
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1375
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
083530508d9c intitial checkin
cg
parents:
diff changeset
  1376
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1377
083530508d9c intitial checkin
cg
parents:
diff changeset
  1378
    "Created: 15.4.1996 / 15:22:18 / cg"
083530508d9c intitial checkin
cg
parents:
diff changeset
  1379
    "Modified: 15.4.1996 / 16:07:01 / cg"
083530508d9c intitial checkin
cg
parents:
diff changeset
  1380
!
083530508d9c intitial checkin
cg
parents:
diff changeset
  1381
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1382
readConstant_Float
433
d9d6841784f1 checkin from browser
cg
parents: 423
diff changeset
  1383
    |b1 b2 b3 b4 aFloat bytes|
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1384
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1385
"/ new code - to be tested ...
352
9093171ef0a6 oops - float reading
cg
parents: 350
diff changeset
  1386
"/
9093171ef0a6 oops - float reading
cg
parents: 350
diff changeset
  1387
"/    bytes := ByteArray new:4.
9093171ef0a6 oops - float reading
cg
parents: 350
diff changeset
  1388
"/    inStream nextBytes:4 into:bytes startingAt:1.
9093171ef0a6 oops - float reading
cg
parents: 350
diff changeset
  1389
"/    msb ~~ UninterpretedBytes isBigEndian ifTrue:[
9093171ef0a6 oops - float reading
cg
parents: 350
diff changeset
  1390
"/        bytes reverse
9093171ef0a6 oops - float reading
cg
parents: 350
diff changeset
  1391
"/    ].
9093171ef0a6 oops - float reading
cg
parents: 350
diff changeset
  1392
"/    aFloat := bytes floatAt:1.
9093171ef0a6 oops - float reading
cg
parents: 350
diff changeset
  1393
"/    Verbose ifTrue:[Transcript show:'float; value= ';     showCR:aFloat].
9093171ef0a6 oops - float reading
cg
parents: 350
diff changeset
  1394
"/    ^ aFloat.
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1395
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1396
"/ old code
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1397
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1398
    aFloat := ShortFloat basicNew.
433
d9d6841784f1 checkin from browser
cg
parents: 423
diff changeset
  1399
d9d6841784f1 checkin from browser
cg
parents: 423
diff changeset
  1400
    b1 := inStream nextByte.
d9d6841784f1 checkin from browser
cg
parents: 423
diff changeset
  1401
    b2 := inStream nextByte.
d9d6841784f1 checkin from browser
cg
parents: 423
diff changeset
  1402
    b3 := inStream nextByte.
d9d6841784f1 checkin from browser
cg
parents: 423
diff changeset
  1403
    b4 := inStream nextByte.
d9d6841784f1 checkin from browser
cg
parents: 423
diff changeset
  1404
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1405
    UninterpretedBytes isBigEndian ifTrue:[
433
d9d6841784f1 checkin from browser
cg
parents: 423
diff changeset
  1406
        aFloat basicAt:1 put:b1.
d9d6841784f1 checkin from browser
cg
parents: 423
diff changeset
  1407
        aFloat basicAt:2 put:b2.
d9d6841784f1 checkin from browser
cg
parents: 423
diff changeset
  1408
        aFloat basicAt:3 put:b3.
d9d6841784f1 checkin from browser
cg
parents: 423
diff changeset
  1409
        aFloat basicAt:4 put:b4.
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1410
    ] ifFalse:[
433
d9d6841784f1 checkin from browser
cg
parents: 423
diff changeset
  1411
        aFloat basicAt:4 put:b1.
d9d6841784f1 checkin from browser
cg
parents: 423
diff changeset
  1412
        aFloat basicAt:3 put:b2.
d9d6841784f1 checkin from browser
cg
parents: 423
diff changeset
  1413
        aFloat basicAt:2 put:b3.
d9d6841784f1 checkin from browser
cg
parents: 423
diff changeset
  1414
        aFloat basicAt:1 put:b4.
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1415
    ].
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1416
    Verbose ifTrue:[Transcript show:'float; value= ';     showCR:aFloat].
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1417
    ^ aFloat
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1418
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1419
    "
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1420
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1421
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class'
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1422
    "
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1423
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1424
    "Created: / 15.4.1996 / 16:34:42 / cg"
433
d9d6841784f1 checkin from browser
cg
parents: 423
diff changeset
  1425
    "Modified: / 10.11.1998 / 22:04:59 / cg"
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1426
!
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1427
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1428
readConstant_Integer
083530508d9c intitial checkin
cg
parents:
diff changeset
  1429
    |value|
083530508d9c intitial checkin
cg
parents:
diff changeset
  1430
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1431
    value := inStream nextLongMSB:msb.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1432
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1433
    Verbose ifTrue:[Transcript show:'integer; value= ';     showCR:value].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1434
083530508d9c intitial checkin
cg
parents:
diff changeset
  1435
    ^ value
083530508d9c intitial checkin
cg
parents:
diff changeset
  1436
083530508d9c intitial checkin
cg
parents:
diff changeset
  1437
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1438
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
083530508d9c intitial checkin
cg
parents:
diff changeset
  1439
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class'
083530508d9c intitial checkin
cg
parents:
diff changeset
  1440
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1441
083530508d9c intitial checkin
cg
parents:
diff changeset
  1442
    "Modified: 15.4.1996 / 15:42:16 / cg"
083530508d9c intitial checkin
cg
parents:
diff changeset
  1443
    "Created: 15.4.1996 / 16:34:42 / cg"
083530508d9c intitial checkin
cg
parents:
diff changeset
  1444
!
083530508d9c intitial checkin
cg
parents:
diff changeset
  1445
14
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
  1446
readConstant_InterfaceMethodref
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
  1447
    |class_index name_and_type_index|
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
  1448
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1449
    class_index := inStream nextUnsignedShortMSB:msb.
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1450
    name_and_type_index := inStream nextUnsignedShortMSB:msb.
14
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
  1451
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1452
    Verbose ifTrue:[Transcript show:'methodref; classindex= ';     showCR:class_index].
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1453
    Verbose ifTrue:[Transcript show:'methodref; name&typeindex= '; showCR:name_and_type_index].
14
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
  1454
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
  1455
    ^ JavaUnresolvedInterfaceMethodrefConstant 
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1456
		pool:constants
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1457
		poolIndex:constSlot
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1458
		classIndex:class_index
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1459
		nameandTypeIndex:name_and_type_index
14
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
  1460
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
  1461
    "
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
  1462
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
  1463
    "
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
  1464
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
  1465
    "Created: 15.4.1996 / 15:22:37 / cg"
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
  1466
    "Modified: 15.4.1996 / 16:07:19 / cg"
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
  1467
!
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
  1468
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1469
readConstant_Long
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1470
    |high low value|
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1471
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1472
    high := inStream nextUnsignedLongMSB:msb.
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1473
    low := inStream nextUnsignedLongMSB:msb.
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1474
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1475
    value := (high bitShift:32) bitOr:low.
60
a763b1780ec0 checkin from browser
cg
parents: 59
diff changeset
  1476
    (high bitTest:16r80000000) ifTrue:[
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1477
	value := value - 16r10000000000000000.
60
a763b1780ec0 checkin from browser
cg
parents: 59
diff changeset
  1478
    ].
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1479
    constNeeds2Slots := true.
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1480
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1481
    Verbose ifTrue:[Transcript show:'long; value= ';     showCR:value].
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1482
    ^ value
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1483
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1484
    "
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1485
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1486
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class'
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1487
    "
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1488
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1489
    "Modified: 15.4.1996 / 15:42:16 / cg"
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1490
    "Created: 15.4.1996 / 16:34:42 / cg"
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1491
!
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1492
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1493
readConstant_Methodref
083530508d9c intitial checkin
cg
parents:
diff changeset
  1494
    |class_index name_and_type_index|
083530508d9c intitial checkin
cg
parents:
diff changeset
  1495
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1496
    class_index := inStream nextUnsignedShortMSB:msb.
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1497
    name_and_type_index := inStream nextUnsignedShortMSB:msb.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1498
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1499
    Verbose ifTrue:[Transcript show:'methodref; classindex= ';     showCR:class_index].
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1500
    Verbose ifTrue:[Transcript show:'methodref; name&typeindex= '; showCR:name_and_type_index].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1501
083530508d9c intitial checkin
cg
parents:
diff changeset
  1502
    ^ JavaUnresolvedMethodrefConstant 
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1503
		pool:constants
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1504
		poolIndex:constSlot
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1505
		classIndex:class_index
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1506
		nameandTypeIndex:name_and_type_index
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1507
083530508d9c intitial checkin
cg
parents:
diff changeset
  1508
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1509
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
083530508d9c intitial checkin
cg
parents:
diff changeset
  1510
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1511
083530508d9c intitial checkin
cg
parents:
diff changeset
  1512
    "Created: 15.4.1996 / 15:22:37 / cg"
083530508d9c intitial checkin
cg
parents:
diff changeset
  1513
    "Modified: 15.4.1996 / 16:07:19 / cg"
083530508d9c intitial checkin
cg
parents:
diff changeset
  1514
!
083530508d9c intitial checkin
cg
parents:
diff changeset
  1515
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
  1516
readConstant_NameAndType
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1517
    |name_index signature_index|
083530508d9c intitial checkin
cg
parents:
diff changeset
  1518
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1519
    name_index := inStream nextUnsignedShortMSB:msb.
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1520
    signature_index := inStream nextUnsignedShortMSB:msb.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1521
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1522
    Verbose ifTrue:[Transcript show:'methodref; nameindex= ';     showCR:name_index].
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1523
    Verbose ifTrue:[Transcript show:'methodref; signatureindex= '; showCR:signature_index].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1524
083530508d9c intitial checkin
cg
parents:
diff changeset
  1525
    ^ JavaUnresolvedNameandTypeConstant 
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1526
		pool:constants
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1527
		poolIndex:constSlot
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1528
		nameIndex:name_index
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1529
		signatureIndex:signature_index  
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1530
083530508d9c intitial checkin
cg
parents:
diff changeset
  1531
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1532
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
083530508d9c intitial checkin
cg
parents:
diff changeset
  1533
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1534
083530508d9c intitial checkin
cg
parents:
diff changeset
  1535
    "Created: 15.4.1996 / 15:23:43 / cg"
083530508d9c intitial checkin
cg
parents:
diff changeset
  1536
    "Modified: 15.4.1996 / 16:17:16 / cg"
083530508d9c intitial checkin
cg
parents:
diff changeset
  1537
!
083530508d9c intitial checkin
cg
parents:
diff changeset
  1538
083530508d9c intitial checkin
cg
parents:
diff changeset
  1539
readConstant_String
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1540
    |tag string_index chars jString|
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1541
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1542
    string_index := inStream nextUnsignedShortMSB:msb.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1543
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1544
    Verbose ifTrue:[Transcript show:'string; index= '; showCR:string_index].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1545
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1546
    "/ resolve here if possible
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1547
    string_index < constSlot ifTrue:[
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1548
        Java java_lang_String notNil ifTrue:[
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1549
            chars := (constants at:string_index).
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1550
            chars isString ifFalse:[
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1551
                self halt:'should not happen'
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1552
            ].
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1553
            jString := Java as_String:chars.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1554
            ^ jString.        
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1555
        ]
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1556
    ].
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1557
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
  1558
    ^ JavaUnresolvedStringConstant 
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1559
        pool:constants 
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1560
        poolIndex:constSlot
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1561
        stringIndex:string_index
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1562
083530508d9c intitial checkin
cg
parents:
diff changeset
  1563
    "
43
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
  1564
     Verbose := true.
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
  1565
     JavaClassReader readFile:'/phys/ibm3/java/lib/java/lang/System.class'
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1566
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1567
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1568
    "Created: / 15.4.1996 / 15:20:33 / cg"
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1569
    "Modified: / 7.5.1998 / 11:42:45 / cg"
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1570
! !
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1571
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1572
!JavaClassReader methodsFor:'file reading - constants-ST'!
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1573
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1574
readConstant_ST_Array
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1575
    |aSize arr|
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1576
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1577
    aSize := inStream nextUnsignedShortMSB:msb.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1578
    arr := Array new:aSize.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1579
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1580
    1 to:aSize do:[:i |
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1581
        |element_index element|
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1582
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1583
        element_index := inStream nextUnsignedShortMSB:msb.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1584
        arr at:i put:element_index.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1585
    ].
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1586
    Verbose ifTrue:[Transcript show:'array; size= ';     showCR:aSize].
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1587
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1588
    ^ JavaUnresolvedSTArrayConstant 
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1589
                pool:constants
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1590
                poolIndex:constSlot
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1591
                array:arr
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1592
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1593
    "Created: / 7.5.1998 / 11:47:01 / cg"
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1594
    "Modified: / 9.5.1998 / 00:25:34 / cg"
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1595
!
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1596
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1597
readConstant_ST_ByteArray
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1598
    |aSize arr|
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1599
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1600
    aSize := inStream nextUnsignedShortMSB:msb.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1601
    arr := ByteArray new:aSize.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1602
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1603
    1 to:aSize do:[:i |
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1604
        |element_index|
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1605
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1606
        arr at:i put:(inStream nextByte).
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1607
    ].
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1608
    Verbose ifTrue:[Transcript show:'byteArray; size= ';     showCR:aSize].
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1609
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1610
    ^ arr
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1611
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1612
    "Created: / 7.5.1998 / 11:47:12 / cg"
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1613
!
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1614
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1615
readConstant_ST_Character
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1616
    |ascii|
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1617
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1618
    ascii := inStream nextUnsignedShortMSB:msb.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1619
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1620
    Verbose ifTrue:[Transcript show:'char; ascii= '; showCR:ascii].
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1621
    ^ Character value:ascii
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1622
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1623
    "Created: / 7.5.1998 / 11:48:12 / cg"
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1624
!
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1625
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1626
readConstant_ST_Special
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1627
    |type|
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1628
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1629
    type := inStream nextUnsignedShortMSB:msb.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1630
    ^ #(
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1631
        nil
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1632
        true
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1633
        false
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1634
     ) at:(type + 1)
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1635
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1636
    "Created: / 8.5.1998 / 23:06:56 / cg"
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1637
    "Modified: / 9.5.1998 / 00:40:14 / cg"
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1638
!
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1639
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1640
readConstant_ST_String
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1641
    |tag string_index chars|
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1642
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1643
    string_index := inStream nextUnsignedShortMSB:msb.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1644
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1645
    Verbose ifTrue:[Transcript show:'string; index= '; showCR:string_index].
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1646
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1647
    "/ resolve here if possible
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1648
    string_index < constSlot ifTrue:[
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1649
        chars := (constants at:string_index).
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1650
        ^ chars
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1651
    ].
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1652
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1653
    ^ JavaUnresolvedSTStringConstant 
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1654
        pool:constants 
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1655
        poolIndex:constSlot
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1656
        stringIndex:string_index
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1657
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1658
    "Modified: / 7.5.1998 / 11:48:28 / cg"
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1659
    "Created: / 7.5.1998 / 11:49:55 / cg"
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1660
!
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1661
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1662
readConstant_ST_Symbol
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1663
    |tag string_index chars|
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1664
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1665
    string_index := inStream nextUnsignedShortMSB:msb.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1666
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1667
    Verbose ifTrue:[Transcript show:'symbol; index= '; showCR:string_index].
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1668
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1669
    "/ resolve here if possible
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1670
    string_index < constSlot ifTrue:[
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1671
        chars := (constants at:string_index).
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1672
        chars isString ifFalse:[
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1673
            self halt:'should not happen'
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1674
        ].
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1675
        ^ chars asSymbol
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1676
    ].
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1677
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1678
    ^ JavaUnresolvedSTSymbolConstant 
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1679
        pool:constants 
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1680
        poolIndex:constSlot
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1681
        stringIndex:string_index
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1682
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1683
    "Modified: / 7.5.1998 / 11:48:28 / cg"
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1684
! !
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1685
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1686
!JavaClassReader methodsFor:'file reading - fields'!
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1687
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1688
readConstantValueAttributeFor:aField
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1689
    |attribute_length constantvalue_index constantValue|
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1690
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1691
    attribute_length := inStream nextUnsignedLongMSB:msb.
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1692
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1693
    constantvalue_index := inStream nextUnsignedShortMSB:msb.
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1694
    constantValue := constants at:constantvalue_index.
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1695
59
38114c3e3e77 checkin from browser
cg
parents: 54
diff changeset
  1696
    aField constantValue:constantValue.
38114c3e3e77 checkin from browser
cg
parents: 54
diff changeset
  1697
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1698
    Verbose ifTrue:[Transcript show:'constantValue: '; showCR:constantValue].
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1699
    ^ true
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1700
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1701
    "
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1702
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1703
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class'
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1704
    "
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1705
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1706
    "Modified: 15.4.1996 / 15:33:28 / cg"
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1707
    "Created: 15.4.1996 / 15:40:17 / cg"
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1708
!
083530508d9c intitial checkin
cg
parents:
diff changeset
  1709
083530508d9c intitial checkin
cg
parents:
diff changeset
  1710
readFieldInfofield
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1711
    |access_flags name_index signature_index attributes_count field|
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1712
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1713
    access_flags := inStream nextUnsignedShortMSB:msb.
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1714
    name_index := inStream nextUnsignedShortMSB:msb.
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1715
    signature_index := inStream nextUnsignedShortMSB:msb.
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1716
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1717
    field := JavaField new.
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1718
    field setAccessFlags:access_flags.
376
ffd6472dbf91 *** empty log message ***
cg
parents: 370
diff changeset
  1719
    field setName:(constants at:name_index) asSymbol.
ffd6472dbf91 *** empty log message ***
cg
parents: 370
diff changeset
  1720
    field setSignature:(constants at:signature_index) asSymbol.
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1721
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1722
    attributes_count := inStream nextUnsignedShortMSB:msb.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1723
99
d1248315f589 support vsn 45.2 AND 45.3 classFile formats
cg
parents: 97
diff changeset
  1724
    Verbose ifTrue:[Transcript show:'  field name: '; show:(constants at:name_index);
376
ffd6472dbf91 *** empty log message ***
cg
parents: 370
diff changeset
  1725
                               show:' access: '; show:access_flags;
ffd6472dbf91 *** empty log message ***
cg
parents: 370
diff changeset
  1726
                               show:' attrib_cnt: '; showCR:attributes_count].
99
d1248315f589 support vsn 45.2 AND 45.3 classFile formats
cg
parents: 97
diff changeset
  1727
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1728
    1 to:attributes_count do:[:i |
376
ffd6472dbf91 *** empty log message ***
cg
parents: 370
diff changeset
  1729
        self readAttributeFor:field.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1730
    ].
083530508d9c intitial checkin
cg
parents:
diff changeset
  1731
27
4560bb77bb36 checkin from browser
cg
parents: 21
diff changeset
  1732
    ^ field
4560bb77bb36 checkin from browser
cg
parents: 21
diff changeset
  1733
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1734
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1735
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
083530508d9c intitial checkin
cg
parents:
diff changeset
  1736
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1737
376
ffd6472dbf91 *** empty log message ***
cg
parents: 370
diff changeset
  1738
    "Created: / 15.4.1996 / 15:38:43 / cg"
ffd6472dbf91 *** empty log message ***
cg
parents: 370
diff changeset
  1739
    "Modified: / 15.10.1998 / 10:38:01 / cg"
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1740
!
083530508d9c intitial checkin
cg
parents:
diff changeset
  1741
083530508d9c intitial checkin
cg
parents:
diff changeset
  1742
readFieldInfofields
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1743
    |nFields fields|
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1744
083530508d9c intitial checkin
cg
parents:
diff changeset
  1745
    "/
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1746
    "/ get fieldInfos
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1747
    "/
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1748
    nFields := inStream nextUnsignedShortMSB:msb.
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1749
    Verbose ifTrue:[Transcript show:'fieldsCount = '; showCR:nFields].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1750
27
4560bb77bb36 checkin from browser
cg
parents: 21
diff changeset
  1751
    fields := Array new:nFields.
4560bb77bb36 checkin from browser
cg
parents: 21
diff changeset
  1752
4560bb77bb36 checkin from browser
cg
parents: 21
diff changeset
  1753
    1 to:nFields do:[:i |
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1754
	Verbose ifTrue:[Transcript show:'field: '; showCR:i].
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1755
	fields at:i put:(self readFieldInfofield)
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1756
    ].
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1757
    ^ fields
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1758
083530508d9c intitial checkin
cg
parents:
diff changeset
  1759
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1760
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
083530508d9c intitial checkin
cg
parents:
diff changeset
  1761
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1762
083530508d9c intitial checkin
cg
parents:
diff changeset
  1763
    "Created: 15.4.1996 / 15:34:41 / cg"
083530508d9c intitial checkin
cg
parents:
diff changeset
  1764
    "Modified: 15.4.1996 / 15:35:28 / cg"
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1765
! !
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1766
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1767
!JavaClassReader methodsFor:'file reading - interfaces'!
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1768
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1769
readInterfaces
110
dfb03e2ea321 *** empty log message ***
cg
parents: 104
diff changeset
  1770
    |interfacesCount interface_index interface interfaces|
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1771
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1772
    "/
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1773
    "/ get interfaces
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1774
    "/
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1775
    interfacesCount := inStream nextUnsignedShortMSB:msb.
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1776
    Verbose ifTrue:[Transcript show:'interfacesCount = '; showCR:interfacesCount].
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1777
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1778
    interfaces := Array new:interfacesCount.
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1779
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1780
    1 to:interfacesCount do:[:i |
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1781
	Verbose ifTrue:[Transcript show:'interface: '; showCR:i].
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1782
	interface_index := inStream nextUnsignedShortMSB:msb.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1783
	interface := constants at:interface_index.
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1784
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1785
	interfaces at:i put:interface.
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1786
    ].
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1787
    ^ interfaces
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1788
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1789
    "
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1790
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1791
    "
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1792
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1793
    "Created: 15.4.1996 / 15:31:59 / cg"
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1794
    "Modified: 15.4.1996 / 15:33:28 / cg"
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1795
! !
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1796
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1797
!JavaClassReader methodsFor:'file reading - methods'!
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1798
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1799
readCodeAttributeFor:aJavaMethod
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1800
    |attribute_length max_stack max_locals code_length code
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
  1801
     exception_table_length exception_table unknown1 unknown2|
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1802
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1803
    attribute_length := inStream nextUnsignedLongMSB:msb.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1804
357
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1805
    Verbose ifTrue:[Transcript show:'code_attribute_length: 0x'; showCR:(attribute_length printStringRadix:16)].
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
  1806
99
d1248315f589 support vsn 45.2 AND 45.3 classFile formats
cg
parents: 97
diff changeset
  1807
    minorVsn > 2 ifTrue:[
348
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1808
        "/ should be:
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1809
        max_stack := inStream nextUnsignedShortMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1810
        max_locals := inStream nextUnsignedShortMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1811
        code_length := inStream nextUnsignedLongMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1812
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1813
"/        unknown1 := inStream nextByte.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1814
"/        max_stack := inStream nextByte.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1815
"/        max_locals := inStream nextUnsignedShortMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1816
"/        unknown2 := inStream nextUnsignedShortMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1817
"/        code_length := inStream nextUnsignedShortMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1818
"/        Verbose ifTrue:[Transcript show:'?1: '; showCR:unknown1].
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1819
"/        Verbose ifTrue:[Transcript show:'?2: '; showCR:unknown2].
39
20fa5af3b873 checkin from browser
cg
parents: 38
diff changeset
  1820
    ] ifFalse:[
348
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1821
        max_stack := inStream nextByte.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1822
        max_locals := inStream nextByte.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1823
        code_length := inStream nextUnsignedShortMSB:msb.
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
  1824
    ].
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
  1825
357
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1826
    Verbose ifTrue:[
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1827
        Transcript show:'code_length: '; showCR:(code_length printStringRadix:16).
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1828
        Transcript show:'code at pos: '; showCR:inStream position
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1829
    ].
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1830
357
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1831
    code_length ~~ 0 ifTrue:[
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1832
        code := ByteArray new:code_length.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1833
        inStream nextBytes:code_length into:code startingAt:1.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1834
    ].
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1835
    Verbose ifTrue:[Transcript show:'method code: '; showCR:code.].
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
  1836
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1837
    exception_table_length := inStream nextUnsignedShortMSB:msb.
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1838
    Verbose ifTrue:[Transcript show:'exception_table_length: '; showCR:(exception_table_length printStringRadix:16)].
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1839
    exception_table_length ~~ 0 ifTrue:[
348
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1840
        Verbose ifTrue:[Transcript show:'exceptionTable length:'; showCR:exception_table_length.].
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
  1841
348
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1842
        exception_table := Array new:exception_table_length.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1843
        1 to:exception_table_length do:[:i |
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1844
            |start_pc end_pc handler_pc catch_type|
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1845
348
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1846
            start_pc := inStream nextUnsignedShortMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1847
            end_pc := inStream nextUnsignedShortMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1848
            handler_pc := inStream nextUnsignedShortMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1849
            catch_type := constants at:(inStream nextUnsignedShortMSB:msb).
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1850
            exception_table at:i put:(JavaExceptionTableEntry
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1851
                                            startPC:start_pc
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1852
                                            endPC:end_pc
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1853
                                            handlerPC:handler_pc
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1854
                                            catchType:catch_type).
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1855
        ].
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1856
        aJavaMethod setExceptionHandlerTable:exception_table.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1857
    ].
083530508d9c intitial checkin
cg
parents:
diff changeset
  1858
29
eb3367f8fb9b checkin from browser
cg
parents: 27
diff changeset
  1859
    aJavaMethod 
348
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1860
        setCode:code 
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1861
        maxStack:max_stack 
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1862
        maxLocals:max_locals 
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1863
        u1:unknown1 
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1864
        u2:unknown2.
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1865
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1866
    self readAttributesFor:aJavaMethod.
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1867
    ^ true
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1868
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1869
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1870
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1871
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class'
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1872
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1873
348
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1874
    "Created: / 15.4.1996 / 15:40:17 / cg"
357
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1875
    "Modified: / 16.5.1998 / 01:39:42 / cg"
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1876
!
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1877
83
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
  1878
readExceptionsAttributeFor:aJavaMethod
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
  1879
    |attribute_length exception_table_length exception_table|
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
  1880
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1881
    attribute_length := inStream nextUnsignedLongMSB:msb.
83
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
  1882
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1883
    exception_table_length := inStream nextUnsignedShortMSB:msb.
83
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
  1884
    exception_table_length ~~ 0 ifTrue:[
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1885
	exception_table := Array new:exception_table_length.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1886
	1 to:exception_table_length do:[:i |
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1887
	    |idx ex|
83
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
  1888
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1889
	    idx := inStream nextUnsignedShortMSB:msb.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1890
	    ex := constants at:idx.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1891
	    exception_table at:i put:ex.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1892
	].
83
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
  1893
    ].
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
  1894
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
  1895
    Verbose ifTrue:[Transcript showCR:'method has an exceptionTable'].
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
  1896
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
  1897
    aJavaMethod setExceptionTable:exception_table.
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
  1898
    ^ true
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
  1899
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
  1900
    "Modified: 15.4.1996 / 15:33:28 / cg"
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
  1901
    "Created: 15.4.1996 / 15:40:17 / cg"
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
  1902
!
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
  1903
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1904
readLineNumberTableAttributeFor:aJavaMethod
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1905
    |attribute_length line_number_table_length line_number_table|
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1906
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1907
    attribute_length := inStream nextUnsignedLongMSB:msb.
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1908
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1909
    line_number_table_length := inStream nextUnsignedShortMSB:msb.
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1910
    line_number_table_length ~~ 0 ifTrue:[
330
c452e536a822 checkin from browser
cg
parents: 327
diff changeset
  1911
        line_number_table := Array new:line_number_table_length.
c452e536a822 checkin from browser
cg
parents: 327
diff changeset
  1912
        1 to:line_number_table_length do:[:i |
c452e536a822 checkin from browser
cg
parents: 327
diff changeset
  1913
            |start_pc line_number|
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1914
330
c452e536a822 checkin from browser
cg
parents: 327
diff changeset
  1915
            start_pc := inStream nextUnsignedShortMSB:msb.
c452e536a822 checkin from browser
cg
parents: 327
diff changeset
  1916
            line_number := inStream nextUnsignedShortMSB:msb.
c452e536a822 checkin from browser
cg
parents: 327
diff changeset
  1917
            line_number_table at:i put:(start_pc -> line_number).
c452e536a822 checkin from browser
cg
parents: 327
diff changeset
  1918
        ].
c452e536a822 checkin from browser
cg
parents: 327
diff changeset
  1919
        Verbose ifTrue:[Transcript showCR:'method has a lineNumberTable'].
c452e536a822 checkin from browser
cg
parents: 327
diff changeset
  1920
c452e536a822 checkin from browser
cg
parents: 327
diff changeset
  1921
        aJavaMethod setLineNumberTable:line_number_table.
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1922
    ].
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1923
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1924
    ^ true
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1925
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1926
    "
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1927
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1928
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/java/lang/Boolean.class'
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1929
    "
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1930
330
c452e536a822 checkin from browser
cg
parents: 327
diff changeset
  1931
    "Created: / 15.4.1996 / 15:40:17 / cg"
c452e536a822 checkin from browser
cg
parents: 327
diff changeset
  1932
    "Modified: / 7.4.1998 / 19:08:42 / cg"
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1933
!
083530508d9c intitial checkin
cg
parents:
diff changeset
  1934
50
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1935
readLocalVariableTableAttributeFor:aJavaMethod
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1936
    |attribute_length local_variable_table_length local_variable_table|
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1937
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1938
    attribute_length := inStream nextUnsignedLongMSB:msb.
50
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1939
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1940
    local_variable_table_length := inStream nextUnsignedShortMSB:msb.
50
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1941
    local_variable_table_length ~~ 0 ifTrue:[
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1942
	local_variable_table := JavaLocalVariableTable new:local_variable_table_length.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1943
	1 to:local_variable_table_length do:[:i |
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1944
	    |start_pc length name_index sig_index slot name signature|
50
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1945
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1946
	    start_pc := inStream nextUnsignedShortMSB:msb.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1947
	    length := inStream nextUnsignedShortMSB:msb.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1948
	    name_index := inStream nextUnsignedShortMSB:msb.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1949
	    name := constants at:name_index.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1950
	    sig_index := inStream nextUnsignedShortMSB:msb.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1951
	    signature := constants at:sig_index.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1952
	    slot := inStream nextUnsignedShortMSB:msb.
50
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1953
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1954
	    local_variable_table at:i put:(JavaLocalVariableTableEntry new 
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1955
						startPC:start_pc 
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1956
						length:length
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1957
						name:name
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1958
						signature:signature
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1959
						slot:slot)
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1960
	].
50
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1961
    ].
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1962
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1963
    Verbose ifTrue:[Transcript showCR:'method has a localvariableTable'].
50
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1964
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1965
    aJavaMethod setLocalVariableTable:local_variable_table.
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1966
    ^ true
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1967
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1968
    "
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1969
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1970
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/java/lang/Boolean.class'
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1971
    "
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1972
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1973
    "Modified: 15.4.1996 / 15:33:28 / cg"
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1974
    "Created: 15.4.1996 / 15:40:17 / cg"
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1975
!
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1976
357
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1977
readMethodFor:aClass
273
bcbea5ac4860 checkin from browser
cg
parents: 269
diff changeset
  1978
    |m access_flags name_index name signature_index signature
bcbea5ac4860 checkin from browser
cg
parents: 269
diff changeset
  1979
     tooManyArgs|
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1980
083530508d9c intitial checkin
cg
parents:
diff changeset
  1981
    "/
083530508d9c intitial checkin
cg
parents:
diff changeset
  1982
    "/ get a method
083530508d9c intitial checkin
cg
parents:
diff changeset
  1983
    "/
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1984
    access_flags := inStream nextUnsignedShortMSB:msb.
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1985
    name_index := inStream nextUnsignedShortMSB:msb.
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1986
    signature_index := inStream nextUnsignedShortMSB:msb.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1987
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1988
    name := constants at:name_index.
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1989
    signature := constants at:signature_index.
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
  1990
357
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1991
    Verbose ifTrue:[
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1992
        Transcript show:'method name:'; showCR:name.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1993
        Transcript show:'signature:'; showCR:signature.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1994
    ].
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
  1995
357
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1996
    aClass isJavaClass ifTrue:[
386
ed3f417b7d02 checkin from browser
cg
parents: 376
diff changeset
  1997
        m := JavaMethodWithHandler new.
357
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1998
        m setAccessFlags:access_flags.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1999
        tooManyArgs := false.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2000
        Method argumentSignal handle:[:ex |
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2001
            'JAVA: ***** java method has too many arguments - will fail to execute' infoPrintCR.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2002
            tooManyArgs := true.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2003
            ex proceed.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2004
        ] do:[
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2005
            m setName:name signature:signature.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2006
        ].
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2007
        m setJavaClass:aClass.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2008
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2009
        self readAttributesFor:m.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2010
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2011
        tooManyArgs ifTrue:[
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2012
            m code:nil.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2013
            m byteCode:nil.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2014
        ].
423
08af061c56a8 javaClass now uses its fullName in name
cg
parents: 407
diff changeset
  2015
        (m exceptionHandlerTable isNil) ifTrue:[
08af061c56a8 javaClass now uses its fullName in name
cg
parents: 407
diff changeset
  2016
            m exceptionTable isNil ifTrue:[
08af061c56a8 javaClass now uses its fullName in name
cg
parents: 407
diff changeset
  2017
                m := JavaMethod fromMethod:m
08af061c56a8 javaClass now uses its fullName in name
cg
parents: 407
diff changeset
  2018
            ] ifFalse:[
08af061c56a8 javaClass now uses its fullName in name
cg
parents: 407
diff changeset
  2019
                m := JavaMethodWithException fromMethod:m
08af061c56a8 javaClass now uses its fullName in name
cg
parents: 407
diff changeset
  2020
            ]
468
4d4f1cb9786b *** empty log message ***
cg
parents: 454
diff changeset
  2021
        ] ifFalse:[
470
b8552cd2407b checkin from browser
cg
parents: 468
diff changeset
  2022
            m setAccessFlags:(m accessFlags bitOr:JavaMethod A_HASHANDLER)
386
ed3f417b7d02 checkin from browser
cg
parents: 376
diff changeset
  2023
        ].
357
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2024
        aClass addMethod:m name:name signature:signature.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2025
    ] ifFalse:[
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2026
        m := Method new.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2027
        self readAttributesFor:m.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2028
        (access_flags bitTest:JavaMethod A_STATIC) ifTrue:[
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2029
            aClass class primAddSelector:name asSymbol withMethod:m.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2030
        ] ifFalse:[
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2031
            aClass primAddSelector:name asSymbol withMethod:m.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2032
        ]
273
bcbea5ac4860 checkin from browser
cg
parents: 269
diff changeset
  2033
    ].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  2034
083530508d9c intitial checkin
cg
parents:
diff changeset
  2035
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  2036
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
083530508d9c intitial checkin
cg
parents:
diff changeset
  2037
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  2038
273
bcbea5ac4860 checkin from browser
cg
parents: 269
diff changeset
  2039
    "Created: / 15.4.1996 / 16:48:49 / cg"
470
b8552cd2407b checkin from browser
cg
parents: 468
diff changeset
  2040
    "Modified: / 27.11.1998 / 01:34:00 / cg"
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  2041
!
083530508d9c intitial checkin
cg
parents:
diff changeset
  2042
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  2043
readMethodsFor:aJavaClass
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  2044
    |methodsCount method|
083530508d9c intitial checkin
cg
parents:
diff changeset
  2045
083530508d9c intitial checkin
cg
parents:
diff changeset
  2046
    "/
083530508d9c intitial checkin
cg
parents:
diff changeset
  2047
    "/ get methods
083530508d9c intitial checkin
cg
parents:
diff changeset
  2048
    "/
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  2049
    methodsCount := inStream nextUnsignedShortMSB:msb.
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  2050
    Verbose ifTrue:[Transcript show:'methodsCount = '; showCR:methodsCount].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  2051
083530508d9c intitial checkin
cg
parents:
diff changeset
  2052
    1 to:methodsCount do:[:i |
348
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2053
        Verbose ifTrue:[Transcript show:'method: '; showCR:i].
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2054
        method := self readMethodFor:aJavaClass
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  2055
    ].
083530508d9c intitial checkin
cg
parents:
diff changeset
  2056
083530508d9c intitial checkin
cg
parents:
diff changeset
  2057
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  2058
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
083530508d9c intitial checkin
cg
parents:
diff changeset
  2059
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  2060
348
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2061
    "Created: / 15.4.1996 / 16:46:30 / cg"
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2062
    "Modified: / 8.5.1998 / 21:20:59 / cg"
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  2063
! !
083530508d9c intitial checkin
cg
parents:
diff changeset
  2064
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  2065
!JavaClassReader methodsFor:'file reading - methods-ST'!
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  2066
348
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2067
readSTCodeAttributeFor:aSmalltalkMethod
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2068
    |attribute_length max_stack max_locals code_length code
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2069
     exception_table_length unknown1 unknown2|
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2070
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2071
    attribute_length := inStream nextUnsignedLongMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2072
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2073
    Verbose ifTrue:[Transcript show:'attribute_length: 0x'; showCR:(attribute_length printStringRadix:16)].
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2074
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2075
    max_stack := inStream nextUnsignedShortMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2076
    max_locals := inStream nextUnsignedShortMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2077
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2078
    code_length := inStream nextUnsignedLongMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2079
    Verbose ifTrue:[Transcript show:'code_length: '; showCR:(code_length printStringRadix:16)].
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2080
    Verbose ifTrue:[Transcript show:'code at pos: '; showCR:inStream position].
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2081
357
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2082
    code_length ~~ 0 ifTrue:[
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2083
        code := ByteArray new:code_length.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2084
        inStream nextBytes:code_length into:code startingAt:1.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2085
    ].
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2086
    Verbose ifTrue:[Transcript show:'method code: '; showCR:code.].
348
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2087
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2088
    exception_table_length := inStream nextUnsignedShortMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2089
    Verbose ifTrue:[Transcript show:'exception_table_length: '; showCR:(exception_table_length printStringRadix:16)].
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2090
    exception_table_length ~~ 0 ifTrue:[
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2091
        self error:'unexpected exceptionTable length'.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2092
        "/ skip it.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2093
        1 to:exception_table_length do:[:i |
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2094
            "start_pc :="   inStream nextUnsignedShortMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2095
            "end_pc :="     inStream nextUnsignedShortMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2096
            "handler_pc :=" inStream nextUnsignedShortMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2097
            "catch_type :=" inStream nextUnsignedShortMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2098
        ].
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2099
    ].
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2100
357
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2101
    aSmalltalkMethod byteCode:code. 
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2102
    aSmalltalkMethod stackSize:max_stack .
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2103
    aSmalltalkMethod numberOfVars:max_locals. 
348
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2104
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2105
    self readAttributesFor:aSmalltalkMethod.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2106
    ^ true
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2107
357
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2108
    "Modified: / 16.5.1998 / 01:39:30 / cg"
348
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2109
!
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2110
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  2111
readSTLiteralsAttributeFor:aSmalltalkMethod
348
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2112
    |attribute_length literal_table_length literal_table litIndex literal|
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2113
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2114
    attribute_length := inStream nextUnsignedLongMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2115
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2116
    literal_table_length := inStream nextUnsignedShortMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2117
    literal_table_length ~~ 0 ifTrue:[
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2118
        literal_table := Array new:literal_table_length.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2119
        1 to:literal_table_length do:[:i |
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2120
            litIndex := inStream nextUnsignedShortMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2121
            literal := (constants at:litIndex).
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2122
            literal_table at:i put:literal.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2123
        ].
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2124
    ].
357
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2125
    Verbose ifTrue:[Transcript show:'literals: '; showCR:literal_table storeString.].
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  2126
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  2127
    "Created: / 7.5.1998 / 11:52:28 / cg"
357
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2128
    "Modified: / 16.5.1998 / 01:52:27 / cg"
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2129
!
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2130
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2131
readSTMethodCategoryAttributeFor:aSmalltalkMethod
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2132
    |attribute_length name_index name|
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2133
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2134
    attribute_length := inStream nextUnsignedLongMSB:msb.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2135
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2136
    name_index := inStream nextUnsignedShortMSB:msb.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2137
    name := (constants at:name_index).
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2138
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2139
    aSmalltalkMethod category:name.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2140
348
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  2141
    "Modified: / 8.5.1998 / 20:39:59 / cg"
357
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  2142
    "Created: / 16.5.1998 / 01:04:19 / cg"
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  2143
! !
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  2144
135
098936234135 *** empty log message ***
cg
parents: 128
diff changeset
  2145
!JavaClassReader class methodsFor:'documentation'!
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  2146
083530508d9c intitial checkin
cg
parents:
diff changeset
  2147
version
548
063963638b8d raise -> query
cg
parents: 547
diff changeset
  2148
    ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaClassReader.st,v 1.84 1999/03/29 11:39:19 cg Exp $'
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  2149
! !
083530508d9c intitial checkin
cg
parents:
diff changeset
  2150
JavaClassReader initialize!