-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
16, 25
-
generic
-
generic
ADDITIONAL SYSTEM INFORMATION :
wsl2-ubuntu 22.04
Linux 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
Java Version:
java 21.0.7 2025-04-15 LTS
Java(TM) SE Runtime Environment (build 21.0.7+8-LTS-245)
Java HotSpot(TM) 64-Bit Server VM (build 21.0.7+8-LTS-245, mixed mode, sharing)
Javac Version:
javac 21.0.7
A DESCRIPTION OF THE PROBLEM :
The following test program can be compiled by javac, however, the code is invalid as the local class is used in a static context.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
javac Test.java
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The source code should be rejected as invalid.
ACTUAL -
The source code compiles successfully.
---------- BEGIN SOURCE ----------
public class Test {
public static void main(String[] args) {
class Nest {
public static void main(String[] args) {
Nest outer = new Nest();
}
}
}
}
---------- END SOURCE ----------
wsl2-ubuntu 22.04
Linux 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
Java Version:
java 21.0.7 2025-04-15 LTS
Java(TM) SE Runtime Environment (build 21.0.7+8-LTS-245)
Java HotSpot(TM) 64-Bit Server VM (build 21.0.7+8-LTS-245, mixed mode, sharing)
Javac Version:
javac 21.0.7
A DESCRIPTION OF THE PROBLEM :
The following test program can be compiled by javac, however, the code is invalid as the local class is used in a static context.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
javac Test.java
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The source code should be rejected as invalid.
ACTUAL -
The source code compiles successfully.
---------- BEGIN SOURCE ----------
public class Test {
public static void main(String[] args) {
class Nest {
public static void main(String[] args) {
Nest outer = new Nest();
}
}
}
}
---------- END SOURCE ----------
- caused by
-
JDK-8254105 allow static nested declarations
-
- Resolved
-