[Bug libgcj/35253] New: reflection on annotation objects throws IllegalAccessException
marcus at better dot se
gcc-bugzilla@gcc.gnu.org
Tue Feb 19 14:40:00 GMT 2008
The following test program throws an IllegalAccessException with gij,
but works with Sun Java.
~$ gij InvokeAnnotationMethod
Exception in thread "main" java.lang.IllegalAccessException
at java.lang.reflect.Method.invoke(libgcj.so.90)
at test.Helper.invoke(Helper.java:11)
at InvokeAnnotationMethod.main(InvokeAnnotationMethod.java:11)
~$ java InvokeAnnotationMethod
~$ java -version
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) 64-Bit Server VM (build 1.6.0-b105, mixed mode)
The odd thing is that if the test.Helper class below is moved up to
the default package, the program works. So there seems to be some
reflection bug.
Report forwarded from Debian:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=466538
------------------------- file InvokeAnnotationMethod.java ----------------
import java.lang.annotation.*;
import test.Helper;
public class InvokeAnnotationMethod
{
public static void main(String[] args)
throws Exception
{
Annotation ann = Inner.class.getAnnotation(Ann.class);
new Helper().invoke(ann);
}
@Retention(RetentionPolicy.RUNTIME)
public @interface Ann {
public int param() default 0;
}
@Ann
public class Inner
{
}
}
-------------------------------------------------------
------------------------- file test/Helper.java ----------------
package test;
import java.lang.reflect.Method;
public class Helper
{
public void invoke(Object a)
throws Exception
{
Method m = a.getClass().getMethod("param", new Class[0]);
m.invoke(a, new Object[0]);
}
}
--
Summary: reflection on annotation objects throws
IllegalAccessException
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libgcj
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: marcus at better dot se
GCC build triplet: x86_64-linux-gnu
GCC host triplet: x86_64-linux-gnu
GCC target triplet: x86_64-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35253
More information about the Java-prs
mailing list