compiles well with eclipse but not with javac
Hello.
I am using Windows XP and eclipse 3.0.2.
I have j2sdk-1_4_2_07-windows also.
I built class files from the code below with eclipse.
On jre, It silently runs and exits as expected.
But when compiled with javac, It does not.
It dumps a stack trace.
Which compiler is right?
publicclass ANullPointerException{
private Object o =new Object();
private Sub sub =new Sub();
privateabstractstaticclass Super{
protectedabstract Object access();
private Super(){
access();
}
}
privateclass Subextends Super{
protected Object access(){
return o;
}
}
publicstaticvoid main(String[] args){
new ANullPointerException();
}
}
the stack trace was as below
java.lang.NullPointerException
at ANullPointerException.access$200(ANullPointerException.java:1)
at ANullPointerException$Sub.access(ANullPointerException.java:15)
at ANullPointerException$Super.<init>(ANullPointerException.java:9)
at ANullPointerException$Super.<init>(ANullPointerException.java:5)
at ANullPointerException$Sub.<init>(ANullPointerException.java:13)
at ANullPointerException$Sub.<init>(ANullPointerException.java:13)
at ANullPointerException.<init>(ANullPointerException.java:3)
at ANullPointerException.main(ANullPointerException.java:20)
Exception in thread"main"
I found 3 class files built by eclipse. They were
ANullPointerException$Sub.class,
ANullPointerException$Super.class and
ANullPointerException.class.
No missing or extra files found, I think.
But I found 4 class files built by javac. They were
ANullPointerException$1.class,
ANullPointerException$Sub.class,
ANullPointerException$Super.class and
ANullPointerException.class.
I do not know why ANullPointerException$1.class is needed.
Thank you in advance.

