JavaObject.st
author hlopkmar
Fri, 30 Nov 2012 20:52:11 +0000
branchdevelopment
changeset 1844 7f4dd9a13c2c
parent 1818 2e5ed72e7dfd
child 1864 60a8dc26c8c6
permissions -rw-r--r--
disabling multibyte char disassempler test as stderr cannot write multibyte chars and hudson reports error
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
     1
"
877
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 752
diff changeset
     2
 COPYRIGHT (c) 1996-2011 by Claus Gittinger
1152
040cba55a7d2 Copyright fixes
vranyj1
parents: 1109
diff changeset
     3
1155
vranyj1
parents: 1152
diff changeset
     4
 New code and modifications done at SWING Research Group [1]:
1152
040cba55a7d2 Copyright fixes
vranyj1
parents: 1109
diff changeset
     5
877
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 752
diff changeset
     6
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 752
diff changeset
     7
                            SWING Research Group, Czech Technical University in Prague
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 752
diff changeset
     8
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
     9
 This software is furnished under a license and may be used
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    10
 only in accordance with the terms of that license and with the
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    11
 inclusion of the above copyright notice.   This software may not
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    12
 be provided or otherwise made available to, or used by, any
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    13
 other person.  No title to or ownership of the software is
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    14
 hereby transferred.
877
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 752
diff changeset
    15
1155
vranyj1
parents: 1152
diff changeset
    16
 [1] Code written at SWING Research Group contains a signature
vranyj1
parents: 1152
diff changeset
    17
     of one of the above copright owners. For exact set of such code,
vranyj1
parents: 1152
diff changeset
    18
     see the differences between this version and version stx:libjava
1152
040cba55a7d2 Copyright fixes
vranyj1
parents: 1109
diff changeset
    19
     as of 1.9.2010
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    20
"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    21
"{ Package: 'stx:libjava' }"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    22
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    23
Object subclass:#JavaObject
1691
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
    24
	instanceVariableNames:'_lockWord_'
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    25
	classVariableNames:''
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    26
	poolDictionaries:''
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    27
	category:'Languages-Java-Classes'
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    28
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    29
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    30
!JavaObject class methodsFor:'documentation'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    31
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    32
copyright
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    33
"
877
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 752
diff changeset
    34
 COPYRIGHT (c) 1996-2011 by Claus Gittinger
1152
040cba55a7d2 Copyright fixes
vranyj1
parents: 1109
diff changeset
    35
1155
vranyj1
parents: 1152
diff changeset
    36
 New code and modifications done at SWING Research Group [1]:
1152
040cba55a7d2 Copyright fixes
vranyj1
parents: 1109
diff changeset
    37
877
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 752
diff changeset
    38
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 752
diff changeset
    39
                            SWING Research Group, Czech Technical University in Prague
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 752
diff changeset
    40
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    41
 This software is furnished under a license and may be used
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    42
 only in accordance with the terms of that license and with the
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    43
 inclusion of the above copyright notice.   This software may not
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    44
 be provided or otherwise made available to, or used by, any
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    45
 other person.  No title to or ownership of the software is
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    46
 hereby transferred.
877
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 752
diff changeset
    47
1155
vranyj1
parents: 1152
diff changeset
    48
 [1] Code written at SWING Research Group contains a signature
vranyj1
parents: 1152
diff changeset
    49
     of one of the above copright owners. For exact set of such code,
vranyj1
parents: 1152
diff changeset
    50
     see the differences between this version and version stx:libjava
1152
040cba55a7d2 Copyright fixes
vranyj1
parents: 1109
diff changeset
    51
     as of 1.9.2010
877
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 752
diff changeset
    52
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    53
"
1691
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
    54
!
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
    55
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
    56
documentation
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
    57
"
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
    58
    'Proto' class for all Java classes: java.lang.Object inherits 
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
    59
    from JavaObject class. Methods provided here are provides a 'glue' 
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
    60
    code necessary to integrate Java objects into Smalltalk world.
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
    61
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
    62
    The 'lock' instance variable here is to support Java monitors.
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
    63
    It contains either smalltinteger with lockword or a reference to
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
    64
    full JavaMonitor.
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
    65
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
    66
    [author:]
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
    67
        Claus Gittinger
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
    68
        Jan Vrany <jan.vrany@fit.cvut.cz>
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
    69
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
    70
    [instance variables:]
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
    71
        _lockWord_  <SmallInteger|JavaMonitor>  either thin-locing lock word
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
    72
                                                or fat-lock (JavaMonitor). The funny name
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
    73
                                                here is to prevent name clashes
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
    74
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
    75
    [class variables:]
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
    76
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
    77
    [see also:]
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
    78
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
    79
"
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    80
! !
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    81
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    82
!JavaObject class methodsFor:'misc'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    83
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    84
resolveClassRefs
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    85
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    86
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    87
resolveClassRefsIgnoring:setOfClasses
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    88
! !
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    89
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    90
!JavaObject class methodsFor:'smalltalk interface'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    91
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    92
convertJavaObject:val signature:retValSignature
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    93
^ val.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    94
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    95
    retValSignature = 'void' ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    96
	^ #void
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    97
    ].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    98
    retValSignature = 'boolean' ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    99
	val == 0 ifTrue:[^ false].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   100
	^ true
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   101
    ].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   102
    retValSignature = 'int' ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   103
	val isInteger ifFalse:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   104
	    self halt
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   105
	].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   106
	^ val
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   107
    ].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   108
    retValSignature = 'char[]' ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   109
	"/ these are ST-strings
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   110
	^ val
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   111
    ].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   112
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   113
    retValSignature = 'char' ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   114
	"/ these are ST-characters
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   115
	val isInteger ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   116
	    ^ Character value:val
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   117
	].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   118
	self halt.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   119
	^ val
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   120
    ].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   121
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   122
    retValSignature = 'Object' ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   123
	^ val
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   124
    ].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   125
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   126
    retValSignature = 'String' ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   127
	^ Java as_ST_String:val
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   128
    ].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   129
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   130
    'no conversion for: ' print. val class name print. ' to: ' print. retValSignature printNL.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   131
    ^ val.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   132
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   133
    "Modified: 8.8.1997 / 12:07:23 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   134
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   135
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   136
javaStringFrom:aString
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   137
    "hard-coding internas of java.lang.String here is bad ..."
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   138
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   139
    self halt.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   140
    ^ Java as_String:aString
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   141
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   142
    "Modified: 7.8.1997 / 21:17:32 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   143
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   144
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   145
stringFromJavaString:aJavaString
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   146
    "hard-coding internas of java.lang.String here is bad ..."
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   147
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   148
    self halt.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   149
    ^ Java as_ST_String:aJavaString
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   150
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   151
    "Modified: 8.8.1997 / 12:07:29 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   152
! !
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   153
1691
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   154
!JavaObject methodsFor:'accessing-Java'!
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   155
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   156
getJavaLockWord
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   157
    "Returns a Java lock word for given object. The returned
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   158
     value is 
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   159
        - either SmallInteger that encodes the thinlock
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   160
        - or a fat lock, instance of JavaMonitor
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   161
    "
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   162
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   163
    "/For nonJava objects, always return fatlock
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   164
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   165
    ^_lockWord_
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   166
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   167
    "Created: / 26-08-2012 / 14:03:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   168
!
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   169
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   170
getJavaMonitor
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   171
    "Returns fat JavaMonitor associated with the receiver"
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   172
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   173
    "/ For Java objects, check if there is allready a thinlock,
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   174
    "/ inflate it and return the fatlock
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   175
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   176
    _lockWord_ class == SmallInteger ifTrue:[
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   177
        _lockWord_ := JavaVM inflateLockFor: self lockword: _lockWord_.
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   178
    ].
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   179
    ^_lockWord_
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   180
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   181
    "Created: / 26-08-2012 / 18:35:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   182
!
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   183
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   184
setJavaLockWord: lockWordOrJavaMonitor
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   185
    "Sets a Java lock word for receiver to lockWordOrJavaMonitor. 
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   186
     The lockWordOrJavaMonitor must be:
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   187
        - either SmallInteger that encodes the thinlock
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   188
        - or a fat lock, instance of JavaMonitor
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   189
    "
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   190
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   191
    "/for non-Java objects, store fat lock in LockTable in JavaVM
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   192
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   193
    ^_lockWord_ := lockWordOrJavaMonitor
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   194
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   195
    "Created: / 26-08-2012 / 14:07:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   196
! !
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   197
1427
13f3765a9bba Some experiments with Exceptions, not that easy :-)
vranyj1
parents: 1394
diff changeset
   198
!JavaObject methodsFor:'exception handling support'!
13f3765a9bba Some experiments with Exceptions, not that easy :-)
vranyj1
parents: 1394
diff changeset
   199
1626
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1549
diff changeset
   200
catchInDebugger
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1549
diff changeset
   201
   "if set, the debugger will handle this signal in its event loop and will close itself
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1549
diff changeset
   202
     without asking for close-confirmation.
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1549
diff changeset
   203
     This allows for debugged processes to be terminated without a user confirmation dialog
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1549
diff changeset
   204
     (for now, this is used in expecco's hard-terminate function to shut down any open debuggers
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1549
diff changeset
   205
      together with the test-process).
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1549
diff changeset
   206
     Dummy here"
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1549
diff changeset
   207
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1549
diff changeset
   208
    ^false
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1549
diff changeset
   209
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1549
diff changeset
   210
    "Created: / 20-08-2012 / 14:15:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1549
diff changeset
   211
!
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1549
diff changeset
   212
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1549
diff changeset
   213
description
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1549
diff changeset
   214
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1549
diff changeset
   215
    self class isThrowable ifTrue:[
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1549
diff changeset
   216
        ^self getMessage
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1549
diff changeset
   217
    ].
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1549
diff changeset
   218
    ^super description
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1549
diff changeset
   219
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1549
diff changeset
   220
    "Created: / 20-08-2012 / 14:19:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1549
diff changeset
   221
!
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1549
diff changeset
   222
1427
13f3765a9bba Some experiments with Exceptions, not that easy :-)
vranyj1
parents: 1394
diff changeset
   223
isQuerySignal
13f3765a9bba Some experiments with Exceptions, not that easy :-)
vranyj1
parents: 1394
diff changeset
   224
13f3765a9bba Some experiments with Exceptions, not that easy :-)
vranyj1
parents: 1394
diff changeset
   225
    ^false
1328
06e2e372ebb0 Support for wrapping/unwrapping JavaObjects
kursjan
parents: 1288
diff changeset
   226
1427
13f3765a9bba Some experiments with Exceptions, not that easy :-)
vranyj1
parents: 1394
diff changeset
   227
    "Created: / 18-03-2012 / 13:11:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
13f3765a9bba Some experiments with Exceptions, not that easy :-)
vranyj1
parents: 1394
diff changeset
   228
!
1328
06e2e372ebb0 Support for wrapping/unwrapping JavaObjects
kursjan
parents: 1288
diff changeset
   229
1427
13f3765a9bba Some experiments with Exceptions, not that easy :-)
vranyj1
parents: 1394
diff changeset
   230
parent
13f3765a9bba Some experiments with Exceptions, not that easy :-)
vranyj1
parents: 1394
diff changeset
   231
    "Required for old instance based exceptions, sigh"
13f3765a9bba Some experiments with Exceptions, not that easy :-)
vranyj1
parents: 1394
diff changeset
   232
    ^nil
13f3765a9bba Some experiments with Exceptions, not that easy :-)
vranyj1
parents: 1394
diff changeset
   233
13f3765a9bba Some experiments with Exceptions, not that easy :-)
vranyj1
parents: 1394
diff changeset
   234
    "Created: / 18-03-2012 / 13:26:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1626
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1549
diff changeset
   235
!
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1549
diff changeset
   236
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1549
diff changeset
   237
signal
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1549
diff changeset
   238
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1549
diff changeset
   239
    self class isThrowable ifTrue:[
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1549
diff changeset
   240
        ^self class.
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1549
diff changeset
   241
    ].
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1549
diff changeset
   242
    ^super signal
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1549
diff changeset
   243
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1549
diff changeset
   244
    "Created: / 20-08-2012 / 14:15:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1328
06e2e372ebb0 Support for wrapping/unwrapping JavaObjects
kursjan
parents: 1288
diff changeset
   245
! !
06e2e372ebb0 Support for wrapping/unwrapping JavaObjects
kursjan
parents: 1288
diff changeset
   246
1109
9bd0544f9046 Initial version of finalize() support - may crash VM!
vranyj1
parents: 1093
diff changeset
   247
!JavaObject methodsFor:'finalization'!
9bd0544f9046 Initial version of finalize() support - may crash VM!
vranyj1
parents: 1093
diff changeset
   248
1548
af9097580037 - JavaVM
vranyj1
parents: 1546
diff changeset
   249
finalizationLobby
af9097580037 - JavaVM
vranyj1
parents: 1546
diff changeset
   250
1549
d99bd163584e - JavaFinalizationRegistry
vranyj1
parents: 1548
diff changeset
   251
"/    ^super finalizationLobby
1109
9bd0544f9046 Initial version of finalize() support - may crash VM!
vranyj1
parents: 1093
diff changeset
   252
1549
d99bd163584e - JavaFinalizationRegistry
vranyj1
parents: 1548
diff changeset
   253
    ^JavaVM finalizationLobby "/ Do not use this yet!!
1109
9bd0544f9046 Initial version of finalize() support - may crash VM!
vranyj1
parents: 1093
diff changeset
   254
1548
af9097580037 - JavaVM
vranyj1
parents: 1546
diff changeset
   255
    "Created: / 24-07-2012 / 01:04:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1109
9bd0544f9046 Initial version of finalize() support - may crash VM!
vranyj1
parents: 1093
diff changeset
   256
! !
9bd0544f9046 Initial version of finalize() support - may crash VM!
vranyj1
parents: 1093
diff changeset
   257
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   258
!JavaObject methodsFor:'initialization'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   259
1502
8caaac85827f Initialization of Java Classes changed to be compatible with TO (I hope I did not broke anything!)
kursjan
parents: 1478
diff changeset
   260
initialize
8caaac85827f Initialization of Java Classes changed to be compatible with TO (I hope I did not broke anything!)
kursjan
parents: 1478
diff changeset
   261
    self perform:#'<init>()V'.
8caaac85827f Initialization of Java Classes changed to be compatible with TO (I hope I did not broke anything!)
kursjan
parents: 1478
diff changeset
   262
8caaac85827f Initialization of Java Classes changed to be compatible with TO (I hope I did not broke anything!)
kursjan
parents: 1478
diff changeset
   263
    "Created: / 09-06-2012 / 21:49:37 / Jan Kurs (kursjan@fit.cvut.cz)"
8caaac85827f Initialization of Java Classes changed to be compatible with TO (I hope I did not broke anything!)
kursjan
parents: 1478
diff changeset
   264
!
8caaac85827f Initialization of Java Classes changed to be compatible with TO (I hope I did not broke anything!)
kursjan
parents: 1478
diff changeset
   265
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   266
initializeToZero
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   267
    |sz|
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   268
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   269
    sz := self class instSize.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   270
    1 to:sz do:[:i |
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   271
	self instVarAt:i put:0
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   272
    ]
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   273
! !
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   274
1213
fc90769151e8 - fix in reflection over methods (signature is nil for non-generic methods)
vranyj1
parents: 1209
diff changeset
   275
!JavaObject methodsFor:'inspecting'!
fc90769151e8 - fix in reflection over methods (signature is nil for non-generic methods)
vranyj1
parents: 1209
diff changeset
   276
fc90769151e8 - fix in reflection over methods (signature is nil for non-generic methods)
vranyj1
parents: 1209
diff changeset
   277
inspectorExtraAttributes
fc90769151e8 - fix in reflection over methods (signature is nil for non-generic methods)
vranyj1
parents: 1209
diff changeset
   278
fc90769151e8 - fix in reflection over methods (signature is nil for non-generic methods)
vranyj1
parents: 1209
diff changeset
   279
    | attrs nm |
fc90769151e8 - fix in reflection over methods (signature is nil for non-generic methods)
vranyj1
parents: 1209
diff changeset
   280
fc90769151e8 - fix in reflection over methods (signature is nil for non-generic methods)
vranyj1
parents: 1209
diff changeset
   281
    attrs := super inspectorExtraAttributes.
fc90769151e8 - fix in reflection over methods (signature is nil for non-generic methods)
vranyj1
parents: 1209
diff changeset
   282
    nm := self class name.
fc90769151e8 - fix in reflection over methods (signature is nil for non-generic methods)
vranyj1
parents: 1209
diff changeset
   283
    nm == #'java/lang/reflect/Method' ifTrue:[
fc90769151e8 - fix in reflection over methods (signature is nil for non-generic methods)
vranyj1
parents: 1209
diff changeset
   284
        attrs at:'-method' put: (JavaVM reflection methodForJavaMethodObject: self).
fc90769151e8 - fix in reflection over methods (signature is nil for non-generic methods)
vranyj1
parents: 1209
diff changeset
   285
        ^attrs.
fc90769151e8 - fix in reflection over methods (signature is nil for non-generic methods)
vranyj1
parents: 1209
diff changeset
   286
    ].
1242
62be7670d158 Few fixes for Tomcat, new Tomcat startup script
vranyj1
parents: 1217
diff changeset
   287
    nm == #'java/lang/Class' ifTrue:[
1213
fc90769151e8 - fix in reflection over methods (signature is nil for non-generic methods)
vranyj1
parents: 1209
diff changeset
   288
        attrs at:'-class' put: (JavaVM reflection classForJavaClassObject: self).
fc90769151e8 - fix in reflection over methods (signature is nil for non-generic methods)
vranyj1
parents: 1209
diff changeset
   289
        ^attrs.
fc90769151e8 - fix in reflection over methods (signature is nil for non-generic methods)
vranyj1
parents: 1209
diff changeset
   290
    ].
fc90769151e8 - fix in reflection over methods (signature is nil for non-generic methods)
vranyj1
parents: 1209
diff changeset
   291
    ^attrs
fc90769151e8 - fix in reflection over methods (signature is nil for non-generic methods)
vranyj1
parents: 1209
diff changeset
   292
fc90769151e8 - fix in reflection over methods (signature is nil for non-generic methods)
vranyj1
parents: 1209
diff changeset
   293
    "Created: / 04-12-2011 / 19:28:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
fc90769151e8 - fix in reflection over methods (signature is nil for non-generic methods)
vranyj1
parents: 1209
diff changeset
   294
! !
fc90769151e8 - fix in reflection over methods (signature is nil for non-generic methods)
vranyj1
parents: 1209
diff changeset
   295
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   296
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   297
!JavaObject methodsFor:'printing & storing'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   298
1478
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1427
diff changeset
   299
basicPrintOn: aStream
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1427
diff changeset
   300
    aStream nextPutAll: self class name.
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1427
diff changeset
   301
    aStream nextPut:$@.
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1427
diff changeset
   302
    self identityHash printOn: aStream.
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1427
diff changeset
   303
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1427
diff changeset
   304
    "Created: / 13-04-2012 / 17:34:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1427
diff changeset
   305
!
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1427
diff changeset
   306
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   307
displayString
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   308
1209
vranyj1
parents: 1155
diff changeset
   309
    JavaVM booted ifTrue:[
1478
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1427
diff changeset
   310
        | toStringM toString |
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1427
diff changeset
   311
        toStringM := self class lookupSelector: #'toString()Ljava/lang/String;'.
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1427
diff changeset
   312
        (toStringM javaClass name ~~ #'java/lang/Object') ifTrue:[
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1427
diff changeset
   313
            [ 
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1427
diff changeset
   314
                toString := Java as_ST_String:(self perform:#'toString()Ljava/lang/String;').
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1427
diff changeset
   315
            ] on: Error do: [ 
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1427
diff changeset
   316
                toString := nil 
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1427
diff changeset
   317
            ].        
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1427
diff changeset
   318
        ].
1209
vranyj1
parents: 1155
diff changeset
   319
        toString notNil ifTrue:[        
vranyj1
parents: 1155
diff changeset
   320
            ^toString
vranyj1
parents: 1155
diff changeset
   321
        ]
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   322
    ].
1478
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1427
diff changeset
   323
    ^String streamContents: [:s|self basicPrintOn: s]
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   324
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   325
    "Modified: / 04-11-1998 / 18:35:00 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   326
    "Modified: / 28-01-2011 / 15:10:05 / Marcel Hlopko <hlopik@gmail.com>"
1478
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1427
diff changeset
   327
    "Modified: / 13-04-2012 / 17:38:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   328
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   329
1209
vranyj1
parents: 1155
diff changeset
   330
printOn: aStream
vranyj1
parents: 1155
diff changeset
   331
    |myClassName |
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   332
1209
vranyj1
parents: 1155
diff changeset
   333
    myClassName := self class name.
vranyj1
parents: 1155
diff changeset
   334
    myClassName == #'java/lang/String' ifTrue:[
vranyj1
parents: 1155
diff changeset
   335
        aStream nextPut:$".
vranyj1
parents: 1155
diff changeset
   336
        aStream nextPutAll: (Java as_ST_String: self).
vranyj1
parents: 1155
diff changeset
   337
        aStream nextPut:$".
vranyj1
parents: 1155
diff changeset
   338
        ^self.
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   339
    ].
1209
vranyj1
parents: 1155
diff changeset
   340
    myClassName == #'java/lang/Class' ifTrue:[
vranyj1
parents: 1155
diff changeset
   341
        super printOn: aStream.
vranyj1
parents: 1155
diff changeset
   342
        aStream nextPut: $(.
1648
ba54c818827d - more reflection stuff moved to JavaMirror
vranyj1
parents: 1626
diff changeset
   343
        (JavaVM reflection classForJavaClassObject:self) javaMirror getName printOn: aStream.
1209
vranyj1
parents: 1155
diff changeset
   344
        aStream nextPut: $).
vranyj1
parents: 1155
diff changeset
   345
        ^self.
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   346
    ].
1209
vranyj1
parents: 1155
diff changeset
   347
    myClassName == #'java.lang.reflect.Method' ifTrue:[
vranyj1
parents: 1155
diff changeset
   348
        super printOn: aStream.
vranyj1
parents: 1155
diff changeset
   349
        aStream nextPut: $(.
vranyj1
parents: 1155
diff changeset
   350
        (JavaVM reflection methodForJavaMethodObject:self) printOn: aStream.
vranyj1
parents: 1155
diff changeset
   351
        aStream nextPut: $).
vranyj1
parents: 1155
diff changeset
   352
        ^self.
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   353
    ].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   354
1209
vranyj1
parents: 1155
diff changeset
   355
    JavaVM booted ifTrue:[
vranyj1
parents: 1155
diff changeset
   356
        | toString |
vranyj1
parents: 1155
diff changeset
   357
        [ toString := Java as_ST_String:(self perform:#'toString()Ljava/lang/String;').]
vranyj1
parents: 1155
diff changeset
   358
            on: Error do: [ toString := nil ].        
vranyj1
parents: 1155
diff changeset
   359
        toString notNil ifTrue:[        
vranyj1
parents: 1155
diff changeset
   360
            "/super printOn: aStream.
vranyj1
parents: 1155
diff changeset
   361
            "/aStream nextPut: $(.
vranyj1
parents: 1155
diff changeset
   362
            aStream nextPutAll: toString.
vranyj1
parents: 1155
diff changeset
   363
            "/aStream nextPut: $).
vranyj1
parents: 1155
diff changeset
   364
            ^self.
vranyj1
parents: 1155
diff changeset
   365
        ] 
vranyj1
parents: 1155
diff changeset
   366
    ].
vranyj1
parents: 1155
diff changeset
   367
    super printOn: aStream.
vranyj1
parents: 1155
diff changeset
   368
vranyj1
parents: 1155
diff changeset
   369
    "Created: / 04-12-2011 / 10:29:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   370
! !
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   371
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   372
!JavaObject methodsFor:'queries'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   373
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   374
isJavaClassRef
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   375
    ^ false
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   376
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   377
    "Created: / 9.11.1999 / 17:13:37 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   378
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   379
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   380
isJavaMethodRef
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   381
    ^ false
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   382
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   383
    "Created: / 9.11.1999 / 15:43:21 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   384
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   385
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   386
isJavaObject
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   387
    ^ true
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   388
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   389
    "Created: 26.3.1997 / 13:34:17 / cg"
1394
dc7d95a99161 Fixes in interop
vranyj1
parents: 1356
diff changeset
   390
!
dc7d95a99161 Fixes in interop
vranyj1
parents: 1356
diff changeset
   391
dc7d95a99161 Fixes in interop
vranyj1
parents: 1356
diff changeset
   392
size
dc7d95a99161 Fixes in interop
vranyj1
parents: 1356
diff changeset
   393
    "What a hack!!!!!!"
dc7d95a99161 Fixes in interop
vranyj1
parents: 1356
diff changeset
   394
dc7d95a99161 Fixes in interop
vranyj1
parents: 1356
diff changeset
   395
    ^(self respondsTo:#'size()I') ifTrue:[
dc7d95a99161 Fixes in interop
vranyj1
parents: 1356
diff changeset
   396
        self perform:#'size()I'
dc7d95a99161 Fixes in interop
vranyj1
parents: 1356
diff changeset
   397
    ] ifFalse:[
dc7d95a99161 Fixes in interop
vranyj1
parents: 1356
diff changeset
   398
        super size.    
dc7d95a99161 Fixes in interop
vranyj1
parents: 1356
diff changeset
   399
    ]
dc7d95a99161 Fixes in interop
vranyj1
parents: 1356
diff changeset
   400
dc7d95a99161 Fixes in interop
vranyj1
parents: 1356
diff changeset
   401
    "Created: / 29-02-2012 / 14:25:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   402
! !
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   403
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   404
!JavaObject methodsFor:'smalltalk interface'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   405
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   406
lookupMethod:selector numArgs:nargs
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   407
    "lookup a method"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   408
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   409
    |method cls sel|
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   410
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   411
    sel := selector.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   412
    (sel includes:$:) ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   413
	sel := sel copyTo:(sel indexOf:$:)-1    
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   414
    ].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   415
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   416
    sel := sel asSymbolIfInterned.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   417
    sel notNil ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   418
	cls := self class.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   419
	[cls notNil and:[cls ~~ JavaObject]] whileTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   420
	    cls methodDictionary keysAndValuesDo:[:jSel :aMethod |
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   421
		(jSel == sel ) ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   422
		    ^ aMethod
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   423
		]
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   424
	    ].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   425
	    cls methodDictionary keysAndValuesDo:[:jSel :aMethod |
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   426
		(aMethod name = sel 
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   427
		or:[aMethod signatureNameWithoutReturnType = sel]) ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   428
		    aMethod numArgs == nargs ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   429
			^ aMethod
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   430
		    ]
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   431
		]
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   432
	    ].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   433
	    cls := cls superclass.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   434
	].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   435
    ].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   436
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   437
    ^ nil
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   438
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   439
    "
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   440
     |stack|
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   441
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   442
     stack := (Java at:'java.util.Stack') basicNew.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   443
     stack lookupMethod:#'<init>' numArgs:0. 
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   444
    "
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   445
    "
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   446
     |stack|
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   447
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   448
     stack := (Java at:'java.util.Stack') new.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   449
     stack lookupMethod:#isEmpty numArgs:0. 
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   450
    "
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   451
    "
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   452
     |frame|
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   453
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   454
     frame := (Java at:'java.awt.Frame') new.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   455
     frame lookupMethod:#'<init> (String)' numArgs:1. 
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   456
    "
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   457
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   458
    "Modified: 22.3.1997 / 00:56:54 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   459
! !
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   460
1093
255c230a1c55 hacking monitors, not working yet :P
hlopkmar
parents: 1022
diff changeset
   461
!JavaObject methodsFor:'unwind'!
255c230a1c55 hacking monitors, not working yet :P
hlopkmar
parents: 1022
diff changeset
   462
255c230a1c55 hacking monitors, not working yet :P
hlopkmar
parents: 1022
diff changeset
   463
unwindHandlerInContext: aContext 
255c230a1c55 hacking monitors, not working yet :P
hlopkmar
parents: 1022
diff changeset
   464
    "given a context which has been marked for unwind,
255c230a1c55 hacking monitors, not working yet :P
hlopkmar
parents: 1022
diff changeset
   465
     retrieve the handler block. This method is called when ST
255c230a1c55 hacking monitors, not working yet :P
hlopkmar
parents: 1022
diff changeset
   466
     exception raises and stack is unwinding. JavaClass instance
255c230a1c55 hacking monitors, not working yet :P
hlopkmar
parents: 1022
diff changeset
   467
     has an opportunity to clean up monitors"
255c230a1c55 hacking monitors, not working yet :P
hlopkmar
parents: 1022
diff changeset
   468
    
255c230a1c55 hacking monitors, not working yet :P
hlopkmar
parents: 1022
diff changeset
   469
    ^ JavaVM unwindHandlerForJavaContext: aContext.
255c230a1c55 hacking monitors, not working yet :P
hlopkmar
parents: 1022
diff changeset
   470
255c230a1c55 hacking monitors, not working yet :P
hlopkmar
parents: 1022
diff changeset
   471
    "Created: / 08-11-2011 / 12:25:15 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
255c230a1c55 hacking monitors, not working yet :P
hlopkmar
parents: 1022
diff changeset
   472
! !
255c230a1c55 hacking monitors, not working yet :P
hlopkmar
parents: 1022
diff changeset
   473
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   474
!JavaObject class methodsFor:'documentation'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   475
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   476
version
1022
38b710d7dfbc svn properties fixed
vranyj1
parents: 1001
diff changeset
   477
    ^ '$Id$'
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   478
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   479
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   480
version_SVN
1022
38b710d7dfbc svn properties fixed
vranyj1
parents: 1001
diff changeset
   481
    ^ '$Id$'
949
8452984ed807 New Implementation of JavaLookup. Slow, no boxing, unboxing is old and needs to be rewritten.
kursjan
parents: 923
diff changeset
   482
! !
1691
826f8d7dc0df thinlocks reintegrated
vranyj1
parents: 1687
diff changeset
   483