Community
Participate
Working Groups
If u create a class file named Test.java and the file only contains a package level class which name is "Test2". The when you use the class in the same package, the compiler will report "Test2 can not be resovle" such as in file Test.java package mytest; class Test2 { } int file Error.java package mytest; public class Error { public Error() { Test2 test2 = new Test2();//This line will trigger this bug } } When you compile Error.java, the compiler will report Test2 can not be resovle
If you compile Error.java with Test.java on its classpath, then no compiler will have the idea to investigate Test when searching for Test2. Try it with command line compilers and you will see this happening. When using the Java builder, then a full build will throw both files in the compilation loop simultaneously, and then Test2 will be accessible. But if doing an incremental recompilation, then your code is depending on the fact that Test.java got processed before Error.java. Basically, you should not use the secondary type Test2 outside of Test.java, if you do then you are exposed to those issues. Either define Test2 inside Test2.java or move Test2 definition to Error.java as a secondary type.