Odd compilation problem with javac and enumerations
For test purposes, I made three simple classes. Eclipse 3.2 (JDT) compiles them without error or warning. However, when trying to compile these classes with javac, I get the following errors:
/com/test/sub/TestCompile.java:19: cannot find symbol
symbol : class TestInterface
location: class com.test.sub.TestCompile
implements TestInterface
^
/com/test/sub/TestCompile.java:15: cannot find symbol
symbol : constructor TestCompileBase(com.test.sub.TestCompile.Constants)
location: class com.test.TestCompileBase
super(ONE);
^
These errors only occur if the TestCompile class is in a different package from the other two. The enumeration also seems to be part of the problem, since the error does not occur if I change the enum into a static nested class. I am using javac version 1.5.0_06 for Mac OS X. Does anyone know what's wrong? The classes are as follows:
// class 1
package com.test;
publicinterface TestInterface
{
public String getOrdinalString();
}
// class 2
package com.test;
publicclass TestCompileBase
{
public TestCompileBase(final TestInterface constant)
{
System.out.println(constant.getOrdinalString());
}
}
// class 3
package com.test.sub;
importstatic com.test.sub.TestCompile.Constants.ONE;
import com.test.TestCompileBase;
import com.test.TestInterface;
publicclass TestCompile
extends TestCompileBase
{
public TestCompile()
{
super(ONE);
}
publicenum Constants
implements TestInterface
{
ONE;
public String getOrdinalString()
{
return String.valueOf(ordinal());
}
}
}
// end test code

