Exception when access inner class reflectively

Posted by MikeJiang on Stack Overflow See other posts from Stack Overflow or by MikeJiang
Published on 2010-05-26T05:06:18Z Indexed on 2010/05/26 5:11 UTC
Read the original article Hit count: 249

Filed under:
|
|
|

Hi Folk, Here is a sample java program. I wonder why the two approaches reslut different stories. Is it a bug or kind of bitter java feature?

And I run the sample upon java 1.5

package test;

public class TestOut{

public static void main(String[] args){

new TestIn();//it works

Class.forName("test.TestOut$TestIn").newInstance();// throw IllegalAccessException

}

private static class TestIn{}

}

© Stack Overflow or respective owner

Related posts about java

Related posts about reflection