Javac error on static methods in interfaces

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Tue Mar 19 03:55:53 PDT 2013


On 18/03/13 20:36, Stephen Colebourne wrote:
> I'm getting a javac error on a static method in an interface:
>
> @FunctionalInterface
> public interface TemporalAdjuster {
>      Temporal adjustInto(Temporal temporal);
>
>      public static TemporalAdjuster firstDayOfMonth() {
>          return (temporal) -> temporal;
>      }
> }
Hi Stephen,
the translation logic for lambdas/method references in static interface 
method is still not working 100%. The problem is that the compiler 
should generate a private static lambda method for that one - but those 
method used to be rejected by the verifier. Robert is working on that 
one with the VM team as we speak.

Maurizio
>
>
> Information:java: An exception has occurred in the compiler
> (1.8.0-internal). Please file a bug at the Java Developer Connection
> (http://java.sun.com/webapps/bugreport)  after checking the Bug Parade
> for duplicates. Include your program and the following diagnostic in
> your report.  Thank you.
> Information:java: java.lang.NullPointerException
> Information:java: 	at com.sun.tools.javac.jvm.Code.emitop0(Code.java:538)
> Information:java: 	at
> com.sun.tools.javac.jvm.Items$SelfItem.load(Items.java:367)
> Information:java: 	at com.sun.tools.javac.jvm.Gen.genArgs(Gen.java:913)
> Information:java: 	at com.sun.tools.javac.jvm.Gen.visitApply(Gen.java:1751)
> Information:java: 	at
> com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1440)
> Information:java: 	at com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:894)
> Information:java: 	at com.sun.tools.javac.jvm.Gen.visitReturn(Gen.java:1719)
> Information:java: 	at
> com.sun.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1359)
> Information:java: 	at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:684)
> Information:java: 	at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:719)
> Information:java: 	at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:705)
> Information:java: 	at com.sun.tools.javac.jvm.Gen.genStats(Gen.java:756)
> Information:java: 	at com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:1094)
> Information:java: 	at
> com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:884)
> Information:java: 	at com.sun.tools.javac.jvm.Gen.genMethod(Gen.java:969)
> Information:java: 	at com.sun.tools.javac.jvm.Gen.visitMethodDef(Gen.java:942)
> Information:java: 	at
> com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:771)
> Information:java: 	at com.sun.tools.javac.jvm.Gen.genClass(Gen.java:2356)
> Information:java: 	at
> com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:753)
> Information:java: 	at
> com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1547)
> Information:java: 	at
> com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1511)
> Information:java: 	at
> com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:909)
> Information:java: 	at
> com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:868)
> Information:java: 	at com.sun.tools.javac.main.Main.compile(Main.java:517)
> Information:java: 	at
> com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
> Information:java: 	at
> com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
> Information:java: 	at
> org.jetbrains.jps.javac.JavacMain.compile(JavacMain.java:144)
> Information:java: 	at
> org.jetbrains.jps.incremental.java.JavaBuilder.compileJava(JavaBuilder.java:319)
> Information:java: 	at
> org.jetbrains.jps.incremental.java.JavaBuilder.compile(JavaBuilder.java:231)
> Information:java: 	at
> org.jetbrains.jps.incremental.java.JavaBuilder.build(JavaBuilder.java:145)
> Information:java: 	at
> org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:963)
> Information:java: 	at
> org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:710)
> Information:java: 	at
> org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:740)
> Information:java: 	at
> org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:673)
> Information:java: 	at
> org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:494)
> Information:java: 	at
> org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:274)
> Information:java: 	at
> org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:164)
> Information:java: 	at
> org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:114)
> Information:java: 	at
> org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:205)
> Information:java: 	at
> org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:102)
> Information:java: 	at
> org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler$1.run(BuildMain.java:107)
> Information:java: 	at
> org.jetbrains.jps.service.impl.SharedThreadPoolImpl$1.run(SharedThreadPoolImpl.java:26)
> Information:java: 	at
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
> Information:java: 	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
> Information:java: 	at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
> Information:java: 	at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
> Information:java: 	at java.lang.Thread.run(Thread.java:722)
> Information:java: Errors occurred while compiling module 'jdk8_310'
> Information:Compilation completed with 1 error and 0 warnings in 3 sec
> Information:1 error
> Information:0 warnings
> Error:java: Compilation failed: internal java compiler error
>
> This is the version of code in
> http://hg.openjdk.java.net/threeten/threeten and sub-repos. (called
> from Intellij, but I doubt that is the issue)
>
> thanks
> Stephen
>



More information about the lambda-dev mailing list