raw param annotations saving development
authorhlopkmar
Sat, 01 Dec 2012 21:19:57 +0000
branchdevelopment
changeset 1848 b508cc4d4bf0
parent 1847 5db5d57223fb
child 1849 96895c73d62c
raw param annotations saving
JavaClassReader.st
JavaMethodAnnotationContainer.st
JavaMirror.st
libjava.rc
--- a/JavaClassReader.st	Sat Dec 01 13:05:45 2012 +0000
+++ b/JavaClassReader.st	Sat Dec 01 21:19:57 2012 +0000
@@ -1022,40 +1022,42 @@
 !
 
 readRuntimeParameterAnnotationsAttributeFor: javaMethod visible: visible 
-    | length  paramsCount  annotationsCount rawAnnotations  startPos  endPos |
-
+    | length  paramsCount  annotationsCount  rawAnnotations  startPos  endPos |
     self assert: inStream isPositionable
         message: '.class file stream must be positionable'.
     length := inStream nextUnsignedLongMSB: msb.
     startPos := inStream position.
     paramsCount := inStream nextByte.
     paramsCount = 0 ifTrue: [ ^ nil ].
-    1 to: paramsCount
-        do: 
-            [:paramIndex | 
-            annotationsCount := inStream nextUnsignedShortMSB: msb.
-            annotationsCount > 0 
-                ifTrue: 
-                    [ | annotations |
-                    annotations := visible 
-                                ifTrue: 
-                                    [ javaMethod ensureHasAnnotations ensureVisibleParameterAnnotationsAt: paramIndex ]
-                                ifFalse: 
-                                    [javaMethod ensureHasAnnotations ensureInvisibleParameterAnnotationsAt: paramIndex ].
-                    annotationsCount timesRepeat: 
-                    [ | annotation |
-
-                    annotation := self readAnnotationFor: javaMethod.
-                    annotations at: (annotation name) put: annotation. ] ]].
+    1 to: paramsCount do: [
+        :paramIndex | 
+        annotationsCount := inStream nextUnsignedShortMSB: msb.
+        annotationsCount > 0 ifTrue: [
+            | annotations |
+            annotations := visible ifTrue: [
+                    javaMethod ensureHasAnnotations 
+                        ensureVisibleParameterAnnotationsAt: paramIndex
+                ] ifFalse: [
+                    javaMethod ensureHasAnnotations 
+                        ensureInvisibleParameterAnnotationsAt: paramIndex
+                ].
+            annotationsCount timesRepeat: [
+                | annotation |
+                annotation := self readAnnotationFor: javaMethod.
+                annotations at: (annotation name) put: annotation.
+            ]
+        ]
+    ].
     endPos := inStream position.
-    rawAnnotations := inStream position: startPos.
+    inStream position: startPos.
     rawAnnotations := inStream next: length.
-    inStream position ~= endPos 
-        ifTrue: [ self halt: 'annotations are probably reading what they shouldnt' ].
-    javaMethod annotations rawAnnotations: rawAnnotations.
+    inStream position ~= endPos ifTrue: [
+        self halt: 'annotations are probably reading what they shouldnt'
+    ].
+    javaMethod annotations rawParamAnnotations: rawAnnotations.
 
     "Modified: / 28-02-2011 / 17:05:47 / Marcel Hlopko <hlopik@gmail.com>"
-    "Modified: / 16-03-2011 / 17:26:42 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 01-12-2012 / 22:00:34 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 !
 
 readSignatureAttributeFor:something
--- a/JavaMethodAnnotationContainer.st	Sat Dec 01 13:05:45 2012 +0000
+++ b/JavaMethodAnnotationContainer.st	Sat Dec 01 21:19:57 2012 +0000
@@ -21,8 +21,8 @@
 "{ Package: 'stx:libjava' }"
 
 JavaAnnotationContainer subclass:#JavaMethodAnnotationContainer
-	instanceVariableNames:'annotationDefault rawAnnotations visibleParameterAnnotations
-		invisibleParameterAnnotations'
+	instanceVariableNames:'annotationDefault rawAnnotations rawParamAnnotations
+		visibleParameterAnnotations invisibleParameterAnnotations'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Languages-Java-Annotations'
@@ -94,6 +94,14 @@
 
 rawAnnotations:something
     rawAnnotations := something.
+!
+
+rawParamAnnotations
+    ^ rawParamAnnotations
+!
+
+rawParamAnnotations:something
+    rawParamAnnotations := something.
 ! !
 
 !JavaMethodAnnotationContainer methodsFor:'initialization'!
--- a/JavaMirror.st	Sat Dec 01 13:05:45 2012 +0000
+++ b/JavaMirror.st	Sat Dec 01 21:19:57 2012 +0000
@@ -224,7 +224,7 @@
 
 !JavaMirror methodsFor:'instance creation-java.lang.reflect.*'!
 
-create: ctorOrMethodClass for: class method: method signature: signature modifiers: modifiers parameterTyoes: parameterClasses exceptionTypes: exceptionClasses annotations: annotations
+create: ctorOrMethodClass for: class method: method signature: signature modifiers: modifiers parameterTyoes: parameterClasses exceptionTypes: exceptionClasses annotations: annotations 
     "Creates a new java.lang.Constructor. Arguments:
 
         ctorOrMethodClass <java.lang.reflect.Constructor|java.lang.reflect.Method>
@@ -234,15 +234,13 @@
         modifiers <SmallInteger>
         parameterClasses <Collection of Class>
         exceptionClasses <Collection of Class>
-        annotations <JavaAnnotationContainer>
-    "
-
+        annotations <JavaAnnotationContainer>"
+    
     | ctorOrMethod |
-
     ctorOrMethod := ctorOrMethodClass new.
-
     ctorOrMethod
-        instVarNamed: #clazz put: (reflection javaClassObjectForClass: "method m"class);
+        instVarNamed: #clazz
+            put: (reflection "method m" javaClassObjectForClass: class);
         instVarNamed: #slot put: method;
         instVarNamed: #modifiers put: modifiers;
         instVarNamed: #parameterTypes
@@ -250,22 +248,16 @@
         instVarNamed: #exceptionTypes
             put: (reflection javaClassObjectArrayForClasses: exceptionClasses);
         instVarNamed: #annotations put: annotations runtimeVisible bytes;
-        breakPoint: #mh info: 'Please, replace ??? by code that accesses parameterAnnotations byte array'.
-        "/ Look at java.lang.reflect.Method/Constructor to figure out what value is needed here."
-        "/ Also, make sure there is a test in libjava tests (stx.libjava.tests.lang.XXXX, if not,
-        "/ add some!!!!!!
-        "/instVarNamed: #parameterAnnotations put: annotations ???;
-
-
-    (method isJavaMethod and:[method signature notNil]) ifTrue:[
-        ctorOrMethod                 
-            instVarNamed: #signature
+        instVarNamed: #parameterAnnotations
+            put: annotations rawParamAnnotations bytes.
+    (method isJavaMethod and: [ method signature notNil ]) ifTrue: [
+        ctorOrMethod instVarNamed: #signature
             put: (reflection javaStringObjectForString: method signature interned: true)
     ].
-
     ^ ctorOrMethod
 
     "Created: / 01-08-2012 / 10:24:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 01-12-2012 / 22:10:33 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 !
 
 createConstructorFor: class method: method signature: signature modifiers: modifiers parameterTyoes: parameterClasses exceptionTypes: exceptionClasses annotations: annotations
--- a/libjava.rc	Sat Dec 01 13:05:45 2012 +0000
+++ b/libjava.rc	Sat Dec 01 21:19:57 2012 +0000
@@ -3,7 +3,7 @@
 // automagically generated from the projectDefinition: stx_libjava.
 //
 VS_VERSION_INFO VERSIONINFO
-  FILEVERSION     6,2,2224,2224
+  FILEVERSION     6,2,2226,2226
   PRODUCTVERSION  6,2,3,0
 #if (__BORLANDC__)
   FILEFLAGSMASK   VS_FF_DEBUG | VS_FF_PRERELEASE
@@ -20,12 +20,12 @@
     BEGIN
       VALUE "CompanyName", "eXept Software AG & SWING Research Group\0"
       VALUE "FileDescription", "Java support for Smalltalk/X (LIB)\0"
-      VALUE "FileVersion", "6.2.2224.2224\0"
+      VALUE "FileVersion", "6.2.2226.2226\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\n          SWING Research Group, Czech Technical University In Prague\0"
       VALUE "ProductName", "Smalltalk/X\0"
       VALUE "ProductVersion", "6.2.3.0\0"
-      VALUE "ProductDate", "Sat, 01 Dec 2012 13:05:28 GMT\0"
+      VALUE "ProductDate", "Sat, 01 Dec 2012 21:14:42 GMT\0"
     END
 
   END