-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
16, 25
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 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)
A DESCRIPTION OF THE PROBLEM :
When compiling following source code with javac, the compiler will accept the code without any errors:
However, accroding to the Java Language Specification, the character constant is valid.
"For char, from '\u0000' to '\uffff' inclusive, that is, from 0 to 65535."
https://docs.oracle.com/javase/specs/jls/se21/html/jls-4.html#jls-4.2.1
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compiling Test.java using javac.
```
>>>javac Test.java
```
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
javac should reject the test program with a compilation error.
ACTUAL -
javac accept the test program without any errors and generates an executable file.
---------- BEGIN SOURCE ----------
public class Test {
public static void main(String[] args) {
char text = '\uD83D\uDE00';
}
}
---------- 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 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)
A DESCRIPTION OF THE PROBLEM :
When compiling following source code with javac, the compiler will accept the code without any errors:
However, accroding to the Java Language Specification, the character constant is valid.
"For char, from '\u0000' to '\uffff' inclusive, that is, from 0 to 65535."
https://docs.oracle.com/javase/specs/jls/se21/html/jls-4.html#jls-4.2.1
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compiling Test.java using javac.
```
>>>javac Test.java
```
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
javac should reject the test program with a compilation error.
ACTUAL -
javac accept the test program without any errors and generates an executable file.
---------- BEGIN SOURCE ----------
public class Test {
public static void main(String[] args) {
char text = '\uD83D\uDE00';
}
}
---------- END SOURCE ----------
- caused by
-
JDK-8254073 Tokenizer improvements (revised)
-
- Resolved
-
- duplicates
-
JDK-8354908 javac mishandles supplementary character in character literal
-
- Resolved
-