Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
5.0.0-alpha-8
-
None
Description
I have the following program
import java.util.function.*; abstract class Foo { Foo(String x) {} } class Test { public static void main(String[] args) { Function<String, Foo> x = Foo::new; x.apply("d"); } }
Actual behavior
The program compiles but I get the following runtime exception, because I call the constructor of an abstract class.
Exception in thread "main" java.lang.InstantiationException: Foo
at java.base/jdk.internal.misc.Unsafe.allocateInstance(Native Method)
at java.base/java.lang.invoke.DirectMethodHandle.allocateInstance(DirectMethodHandle.java:501)
at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:336)
at Test.ctorRef$main$0(test.groovy)
at Test.main(test.groovy:10)
Expected behavior
The program should have been rejected instead.