slightly refactored exceptionTable methods and their callers.. no typechanging side effects jk_new_structure
authorhlopkmar
Sat, 04 Jun 2011 15:23:37 +0000
branchjk_new_structure
changeset 837 8f42226d82c0
parent 836 b64228c3acaa
child 838 acac3cc5022f
slightly refactored exceptionTable methods and their callers.. no typechanging side effects
src/JavaByteCodeDisassembler.st
src/JavaDecompiler.st
src/JavaMethodWithException.st
src/JavaVM.st
src/stx_libjava.st
--- a/src/JavaByteCodeDisassembler.st	Sat Jun 04 15:08:01 2011 +0000
+++ b/src/JavaByteCodeDisassembler.st	Sat Jun 04 15:23:37 2011 +0000
@@ -387,11 +387,12 @@
 
 prettyPrintExceptionTable: table 
     table isNil ifTrue: [ ^ '' ].
-    ^ 'Throws:' , (table inject: ''
-        into: [:acc :each | acc , ' ' , each printString ]).
+    ^ 'Throws:' 
+        , (table inject: '' into: [:acc :each | acc , ' ' , each name ]).
 
     "Created: / 22-03-2011 / 16:16:34 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
     "Modified: / 22-03-2011 / 20:59:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 04-06-2011 / 17:19:17 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 !
 
 prettyPrintField: fieldIndex 
--- a/src/JavaDecompiler.st	Sat Jun 04 15:08:01 2011 +0000
+++ b/src/JavaDecompiler.st	Sat Jun 04 15:23:37 2011 +0000
@@ -615,84 +615,79 @@
     "Modified: / 5.12.1998 / 15:58:37 / cg"
 !
 
-methodDefinitionOf:m inPackage:pckgName on:s
-    |aMethod type nm specComponents accessAttributeStyle codeStyle methodNameStyle|
+methodDefinitionOf: m inPackage: pckgName on: s 
+    | aMethod nm  specComponents  accessAttributeStyle  codeStyle  methodNameStyle |
 
     aMethod := m.
-    m isWrapped ifTrue:[
+    m isWrapped ifTrue: [
         aMethod := m originalMethod
     ].
-
-    accessAttributeStyle := Java prettyPrintStyle at:#accessAttribute.
-    codeStyle := Java prettyPrintStyle at:#code.
-    methodNameStyle := Java prettyPrintStyle at:#methodName.
-
-    s nextPutAll:'    '.
-    s emphasis:accessAttributeStyle.
-    aMethod isPublic ifTrue:[
-        s nextPutAll:'public '.
-    ] ifFalse:[
-        aMethod isProtected ifTrue:[
-            s nextPutAll:'protected '.
-        ] ifFalse:[
-            s nextPutAll:'private '.
-        ]
+    accessAttributeStyle := Java prettyPrintStyle at: #accessAttribute.
+    codeStyle := Java prettyPrintStyle at: #code.
+    methodNameStyle := Java prettyPrintStyle at: #methodName.
+    s nextPutAll: '    '.
+    s emphasis: accessAttributeStyle.
+    aMethod isPublic ifTrue: [
+        s nextPutAll: 'public '.
+    ] ifFalse: [
+        aMethod isProtected ifTrue: [
+            s nextPutAll: 'protected '.
+        ] ifFalse: [ s nextPutAll: 'private '. ]
     ].
-    aMethod isFinal ifTrue:[
-        s nextPutAll:'final '.
+    aMethod isFinal ifTrue: [
+        s nextPutAll: 'final '.
     ].
-    aMethod isStatic ifTrue:[
-        s nextPutAll:'static '.
+    aMethod isStatic ifTrue: [
+        s nextPutAll: 'static '.
     ].
-    aMethod isNative ifTrue:[
-        s nextPutAll:'native '.
+    aMethod isNative ifTrue: [
+        s nextPutAll: 'native '.
     ].
-    aMethod isSynchronized ifTrue:[
-        s nextPutAll:'synchronized '.
+    aMethod isSynchronized ifTrue: [
+        s nextPutAll: 'synchronized '.
     ].
-    s emphasis:codeStyle.
-
-    (nm := aMethod name) = '<init>' ifTrue:[
+    s emphasis: codeStyle.
+    (nm := aMethod name) = '<init>' ifTrue: [
         nm := aMethod javaClass lastName.
     ].
-    specComponents := JavaMethod
-                          specComponentsWithArgsFromSignature:(aMethod signature)
-                          withName:nm 
-                          in:(aMethod javaClass package).
-
-    s nextPutAll:(specComponents at:1).
+    specComponents := JavaMethod 
+                specComponentsWithArgsFromSignature: (aMethod signature)
+                withName: nm
+                in: (aMethod javaClass package).
+    s nextPutAll: (specComponents at: 1).
     s space.
-    s emphasis:methodNameStyle.
-    s nextPutAll:(specComponents at:2).
-    s emphasis:codeStyle.
-    s nextPutAll:' ('.
-    s nextPutAll:(specComponents at:3).
-    s nextPutAll:')'.
-
-    aMethod exceptionTable size > 0 ifTrue:[
-        s nextPutAll:' throws '.
+    s emphasis: methodNameStyle.
+    s nextPutAll: (specComponents at: 2).
+    s emphasis: codeStyle.
+    s nextPutAll: ' ('.
+    s nextPutAll: (specComponents at: 3).
+    s nextPutAll: ')'.
+    aMethod exceptionTable size > 0 ifTrue: [
+        s nextPutAll: ' throws '.
+        aMethod exceptionTable 
+            keysAndValuesDo: [
+                :index :aClassRef | 
+                | nm |
 
-        aMethod exceptionTable keysAndValuesDo:[:index :aClassRef |
-            |nm|
-
-            nm := aClassRef fullName.
-            (nm startsWith:pckgName) ifTrue:[
-                nm := nm copyFrom:pckgName size + 2
-            ] ifFalse:[
-                (nm startsWith:'java/lang') ifTrue:[
-                   nm := nm copyFrom:'java/lang' size + 2.
+                nm := aClassRef name.
+                (nm startsWith: pckgName) ifTrue: [
+                    nm := nm copyFrom: pckgName size + 2
+                ] ifFalse: [
+                    (nm startsWith: 'java/lang') ifTrue: [
+                        nm := nm copyFrom: 'java/lang' size + 2.
+                    ].
                 ].
-            ].
-            index ~~ 1 ifTrue:[
-                s nextPutAll:', '
-            ].
-            s nextPutAll:(nm copyReplaceAll:$/ with:$.)
-        ]
+                index ~~ 1 ifTrue: [ s nextPutAll: ', ' ].
+                s nextPutAll: (nm copyReplaceAll: $/ with: $.)
+            ]
     ].
-    s nextPutAll:';'; cr.
+    s
+        nextPutAll: ';';
+        cr.
 
-    "Created: / 1.8.1997 / 12:24:11 / cg"
-    "Modified: / 14.11.1998 / 00:03:09 / cg"
+    "Created: / 01-08-1997 / 12:24:11 / cg"
+    "Modified: / 14-11-1998 / 00:03:09 / cg"
+    "Modified: / 04-06-2011 / 17:18:56 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 ! !
 
 !JavaDecompiler class methodsFor:'decompiling'!
--- a/src/JavaMethodWithException.st	Sat Jun 04 15:08:01 2011 +0000
+++ b/src/JavaMethodWithException.st	Sat Jun 04 15:23:37 2011 +0000
@@ -44,27 +44,37 @@
 !JavaMethodWithException methodsFor:'accessing'!
 
 exceptionTable
-    exceptionTable notNil ifTrue: [
-        exceptionTable := exceptionTable collect: [:classRef | classRef resolve ]
-    ].
+    "return exception table - collection of classRefs"
     ^ exceptionTable.
 
     "Created: / 05-11-1998 / 19:58:38 / cg"
     "Modified: / 04-02-2011 / 22:07:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 04-06-2011 / 17:05:24 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 04-06-2011 / 17:20:17 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 !
 
 getExceptionTable
-
-    ^exceptionTable
+ "return exception table - collection of classRefs"
+    ^ exceptionTable
 
     "Created: / 04-02-2011 / 23:07:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 04-06-2011 / 17:20:29 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 !
 
-setExceptionTable:anArray
+javaExceptionTable 
+    "return exception table - collection of resolved java classes"
+    exceptionTable ifNil: [ ^ nil ].
+    ^ exceptionTable collect: [:classRef | classRef resolve ].
+
+    "Modified: / 04-02-2011 / 22:07:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Created: / 04-06-2011 / 17:16:50 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+setExceptionTable: anArray 
+     "set exception table - expected arg: collection of classRefs"
     exceptionTable := anArray.
 
-    "Created: / 5.11.1998 / 19:58:43 / cg"
+    "Created: / 05-11-1998 / 19:58:43 / cg"
+    "Modified: / 04-06-2011 / 17:21:17 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 ! !
 
 !JavaMethodWithException class methodsFor:'documentation'!
--- a/src/JavaVM.st	Sat Jun 04 15:08:01 2011 +0000
+++ b/src/JavaVM.st	Sat Jun 04 15:23:37 2011 +0000
@@ -4142,33 +4142,33 @@
     "Modified: / 16-03-2011 / 15:43:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-_java_lang_Class_getDeclaredMethods0: aJavaContext
-
+_java_lang_Class_getDeclaredMethods0: aJavaContext 
     <javanative: 'java/lang/Class' name: 'getDeclaredMethods0'>
-
-        |class publicOnly methods|
-
-    class := self reflection classForJavaClassObject:(aJavaContext receiver).
-    publicOnly := (aJavaContext argAt:1) == 1.
+    | class  publicOnly  methods |
+
+    class := self reflection classForJavaClassObject: (aJavaContext receiver).
+    publicOnly := (aJavaContext argAt: 1) == 1.
     methods := OrderedCollection new.
     class 
-        selectorsAndMethodsDo:[:selector :method | 
+        selectorsAndMethodsDo: [
+            :selector :method | 
             (method isJavaMethod 
-                and:[
-                    (selector at:1) ~~ $< 
-                        and:[
-                            (selector startsWith:'<init>(') not 
-                                and:[publicOnly not or:[method isPublic]]
+                and: [
+                    (selector at: 1) ~~ $< 
+                        and: [
+                            (selector startsWith: '<init>(') not 
+                                and: [ publicOnly not or: [ method isPublic ] ]
                         ]
                 ]) 
-                    ifTrue:[methods add:(self javaMethodObjectForMethod:method)]
+                    ifTrue: [ methods add: (self javaMethodObjectForMethod: method) ]
         ].
-    ^ (self classForName: 'java.lang.reflect.Method')
-        arrayClass withAll: methods asArray
+    ^ (self classForName: 'java.lang.reflect.Method') arrayClass 
+        withAll: methods asArray
 
     "Created: / 21-12-2010 / 22:39:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 28-01-2011 / 15:19:09 / Marcel Hlopko <hlopik@gmail.com>"
     "Modified: / 11-02-2011 / 08:35:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 04-06-2011 / 17:07:04 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 !
 
 _java_lang_Class_getEnclosingMethod0: nativeContext
@@ -5207,20 +5207,18 @@
 
 !JavaVM class methodsFor:'native - java.lang.reflect'!
 
-_java_lang_reflect_Array_newArray: aJavaContext
-
+_java_lang_reflect_Array_newArray: aJavaContext 
     <javanative: 'java/lang/reflect/Array' name: 'newArray'>
-
-        |componentClass size|
-
+    | componentClass  size |
     componentClass := self reflection 
-                classForJavaClassObject:(aJavaContext argAt:1).
-    size := aJavaContext argAt:2.
-    ^ componentClass arrayClass new:size
+                classForJavaClassObject: (aJavaContext argAt: 1).
+    size := aJavaContext argAt: 2.
+    ^ componentClass arrayClass new: size
 
     "Created: / 17-12-2010 / 14:49:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 19-12-2010 / 17:54:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 28-01-2011 / 15:18:50 / Marcel Hlopko <hlopik@gmail.com>"
+    "Modified: / 04-06-2011 / 17:06:41 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 !
 
 _java_lang_reflect_Array_set: nativeContext
@@ -15045,29 +15043,31 @@
     "Modified: / 03-03-2011 / 23:50:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-javaMethodObjectLikeSlotsInto: jMethod forMethod:method 
-     "
-        Fill in slots of given instance of java.lang.Method or 
-        java.lang.Constructor
-    "
+javaMethodObjectLikeSlotsInto: jMethod forMethod: method 
+    "
+       Fill in slots of given instance of java.lang.Method or
+       java.lang.Constructor"
+    
     | desc |
+
     desc := method descriptor.
-
     jMethod
-        instVarNamed: #clazz            put: (self javaClassObjectForClass: method javaClass);
-        instVarNamed: #slot             put: 0"Ignored";
-        instVarNamed: #modifiers        put: method accessFlags;
-        instVarNamed: #signature        put: (self javaStringObjectForString: method signature interned: true);
-        instVarNamed: #parameterTypes   put: (self javaClassObjectArrayForClasses: desc parameterClasses);
-        instVarNamed: #exceptionTypes   put: (self javaClassObjectArrayForClasses: method exceptionTable);
-        instVarNamed: #annotations      put: (method annotations runtimeVisible bytes);
-
+        instVarNamed: #clazz put: (self javaClassObjectForClass: method javaClass);
+        instVarNamed: #slot put: 0;
+        instVarNamed: #modifiers put: method accessFlags;
+        instVarNamed: #signature
+            put: (self javaStringObjectForString: method signature interned: true);
+        instVarNamed: #parameterTypes
+            put: (self javaClassObjectArrayForClasses: desc parameterClasses);
+        instVarNamed: #exceptionTypes
+            put: (self javaClassObjectArrayForClasses: method javaExceptionTable);
+        instVarNamed: #annotations put: (method annotations runtimeVisible bytes);
         yourself.
-
     ^ jMethod
 
     "Created: / 11-02-2011 / 06:44:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 03-03-2011 / 23:07:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 04-06-2011 / 17:17:04 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 !
 
 methodForJavaConstructorObject:constructor 
--- a/src/stx_libjava.st	Sat Jun 04 15:08:01 2011 +0000
+++ b/src/stx_libjava.st	Sat Jun 04 15:23:37 2011 +0000
@@ -61,8 +61,8 @@
     javaTestCases do:[:each | suite addTests:each buildSuite tests ].
 
     suite tests withIndexDo:
-	[:t :i|
-	Stdout nextPutAll: i printString; space; nextPutAll: t printString; cr].
+        [:t :i|
+        Stdout nextPutAll: i printString; space; nextPutAll: t printString; cr].
 
     ^suite
 
@@ -73,7 +73,7 @@
 
     "Created: / 07-05-2011 / 19:58:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 07-05-2011 / 22:26:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-
+    "Modified: / 04-06-2011 / 17:23:05 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 ! !
 
 !stx_libjava class methodsFor:'description'!
@@ -387,7 +387,7 @@
     "Return a SVN revision number of myself.
      This number is updated after a commit"
 
-    ^ "$SVN-Revision:"'1178M'"$"
+    ^ "$SVN-Revision:"'1181'"$"
 ! !
 
 !stx_libjava class methodsFor:'file generation'!