Merged with /branches/jk jk_new_structure
authorvranyj1
Sat, 07 May 2011 16:18:07 +0000
branchjk_new_structure
changeset 762 d995915ebc0b
parent 761 43e017ec7958
child 763 1e82b558abd3
Merged with /branches/jk
src/JavaVM.st
src/extensions.st
src/stx_libjava.st
--- a/src/JavaVM.st	Sun May 01 12:52:23 2011 +0000
+++ b/src/JavaVM.st	Sat May 07 16:18:07 2011 +0000
@@ -4777,6 +4777,32 @@
 
     "Created: / 4.1.1998 / 14:27:40 / cg"
     "Modified: / 8.5.1998 / 21:29:53 / cg"
+!
+
+_java_lang_Throwable_getStackTraceDepth: nativeContext
+
+    <javanative: 'java/lang/Throwable' name: 'getStackTraceDepth'>
+
+
+    ^(nativeContext receiver instVarNamed: #backtrace) size
+
+    "Modified: / 01-05-2011 / 20:25:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Throwable_getStackTraceElement: nativeContext
+
+    <javanative: 'java/lang/Throwable' name: 'getStackTraceElement'>
+
+    | throwable index backtraceCtx stackTraceElement |
+    throwable := nativeContext receiver.
+    index :=  nativeContext argAt: 1.
+    backtraceCtx := (throwable instVarNamed:#backtrace) at: index + 1.
+
+    stackTraceElement := (self classForName: 'java.lang.StackTraceElement') new.
+
+    self halt:'Unfinished'
+
+    "Modified: / 01-05-2011 / 20:31:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !JavaVM class methodsFor:'native - java.lang.reflect'!
@@ -4826,14 +4852,29 @@
 
 !JavaVM class methodsFor:'native - java.util.zip'!
 
-_java_util_zip_Inflater_inflateBytes: aJavaContext
+_java_util_zip_Inflater_inflateBytes: nativeContext
 
     <javanative: 'java/util/zip/Inflater' name: 'inflateBytes'>
 
-    
-    UnimplementedNativeMethodSignal raise
+    | inflater inputBuf outputBuf b off len|
+    inflater := nativeContext receiver.
+    inputBuf := inflater instVarNamed: #buf.
+    inputBuf size == 0 ifTrue:[^0].
+
+    b := nativeContext argAt: 3.
+    off := nativeContext argAt: 4.
+    len := nativeContext argAt: 5.
+
+    outputBuf := ByteArray new: (len + 1000"save").
+
+    ZipArchive basicNew inflate:inputBuf to:outputBuf.
+
+    b replaceFrom:off + 1 to: off + len with: outputBuf startingAt:1.
+
+    ^len
 
     "Created: / 30-04-2011 / 23:02:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 01-05-2011 / 16:37:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_util_zip_Inflater_init: nativeContext
@@ -4924,6 +4965,24 @@
     "Created: / 30-04-2011 / 21:50:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+_java_util_zip_ZipFile_getEntry: nativeContext
+
+    <javanative: 'java/util/zip/ZipFile' name: 'getEntry'>
+
+    | zipArchive  filename  result |
+
+    zipArchive := ZipCache at: (nativeContext at: 1).
+    filename := Java as_ST_String: (nativeContext at: 3).
+    result := (zipArchive membersMatching: filename).
+    result size = 0 
+        ifTrue: [ ^ 0 ]
+        ifFalse: [ ^ ZipEntryCache indexOf: (ZipEntryCache add: result first) ].
+
+    "Created: / 27-03-2011 / 16:59:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 01-04-2011 / 16:03:01 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 01-05-2011 / 15:12:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 _java_util_zip_ZipFile_getMethod: aJavaContext
 
     <javanative: 'java/util/zip/ZipFile' name: 'getMethod'>
@@ -4989,6 +5048,30 @@
 
     "Modified: / 01-04-2011 / 15:35:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
     "Modified: / 01-05-2011 / 13:29:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_util_zip_ZipFile_read: aJavaContext
+
+    <javanative: 'java/util/zip/ZipFile' name: 'read'>
+
+    
+    | jzfile jzentry pos b off len zar zmember bytesToRead |
+    jzfile := aJavaContext argAt: 1.
+    jzentry := aJavaContext argAt: 3. "first arg is long!!!!!!"
+    pos := aJavaContext argAt: 5. "jzentry arg is long!!!!!!"
+    b := aJavaContext argAt: 7.
+    off := aJavaContext argAt: 8.
+    len := aJavaContext argAt: 9.
+
+    zar := ZipCache at: jzfile.
+    zmember := ZipEntryCache at: jzentry.
+
+    bytesToRead := len min: (zmember compressedSize - pos).
+
+    ^zar nextBytes: bytesToRead of: zmember startingAt: pos into: b startingAt: off + 1.
+
+    "Created: / 30-04-2011 / 22:15:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 01-05-2011 / 16:22:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !JavaVM class methodsFor:'native - old-style'!
@@ -12898,27 +12981,6 @@
 
 _X11Graphics_pSetForeground:nativeContext
     ^ self _WGraphics_pSetForeground:nativeContext
-!
-
-_ZipFile_read:aJavaContext
-
-    | jzfile jzentry pos b off len zar zmember data nread |
-    jzfile := aJavaContext argAt: 1.
-    jzentry := aJavaContext argAt: 3. "first arg is long!!!!!!"
-    pos := aJavaContext argAt: 5. "jzentry arg is long!!!!!!"
-    b := aJavaContext argAt: 7.
-    off := aJavaContext argAt: 8.
-    len := aJavaContext argAt: 9.
-
-    zar := ZipCache at: jzfile.
-    zmember := ZipEntryCache at: jzentry.
-
-    data := zar extract: zmember fileName.
-    nread := len min: (data size - pos).
-    b replaceFrom: off to: off + len with: data startingAt: nread.
-    ^nread.
-
-    "Created: / 30-04-2011 / 22:15:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !JavaVM class methodsFor:'native - old-style (converted)'!
@@ -14237,6 +14299,27 @@
         indexOf: ( ZipCache add: (ZipArchive readingFrom: result readStream) ).
 
     "Modified: / 01-04-2011 / 15:35:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+_ZipFile_read:aJavaContext
+
+    | jzfile jzentry pos b off len zar zmember data nread |
+    jzfile := aJavaContext argAt: 1.
+    jzentry := aJavaContext argAt: 3. "first arg is long!!!!!!"
+    pos := aJavaContext argAt: 5. "jzentry arg is long!!!!!!"
+    b := aJavaContext argAt: 7.
+    off := aJavaContext argAt: 8.
+    len := aJavaContext argAt: 9.
+
+    zar := ZipCache at: jzfile.
+    zmember := ZipEntryCache at: jzentry.
+
+    data := zar extract: zmember fileName.
+    nread := len min: (data size - pos).
+    b replaceFrom: off to: off + len with: data startingAt: nread.
+    ^nread.
+
+    "Created: / 30-04-2011 / 22:15:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !JavaVM class methodsFor:'native - sun.misc'!
@@ -14714,10 +14797,6 @@
 
     class := classOrClassRef javaClass.
 
-    | class |
-
-    class := classOrClassRef javaClass.
-
     "
     Java VM Spec, 3rd edition, p 280:
 
@@ -16017,3 +16096,4 @@
 
 JavaVM initialize!
 
+
--- a/src/extensions.st	Sun May 01 12:52:23 2011 +0000
+++ b/src/extensions.st	Sat May 07 16:18:07 2011 +0000
@@ -75,14 +75,14 @@
     "Created: / 07-02-2011 / 11:18:03 / Marcel Hlopko <hlopik@gmail.com>"
     "Modified: / 08-02-2011 / 01:08:15 / Marcel Hlopko <hlopik@gmail.com>"
 ! !
-!ZipArchive methodsFor:'java-compatibility'!
+!ZipArchive methodsFor:'reading - java support'!
+
+nextBytes: bytesToRead of: zmember startingAt: pos into: b startingAt: off
 
-> aNum 
-    "Dirty and ugly - in jvm, refs are passed by a long pointer, and testing if ref is null is done by comparing pointer with 0.
-    so this is how we can pretend to be pointer and ref together :)"
-    ^ true.
+    file position0Based: zmember fileStart + startOfArchive + pos.
+    ^ file nextBytes: bytesToRead into: b startingAt: off.
 
-    "Created: / 27-03-2011 / 16:58:13 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Created: / 01-05-2011 / 16:21:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 !Boolean class methodsFor:'queries'!
 
@@ -635,3 +635,4 @@
     ^'['.
 ! !
 
+
--- a/src/stx_libjava.st	Sun May 01 12:52:23 2011 +0000
+++ b/src/stx_libjava.st	Sat May 07 16:18:07 2011 +0000
@@ -69,14 +69,14 @@
 
     ^ #(
         #'squeak:petitparser'    "PPParser - superclass of JavaParser::BlockParser "
-        #'stx:goodies/sunit'    "TestAsserter - superclass of JUnitTestCaseProxy "
+        #'stx:goodies/sunit'
         #'stx:libbasic'    "Object - superclass of JavaUnresolvedFieldrefConstant "
         #'stx:libbasic2'    "ZipArchive - referenced by Java class>>classSource:package:in: "
         #'stx:libbasic3'    "MessageTracer - referenced by JavaMethod>>setBreakPoint "
         #'stx:libcomp'    "Parser - referenced by JavaClass>>evaluatorClass "
         #'stx:libhtml'    "URL - referenced by JavaEmbeddedFrameView>>setupAppletFrameIn:initializeJava: "
         #'stx:libtool'    "DebugView - referenced by Java class>>flushClasses "
-        #'stx:libview'    "DisplaySurface - superclass of JavaView "
+        #'stx:libview'    "DeviceGraphicsContext - superclass of JavaEmbeddedFrameView "
         #'stx:libview2'    "Plug - referenced by JavaSourceCodeCache>>findMethodLine:inMethods: "
         #'stx:libwidg'    "Label - referenced by JavaVM class>>processEvent: "
         #'stx:libwidg2'    "MenuPanel - referenced by JavaVM class>>processEvent: "
@@ -240,7 +240,7 @@
         Object isJavaArray
         Object isJavaRef
         String asArrayOfSubstringsSeparatedBy:
-        ZipArchive #'>'
+        ZipArchive nextBytes:of:startingAt:into:startingAt:
         'Boolean class' arrayClass
         'Boolean class' isJavaPrimitiveType
         'Boolean class' javaName
@@ -344,7 +344,7 @@
     "Return a SVN revision number of myself.
      This number is updated after a commit"
 
-    ^ "$SVN-Revision:"'1091M'"$"
+    ^ "$SVN-Revision:"'1098M'"$"
 ! !
 
 !stx_libjava class methodsFor:'file generation'!