JavaBehavior.st
changeset 2353 fa7400d022a0
parent 2298 252a59ff897d
child 2380 9195eccdcbd9
child 2396 fadc6d7a2f5b
equal deleted inserted replaced
2352:ab9bb9d8ff4d 2353:fa7400d022a0
     1 "
     1 "
     2  COPYRIGHT (c) 1996-2011 by Claus Gittinger
     2  COPYRIGHT (c) 1996-2011 by Claus Gittinger
       
     3 
       
     4  New code and modifications done at SWING Research Group [1]:
       
     5 
       
     6  COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
       
     7                             SWING Research Group, Czech Technical University in Prague
     3 
     8 
     4  This software is furnished under a license and may be used
     9  This software is furnished under a license and may be used
     5  only in accordance with the terms of that license and with the
    10  only in accordance with the terms of that license and with the
     6  inclusion of the above copyright notice.   This software may not
    11  inclusion of the above copyright notice.   This software may not
     7  be provided or otherwise made available to, or used by, any
    12  be provided or otherwise made available to, or used by, any
     8  other person.  No title to or ownership of the software is
    13  other person.  No title to or ownership of the software is
     9  hereby transferred.
    14  hereby transferred.
       
    15 
       
    16  [1] Code written at SWING Research Group contains a signature
       
    17      of one of the above copright owners. For exact set of such code,
       
    18      see the differences between this version and version stx:libjava
       
    19      as of 1.9.2010
    10 "
    20 "
    11 "{ Package: 'stx:libjava' }"
    21 "{ Package: 'stx:libjava' }"
    12 
    22 
    13 Class subclass:#JavaBehavior
    23 Class subclass:#JavaBehavior
    14 	instanceVariableNames:'constantPool interfaces accessFlags'
    24 	instanceVariableNames:'constantPool interfaces accessFlags initValues'
    15 	classVariableNames:'InitialValuePerType A_OBSOLETE A_INTERFACE A_PUBLIC A_FINAL
    25 	classVariableNames:'InitialValuePerType ACX_ABSTRACT_OR_INTERFACE'
    16 		A_ABSTRACT A_INITIALIZED A_SMALLTALK A_ABSTRACT_OR_INTERFACE
    26 	poolDictionaries:'JavaConstants'
    17 		A_STATIC A_NATIVE A_SYNTHETIC A_ANNOTATION A_ENUM'
       
    18 	poolDictionaries:''
       
    19 	category:'Languages-Java-Classes'
    27 	category:'Languages-Java-Classes'
    20 !
    28 !
    21 
    29 
    22 !JavaBehavior class methodsFor:'documentation'!
    30 !JavaBehavior class methodsFor:'documentation'!
    23 
    31 
    24 copyright
    32 copyright
    25 "
    33 "
    26  COPYRIGHT (c) 1996-2011 by Claus Gittinger
    34  COPYRIGHT (c) 1996-2011 by Claus Gittinger
       
    35 
       
    36  New code and modifications done at SWING Research Group [1]:
       
    37 
       
    38  COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
       
    39                             SWING Research Group, Czech Technical University in Prague
    27 
    40 
    28  This software is furnished under a license and may be used
    41  This software is furnished under a license and may be used
    29  only in accordance with the terms of that license and with the
    42  only in accordance with the terms of that license and with the
    30  inclusion of the above copyright notice.   This software may not
    43  inclusion of the above copyright notice.   This software may not
    31  be provided or otherwise made available to, or used by, any
    44  be provided or otherwise made available to, or used by, any
    32  other person.  No title to or ownership of the software is
    45  other person.  No title to or ownership of the software is
    33  hereby transferred.
    46  hereby transferred.
    34 
    47 
       
    48  [1] Code written at SWING Research Group contains a signature
       
    49      of one of the above copright owners. For exact set of such code,
       
    50      see the differences between this version and version stx:libjava
       
    51      as of 1.9.2010
       
    52 
    35 "
    53 "
    36 !
    54 !
    37 
    55 
    38 documentation
    56 documentation
    39 "
    57 "
    40     Describes what is known and required by the VM.
    58     A base class for all Java classes. Slots & behavior defined here
       
    59     is known to the VM. Do not change the order of slots and
       
    60     add only to the end. You will have to modify stc.h then.
       
    61 
       
    62     Non-VM known stuff could be added to JavaClass safely.
       
    63 
       
    64     [author:]
       
    65         Jan Vrany <jan.vrany@fit.cvut.cz>
       
    66 
       
    67     [instance variables:]
       
    68         constantPool
       
    69         interfaces
       
    70         accessFlags
       
    71     [class variables:]
       
    72 
       
    73     [see also:]
       
    74 
    41 "
    75 "
    42 ! !
    76 ! !
    43 
    77 
    44 !JavaBehavior class methodsFor:'initialization'!
    78 !JavaBehavior class methodsFor:'initialization'!
    45 
    79 
    46 initialize
    80 initialize
    47     "/ those are defined in Java and read from the classFile
    81 
    48     A_PUBLIC      := 16r000001.
    82     "/ Cannot do this as the constant pool may not be initialized
    49     "/ A_PRIVATE     := 16r000002.
    83     "/ACX_ABSTRACT_OR_INTERFACE := ACC_ABSTRACT bitOr:ACC_INTERFACE.
    50     "/ A_PROTECTED   := 16r000004.
    84     ACX_ABSTRACT_OR_INTERFACE := 16r0000400 bitOr: 16r0000200.
    51     A_STATIC      := 16r000008.
       
    52     A_FINAL       := 16r000010.
       
    53     "/ A_SUPER         := 16r000020.
       
    54     "/ A_SYNCHRONIZED  := 16r000020.
       
    55     "/ A_VOLATILE      := 16r000040.
       
    56     "/ A_TRANSIENT     := 16r000080.
       
    57     A_NATIVE        := 16r000100.
       
    58 
       
    59     A_INTERFACE   := 16r000200.
       
    60     A_ABSTRACT    := 16r000400.
       
    61     A_SYNTHETIC   := 16r001000.   "/ 1.1
       
    62     A_ANNOTATION  := 16r002000.   "/ 1.1
       
    63     A_ENUM        := 16r004000.   "/ 1.1
       
    64     A_OBSOLETE    := 16r008000.
       
    65 
       
    66     "/ those are local to the ST/X implementation
       
    67     A_INITIALIZED := 16r100000.
       
    68     A_SMALLTALK   := 16r200000.
       
    69 
       
    70     A_ABSTRACT_OR_INTERFACE := A_ABSTRACT bitOr:A_INTERFACE.
       
    71 
    85 
    72     InitialValuePerType := IdentityDictionary new.
    86     InitialValuePerType := IdentityDictionary new.
    73     InitialValuePerType at:$B put:0.
    87     InitialValuePerType at:$B put:0.
    74     InitialValuePerType at:$C put:0.
    88     InitialValuePerType at:$C put:0.
    75     InitialValuePerType at:$D put:0.0.
    89     InitialValuePerType at:$D put:0.0.
    83 
    97 
    84     "
    98     "
    85      JavaBehavior initialize
    99      JavaBehavior initialize
    86     "
   100     "
    87 
   101 
    88     "Modified: / 13.11.1998 / 14:09:52 / cg"
   102     "Modified: / 13-11-1998 / 14:09:52 / cg"
       
   103     "Modified: / 11-02-2012 / 16:55:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    89 ! !
   104 ! !
    90 
   105 
    91 !JavaBehavior class methodsFor:'constants'!
   106 !JavaBehavior class methodsFor:'constants'!
    92 
   107 
    93 A_NATIVE
   108 ACC_NATIVE
    94     ^ A_NATIVE
   109     ^ ACC_NATIVE
    95 
   110 
    96     "Created: / 16.5.1998 / 01:18:43 / cg"
   111     "Created: / 16.5.1998 / 01:18:43 / cg"
    97 !
   112 !
    98 
   113 
    99 A_PUBLIC
   114 ACC_PUBLIC
   100     ^ A_PUBLIC
   115     ^ ACC_PUBLIC
   101 
   116 
   102     "Created: / 13.5.1998 / 13:03:18 / cg"
   117     "Created: / 13.5.1998 / 13:03:18 / cg"
   103 !
   118 !
   104 
   119 
   105 A_STATIC
   120 ACC_STATIC
   106     ^ A_STATIC
   121     ^ ACC_STATIC
   107 
   122 
   108     "Created: / 16.5.1998 / 00:02:07 / cg"
   123     "Created: / 16.5.1998 / 00:02:07 / cg"
   109 ! !
   124 ! !
   110 
   125 
   111 !JavaBehavior class methodsFor:'signature parsing'!
   126 !JavaBehavior class methodsFor:'signature parsing'!
   142 
   157 
   143 constantPool
   158 constantPool
   144     ^ constantPool
   159     ^ constantPool
   145 !
   160 !
   146 
   161 
       
   162 interfaceNames
       
   163     "Returns set of intefaces as java names (dotted)"
       
   164     ^( interfaces ? #() ) collect:[:e|e isJavaClassRef ifTrue:[e javaClassName] ifFalse:[e name asDottedJavaClassName]].
       
   165 
       
   166     "Created: / 13-02-2013 / 09:33:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   167 !
       
   168 
   147 interfaces
   169 interfaces
   148     interfaces notNil ifTrue:[
   170     interfaces notNil 
   149 	interfaces := interfaces collect:[:clsRef |
   171         ifTrue:
   150 				    clsRef isUnresolved ifTrue:[
   172             [ interfaces := interfaces collect:
   151 					clsRef preResolve
   173                 [:clsRef | clsRef javaClass ] ].
   152 				    ] ifFalse:[
   174 
   153 					clsRef
   175     ^ interfaces ? #()
   154 				    ]
   176 
   155 				 ].
   177     "Modified: / 31-05-2011 / 09:40:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   156     ].
       
   157     ^ interfaces
       
   158 ! !
   178 ! !
   159 
   179 
   160 !JavaBehavior methodsFor:'compiler interface'!
   180 !JavaBehavior methodsFor:'compiler interface'!
   161 
   181 
   162 programmingLanguage
   182 programmingLanguage
   167 ! !
   187 ! !
   168 
   188 
   169 !JavaBehavior methodsFor:'private accessing'!
   189 !JavaBehavior methodsFor:'private accessing'!
   170 
   190 
   171 makeObsolete
   191 makeObsolete
   172     accessFlags := accessFlags bitOr:A_OBSOLETE
   192     accessFlags := accessFlags bitOr:ACC_OBSOLETE
   173 
   193 
   174     "Created: 7.8.1997 / 19:04:48 / cg"
   194     "Created: 7.8.1997 / 19:04:48 / cg"
   175 !
   195 !
   176 
   196 
   177 markUninitialized
   197 markUninitialized
   178     (accessFlags bitAnd:A_INITIALIZED) ~~ 0 ifTrue:[
   198     (accessFlags bitAnd:ACX_INITIALIZED) ~~ 0 ifTrue:[
   179 	accessFlags := accessFlags bitXor:A_INITIALIZED
   199 	accessFlags := accessFlags bitXor:ACX_INITIALIZED
   180     ].
   200     ].
   181 !
   201 !
   182 
   202 
   183 setAccessFlags:flags
   203 setAccessFlags:flags
   184     accessFlags := flags.
   204     accessFlags := flags.
   235 
   255 
   236 isAbstract
   256 isAbstract
   237     "return true, if the receiver is abstract
   257     "return true, if the receiver is abstract
   238      (i.e. may not have instances)"
   258      (i.e. may not have instances)"
   239 
   259 
   240     ^ (accessFlags bitAnd:A_ABSTRACT) ~~ 0
   260     ^ (accessFlags bitAnd:ACC_ABSTRACT) ~~ 0
   241 
   261 
   242     "Modified: / 7.5.1998 / 12:24:42 / cg"
   262     "Modified: / 7.5.1998 / 12:24:42 / cg"
       
   263 !
       
   264 
       
   265 isAnnotation
       
   266     "return true, if the receiver is an interface"
       
   267 
       
   268     ^ (accessFlags bitAnd:ACC_ANNOTATION) ~~ 0
       
   269 
       
   270     "Modified: / 07-05-1998 / 12:23:39 / cg"
       
   271     "Created: / 11-02-2012 / 16:55:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   272 !
       
   273 
       
   274 isEnum
       
   275     "return true, if the receiver is an interface"
       
   276 
       
   277     ^ (accessFlags bitAnd:ACC_ENUM) ~~ 0
       
   278 
       
   279     "Modified: / 07-05-1998 / 12:23:39 / cg"
       
   280     "Created: / 11-02-2012 / 16:55:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   243 !
   281 !
   244 
   282 
   245 isFinal
   283 isFinal
   246     "return true, if the receiver is final
   284     "return true, if the receiver is final
   247      (i.e. may not be subclassed)"
   285      (i.e. may not be subclassed)"
   248 
   286 
   249     ^ (accessFlags bitAnd:A_FINAL) ~~ 0
   287     ^ (accessFlags bitAnd:ACC_FINAL) ~~ 0
   250 
   288 
   251     "Modified: / 7.5.1998 / 12:24:21 / cg"
   289     "Modified: / 7.5.1998 / 12:24:21 / cg"
   252 !
   290 !
   253 
   291 
   254 isInitialized
   292 isInitialized
   255     "return true, if the receiver is initialized"
   293     "return true, if the receiver is initialized"
   256 
   294 
   257     ^ (accessFlags bitAnd:A_INITIALIZED) ~~ 0
   295     ^ (accessFlags bitAnd:ACX_INITIALIZED) ~~ 0
   258 
   296 
   259     "Modified: / 7.5.1998 / 12:23:54 / cg"
   297     "Modified: / 7.5.1998 / 12:23:54 / cg"
   260 !
   298 !
   261 
   299 
   262 isInterface
   300 isInterface
   263     "return true, if the receiver is an interface"
   301     "return true, if the receiver is an interface"
   264 
   302 
   265     ^ (accessFlags bitAnd:A_INTERFACE) ~~ 0
   303     ^ (accessFlags bitAnd:ACC_INTERFACE) ~~ 0
   266 
   304 
   267     "Modified: / 7.5.1998 / 12:23:39 / cg"
   305     "Modified: / 7.5.1998 / 12:23:39 / cg"
   268 !
   306 !
   269 
   307 
   270 isObsolete
   308 isObsolete
   271     "return true, if the receiver is obsolete
   309     "return true, if the receiver is obsolete
   272      Java classes are never."
   310      Java classes are never."
   273 
   311 
   274     ^ (accessFlags bitAnd:A_OBSOLETE) ~~ 0.
   312     ^ (accessFlags bitAnd:ACC_OBSOLETE) ~~ 0.
   275 
   313 
   276     "Modified: 7.8.1997 / 19:04:28 / cg"
   314     "Modified: 7.8.1997 / 19:04:28 / cg"
       
   315 !
       
   316 
       
   317 isPackagePrivate
       
   318     ^ (accessFlags bitAnd:ACC_PRIVATE | ACC_PUBLIC | ACC_PROTECTED) = 0
       
   319 
       
   320     "Created: / 05-07-2012 / 10:13:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   321 !
       
   322 
       
   323 isPrivate
       
   324     "return true, if the receiver is an interface"
       
   325 
       
   326     ^ (accessFlags bitAnd:ACC_PRIVATE) ~~ 0
       
   327 
       
   328     "Modified: / 07-05-1998 / 12:23:39 / cg"
       
   329     "Created: / 11-02-2012 / 16:55:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   330 !
       
   331 
       
   332 isProtected
       
   333     "return true, if the receiver is an interface"
       
   334 
       
   335     ^ (accessFlags bitAnd:ACC_PROTECTED) ~~ 0
       
   336 
       
   337     "Modified: / 07-05-1998 / 12:23:39 / cg"
       
   338     "Created: / 11-02-2012 / 16:56:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   277 !
   339 !
   278 
   340 
   279 isPublic
   341 isPublic
   280     "return true, if the receiver is public"
   342     "return true, if the receiver is public"
   281 
   343 
   282     ^ (accessFlags bitAnd:A_PUBLIC) ~~ 0
   344     ^ (accessFlags bitAnd:ACC_PUBLIC) ~~ 0
   283 
   345 
   284     "Modified: / 7.5.1998 / 12:22:44 / cg"
   346     "Modified: / 7.5.1998 / 12:22:44 / cg"
       
   347 !
       
   348 
       
   349 isSynthetic
       
   350     "return true, if the receiver is a synthetic class
       
   351      (usually a proxy generated at runtime)"
       
   352 
       
   353     ^ (accessFlags bitAnd:ACC_SYNTHETIC) ~~ 0
       
   354 
       
   355     "Created: / 13-04-2012 / 18:51:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   285 ! !
   356 ! !
   286 
   357 
   287 !JavaBehavior class methodsFor:'documentation'!
   358 !JavaBehavior class methodsFor:'documentation'!
   288 
   359 
   289 version
   360 version
   290     ^ '$Header: /cvs/stx/stx/libjava/JavaBehavior.st,v 1.6 2011-11-24 11:54:40 cg Exp $'
   361     ^ '$Header: /cvs/stx/stx/libjava/JavaBehavior.st,v 1.7 2013-02-16 18:08:32 vrany Exp $'
   291 !
   362 !
   292 
   363 
   293 version_CVS
   364 version_CVS
   294     ^ '$Header: /cvs/stx/stx/libjava/JavaBehavior.st,v 1.6 2011-11-24 11:54:40 cg Exp $'
   365     ^ '$Header: /cvs/stx/stx/libjava/JavaBehavior.st,v 1.7 2013-02-16 18:08:32 vrany Exp $'
       
   366 !
       
   367 
       
   368 version_HG
       
   369 
       
   370     ^ '$Changeset: <not expanded> $'
   295 !
   371 !
   296 
   372 
   297 version_SVN
   373 version_SVN
   298     ^ '§Id: JavaBehavior.st,v 1.4 2011/08/18 18:42:48 vrany Exp §'
   374     ^ '§Id§'
   299 ! !
   375 ! !
       
   376 
   300 
   377 
   301 JavaBehavior initialize!
   378 JavaBehavior initialize!