-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
1.1, 1.1.3, 1.1.4
-
generic, x86, sparc
-
solaris_2.5.1, windows_95
I have
package P
protected class A implements B {
blabla...
}
public interface B {
public void bongo();
}
And then I do the things below outside of package P
B a = somehowGetAHandleOfAnInstanceOfA
Method m = a.getClass().getMethod("bongo", new Class[] {Void.class});
When I do
m.invoke(a, null);
I get a IllegalAccessException.
At least the docs should point out this behavior (so it's at least a docu bug).
I don't know if the behavior is not a bug.
getMethod should work for all methods that A understands.
After all I can do a.bongo(), and reflection should support
everything that can be done directly.
The workaround is
a.getInterfaces() and then look in the interfaces for the right Method instance.
package P
protected class A implements B {
blabla...
}
public interface B {
public void bongo();
}
And then I do the things below outside of package P
B a = somehowGetAHandleOfAnInstanceOfA
Method m = a.getClass().getMethod("bongo", new Class[] {Void.class});
When I do
m.invoke(a, null);
I get a IllegalAccessException.
At least the docs should point out this behavior (so it's at least a docu bug).
I don't know if the behavior is not a bug.
getMethod should work for all methods that A understands.
After all I can do a.bongo(), and reflection should support
everything that can be done directly.
The workaround is
a.getInterfaces() and then look in the interfaces for the right Method instance.
- duplicates
-
JDK-4082806 Erroneous IllegalAccessException on non-public classes
-
- Closed
-
-
JDK-4053619 java.lang.Method.invoke cannot invoke method from non-public inherited class
-
- Closed
-