Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4392283

java.lang.reflect.AccessibleObject.setAccessible() broken in merlin B42

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 1.4.0
    • 1.4.0
    • hotspot
    • None
    • beta
    • generic, x86, sparc
    • generic, solaris_2.6, solaris_7, solaris_8

      The java.lang.reflect.AccessibleObject.setAccessible() method appears to be
      broken in merlin promoted build B42 (B41 works properly):

        $ which java
        java is /jini/files/jdk/promoted/1.4/B42/build/sparc/bin/java
        $ cat Bar.java
        import java.lang.reflect.*;
        
        class Gub {
            private void func() { System.out.println("func called"); }
        }
        
        public class Bar {
            public static void main(String[] args) throws Exception {
                Method meth = Gub.class.getDeclaredMethod("func", new Class[0]);
                meth.setAccessible(true);
                meth.invoke(new Gub(), new Object[0]);
            }
        }
        $ javac Bar.java
        $ java Bar
        Exception in thread "main" java.lang.IllegalAccessException
                at java.lang.reflect.Method.invoke(Native Method)
                at Bar.main(Bar.java:11)
        $ setjdk 1.4-B41
        $ which java
        java is /jini/files/jdk/promoted/1.4/B41/build/sparc/bin/java
        $ java Bar
        func called
        $

      The same error occurs for Field objects:

        $ which java
        java is /jini/files/jdk/promoted/1.4/B42/build/sparc/bin/java
        $ cat Foo.java
        import java.lang.reflect.*;
        
        class Baz {
            private int i;
        }
        
        public class Foo {
            public static void main(String[] args) throws Exception {
                Field f = Baz.class.getDeclaredField("i");
                f.setAccessible(true);
                f.getInt(new Baz());
            }
        }
        $ javac Foo.java
        $ java Foo
        Exception in thread "main" java.lang.IllegalAccessException
                at java.lang.reflect.Field.getInt(Native Method)
                at Foo.main(Foo.java:11)
        $ setjdk 1.4-B41
        $ java Foo
        $

            bobv Bob Vandette (Inactive)
            mwarressunw Michael Warres (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: