-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
14, 15
ADDITIONAL SYSTEM INFORMATION :
$ uname -a
Linux polaris 5.6.14-arch1-1 #1 SMP PREEMPT Wed, 20 May 2020 20:43:19 +0000 x86_64 GNU/Linux
$ java -version
java -version
openjdk version "14.0.1" 2020-04-14
OpenJDK Runtime Environment AdoptOpenJDK (build 14.0.1+7)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 14.0.1+7, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
When inside a record compact constructor, a method that receives a Supplier is called, the compiler fails with the error "compact constructor must not have return statements", but there's not return statement inside the constructor.
Example:
import java.util.function.Supplier;
public record Bug(int value) {
static void bug(Supplier<String> str) {
System.out.println(str.get());
}
public Bug {
bug(() -> "hello");
}
public static void main(String[] args) {
new Bug(1);
}
}
Compiler output:
Bug.java:9: error: invalid compact constructor in record Bug(int)
public Bug {
^
(compact constructor must not have return statements)
Note: Bug.java uses preview language features.
Note: Recompile with -Xlint:preview for details.
1 error
Also the error can be reproduced using java 15.ea.25.
FREQUENCY : always
$ uname -a
Linux polaris 5.6.14-arch1-1 #1 SMP PREEMPT Wed, 20 May 2020 20:43:19 +0000 x86_64 GNU/Linux
$ java -version
java -version
openjdk version "14.0.1" 2020-04-14
OpenJDK Runtime Environment AdoptOpenJDK (build 14.0.1+7)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 14.0.1+7, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
When inside a record compact constructor, a method that receives a Supplier is called, the compiler fails with the error "compact constructor must not have return statements", but there's not return statement inside the constructor.
Example:
import java.util.function.Supplier;
public record Bug(int value) {
static void bug(Supplier<String> str) {
System.out.println(str.get());
}
public Bug {
bug(() -> "hello");
}
public static void main(String[] args) {
new Bug(1);
}
}
Compiler output:
Bug.java:9: error: invalid compact constructor in record Bug(int)
public Bug {
^
(compact constructor must not have return statements)
Note: Bug.java uses preview language features.
Note: Recompile with -Xlint:preview for details.
1 error
Also the error can be reproduced using java 15.ea.25.
FREQUENCY : always