The "Flexible Constructor Bodies" implementation generates an (incorrect) error for a rare case where a user supplied java.lang.Object class is compiled.
Consider the attached Object.java file. When compiling with `-source 8`, till Java 21, this compiles fine:
$JDK21_HOME/bin/javac -source 8 /tmp/Object.java
warning: [options] bootstrap class path not set in conjunction with -source 8
warning: [options] source value 8 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
3 warnings
echo $?
0
However, starting Java 22 (including Java 25 and current mainline) it generates the following (incorrect) error:
$JAVA25_HOME/bin/javac -source 8 /tmp/Object.java
...
/tmp/Object.java:9: error: flexible constructors is not supported in -source 8
x = 0;
^
(use -source 25 or higher to enable flexible constructors)
1 error
3 warnings
echo $?
1
Consider the attached Object.java file. When compiling with `-source 8`, till Java 21, this compiles fine:
$JDK21_HOME/bin/javac -source 8 /tmp/Object.java
warning: [options] bootstrap class path not set in conjunction with -source 8
warning: [options] source value 8 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
3 warnings
echo $?
0
However, starting Java 22 (including Java 25 and current mainline) it generates the following (incorrect) error:
$JAVA25_HOME/bin/javac -source 8 /tmp/Object.java
...
/tmp/Object.java:9: error: flexible constructors is not supported in -source 8
x = 0;
^
(use -source 25 or higher to enable flexible constructors)
1 error
3 warnings
echo $?
1
- relates to
-
JDK-8344703 Compiler Implementation for Flexible Constructor Bodies
-
- Resolved
-
- links to
-
Commit(master) openjdk/jdk/1934bd8d
-
Review(master) openjdk/jdk/26158