Consider a project test-b containing one file, B.java:
package test;
public class B {}
Consider another project, test-a, containing two files, Main.java:
package test;
public class Main {
public static void main(String[] args) {
B b = new B();
}
}
and A.java:
package test;
public class A {
public class B {}
}
test-b is referenced in the classpath of test-a, and consequently the main method compiles happily with B b resolving to the class defined in test-b/B.java.
However, if I switch class A to be a record as follows, things break down:
package test;
public record A() {
public class B {
}
}
the main method no longer compiles, claiming that B cannot be resolved to a type.
Eclipse suggests to Import 'B' (test) when triggering quickfixes on the B b = new B() declaration, but this has no effect (as B should already have package visibility).
Going to declarations opens record A.
If I modify the Order and Export settings so that test-b comes before test-a/src in the Java build path, then things fall back into place. Same if I rename the inner class test-a/A.B to test-a/A.C.
Consider a project
test-b
containing one file,B.java
:Consider another project,
test-a
, containing two files,Main.java
:and
A.java
:test-b
is referenced in the classpath oftest-a
, and consequently themain
method compiles happily withB b
resolving to the class defined intest-b/B.java
.However, if I switch class A to be a record as follows, things break down:
B cannot be resolved to a type
.Import 'B' (test)
when triggering quickfixes on theB b = new B()
declaration, but this has no effect (as B should already have package visibility).A
.test-b
comes beforetest-a/src
in the Java build path, then things fall back into place. Same if I rename the inner classtest-a/A.B
totest-a/A.C
.