Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] @Getter(lazy = true) in jdk11 compile error #3448

Closed
liudaomanbu opened this issue Jul 2, 2023 · 1 comment · Fixed by #3482
Closed

[BUG] @Getter(lazy = true) in jdk11 compile error #3448

liudaomanbu opened this issue Jul 2, 2023 · 1 comment · Fixed by #3482

Comments

@liudaomanbu
Copy link

Describe the bug
Executing pre-compile tasks...
Loading Ant configuration...
Running Ant tasks...
Running 'before' tasks
Checking sources
Parsing java... [test]
java: compiler message file broken: key=compiler.misc.msg.bug arguments=11.0.19, {1}, {2}, {3}, {4}, {5}, {6}, {7}
java: java.lang.ClassCastException: class com.sun.tools.javac.tree.JCTree$JCConditional cannot be cast to class com.sun.tools.javac.tree.JCTree$JCMethodInvocation (com.sun.tools.javac.tree.JCTree$JCConditional and com.sun.tools.javac.tree.JCTree$JCMethodInvocation are in module jdk.compiler of loader 'app')
java: at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr$ResolvedMethodType.dup(ArgumentAttr.java:610)
java: at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.processArg(ArgumentAttr.java:240)
java: at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.processArg(ArgumentAttr.java:219)
java: at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.visitConditional(ArgumentAttr.java:255)
java: at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCConditional.accept(JCTree.java:1401)
java: at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.attribArg(ArgumentAttr.java:197)
java: at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:653)
java: at jdk.compiler/com.sun.tools.javac.comp.Attr.attribArgs(Attr.java:751)
java: at jdk.compiler/com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1997)
java: at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1650)
java: at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
java: at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr.attribSpeculative(DeferredAttr.java:501)
java: at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr.attribSpeculative(DeferredAttr.java:488)
java: at jdk.compiler/com.sun.tools.javac.comp.Attr.isBooleanOrNumeric(Attr.java:1629)
java: at jdk.compiler/com.sun.tools.javac.comp.Attr.isBooleanOrNumeric(Attr.java:1625)
java: at jdk.compiler/com.sun.tools.javac.comp.Attr.visitConditional(Attr.java:1588)
java: at jdk.compiler/com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:695)
java: at jdk.compiler/com.sun.tools.javac.comp.Attr.visitVarDef(Attr.java:1174)
java: at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:972)
java: at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:724)
java: at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStats(Attr.java:743)
java: at jdk.compiler/com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1294)
java: at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1036)
java: at jdk.compiler/com.sun.tools.javac.comp.Attr.visitIf(Attr.java:1762)
java: at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCIf.accept(JCTree.java:1437)
java: at jdk.compiler/com.sun.tools.javac.comp.Attr.visitSynchronized(Attr.java:1479)
java: at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCSynchronized.accept(JCTree.java:1293)
java: at jdk.compiler/com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:1098)
java: at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:866)
java: at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4694)
java: at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4585)
java: at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4514)
java: at jdk.compiler/com.sun.tools.javac.comp.Attr.attrib(Attr.java:4459)
java: at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1337)
java: at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:973)
java: at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:104)
java: at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:147)
java: at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100)
java: at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94)
java: at org.jetbrains.jps.javac.JavacMain.compile(JavacMain.java:238)
java: at org.jetbrains.jps.incremental.java.JavaBuilder.lambda$compileJava$2(JavaBuilder.java:514)
java: at org.jetbrains.jps.incremental.java.JavaBuilder.invokeJavac(JavaBuilder.java:560)
java: at org.jetbrains.jps.incremental.java.JavaBuilder.compileJava(JavaBuilder.java:512)
java: at org.jetbrains.jps.incremental.java.JavaBuilder.compile(JavaBuilder.java:355)
java: at org.jetbrains.jps.incremental.java.JavaBuilder.doBuild(JavaBuilder.java:280)
java: at org.jetbrains.jps.incremental.java.JavaBuilder.build(JavaBuilder.java:234)
java: at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1485)
java: at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:1123)
java: at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:1268)
java: at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:1088)
java: at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:854)
java: at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:441)
java: at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:190)
java: at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:132)
java: at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:318)
java: at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:146)
java: at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:218)
java: at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
java: at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
java: at java.base/java.lang.Thread.run(Thread.java:829)
java: Compilation failed: internal java compiler error
Checking dependencies... [test]
Dependency analysis found 0 affected files
Errors occurred while compiling module 'test'
javac 11.0.19 was used to compile java sources
Finished, saving caches...
Compilation failed: errors: 1; warnings: 0
Executing post-compile tasks...
Loading Ant configuration...
Running Ant tasks...
Synchronizing output directories...
2023/7/3 0:18 - Build completed with 1 error and 0 warnings in 1 sec, 259 ms

To Reproduce
`import com.google.common.collect.BoundType;
import com.google.common.collect.Range;
import lombok.Getter;

import java.math.BigInteger;

public class Test {

Range<BigInteger> valueTargetRange;

@Getter(lazy = true)
private final Range<BigInteger> valueTargetLowerRange = true ?
        Range.upTo(valueTargetRange.lowerEndpoint(), valueTargetRange.lowerBoundType() == BoundType.CLOSED ? BoundType.OPEN : BoundType.CLOSED) :
        null;

}
`

pom.xml
`
4.0.0
org.example
lombok-lazy-bug-sample
pom
1.0.0-SNAPSHOT

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>11</java.version>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
    <lombok.version>1.18.28</lombok.version>
    <guava.version>31.1-jre</guava.version>
</properties>
<dependencies>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>${lombok.version}</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>${guava.version}</version>
    </dependency>

</dependencies>

`

Expected behavior
Successful compilation. Code should run as expected.

Version info (please complete the following information):

  • Lombok version:1.18.28
  • jdk:corretto-11.0.19/corretto-17.0.7/openjdk-20.0.1

Additional context
if use jdk1.8,it can compile successful .

@rzwitserloot
Copy link
Collaborator

Duplicate of #3314.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants