Weird compile issue with inner classes

All,

I am trying to troubleshoot a problem in which code behaves differently (and the *.class files have a few byte's difference) when compiled under IDEA or Ant (from within the same IDEA project). All compiler settings seem to be the same in both places.

I am feeling that IDEA is using a slightly different set of compiler options or compiler version. Is there a way that I can see the output from the compiler used from IDEA?

The test code below prints the following in the two cases:

// Test code
B b = new B();
B.Y y = b.new Y();

//Compiled under IDEA
Enclosing class is null = false

//Compiled under Ant (from within IDEA)
Enclosing class is null = true

Here are some more details which may help:

IDEA version: 4.5
"Run with Ant" option from "Build File Properties" within IDEA: (Bundled Ant) 1.6.1
"Run under JDK" option from "Build File Properties" within IDEA: Project JDK (JDK 1.4.2_05)
"Target JDK" option from "Libraries" tab of "Project Settings" within IDEA: JDK 1.4.2_05
Compiler: javac (in both cases)
Javac options: debug, deprecated, nowarn


Here are the classes in question:

public class A{
public abstract class X{
protected X(){
foo();
}
protected abstract void foo();
}
public void bar(){}
}

public class B extends A{
public class Y extends X{
public void foo(){
System.out.println("Enclosing class is null = " + (B.this == null));
}
}
}

1 comment

Looks like you are hit on this bug: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4030374

Check -target settings in ant script.

0

Please sign in to leave a comment.