[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#466538: gij-4.3: reflection on annotation objects throws IllegalAccessException



Package: gij-4.3
Version: 4.3-20080202-1
Severity: normal

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.

------------------------- 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]);
    }
}
-------------------------------

-- System Information:
Debian Release: lenny/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (500, 'stable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.24-melech (SMP w/2 CPU cores; PREEMPT)
Locale: LANG=sv_SE.UTF-8, LC_CTYPE=sv_SE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages gij-4.3 depends on:
ii  gcj-4.3-base           4.3-20080202-1    The GNU Compiler Collection (gcj b
ii  libc6                  2.7-6             GNU C Library: Shared libraries
ii  libgcc1                1:4.3-20080202-1  GCC support library
ii  libgcj9-0              4.3-20080202-1    Java runtime library for use with 
ii  zlib1g                 1:1.2.3.3.dfsg-11 compression library - runtime

Versions of packages gij-4.3 recommends:
ii  libgcj9-0-awt             4.3-20080202-1 AWT peer runtime libraries for use

-- no debconf information



Reply to: