javac throws AssertionError when it compiles the program using Generics(Void) to ReturnType and MethodReference.
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Thu Dec 1 05:26:02 PST 2011
Thanks for the reoprt - I have a fix for this; I will push it later today.
Maurizio
On 01/12/11 01:16, 苦狐 wrote:
> Hi.
>
> javac(version-1.8.0-ea(lambda-8-b1314-windows-x64-10_nov_2011)) throws
> AssertionError when it compiles the program using Generics(Void) to
> ReturnType and MethodReference.
>
> This is the test case.
>
> // vvvvvvvvvvvvv Code vvvvvvvvvvvvv
>
> import java.io.PrintStream;
>
> public class Main
> {
> interface Functional
> {
> public void invoke();
> }
>
> interface Functionl0<RET>
> {
> public RET invoke();
> }
>
> interface Functional1<RET, ARG1>
> {
> public RET invoke(ARG1 arg1);
> }
>
> public static void staticTest_void()
> {
> System.out.println("HelloWorld");
> }
>
> public void test_void()
> {
> System.out.println("HelloWorld");
> }
>
> public static void main(String[] args)
> {
> Functional f0 = () ->
> System.out.println("HelloWorld"); // OK
> Functional f1 =
> Main#staticTest_void(); // OK
>
> Functional0<Void> f2 = () ->
> System.out.println("HelloWorld"); // OK
> Functional0<Void> f3 =
> Main#staticTest_void; // throws AssertionError
> Functional0<Void> f4 = () ->
> Main.staticTest_void(); // OK
>
> Functional1<Void, String> f5 = s ->
> System.out.println(s); // OK
> Functional1<Void, String> f6 =
> System.out#println; // throws AssertionError
> Functional1<PrintStream, String> f7 =
> System.out#printf; // OK
>
> Functional1<Void, Main> f8 =
> Main#test_void; // throws AssertionError
>
> Functional f9 = new
> Main()#test_void; // OK
> Functional0<Void> f10 = new
> Main()#test_void; // throws AssertionError
> }
> }
>
> // ^^^^^^^^^^^^^ Code ^^^^^^^^^^^^^
>
> This problem is like "Javac crashes when SAM converting method reference".(
> http://mail.openjdk.java.net/pipermail/lambda-dev/2011-November/004185.html)
> And it was fixed by "hg: lambda/lambda/langtools: Bug fixes".(
> http://mail.openjdk.java.net/pipermail/lambda-dev/2011-November/004252.html)
> So this problem might already be fixed together with that.
> Please check this.
>
> This is the Message from javac, and the StackTrace.
>
> ==========================================================================================
> コンパイラで例外が発生しました(1.8.0-ea)。Bug Paradeに同じバグが登録されていない
> ことをご確認の上、Java Developer Connection(http://java.sun.com/webapps/bugrepor
> t)でバグの登録をお願いいたします。レポートには、そのプログラムと下記の診断内容を
> 含めてください。ご協力ありがとうございます。
> java.lang.AssertionError
> at com.sun.tools.javac.jvm.Items$Item.load(Items.java:206)
> at com.sun.tools.javac.jvm.Items$Item.coerce(Items.java:254)
> at com.sun.tools.javac.jvm.Items$Item.coerce(Items.java:273)
> at com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:844)
> at com.sun.tools.javac.jvm.Gen.visitReturn(Gen.java:1669)
> at com.sun.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1266)
> at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:689)
> at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:724)
> at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:710)
> at com.sun.tools.javac.jvm.Gen.genStats(Gen.java:761)
> at com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:1040)
> at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:792)
> at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:689)
> at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:724)
> at com.sun.tools.javac.jvm.Gen.genMethod(Gen.java:918)
> at com.sun.tools.javac.jvm.Gen.visitMethodDef(Gen.java:890)
> at
> com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:676)
> at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:689)
> at com.sun.tools.javac.jvm.Gen.genClass(Gen.java:2256)
> at
> com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:727)
> at
> com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1466)
> at
> com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1434)
> at
> com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:885)
> at
> com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:844)
> at com.sun.tools.javac.main.Main.compile(Main.java:430)
> at com.sun.tools.javac.main.Main.compile(Main.java:344)
> at com.sun.tools.javac.main.Main.compile(Main.java:335)
> at com.sun.tools.javac.Main.compile(Main.java:76)
> at com.sun.tools.javac.Main.main(Main.java:61)
> ==========================================================================================
>
> Thanks.
> bitter_fox
>
More information about the lambda-dev
mailing list