few more natives (CRC32) jk_new_structure
authorvranyj1
Mon, 05 Dec 2011 08:53:23 +0000
branchjk_new_structure
changeset 1216 782cf167a96c
parent 1215 1df6270d9c55
child 1217 a7d011bc112b
few more natives (CRC32)
src/JavaMethod.st
src/JavaVM.st
--- a/src/JavaMethod.st	Sun Dec 04 23:03:31 2011 +0000
+++ b/src/JavaMethod.st	Mon Dec 05 08:53:23 2011 +0000
@@ -1850,6 +1850,18 @@
     "Modified: / 25.9.1999 / 23:04:01 / cg"
 !
 
+printOn: aStream
+
+    super printOn: aStream.
+    aStream nextPut: $(.
+    javaClass name printOn: aStream.
+    aStream nextPut: $..    
+    selector printOn: aStream.
+    aStream nextPut: $).
+
+    "Created: / 05-12-2011 / 01:30:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 printStringForBrowserWithSelector:dummySelector inClass:dummyClass
 "/    self isStatic ifTrue:[
 "/        ^ 'static ' , self signatureName
--- a/src/JavaVM.st	Sun Dec 04 23:03:31 2011 +0000
+++ b/src/JavaVM.st	Mon Dec 05 08:53:23 2011 +0000
@@ -2568,6 +2568,7 @@
     ExceptionDebugPatterns add: 'java/lang/SecurityException*'
     ExceptionDebugPatterns add: 'java/net/ConnectException*'
     ExceptionDebugPatterns add: 'java/lang/IllegalArgumentException'
+    ExceptionDebugPatterns add: 'java/lang/ClassNotFoundException'
     "
 
     "Created: / 25-02-2011 / 08:08:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -2926,7 +2927,7 @@
         1 to: args size do:[:i|
             | cls |
             bi > bargss ifTrue:[
-                 self throwExceptionClassName: 'java.lang.InvocationTargetException'
+                 self throwExceptionClassName: 'java.lang.reflect.InvocationTargetException'
                                   withMessage: 'passed more arguments than expected'
             ].
 
@@ -2945,7 +2946,7 @@
             bi := bi + 1.
        ].
         bi <= bargss ifTrue:[
-             self throwExceptionClassName: 'java.lang.InvocationTargetException'
+             self throwExceptionClassName: 'java.lang.reflect.InvocationTargetException'
                               withMessage: 'not enough arguments'
         ].
     ] ifFalse:[
@@ -5779,14 +5780,20 @@
 
     <javanative: 'java/lang/Class' name: 'getRawAnnotations'>
 
-        |class |
+    |class |
 
     class := self reflection classForJavaClassObject:aJavaContext receiver.
+    class isJavaArrayClass ifTrue:[
+        ^nil
+    ].
+    class isJavaPrimitiveType ifTrue:[
+        ^nil
+    ].
     ^ class runtimeVisibleAnnotationsAsBytesOrNil
 
     "Created: / 21-12-2010 / 19:35:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 28-01-2011 / 15:19:20 / Marcel Hlopko <hlopik@gmail.com>"
-    "Modified: / 25-02-2011 / 16:48:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 05-12-2011 / 00:50:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_lang_Class_getSuperclass: nativeContext 
@@ -8080,6 +8087,21 @@
     ^ UnimplementedNativeMethodSignal raise
 !
 
+_java_util_zip_CRC32_updateBytes: nativeContext
+
+    <javanative: 'java/util/zip/CRC32' name: 'updateBytes(I[BII)I'>
+
+    | crc b off len |
+    crc := nativeContext argAt: 1.
+    b   := nativeContext argAt: 2.
+    off := nativeContext argAt: 3.
+    len := nativeContext argAt: 4.
+
+    ^ZipStream crc32BytesIn:b from:off + 1  to: off + len crc:crc
+
+    "Modified: / 05-12-2011 / 00:41:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 _java_util_zip_Deflater_initIDs: nativeContext
 
     <javanative: 'java/util/zip/Deflater' name: 'initIDs'>
@@ -8102,6 +8124,18 @@
     "Modified: / 03-11-2011 / 22:51:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+_java_util_zip_Inflater_getBytesRead: nativeContext
+
+    <javanative: 'java/util/zip/Inflater' name: 'getBytesRead(J)J'>
+
+    | addr inflater |
+    addr := nativeContext argAt: 1.
+    inflater := ZipInflaters at: addr.
+    ^inflater bytesRead.
+
+    "Modified: / 05-12-2011 / 00:56:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 _java_util_zip_Inflater_getBytesWritten: nativeContext
 
     <javanative: 'java/util/zip/Inflater' name: 'getBytesWritten'>
@@ -18221,19 +18255,23 @@
 methodForJavaConstructorObject:constructor 
      "given a java.lang.reflect.Constructor, return the corresponding method
       it."
-    
-    |class signature|
-    class := self classForJavaClassObject:(constructor instVarNamed:#clazz).
-    signature := Java as_ST_String:(constructor instVarNamed:#signature).
-    class methodsDo:[:mthd|
-        mthd signature = signature ifTrue:[
-            ^mthd
-        ].
-    ].
+
+    javaMethods keysAndValuesDo:[:mthd :jmthd|
+        jmthd == constructor ifTrue:[^mthd].
+    ].
+
+"/    |class signature|
+"/    class := self classForJavaClassObject:(constructor instVarNamed:#clazz).
+"/    signature := Java as_ST_String:(constructor instVarNamed:#signature).
+"/    class methodsDo:[:mthd|
+"/        mthd signature = signature ifTrue:[
+"/            ^mthd
+"/        ].
+"/    ].
     self error: 'No ctor found for java ctor object'
 
     "Created: / 09-02-2011 / 10:36:07 / Marcel Hlopko <hlopik@gmail.com>"
-    "Modified: / 14-08-2011 / 18:36:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 05-12-2011 / 01:43:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 methodForJavaMethodObject:aJavaMethodObject 
@@ -18241,21 +18279,25 @@
          Given an instance of java.lang.reflect.Method, answers
          real method associated with it. 
     "
-    |class name signature |
-
-    class := self classForJavaClassObject:(aJavaMethodObject instVarNamed:#clazz).
-    name := Java as_ST_String:(aJavaMethodObject instVarNamed:#name).
-    signature := Java as_ST_String:(aJavaMethodObject instVarNamed:#signature).
-    class methodsDo:[:mthd|
-        (mthd name = name and:[mthd signature = signature]) ifTrue:[
-            ^mthd
-        ]
-    ].
+
+    javaMethods keysAndValuesDo:[:mthd :jmthd|
+        jmthd == aJavaMethodObject ifTrue:[^mthd].
+    ].
+"/    |class name signature |
+"/
+"/    class := self classForJavaClassObject:(aJavaMethodObject instVarNamed:#clazz).
+"/    name := Java as_ST_String:(aJavaMethodObject instVarNamed:#name).
+"/    signature := Java as_ST_String:(aJavaMethodObject instVarNamed:#signature).
+"/    class methodsDo:[:mthd|
+"/        (mthd name = name and:[mthd signature = signature]) ifTrue:[
+"/            ^mthd
+"/        ]
+"/    ].
     self assert: false description: 'No such method, malformed java.lang.reflect.Method object?'.
     ^nil.
 
     "Created: / 09-02-2011 / 10:32:14 / Marcel Hlopko <hlopik@gmail.com>"
-    "Modified: / 17-08-2011 / 09:50:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 05-12-2011 / 01:43:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !JavaVM::Reflection methodsFor:'reflection - other'!