Possible bug in the compiler
Andrej Golovnin
andrej.golovnin at gmail.com
Fri Sep 7 08:45:38 UTC 2018
Hi all,
I'm in the process to migrate our product to Java 11.
When I try to compile our product using javac from OpenJDK 11 (build 11+28),
then the compiler stops at some point with the following exception:
compiler message file broken: key=compiler.misc.msg.bug arguments=11,
{1}, {2}, {3}, {4}, {5}, {6}, {7}
com.sun.tools.javac.code.Types$SignatureGenerator$InvalidSignatureException
at jdk.compiler/com.sun.tools.javac.code.Types$SignatureGenerator.assembleSig(Types.java:5107)
at jdk.compiler/com.sun.tools.javac.comp.LambdaToMethod.typeSig(LambdaToMethod.java:2436)
at jdk.compiler/com.sun.tools.javac.comp.LambdaToMethod$LambdaAnalyzerPreprocessor$LambdaTranslationContext.serializedLambdaDisambiguation(LambdaToMethod.java:2049)
at jdk.compiler/com.sun.tools.javac.comp.LambdaToMethod$LambdaAnalyzerPreprocessor$LambdaTranslationContext.serializedLambdaName(LambdaToMethod.java:2082)
at jdk.compiler/com.sun.tools.javac.comp.LambdaToMethod$LambdaAnalyzerPreprocessor$LambdaTranslationContext.complete(LambdaToMethod.java:2282)
at jdk.compiler/com.sun.tools.javac.comp.LambdaToMethod$LambdaAnalyzerPreprocessor.analyzeLambda(LambdaToMethod.java:1477)
at jdk.compiler/com.sun.tools.javac.comp.LambdaToMethod$LambdaAnalyzerPreprocessor.visitLambda(LambdaToMethod.java:1454)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1807)
at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:70)
at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.visitApply(TreeTranslator.java:280)
at jdk.compiler/com.sun.tools.javac.comp.LambdaToMethod$LambdaAnalyzerPreprocessor.visitApply(LambdaToMethod.java:1337)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1634)
at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.visitExec(TreeTranslator.java:250)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1452)
at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
...
(I can provide the full stack trace when needed.)
Unfortunately I'm not able to create a small example to reproduce this error.
But the code that causes this error looks like this:
public class JDK11CompilerBug {
interface IFilter {
Component getComponent();
}
static class Filter implements IFilter {
@Override
public Component getComponent() {}
}
public Component buildFilter(List<? extends Filter> l, Dialog dialog) {
Panel c = new Panel();
l.stream()
.map(f -> {
Button btn = (Button) f.getComponent();
btn.addActionListener(evt -> {
applyFilter(f);
dialog.setVisible(false);
});
return btn;
})
.forEach(c::add);
return c;
}
private void applyFilter(IFilter f) {}
}
When I remove the call "applyFilter(f);", then the error disappears.
But this is not really helpful.
The real workaround is to add the type to the lambda parameter:
.map((Filter f) -> {}).
When I do so, then the project is compiled without any problem.
The compiler from OpenJDK 10 compiles the project even without this
modifications.
I hope this helps to identify the problem in the compiler.
Please let me know if there are some options that allow to get more
diagnostic informations from the compiler. (FYI: I have already tried
-Xdiags:verbose.
But it doesn't seem to produce any useful information or I'm not able
to find it.)
Best regards,
Andrej Golovnin
More information about the compiler-dev
mailing list