[Bug libgcj/11779] New: Field reflection incorrectly throws IllegalAccessException

bryce at mckinlay dot net dot nz gcc-bugzilla@gcc.gnu.org
Sun Aug 3 06:03:00 GMT 2003


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11779

           Summary: Field reflection incorrectly throws
                    IllegalAccessException
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libgcj
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bryce at mckinlay dot net dot nz
                CC: gcc-bugs at gcc dot gnu dot org

There appears to be a problem with security checks recently added to reflection code. The 
following test case incorrectly throws IllegalAccessException.

import java.lang.reflect.*;

public class RefTest
{
  int value;

  public static void main(String[] args) 
    throws NoSuchFieldException, IllegalAccessException
  {
    RefTest testObj = new RefTest();
    Field field = RefTest.class.getDeclaredField("value");
    field.setInt(testObj, 777);
  }
}



More information about the Gcc-bugs mailing list