-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regression in playframework/playframework
for access to private static class public members
#21599
Comments
IMHO, this is the correct behavior for public class Main {
public static void main(String[] args) {
RoutingDsl x = null;
for(RoutingDsl.Route route : x.routes) {
System.out.println(route.actionMethod);
}
}
} which results in Main.java:4: error: Route has private access in RoutingDsl
for(RoutingDsl.Route route : x.routes) {
^
1 error So it looks like we got it wrong in Scala 3 until #21362 which is to say, that Edit: The following is closer to the Scala version, but my point remains the same: public class Main {
public static void main(String[] args) {
RoutingDsl x = null;
x.routes.forEach(route -> System.out.println(route.actionMethod));
}
} |
@bracevac I think one could argue both ways. If the However, in the example source code there's no reference to I haven't looked in detail how Scala 2 makes the difference between the two cases, it could even be accidental / a bug. To make an argument for your side, replacing |
I wonder why javac emits the class as public. So it can be instantiated by RoutingDsl? |
I was wrong here, the nested class has default access (package protected). Scala 2 is still correct, Dale and me tried a simpler example: // package p
public class A {
public static B b() { return new B(); }
private static class B {
public String bar() { return "l"; }
}
} object T {
def main(args: Array[String]): Unit = {
println(/* p. */ A.b.bar)
}
} Again, no reference to the private Scala 3.5 compiles the example even when moving A.java to a different package, which is clearly a bug, things then fail at runtime (IllegalAccessError). Overall, I htink enforcing access as current |
Based on Open CB failure in
playframework/playframework
- builds logsCompiler version
3.6.0-RC1-bin-20240915-ad8c21a-NIGHTLY
Bisect points to e7d479f / #21362
Minimized code
Output
Expectation
Should compile. This code does compile in Scala 3.5.0 and lower. It also compiles in Scala 2.12/2.13
The text was updated successfully, but these errors were encountered: