src/JavaVM.st
branchjk_new_structure
changeset 1075 927aeb3649fc
parent 1073 e842ab17fe16
child 1078 614cf5325969
--- a/src/JavaVM.st	Wed Nov 02 22:59:27 2011 +0000
+++ b/src/JavaVM.st	Thu Nov 03 10:04:56 2011 +0000
@@ -1768,7 +1768,8 @@
     props at: 'user.home'
         put: (OperatingSystem getHomeDirectory ? Filename currentDirectory name).
     props at: 'user.dir'
-        put: (UserPreferences current javaTestsDirectory asFilename / 'libjava' asFilename) name.
+        put: (UserPreferences current javaTestsDirectory asFilename 
+                / 'libjava' asFilename) pathName.
     
     "/ props at:'user.dir'           put:(Filename currentDirectory pathName).
     "/props at:'awt.toolkit'        put:(self defaultWindowingToolKit).
@@ -1809,7 +1810,7 @@
     "Created: / 03-01-1998 / 14:26:39 / cg"
     "Modified: / 27-01-2000 / 02:20:18 / cg"
     "Modified: / 31-08-2011 / 20:03:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 01-11-2011 / 13:29:10 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 03-11-2011 / 11:04:26 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 !
 
 initializeVM
@@ -3414,107 +3415,106 @@
     "Created: / 8.1.1999 / 14:28:15 / cg"
 !
 
-throwException:aJavaException
-
+throwException: aJavaException 
     <resource: #skipInDebuggersWalkBack>
-
-    |con jMsg msg exClass srchCon handlerContext handlerPC method pc hPC
-     monitorObject|
-
-
-
-    ExceptionTrace ifTrue:[
-        'JAVA: exception: ' print. aJavaException class fullName print.
-        msg := aJavaException instVarNamed:'detailMessage'.
-        msg notNil ifTrue:[
-            ' (' print.
-            (Java as_ST_String:msg) print.
-            ')' print.
-        ].
-        '' printCR.
-    ].
-    ExceptionDebug ifTrue:[
-"/        self internalError:('JAVA: exception: ' , aJavaException class fullName).        
-        (ExceptionDebugPatterns isNilOrEmptyCollection or:
-            [ExceptionDebugPatterns anySatisfy: [:pattern|pattern match:aJavaException class fullName]])
-            ifTrue:
-                [self halt:('JAVA: exceptionDebug: ' , aJavaException class fullName)]
-    ].
-
+    | con  jMsg  msg  exClass  srchCon  handlerContext  handlerPC  method  pc  hPC  monitorObject |
+    ExceptionTrace ifTrue: [
+        | tmpMessage |
+        tmpMessage := aJavaException instVarNamed: 'detailMessage'.
+        tmpMessage isNil ifTrue: [ tmpMessage := '' ] ifFalse: [
+            tmpMessage := Java as_ST_String: tmpMessage
+        ].
+        Logger 
+            log: 'JAVA: exception: ' , aJavaException class fullName , ' (' 
+                    , tmpMessage , ')'
+            severity: #debug
+            facility: 'JVM'
+    ].
+    ExceptionDebug ifTrue: [
+        "/        self internalError:('JAVA: exception: ' , aJavaException class fullName).        
+        (ExceptionDebugPatterns isNilOrEmptyCollection 
+            or: [
+                ExceptionDebugPatterns 
+                    anySatisfy: [:pattern | pattern match: aJavaException class fullName ]
+            ]) 
+                ifTrue: [
+                    self halt: ('JAVA: exceptionDebug: ' , aJavaException class fullName)
+                ]
+    ].
+    
     "/
     "/ search stack for a javaContext which handles that exception
     "/
+    
     srchCon := thisContext sender.
-    [handlerContext isNil and:[srchCon notNil]] whileTrue:[
-        (srchCon isJavaContext) ifTrue:[
+    [ handlerContext isNil and: [ srchCon notNil ] ] whileTrue: [
+        (srchCon isJavaContext) ifTrue: [
             method := srchCon method.
             pc := srchCon pc.
-            (hPC := method handlerFor:aJavaException at:pc) notNil ifTrue:[
+            (hPC := method handlerFor: aJavaException at: pc) notNil ifTrue: [
                 "JV@2011-02-25: Another crap in JVM and Java VM Spec?
                  Or theri proxu generator? Assume that if athrow's pc
                  is same as the handler's pc it means rethrow to
                  handling context - so DO NOT HANDLE IT!!"
                 "Hack disabled for now"
-                "pc ~~ hPC"true ifTrue:[
+                "pc ~~ hPC"
+                true ifTrue: [
                     handlerPC := hPC.
                     handlerContext := srchCon
                 ].
-            ] ifFalse:[
+            ] ifFalse: [
                 "/ on the fly, release any monitor
-                method isSynchronized ifTrue:[
-                    method isStatic ifTrue:[
+                method isSynchronized ifTrue: [
+                    method isStatic ifTrue: [
                         self assert: srchCon receiver == method javaClass.
                         monitorObject := method javaClass.
-                    ] ifFalse:[
-                        monitorObject := srchCon receiver
-                    ].
-                    self _MONITOREXIT:monitorObject
+                    ] ifFalse: [ monitorObject := srchCon receiver ].
+                    self _MONITOREXIT: monitorObject
                 ]
             ]
         ].
         srchCon := srchCon sender.
     ].
-
-    handlerContext isNil ifTrue:[
+    handlerContext isNil ifTrue: [
         "/
         "/ no JavaHandler ... let smalltalk handle it
         "/
         exClass := aJavaException class.
         msg := 'Java ' , exClass name.
-        jMsg := aJavaException instVarNamed:'detailMessage'.
-        jMsg notNil ifTrue:[
-            msg := msg , ': ' , (Java as_ST_String:jMsg).
-        ].
-
+        jMsg := aJavaException instVarNamed: 'detailMessage'.
+        jMsg notNil ifTrue: [ msg := msg , ': ' , (Java as_ST_String: jMsg). ].
+        
         "/ for our convenience: skip ST contexts 
         "/ (i.e. the handler or debugger will see the javaContext first )
-
+        
         con := thisContext sender.
-        [con isNil or:[con isJavaContext]] whileFalse:[
-            con := con sender
-        ].
-        con isNil ifTrue:[con := thisContext sender].
-        JavaUnhandledExceptionError
-                raiseWith:aJavaException
-                errorString:msg
-                in:con.
-    ] ifFalse:[
+        [ con isNil or: [ con isJavaContext ] ] whileFalse: [ con := con sender ].
+        con isNil ifTrue: [ con := thisContext sender ].
+        JavaUnhandledExceptionError 
+            raiseWith: aJavaException
+            errorString: msg
+            in: con.
+    ] ifFalse: [
         "/
         "/ found a java exceptionHandler
         "/
-        handlerContext setPC:handlerPC.
-        handlerContext exceptionArg:aJavaException pc:handlerPC.
+        handlerContext setPC: handlerPC.
+        handlerContext exceptionArg: aJavaException pc: handlerPC.
         handlerContext markForException.
         handlerContext unwindAndRestart.
-        self halt:'should not be reached'.
-    ].
-Processor activeProcess == JavaScreenUpdaterThread ifTrue:[self halt].
-Processor activeProcess == JavaEventQueueThread ifTrue:[self halt].
+        self halt: 'should not be reached'.
+    ].
+    Processor activeProcess == JavaScreenUpdaterThread ifTrue: [ self halt ].
+    Processor activeProcess == JavaEventQueueThread ifTrue: [ self halt ].
     Processor activeProcess terminate.
 
+    "
+     ExceptionTrace := true"
+
     "Created: / 07-01-1998 / 15:28:22 / cg"
     "Modified: / 24-12-1999 / 02:33:25 / cg"
     "Modified: / 10-08-2011 / 20:23:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 03-11-2011 / 10:28:33 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 !
 
 throwExceptionClassName: aJavaExceptionClassName withMessage: someMessage 
@@ -4823,10 +4823,9 @@
 _java_io_UnixFileSystem_getBooleanAttributes0: aJavaContext 
     <javanative: 'java/io/UnixFileSystem' name: 'getBooleanAttributes0'>
     | file  path  retval  fileSystemClass |
-
     retval := 0.
-    file := aJavaContext argAt: 1.
-    path := Java as_ST_String: (file instVarNamed: #path).
+    file := (aJavaContext argAt: 1).
+    path := Java as_ST_String: ((aJavaContext argAt: 1) perform: #'getAbsolutePath()Ljava/lang/String;').
     fileSystemClass := (self classForName: 'java.io.FileSystem').
     path asFilename exists ifTrue: [
         retval := retval bitOr: (fileSystemClass instVarNamed: #'BA_EXISTS')
@@ -4845,6 +4844,7 @@
     "Modified: / 10-12-2010 / 14:43:31 / Jan Kurs <kurs.jan@post.cz>"
     "Created: / 10-12-2010 / 14:46:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 11-12-2010 / 19:44:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 03-11-2011 / 11:03:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 !
 
 _java_io_UnixFileSystem_getLastModifiedTime: aJavaContext