- JavaVM fixes in natives (RandomAccessFile, mostly) jk_new_structure
authorvranyj1
Fri, 06 Jul 2012 11:45:41 +0000
branchjk_new_structure
changeset 1513 58c59c580675
parent 1512 96a1223f511c
child 1514 b7e3d52a293d
- JavaVM fixes in natives (RandomAccessFile, mostly)
src/JavaVM.st
src/libjava.rc
--- a/src/JavaVM.st	Thu Jul 05 23:10:34 2012 +0000
+++ b/src/JavaVM.st	Fri Jul 06 11:45:41 2012 +0000
@@ -2639,8 +2639,10 @@
     ExceptionDebugPatterns add: 'java/lang/ClassNotFoundException'.
     ExceptionDebugPatterns add: 'java/io/IOException'.
     ExceptionDebugPatterns add: 'java/io/FileNotFoundException'.
+    ExceptionDebugPatterns add: 'java/io/EOFException'.
     ExceptionDebugPatterns add: 'java/lang/NoSuchMethodException'.
     ExceptionDebugPatterns add: 'java/lang/ArrayIndexOutOfBoundsException'.
+    ExceptionDebugPatterns add: 'java/lang/IllegalMonitorStateException'.
     "
 
     "Created: / 25-02-2011 / 08:08:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -5712,6 +5714,30 @@
     "Modified: / 06-07-2012 / 00:09:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+_java_io_RandomAccessFile_getFilePointer: nativeContext
+    "
+    /**
+     * Returns the current offset in this file.
+     *
+     * @return     the offset from the beginning of the file, in bytes,
+     *             at which the next read or write occurs.
+     * @exception  IOException  if an I/O error occurs.
+     */
+    "
+    <javanative: 'java/io/RandomAccessFile' name: 'getFilePointer()J'>
+
+    | file |
+
+    file := self validateFile:(nativeContext receiver).
+
+    FileIOTrace ifTrue:[
+        ('JAVA: getFilePointer on ' , file pathName) infoPrintCR.
+    ].
+    ^file position0Based
+
+    "Modified: / 06-07-2012 / 12:40:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 _java_io_RandomAccessFile_initIDs: nativeContext
 
     <javanative: 'java/io/RandomAccessFile' name: 'initIDs'>
@@ -5799,14 +5825,19 @@
         ]
     ].
 
+    filename exists ifFalse:[
+        self throwIOExceptionWithMessage:'File ', name , ' does not exist'
+    ].
+
     readonly ifTrue:[
         stream := filename readStream.
     ] ifFalse:[
         stream := filename readWriteStream.
-    ].
-    stream isNil ifTrue:[
-        self throwIOExceptionWithMessage:('cannot open ' , name , ' for writing').
-    ].
+        stream isNil ifTrue:[
+            self throwIOExceptionWithMessage:('cannot open ' , name , ' for writing').
+        ].
+    ].
+
 
     fileNo := self addOpenFile:stream.
 
@@ -5818,7 +5849,7 @@
 
     "Created: / 04-02-1998 / 00:14:48 / cg"
     "Modified: / 12-11-1998 / 21:29:46 / cg"
-    "Modified: / 06-07-2012 / 00:07:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 06-07-2012 / 09:56:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_io_RandomAccessFile_read: nativeContext
@@ -5862,14 +5893,14 @@
     file := self validateFile:(nativeContext receiver).
 
     FileIOTrace ifTrue:[
-	('JAVA: seek on ' , file pathName) infoPrintCR.
+        ('JAVA: seek on ' , file pathName) infoPrintCR.
     ].
 
     pos := nativeContext argAt:1.
-    file position:pos+1 "/ ST/X position starts at 1
-
-    "Created: / 4.2.1998 / 13:25:38 / cg"
-    "Modified: / 4.2.1998 / 13:28:12 / cg"
+    file position0Based:pos
+
+    "Created: / 04-02-1998 / 13:25:38 / cg"
+    "Modified (comment): / 06-07-2012 / 12:39:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_io_UnixFileSystem_canonicalize0: aJavaContext
@@ -6006,17 +6037,19 @@
 
     <javanative: 'java/io/UnixFileSystem' name: 'getLastModifiedTime'>
 
-        | file  path  retval |
-
-    retval := 0.
+    | file  filename  |
+
     file := aJavaContext argAt: 1.
-    path := Java as_ST_String: (file instVarNamed: #path).
-    retval := path asFilename modificationTime asMilliseconds.
-    ^ retval
+    filename := (Java as_ST_String: (file instVarNamed: #path)) utf8Encoded asFilename.
+    ^filename exists ifTrue:[
+        filename modificationTime asMilliseconds
+    ] ifFalse:[
+        0
+    ].
 
     "Modified: / 10-12-2010 / 14:43:31 / Jan Kurs <kurs.jan@post.cz>"
-    "Modified: / 11-12-2010 / 19:44:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Created: / 27-03-2011 / 15:32:59 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 06-07-2012 / 08:57:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_io_UnixFileSystem_getLength: nativeContext
@@ -6521,7 +6554,21 @@
 
     <javanative: 'java/lang/ClassLoader' name: 'retrieveDirectives()Ljava/lang/AssertionStatusDirectives;'>
 
-    ^ UnimplementedNativeMethodSignal raise
+    | directives |
+    directives := (self classForName:'java.lang.AssertionStatusDirectives') new.
+    directives instVarNamed:#classes
+        put: ((self classForName:'java.lang.String') javaArrayClass new:0).
+    directives instVarNamed:#classEnabled
+        put: (Boolean javaArrayClass new:0).
+    directives instVarNamed:#packages
+        put: ((self classForName:'java.lang.String') javaArrayClass new:0).
+    directives instVarNamed:#packageEnabled
+        put: (Boolean javaArrayClass new:0).
+    directives instVarNamed:#deflt 
+        put: ((AssertionsEnabled == true) ifTrue:[1] ifFalse:[0]).
+    ^directives
+
+    "Modified: / 06-07-2012 / 08:49:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_lang_Class_desiredAssertionStatus0: aJavaContext
@@ -15853,175 +15900,6 @@
     ^ self _WGraphics_pSetForeground:nativeContext
 ! !
 
-!JavaVM class methodsFor:'native - old-style (converted)'!
-
-_PlainDatagramSocketImpl_socketSetOption:nativeContext
-    "/ native void socketSetOption (int arg1, java.lang.Object arg2)
-
-    |jsock opt optVal sock ok err jSocketOptions|
-
-    jsock := nativeContext receiver.
-    opt := nativeContext argAt:1.
-    optVal := nativeContext argAt:2.
-
-    sock := self validateFile:jsock.
-    sock notNil ifTrue:[
-	FileIOTrace ifTrue:[
-	    ('JAVA: socket setOption ' , opt printString) infoPrintCR
-	].
-
-	jSocketOptions := Java at:'java.net.SocketOptions'.
-	(opt == (jSocketOptions instVarNamed:'TCP_NODELAY')) ifTrue:[
-	] ifFalse:[
-	    (opt == (jSocketOptions instVarNamed:'SO_BINDADDR')) ifTrue:[
-	    ] ifFalse:[
-		(opt == (jSocketOptions instVarNamed:'SO_REUSEADDR')) ifTrue:[
-		] ifFalse:[
-		    (opt == (jSocketOptions instVarNamed:'IP_MULTICAST_IF')) ifTrue:[
-		    ] ifFalse:[
-			(opt == (jSocketOptions instVarNamed:'SO_LINGER')) ifTrue:[
-			] ifFalse:[
-			    (opt == (jSocketOptions instVarNamed:'SO_TIMEOUT')) ifTrue:[
-			    ] ifFalse:[
-				self throwIOExceptionWithMessage:'bad arg to setOption'.
-			    ]
-			]
-		    ]
-		]
-	    ]
-	].
-	self throwIOExceptionWithMessage:'unimplemented: setOption'.
-self halt.
-	^ nil.  "/ void
-    ].
-
-    "Created: / 4.2.1998 / 15:06:20 / cg"
-    "Modified: / 30.12.1998 / 20:10:16 / cg"
-!
-
-_RandomAccessFile_length:nativeContext
-    |file sz|
-
-    file := self validateFile:(nativeContext receiver).
-
-    FileIOTrace ifTrue:[
-	('JAVA: length of ' , file pathName) infoPrintCR.
-    ].
-
-    sz := file size.
-    ^ sz.
-
-    "Created: / 4.2.1998 / 13:27:58 / cg"
-!
-
-_RandomAccessFile_read:nativeContext
-    |file byte|
-
-    file := self validateFile:(nativeContext receiver).
-
-    FileIOTrace ifTrue:[
-	('JAVA: read 1 byte from ' , file pathName) infoPrintCR.
-    ].
-
-    byte := file nextByte.
-    byte isNil ifTrue:[
-	^ -1
-    ].
-    ^ byte
-
-    "Modified: / 5.1.1998 / 02:17:25 / cg"
-    "Created: / 27.1.1999 / 19:01:15 / cg"
-!
-
-_RandomAccessFile_readBytes:nativeContext
-    ^ self anyStream_readBytes:nativeContext
-
-    "Modified: / 4.2.1998 / 15:23:27 / cg"
-!
-
-_RandomAccessFile_seek:nativeContext
-    |file pos|
-
-    file := self validateFile:(nativeContext receiver).
-
-    FileIOTrace ifTrue:[
-	('JAVA: seek on ' , file pathName) infoPrintCR.
-    ].
-
-    pos := nativeContext argAt:1.
-    file position:pos+1 "/ ST/X position starts at 1
-
-    "Created: / 4.2.1998 / 13:25:38 / cg"
-    "Modified: / 4.2.1998 / 13:28:12 / cg"
-!
-
-_Runtime_freeMemory:nativeContext
-    "free memory - Returns the number of free bytes"
-
-    ^ ObjectMemory freeListSpace + ObjectMemory freeSpace
-
-    "Created: / 12.1.1998 / 12:59:53 / cg"
-!
-
-_Thread_resume0:nativeContext
-    "yield"
-
-    |jThread stProcess|
-
-    jThread := nativeContext receiver.
-    stProcess := JavaVM stProcessForJavaThread:jThread.
-    stProcess isNil ifTrue:[
-	ThreadTrace == true ifTrue:[
-	    ('JAVA: no stProcess for javaThread: ' , jThread displayString) printNL.
-	].
-	^ nil "void"
-    ].
-    stProcess resume
-
-    "Created: / 8.1.1998 / 01:06:27 / cg"
-    "Modified: / 6.2.1998 / 02:15:08 / cg"
-!
-
-_Thread_stop0: nativeContext 
-    "terminate a thread"
-    
-    | jThread  stProcess  death |
-    jThread := nativeContext receiver.
-    stProcess := JavaVM stProcessForJavaThread: jThread.
-    stProcess isNil ifTrue: [
-        ThreadTrace == true ifTrue: [
-            ('JAVA: no stProcess for javaThread: ' , jThread displayString) printNL.
-        ].
-        ^ nil "void"
-    ].
-    stProcess == JavaScreenUpdaterThread ifTrue: [ self halt ].
-    stProcess == JavaEventQueueThread ifTrue: [ self halt ].
-    death := nativeContext argAt: 1.
-    stProcess 
-        interruptWith: [
-            JavaVM javaExceptionSignal 
-                handle: [
-                    :ex | 
-                    Processor activeProcess == JavaScreenUpdaterThread ifTrue: [ self halt ].
-                    Processor activeProcess == JavaEventQueueThread ifTrue: [ self halt ].
-                    Processor activeProcess terminate
-                ]
-                do: [
-                    ThreadTrace == true ifTrue: [
-                        ('JAVA: thread exit: ' , jThread displayString) infoPrintNL.
-                    ].
-                    
-                    jThread perform: #'exit()V'.
-                    
-                    self throwException: death.
-                ]
-        ].
-
-    "Created: / 08-01-1998 / 13:11:17 / cg"
-    "Modified: / 24-12-1999 / 02:32:45 / cg"
-    "Modified: / 01-12-2011 / 18:26:51 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-! !
-
 !JavaVM class methodsFor:'native - stx.libjava.groovy'!
 
 _stx_libjava_groovy_GroovyClassLoader_SystemClassCollector_getDefiningClassLoader: nativeContext
@@ -16428,11 +16306,11 @@
     real := o instVarAt: offset.
     (real == expected)
             ifTrue:[o instVarAt: offset put: new. ok := 1]
-            ifFalse:[ok := 1].
+            ifFalse:[ok := 0].
     OperatingSystem unblockInterrupts.
     ^ok
 
-    "Modified: / 07-08-2011 / 21:53:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 06-07-2012 / 09:31:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _sun_misc_Unsafe_defineClass: nativeContext
--- a/src/libjava.rc	Thu Jul 05 23:10:34 2012 +0000
+++ b/src/libjava.rc	Fri Jul 06 11:45:41 2012 +0000
@@ -3,7 +3,7 @@
 // automagically generated from the projectDefinition: stx_libjava.
 //
 VS_VERSION_INFO VERSIONINFO
-  FILEVERSION     6,2,1863,1863
+  FILEVERSION     6,2,1866,1866
   PRODUCTVERSION  6,2,1,1
 #if (__BORLANDC__)
   FILEFLAGSMASK   VS_FF_DEBUG | VS_FF_PRERELEASE
@@ -20,12 +20,12 @@
     BEGIN
       VALUE "CompanyName", "eXept Software AG\0"
       VALUE "FileDescription", "Smalltalk/X Class library (LIB)\0"
-      VALUE "FileVersion", "6.2.1863.1863\0"
+      VALUE "FileVersion", "6.2.1866.1866\0"
       VALUE "InternalName", "stx:libjava\0"
       VALUE "LegalCopyright", "Copyright Claus Gittinger 1988-2011\nCopyright eXept Software AG 1998-2011\nCopyright Jan Vrany, Jan Kurs and Marcel Hlopko\b          SWING Research Group, Czech Technical University In Prague\0"
       VALUE "ProductName", "Smalltalk/X\0"
       VALUE "ProductVersion", "6.2.1.1\0"
-      VALUE "ProductDate", "Thu, 05 Jul 2012 23:13:41 GMT\0"
+      VALUE "ProductDate", "Fri, 06 Jul 2012 11:47:41 GMT\0"
     END
 
   END