Javac crashes when SAM converting method reference

Tomasz Kowalczewski tomasz.kowalczewski at gmail.com
Tue Nov 15 03:03:39 PST 2011


When using latest prototype (both from hg repo and the one available
at http://jdk8.java.net/lambda/) following:

import java.util.concurrent.Callable;

public class IntOrInteger {
	public static int returnOne() {
		return 1;
	}

	public static void main(String[] args) {
		Callable<Integer> callable = IntOrInteger#returnOne;
	}
}

produces:

java.lang.ArrayIndexOutOfBoundsException: -1
	at com.sun.tools.javac.jvm.Code$State.pop(Code.java:1725)
	at com.sun.tools.javac.jvm.Code.emitop0(Code.java:661)
	at com.sun.tools.javac.jvm.Items$Item.coerce(Items.java:260)
	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)

When I change return type of returnOne to Integer it will compile and
work as expected.
Hope that this bug report helps. Is there a bug database for lambda
that I can check in the future to make sure it is not a known bug?

-- 
Tomasz Kowalczewski


More information about the lambda-dev mailing list