--- a/JavaMethod.st Tue Jan 27 21:01:25 1998 +0000
+++ b/JavaMethod.st Tue Jan 27 21:03:54 1998 +0000
@@ -2,9 +2,10 @@
instanceVariableNames:'accessFlags selector javaClass exceptionHandlerTable
exceptionTable returnType signature lineNumberTable
localVariableTable isNOOPMethod'
- classVariableNames:'SignatureTypeCodes ForceByteCodeDisplay A_PUBLIC A_PRIVATE
- A_PROTECTED A_STATIC A_FINAL A_SYNCHRONIZED A_ABSTRACT A_NATIVE
- A_BREAKPOINT R_VOID R_LONG R_DOUBLE'
+ classVariableNames:'AbstractMethodInvokationSignal SignatureTypeCodes
+ ForceByteCodeDisplay A_PUBLIC A_PRIVATE A_PROTECTED A_STATIC
+ A_FINAL A_SYNCHRONIZED A_ABSTRACT A_NATIVE A_BREAKPOINT R_VOID
+ R_LONG R_DOUBLE'
poolDictionaries:''
category:'Java-Classes'
!
@@ -13,6 +14,12 @@
!JavaMethod class methodsFor:'initialization'!
initialize
+ AbstractMethodInvokationSignal isNil ifTrue:[
+ AbstractMethodInvokationSignal := ExecutionErrorSignal newSignalMayProceed:true.
+ AbstractMethodInvokationSignal nameClass:self message:#abstractMethodInvokationSignal.
+ AbstractMethodInvokationSignal notifierString:'attempt to execute abstract method'.
+ ].
+
A_PUBLIC := 16r0001.
A_PRIVATE := 16r0002.
A_PROTECTED := 16r0004.
@@ -50,7 +57,17 @@
ForceByteCodeDisplay := false.
"
- "Modified: / 7.1.1998 / 14:43:46 / cg"
+ "Modified: / 27.1.1998 / 21:49:23 / cg"
+! !
+
+!JavaMethod class methodsFor:'Signal constants'!
+
+abstractMethodInvokationSignal
+ "return the signal raised when an abstract method is invoked"
+
+ ^ AbstractMethodInvokationSignal
+
+ "Created: / 27.1.1998 / 21:50:05 / cg"
! !
!JavaMethod class methodsFor:'misc'!
@@ -1004,6 +1021,18 @@
"Created: / 13.1.1998 / 15:03:05 / cg"
! !
+!JavaMethod methodsFor:'error handling'!
+
+invalidByteCode
+ self isAbstract ifTrue:[
+ ^ AbstractMethodInvokationSignal raise.
+ ].
+ ^ super invalidByteCode
+
+ "Created: / 27.1.1998 / 21:48:01 / cg"
+ "Modified: / 27.1.1998 / 21:50:19 / cg"
+! !
+
!JavaMethod methodsFor:'methodref interchangability'!
method
@@ -1775,6 +1804,6 @@
!JavaMethod class methodsFor:'documentation'!
version
- ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaMethod.st,v 1.60 1998/01/27 16:53:43 cg Exp $'
+ ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaMethod.st,v 1.61 1998/01/27 21:03:54 cg Exp $'
! !
JavaMethod initialize!
--- a/JavaVM.st Tue Jan 27 21:01:25 1998 +0000
+++ b/JavaVM.st Tue Jan 27 21:03:54 1998 +0000
@@ -4,10 +4,11 @@
UnimplementedInstructionSignal UnimplementedNativeMethodSignal
BadMessageSignal InternalErrorSignal CallHandlerSignal
FullExceptionTrace StackTrace TraceHistory LockTable
- LockTableAccess LibPath SimulatedLibs LoadedLibs WaitTable
- WaitTableAccess JavaWindowGroup KnownWindows DrawOPTrace
- WindowOPTrace WindowCreationTrace EventTrace ThreadTrace
- MonitorTrace ExceptionTrace InsnCount InsnCounts FileOpenTrace
+ LockTableAccess LibPath SimulatedLibs LoadedLibs
+ SimulatedNativeLibs LoadedNativeLibs WaitTable WaitTableAccess
+ JavaWindowGroup KnownWindows DrawOPTrace WindowOPTrace
+ WindowCreationTrace EventTrace ThreadTrace MonitorTrace
+ ExceptionTrace InsnCount InsnCounts FileOpenTrace
FileOpenConfirmation FileIOTrace OpenFileTable
CachedNativeMethodTable ExceptionDebug JavaConsoleStream
StandardThreadGroup EnteredMonitorsPerProcess JavaClasses
@@ -540,18 +541,37 @@
!
initializeSimulatedLibs
+ "return a collection of native libs which are considered
+ being already loaded. (used with jdk < 1.2)"
+
LibPath := #('__builtIn__' '/usr/local/lib' '/usr/local/lib/java').
SimulatedLibs := #('__builtIn__/net'
- '__builtIn__/awt'
- '__builtIn__/tawt'
- '__builtIn__/winawt'
- '__builtIn__/jpeg'
- '__builtIn__/mmedia'
- '__builtIn__/zip'
- '__builtIn__/math'
- ).
+ '__builtIn__/awt'
+ '__builtIn__/tawt'
+ '__builtIn__/winawt'
+ '__builtIn__/jpeg'
+ '__builtIn__/mmedia'
+ '__builtIn__/zip'
+ '__builtIn__/math'
+ ).
"Created: / 4.1.1998 / 19:05:03 / cg"
+ "Modified: / 27.1.1998 / 18:43:03 / cg"
+!
+
+initializeSimulatedNativeLibs
+ "return a collection of native libs which are considered
+ being already loaded (used with jdk >= 1.2)"
+
+ SimulatedNativeLibs := #(
+ '/libawt.so'
+ ).
+
+ "
+ self initializeSimulatedNativeLibs
+ "
+
+ "Modified: / 27.1.1998 / 18:43:10 / cg"
!
initializeSystemPropertiesInto:props
@@ -613,7 +633,8 @@
self releaseAllWindows.
self releaseAllStreams.
- self initializeSimulatedLibs.
+ self initializeSimulatedLibs. "/ < jdk 1.2
+ self initializeSimulatedNativeLibs. "/ >= jdk 1.2
self initializeOpenFileTable.
self initializeBaseClasses.
@@ -625,11 +646,12 @@
ObjectMemory addDependent:self.
"
+ JavaVM initialize
JavaVM initializeVM
"
"Created: / 3.1.1998 / 21:29:09 / cg"
- "Modified: / 15.1.1998 / 17:29:34 / cg"
+ "Modified: / 27.1.1998 / 21:52:29 / cg"
!
initializeVMIfNoEventThreadRunning
@@ -857,11 +879,11 @@
"/ prefer the windows toolkit ...
(Java classForName:'sun.awt.windows.WToolkit') notNil ifTrue:[
- ^ 'sun.awt.windows.WToolkit'.
- ].
-"/ (Java classForName:'sun.awt.motif.MToolkit') notNil ifTrue:[
-"/ ^ 'sun.awt.motif.MToolkit'.
-"/ ].
+ ^ 'sun.awt.windows.WToolkit'.
+ ].
+ (Java classForName:'sun.awt.motif.MToolkit') notNil ifTrue:[
+ ^ 'sun.awt.motif.MToolkit'.
+ ].
^ 'sun.awt.tiny.TinyToolkit'.
@@ -869,8 +891,12 @@
"/ ^ 'sun.awt.win32.MToolkit'.
"/ ^ 'sun.awt.motif.MToolkit'.
- "Modified: / 14.8.1997 / 16:12:58 / cg"
+ "
+ self defaultWindowingToolKit
+ "
+
"Created: / 3.1.1998 / 14:27:49 / cg"
+ "Modified: / 27.1.1998 / 21:52:52 / cg"
!
javaConsole:aStream
@@ -1050,10 +1076,9 @@
!JavaVM class methodsFor:'helpers - awt'!
commonReshapeComponent:nativeContext
- |jFramePeer view x y width height ext menu|
-
- jFramePeer := nativeContext receiver.
- view := jFramePeer instVarNamed:'pData'.
+ |view x y width height ext menu|
+
+ view := self viewForWPeer:nativeContext.
x := nativeContext argAt:1.
y := nativeContext argAt:2.
@@ -1119,7 +1144,7 @@
^ nil
"Created: / 4.1.1998 / 18:00:52 / cg"
- "Modified: / 25.1.1998 / 13:26:05 / cg"
+ "Modified: / 27.1.1998 / 21:38:48 / cg"
!
createdWindowsView:aView for:aJavaPeer
@@ -1235,14 +1260,22 @@
!
viewForWPeer:nativeContext
- |jPeer view|
+ |jPeer view pDataIdx|
jPeer := nativeContext receiver.
- view := jPeer instVarNamed:'pData'.
+
+ "/ sigh; pData was renamed to pNativeWidget in jdk1.2 ...
+ pDataIdx := jPeer class instVarOffsetOf:'pNativeWidget'.
+ pDataIdx isNil ifTrue:[
+ "/ ok, we are < 1.2
+ pDataIdx := jPeer class instVarOffsetOf:'pData'.
+ ].
+
+ view := jPeer instVarAt:pDataIdx.
^ view
- "Modified: / 8.1.1998 / 00:17:44 / cg"
"Created: / 8.1.1998 / 17:31:25 / cg"
+ "Modified: / 27.1.1998 / 21:37:43 / cg"
! !
!JavaVM class methodsFor:'helpers - exceptions'!
@@ -2199,7 +2232,7 @@
!
_WFramePeer_create:nativeContext
- |jFramePeer jFrame frame|
+ |jFramePeer jFrame frame pDataIdx|
jFramePeer := nativeContext receiver.
@@ -2208,33 +2241,39 @@
jFrame := jFramePeer instVarNamed:'target'.
(jFrame notNil
- and:[(jFrame class instVarOffsetOf:'pData') notNil])
+ and:[(pDataIdx := jFrame class instVarOffsetOf:'pData') notNil])
ifTrue:[
- ((frame := jFrame instVarNamed:'pData') notNil
- and:[frame ~~ 0]) ifTrue:[
- 'JAVA: targetFrame view already created: ' infoPrintCR.
- jFramePeer instVarNamed:'pData' put:frame.
- ]
+ ((frame := jFrame instVarAt:pDataIdx) notNil
+ and:[frame ~~ 0]) ifTrue:[
+ 'JAVA: targetFrame view already created: ' infoPrintCR.
+ "/ sigh; pData was renamed to pNativeWidget in jdk1.2 ...
+ pDataIdx := jFramePeer class instVarOffsetOf:'pNativeWidget'.
+ pDataIdx isNil ifTrue:[
+ "/ ok, we are < 1.2
+ pDataIdx := jFramePeer class instVarOffsetOf:'pData'.
+ ].
+ jFramePeer instVarAt:pDataIdx put:frame.
+ ]
] ifFalse:[
- frame := jFramePeer instVarNamed:'pData'
+ frame := jFramePeer instVarNamed:'pData'
].
(frame notNil and:[frame ~~ 0]) ifTrue:[
- 'JAVA: frame view already created: ' infoPrint.
- jFramePeer class name infoPrintCR.
+ 'JAVA: frame view already created: ' infoPrint.
+ jFramePeer class name infoPrintCR.
] ifFalse:[
- frame := StandardSystemView new.
- self createdWindowsView:frame for:jFramePeer.
- JavaWindowGroup addTopView:frame.
+ frame := StandardSystemView new.
+ self createdWindowsView:frame for:jFramePeer.
+ JavaWindowGroup addTopView:frame.
].
WindowCreationTrace == true ifTrue:[
- 'JAVA: WFramePeer_create: ' print. jFramePeer displayString print.
- ' frame: ' print. frame printNL.
+ 'JAVA: WFramePeer_create: ' print. jFramePeer displayString print.
+ ' frame: ' print. frame printNL.
].
"Created: / 4.1.1998 / 17:56:39 / cg"
- "Modified: / 15.1.1998 / 16:02:46 / cg"
+ "Modified: / 27.1.1998 / 21:35:15 / cg"
!
_WFramePeer_setMenuBar0:nativeContext
@@ -3303,6 +3342,37 @@
"Created: / 4.1.1998 / 18:09:04 / cg"
! !
+!JavaVM class methodsFor:'native - awt.windows - jdk1.2'!
+
+_Font_initIDs:nativeContext
+ "/ new with jdk1.2 ...
+
+ "Created: / 27.1.1998 / 21:43:25 / cg"
+!
+
+_WFramePeer_setTitle:nativeContext
+ |view jString string|
+
+ view := self viewForWPeer:nativeContext.
+
+ jString := nativeContext argAt:1.
+ string := Java as_ST_String:jString.
+
+"/ 'JAVA: WFramePeer_pSetTitle: ' print. string print. ' ' print. view printNL.
+
+ view label:string.
+ ^ nil
+
+ "Modified: / 8.1.1998 / 17:37:41 / cg"
+ "Created: / 27.1.1998 / 21:42:57 / cg"
+!
+
+_WPanelPeer_calculateInsets:nativeContext
+ "/ new with jdk1.2 ...
+
+ "Created: / 27.1.1998 / 21:40:00 / cg"
+! !
+
!JavaVM class methodsFor:'native - java.io'!
_FileDescriptor_initSystemFD:nativeContext
@@ -3312,18 +3382,18 @@
fileNo := nativeContext argAt:2.
fileNo == 0 ifTrue:[
- myStream := Stdin
+ myStream := Stdin
] ifFalse:[
- fileNo == 1 ifTrue:[
- myStream := JavaConsoleStream ? Stdout
- ] ifFalse:[
- fileNo == 2 ifTrue:[
- myStream := JavaConsoleStream ? Stderr
- ] ifFalse:[
- self halt:'invalid fileNo given'.
- self internalError:'invalid fileNo given'.
- ]
- ]
+ fileNo == 1 ifTrue:[
+ myStream := JavaConsoleStream ? Stdout
+ ] ifFalse:[
+ fileNo == 2 ifTrue:[
+ myStream := JavaConsoleStream ? Stderr
+ ] ifFalse:[
+ self halt:'invalid fileNo given'.
+ self internalError:'invalid fileNo given'.
+ ]
+ ]
].
self setOpenFile:myStream at:fileNo.
@@ -3331,7 +3401,7 @@
descriptor instVarNamed:'fd' put:fileNo.
^ descriptor
- "Modified: / 3.1.1998 / 14:52:02 / cg"
+ "Modified: / 27.1.1998 / 18:15:28 / cg"
!
_FileInputStream_available:nativeContext
@@ -3366,28 +3436,30 @@
fs := nativeContext receiver.
fd := fs instVarNamed:'fd'.
- (fd instVarNamed:'fd') ~~ 0 ifTrue:[
- self halt:'file already open'.
- self internalError:'file already open'.
- ^ self.
+ (fileNo := fd instVarNamed:'fd') ~~ 0 ifTrue:[
+ fileNo ~~ -1 ifTrue:[
+ self halt:'file already open'.
+ self internalError:'file already open'.
+ ^ self.
+ ]
].
name := nativeContext argAt:1.
name := Java as_ST_String:name.
FileOpenTrace ifTrue:[
- ('JAVA: opening ' , name) infoPrintCR.
+ ('JAVA: opening ' , name) infoPrintCR.
].
stream := self fileStreamForReading:name.
stream isNil ifTrue:[
- FileOpenTrace ifTrue:[
- ('JAVA: failed to open ' , name , ' for reading.') infoPrintCR.
- ].
-
- self throwIOExceptionWithMessage:('cannot open ' , name , ' for reading').
-
- ^ self.
+ FileOpenTrace ifTrue:[
+ ('JAVA: failed to open ' , name , ' for reading.') infoPrintCR.
+ ].
+
+ self throwIOExceptionWithMessage:('cannot open ' , name , ' for reading').
+
+ ^ self.
].
"/ FileOpenConfirmation ifTrue:[
@@ -3401,13 +3473,13 @@
fileNo := self addOpenFile:stream.
FileOpenTrace ifTrue:[
- ('JAVA: opened ' , name , ' as FD ' , fileNo printString) infoPrintCR.
+ ('JAVA: opened ' , name , ' as FD ' , fileNo printString) infoPrintCR.
].
fd instVarNamed:'fd' put:fileNo.
"Created: / 4.1.1998 / 16:47:12 / cg"
- "Modified: / 16.1.1998 / 13:35:27 / cg"
+ "Modified: / 27.1.1998 / 18:27:01 / cg"
!
_FileInputStream_read:nativeContext
@@ -3696,6 +3768,49 @@
"Modified: / 14.1.1998 / 21:32:09 / cg"
! !
+!JavaVM class methodsFor:'native - java.io - jdk1.2'!
+
+_FileDescriptor_initIDs:nativeContext
+ "/ introduced with jdk1.2 ... (sigh)
+
+ "Created: / 27.1.1998 / 18:16:29 / cg"
+!
+
+_FileInputStream_initIDs:nativeContext
+ "/ introduced with jdk1.2 ... (sigh)
+
+ "Created: / 27.1.1998 / 18:15:51 / cg"
+!
+
+_FileOutputStream_initIDs:nativeContext
+ "/ introduced with jdk1.2 ... (sigh)
+
+ "Created: / 27.1.1998 / 18:16:40 / cg"
+!
+
+_File_canonPath:nativeContext
+ "/ introduced with jdk1.2 ... (sigh)
+
+ |jPath path realPath|
+
+ jPath := nativeContext argAt:1.
+ jPath isNil ifTrue:[^ jPath].
+
+ path := Java as_ST_String:jPath.
+ realPath := path asFilename pathName.
+
+ ^ Java as_String:realPath
+
+ "Created: / 27.1.1998 / 18:35:58 / cg"
+ "Modified: / 27.1.1998 / 21:36:03 / cg"
+!
+
+_File_initIDs:nativeContext
+ "/ introduced with jdk1.2 ... (sigh)
+
+ "Created: / 27.1.1998 / 18:25:19 / cg"
+! !
+
!JavaVM class methodsFor:'native - java.lang'!
_ClassLoader_defineClass0:nativeContext
@@ -3805,26 +3920,28 @@
jString := nativeContext argAt:1.
rString := Java as_ST_String:jString.
Java classPath do:[:aPath |
- (dir := aPath asFilename) exists ifTrue:[
- (file := dir construct:rString) exists ifTrue:[
- text := file contents asString.
-
- "/ Copy data from returned buffer into Java byte array.
-
- data := text asByteArray.
-
- "/ Create input stream using byte array
-
- inStream := (Java classForName:'java.io.ByteArrayInputStream') basicNew.
- inStream invoke:'<init>([B)V' with:data.
- ^ inStream.
- ]
- ]
+ (dir := aPath asFilename) exists ifTrue:[
+ (file := dir construct:rString) exists ifTrue:[
+ (Java isExcludedFromClassPath:file) ifFalse:[
+ text := file contents asString.
+
+ "/ Copy data from returned buffer into Java byte array.
+
+ data := text asByteArray.
+
+ "/ Create input stream using byte array
+
+ inStream := (Java classForName:'java.io.ByteArrayInputStream') basicNew.
+ inStream invoke:'<init>([B)V' with:data.
+ ^ inStream.
+ ]
+ ]
+ ]
].
^ nil
- "Modified: / 8.8.1997 / 12:03:45 / cg"
"Created: / 8.1.1998 / 16:06:56 / cg"
+ "Modified: / 27.1.1998 / 21:58:54 / cg"
!
_ClassLoader_init:nativeContext
@@ -5037,6 +5154,119 @@
"Modified: / 15.1.1998 / 00:14:40 / cg"
! !
+!JavaVM class methodsFor:'native - java.lang - jdk1.2'!
+
+_AccessController_beginPrivileged:nativeContext
+ "/ introduced with jdk1.2
+
+ "Created: / 27.1.1998 / 18:18:11 / cg"
+!
+
+_AccessController_endPrivileged:nativeContext
+ "/ introduced with jdk1.2
+
+ "Created: / 27.1.1998 / 18:18:32 / cg"
+!
+
+_AccessController_getStackAccessControlContext:nativeContext
+ "/ introduced with jdk1.2
+
+ "/ supposed to do more here ...
+
+ ^ nil
+
+ "Created: / 27.1.1998 / 18:22:15 / cg"
+!
+
+_ClassLoader$NativeLibrary_load:nativeContext
+ "/ introduced with jdk1.2 ... (sigh)
+
+ |nativeLoader jLibName libName libHandle index|
+
+ nativeLoader := nativeContext receiver.
+ jLibName := nativeContext argAt:1.
+ libName := Java as_ST_String:jLibName.
+
+ (index := SimulatedNativeLibs indexOf:libName) ~~ 0 ifTrue:[
+ ('JAVA: builtIn nativeLibLoad simulated: ' , libName) printNL.
+ nativeLoader instVarNamed:'handle' put:index.
+ ^ self "/ void
+ ].
+ (LoadedNativeLibs notNil
+ and:[LoadedNativeLibs includesKey:libName]) ifTrue:[
+ ('JAVA: native library already loaded: ' , libName) printNL.
+ nativeLoader instVarNamed:'handle' put:(LoadedNativeLibs at:libName).
+ ^ self "/ void
+ ].
+
+ libName asFilename exists ifFalse:[
+ ('JAVA: no file to load nativeLib: ' , libName) printNL.
+ ^ self "/ void
+ ].
+
+ libHandle := ObjectFileLoader loadLibrary:libName.
+ libHandle isNil ifTrue:[
+ ('JAVA: failed to load nativeLib: ' , libName) printNL.
+ ^ self "/ void
+ ].
+
+ LoadedNativeLibs isNil ifTrue:[
+ LoadedNativeLibs := Dictionary new.
+ ].
+
+ LoadedNativeLibs at:libName put:libHandle.
+ nativeLoader instVarNamed:'handle' put:(LoadedNativeLibs at:libName).
+ ^ self "/ void
+
+ "Created: / 27.1.1998 / 18:38:37 / cg"
+ "Modified: / 27.1.1998 / 18:55:06 / cg"
+!
+
+_ClassLoader_initIDs:nativeContext
+ "/ introduced with jdk1.2 ... (sigh)
+
+ "Created: / 27.1.1998 / 18:37:08 / cg"
+!
+
+_Component_initIDs:nativeContext
+ "/ introduced with jdk1.2 ... (sigh)
+
+ "Created: / 27.1.1998 / 19:53:29 / cg"
+!
+
+_System_getCallerClass:nativeContext
+ "/ introduced with jdk1.2
+
+ |senderContext cls|
+
+ senderContext := nativeContext sender.
+ [senderContext receiver == (Java at:'java.lang.System')] whileTrue:[
+ senderContext := senderContext sender.
+ ].
+
+ senderContext method isStatic ifTrue:[
+ cls := senderContext receiver
+ ] ifFalse:[
+ cls := senderContext receiver class
+ ].
+ cls isJavaClass ifTrue:[
+ ^ self javaClassObjectForClass:cls
+ ].
+ (cls isMemberOf:(Java at:'java.lang.Class')) ifTrue:[
+ ^ Java at:'java.lang.Class'
+ ].
+ self halt.
+ ^ nil
+
+ "Modified: / 27.1.1998 / 18:33:13 / cg"
+!
+
+_Toolkit_initIDs:nativeContext
+ "/ introduced with jdk1.2 ... (sigh)
+
+ "Created: / 27.1.1998 / 19:53:50 / cg"
+! !
+
!JavaVM class methodsFor:'native - java.math'!
_BigInteger_plumbInit:nativeContext
@@ -6314,6 +6544,6 @@
!JavaVM class methodsFor:'documentation'!
version
- ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaVM.st,v 1.10 1998/01/27 16:48:27 cg Exp $'
+ ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaVM.st,v 1.11 1998/01/27 21:02:00 cg Exp $'
! !
JavaVM initialize!