harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From var...@apache.org
Subject svn commit: r598227 - in /harmony/enhanced/drlvm/trunk: build/make/targets/ vm/tests/kernel/org/apache/harmony/lang/annotation/ vm/tests/kernel_resources/org/apache/harmony/lang/test/resource/ vm/vmcore/include/ vm/vmcore/src/kernel_classes/native/ vm/...
Date Mon, 26 Nov 2007 11:15:46 GMT
Author: varlax
Date: Mon Nov 26 03:15:44 2007
New Revision: 598227

URL: http://svn.apache.org/viewvc?rev=598227&view=rev
Log:
Fixed HARMONY-5180 [drlvm][kernel][geronimo] Annotations get loaded with wrong classloader

Modified:
    harmony/enhanced/drlvm/trunk/build/make/targets/kernel.test.xml
    harmony/enhanced/drlvm/trunk/vm/tests/kernel/org/apache/harmony/lang/annotation/AnnotationLoaderTest.java
    harmony/enhanced/drlvm/trunk/vm/tests/kernel_resources/org/apache/harmony/lang/test/resource/AnnotatedMembers.java
    harmony/enhanced/drlvm/trunk/vm/vmcore/include/annotations.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_vm_VMGenericsAndAnnotations.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/reflection/annotations.cpp

Modified: harmony/enhanced/drlvm/trunk/build/make/targets/kernel.test.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/build/make/targets/kernel.test.xml?rev=598227&r1=598226&r2=598227&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/build/make/targets/kernel.test.xml (original)
+++ harmony/enhanced/drlvm/trunk/build/make/targets/kernel.test.xml Mon Nov 26 03:15:44 2007
@@ -87,10 +87,12 @@
     </target>
 
     <target name="compile-kernel-test">
-        <compile-java src="${kernel.test.javasrc}/../kernel_resources" 
-            dest="${test.resource.path}"/>
         <compile-java src="${kernel.test.javasrc}" 
             dest="${test.class.path}"/>
+        <compile-java src="${kernel.test.javasrc}/../kernel_resources" 
+            dest="${test.resource.path}">
+            <classpath path="${test.class.path}"/>
+        </compile-java>
         <delete quiet="true" dir="${test.class.path}/notfound" />
     </target>
     

Modified: harmony/enhanced/drlvm/trunk/vm/tests/kernel/org/apache/harmony/lang/annotation/AnnotationLoaderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/kernel/org/apache/harmony/lang/annotation/AnnotationLoaderTest.java?rev=598227&r1=598226&r2=598227&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/kernel/org/apache/harmony/lang/annotation/AnnotationLoaderTest.java
(original)
+++ harmony/enhanced/drlvm/trunk/vm/tests/kernel/org/apache/harmony/lang/annotation/AnnotationLoaderTest.java
Mon Nov 26 03:15:44 2007
@@ -40,11 +40,13 @@
     
     protected ClassLoader ld;
     protected Class<?> test;
+    protected Class<?> anotherAntnClass;
     
     @Override
     protected void setUp() throws Exception {
         ld = TestResources.getLoader();
         test = ld.loadClass("org.apache.harmony.lang.test.resource.AnnotatedMembers");
+        anotherAntnClass = ld.loadClass("org.apache.harmony.lang.test.resource.AnotherAntn");
     }
     
     /**
@@ -54,7 +56,7 @@
         Annotation[] an = test.getAnnotations();
         assertNotNull(an);
         assertEquals("annotations num", 1, an.length);
-        assertEquals("the class annotation", "AnotherAntn", an[0].annotationType().getSimpleName());
+        assertEquals("the class annotation", anotherAntnClass, an[0].annotationType());
     }
 
     /**
@@ -121,4 +123,18 @@
         assertEquals("annotations num", 1, an[0].length);
         assertEquals("the class annotation", "AnotherAntn", an[0][0].annotationType().getSimpleName());
     }
+    
+    /**
+     * HARMONY-5180 regression test.  
+     */
+    public void testMemberValue() throws Throwable {
+        Field f = test.getField("acme");
+        assertNotNull("field", f);
+        Annotation[] an = f.getAnnotations();
+        assertNotNull("annotations", an);
+        assertEquals("annotations num", 1, an.length);
+        assertEquals("the class annotation", AllTypesAntn.class, an[0].annotationType());
+        assertEquals("the class-member", anotherAntnClass, ((AllTypesAntn)an[0]).classValue());
+    }
+
 }

Modified: harmony/enhanced/drlvm/trunk/vm/tests/kernel_resources/org/apache/harmony/lang/test/resource/AnnotatedMembers.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/kernel_resources/org/apache/harmony/lang/test/resource/AnnotatedMembers.java?rev=598227&r1=598226&r2=598227&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/kernel_resources/org/apache/harmony/lang/test/resource/AnnotatedMembers.java
(original)
+++ harmony/enhanced/drlvm/trunk/vm/tests/kernel_resources/org/apache/harmony/lang/test/resource/AnnotatedMembers.java
Mon Nov 26 03:15:44 2007
@@ -16,6 +16,8 @@
  */
 package org.apache.harmony.lang.test.resource;
 
+import org.apache.harmony.lang.annotation.AllTypesAntn;
+
 /**
  * @author Alexey V. Varlamov
  * @version $Revision$
@@ -32,4 +34,7 @@
     
     @AnotherAntn
     public AnnotatedMembers() {}
+    
+    @AllTypesAntn(classValue=AnotherAntn.class)
+    public Object acme;
 }

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/include/annotations.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/include/annotations.h?rev=598227&r1=598226&r2=598227&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/include/annotations.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/include/annotations.h Mon Nov 26 03:15:44 2007
@@ -18,6 +18,10 @@
  * @author Alexey V. Varlamov
  * @version $Revision$
  */  
+/**
+ * @file
+ * @brief Declaration of main resolution routines for Java annotations.
+ */
 
 #ifndef _ANNOTATIONS_H_
 #define _ANNOTATIONS_H_
@@ -29,25 +33,53 @@
 struct Annotation;
 struct AnnotationValue;
 
-// Returns array of declared visible annotations
-// and in case -Xinvisible command line flag is set also returns array of invisible annotations.
-// Returns zero-sized array if there are no annotations.
-// May raise an exception, in this case returns null.
+/**
+ * Returns common array of visible and invisible annotations.
+ * @note invisible annotations are present only if -Xinvisible command line flag is set
+ * An annotation which cannot be resolved (i.e. it's type cannot be loaded) 
+ * is silently ignored, per JSR-175.
+ * Returns zero-sized array if there are no (resolved) annotations.
+ * May raise an exception, in this case returns null.
+ *
+ * @param jenv - JNI interface 
+ * @param table - annotations to resolve
+ * @param inv_table - invisible annotations to resolve
+ * @param clss - an "owner" class, which is annotated or whose member is annotated
+ * @return - array of resolved annotations or null
+ */
 jobjectArray get_annotations(JNIEnv* jenv, AnnotationTable* table, AnnotationTable *inv_table,
Class* clss);
 
-// Returns resolved annotation or null if resolution failed.
-// If the cause parameter is not null, resolution error is assigned to it for upstream processing;
-// otherwise the error is raised.
-// In case of errors other than resolving failure, the error is raised, 
-// null is returned and cause is unchanged
+/**
+ * Returns resolved annotation or null if resolution failed.
+ * If the cause parameter is not null, resolution error is assigned to it for upstream processing;
+ * otherwise the error is raised.
+ * In case of errors other than resolving failure, the error is raised, 
+ * null is returned and cause is unchanged
+ *
+ * @param jenv - JNI interface 
+ * @param antn - the annotation to be resolved
+ * @param clss - an "owner" class, which is annotated or whose member is annotated
+ * @param cause - out-parameter to return resolution failure (if any)
+ * @return - resolved annotation or null if resolution failed
+ */
 jobject resolve_annotation(JNIEnv* jenv, Annotation* antn, Class* clss, jthrowable* cause
= NULL);
 
-// Returns resolved annotation value or null if resolution failed.
-// In case of a resolution failure, the error is assigned to the "cause" parameter 
-// for upstream processing.
-// In case of errors other than resolving failure, the error is raised, 
-// null is returned and cause is unchanged
-jobject resolve_annotation_value(JNIEnv* jenv, AnnotationValue& antn, Class* antn_clss,

+/**
+ * Returns resolved annotation value or null if resolution failed.
+ * In case of a resolution failure, the error is assigned to the "cause" parameter 
+ * for upstream processing.
+ * In case of errors other than resolving failure, the error is raised, 
+ * null is returned and cause is unchanged
+ *
+ * @param jenv - JNI interface pointer
+ * @param clss - an "owner" class, which is annotated or whose member is annotated
+ * @param antn - the value to be resolved
+ * @param antn_clss - annotation type
+ * @param name - the name of an annotation member which holds the value
+ * @param cause - out-parameter to return resolution failure (if any)
+ * @return - resolved annotation value or null if resolution failed
+ */
+jobject resolve_annotation_value(JNIEnv* jenv, Class* clss, AnnotationValue& antn, Class*
antn_clss, 
                                  String* name, jthrowable* cause);
 
 #endif // !_ANNOTATIONS_H_

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_vm_VMGenericsAndAnnotations.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_vm_VMGenericsAndAnnotations.cpp?rev=598227&r1=598226&r2=598227&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_vm_VMGenericsAndAnnotations.cpp
(original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_vm_VMGenericsAndAnnotations.cpp
Mon Nov 26 03:15:44 2007
@@ -166,7 +166,7 @@
         Class* antn_class = method->get_class();
         jthrowable error = NULL;
         // FIXME need to clarify against JSR-175 spec which exception should be raised
-        jobject jval = resolve_annotation_value(jenv, *value, antn_class, 
+        jobject jval = resolve_annotation_value(jenv, antn_class, *value, antn_class, 
             method->get_name(), &error);
         if (!jval && error) {
             assert(!exn_raised());

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/reflection/annotations.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/reflection/annotations.cpp?rev=598227&r1=598226&r2=598227&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/reflection/annotations.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/reflection/annotations.cpp Mon Nov 26 03:15:44
2007
@@ -182,7 +182,8 @@
             if (name) {
                 jobject element = NULL;
                 jthrowable error = NULL;
-                jobject value = resolve_annotation_value(jenv, antn->elements[i].value,
antn_type, 
+                jobject value = resolve_annotation_value(jenv, clss, 
+                    antn->elements[i].value, antn_type, 
                     antn->elements[i].name, &error);
                 if (value) {
                     element = NewObject(jenv, jelc, element_ctor, name, value);
@@ -239,7 +240,8 @@
     return NULL;
 }
 
-static bool process_array_element(JNIEnv* jenv, AnnotationValue& value, Class* antn_type,

+static bool process_array_element(JNIEnv* jenv, Class* clss, 
+                                  AnnotationValue& value, Class* antn_type, 
                                   String* name, jthrowable* cause, 
                                   jarray array, unsigned idx, Class* type) 
 {
@@ -321,7 +323,7 @@
         }
     default: 
         {
-            jobject jelement = resolve_annotation_value(jenv, value, antn_type, name, cause);
+            jobject jelement = resolve_annotation_value(jenv, clss, value, antn_type, name,
cause);
             if (jelement) {
                 SetObjectArrayElement(jenv, array, idx, jelement);
                 if (exn_raised()) {
@@ -339,7 +341,8 @@
 }
 
 
-jobject resolve_annotation_value(JNIEnv* jenv, AnnotationValue& value, Class* antn_type,

+jobject resolve_annotation_value(JNIEnv* jenv, Class* clss, 
+                                 AnnotationValue& value, Class* antn_type, 
                                  String* name, jthrowable* cause)
 {
     TRACE("Resolving value of tag " << (char)value.tag);
@@ -368,15 +371,15 @@
     case AVT_CLASS: 
         {
             // preserve failure if no Class value found
-            Class* type = field_descriptor_to_type(jenv, value.class_name, antn_type, cause);
+            Class* type = field_descriptor_to_type(jenv, value.class_name, clss, cause);
             return type ? struct_Class_to_java_lang_Class_Handle(type) : NULL;
         }
 
     case AVT_ANNOTN:
-        return resolve_annotation(jenv, value.nested, antn_type, cause);
+        return resolve_annotation(jenv, value.nested, clss, cause);
 
     case AVT_ENUM:
-        return process_enum_value(jenv, value, antn_type, name, cause);
+        return process_enum_value(jenv, value, clss, name, cause);
 
     case AVT_ARRAY:
         {
@@ -419,7 +422,8 @@
             }
 
             for (i = 0; i < value.array.length; ++i) {
-                if (!process_array_element(jenv, value.array.items[i], antn_type, 
+                if (!process_array_element(jenv, clss,
+                    value.array.items[i], antn_type, 
                     name, cause, array, i, arr_type)) 
                 {
                     return NULL;



Mime
View raw message