Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
None
-
None
-
None
-
Patch Available
Description
When AccessibleObject.getDeclaredAnnotations() is called and the annotation class to be returned cannot be loaded, RI just skips that annotation, and Harmony throws exception.
To reproduce, use the following code:
import java.lang.annotation.*;
import java.lang.reflect.*;
import java.net.*;
public class Test {
public static void main(String[] args) {
try
catch (Exception e)
{ e.printStackTrace(System.out); } }
}
@Retention(RetentionPolicy.RUNTIME)
@interface Ann {}
@Ann class Foo {
@Ann int field;
@Ann Foo() {}
@Ann void method() {}
}
If the test is run normally, both RI and Harmony produce the same result, but if Ann.class file is REMOVED, the output becomes different.
Output on RI and Harmony with Ann.class present:
SUCCESS: 1 1 1
Output on RI with Ann.class removed:
SUCCESS: 0 0 0
Output on Harmony with Ann.class removed:
java.lang.TypeNotPresentException: Type Ann not present
at org.apache.harmony.vm.VMGenericsAndAnnotations.getDeclaredAnnotations(VMGenericsAndAnnotations.java)
at java.lang.reflect.Field$FieldData.getAnnotations(Field.java:457)
at java.lang.reflect.Field.getDeclaredAnnotations(Field.java:42)
at Test.main(Test.java:11)
Caused by: java.lang.NoClassDefFoundError: Ann
at org.apache.harmony.vm.VMGenericsAndAnnotations.getDeclaredAnnotations(VMGenericsAndAnnotations.java)
... 3 more
Caused by: java.lang.ClassNotFoundException: Ann
at java.net.URLClassLoader.findClass(URLClassLoader.java:894)
at java.lang.ClassLoader.loadClass(ClassLoader.java:575)
at java.lang.ClassLoader$SystemClassLoader.loadClass(ClassLoader.java:963)
at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
at org.apache.harmony.vm.VMGenericsAndAnnotations.getDeclaredAnnotations(VMGenericsAndAnnotations.java)
... 3 more
This issue prevents Apache Geronimo 2.0 from starting on Harmony.
Attachments
Attachments
Issue Links
- is related to
-
HARMONY-5005 [drlvm][kernel][geronimo] Field.getGenericType() fails on a parametrized class from custom classloader
- Closed
- relates to
-
HARMONY-5180 [drlvm][kernel][geronimo] Annotations get loaded with wrong classloader
- Closed
-
HARMONY-5622 [drlvm][kernel][geronimo] Method.getGeneric*() methods throw NPE for parametrized interface methods
- Closed