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] Stack overflow in val handler #2358

Closed
shoaniki opened this issue Feb 9, 2020 · 0 comments
Closed

[BUG] Stack overflow in val handler #2358

shoaniki opened this issue Feb 9, 2020 · 0 comments
Assignees
Milestone

Comments

@shoaniki
Copy link

shoaniki commented Feb 9, 2020

Describe the bug
Attempting to use val can cause a stack overflow within Lombok in certain cases.

In the miminal example below, the issue is an interface with a recursive generic type. The problem only arises in this specific case -- many minor changes to the code will bypass it (e.g. changing the method parameter to a raw Thing, or giving it a concrete type such as Thing<Integer>, or changing the interface type to <T extends Comparable<T>> or <T extends Comparable<?>> will all cause the code to compile successfully).

To Reproduce

import lombok.val;

public class Example {
    public void run(Thing<?> thing) {
        val x = thing;
    }
}

interface Thing<T extends Comparable<? super T>> {}

Expected behavior
Lombok infers the type of x as Thing<?>, or emits an informative error if it is unable to handle this case by design.

Version info (please complete the following information):

  • Lombok version 1.18.12 (and all the earlier versions I tried, back to 1.12.2)
  • Platform: javac 1.8.0_211 and javac 11.0.4-ojdkbuild

Additional context
The stack trace I get (for javac 11, Lombok 1.18.12) is:

java.lang.StackOverflowError
    at lombok.javac.JavacResolution.typeToJCTree0(JavacResolution.java:322)
    at lombok.javac.JavacResolution.typeToJCTree(JavacResolution.java:308)
    at lombok.javac.JavacResolution.typeToJCTree0(JavacResolution.java:373)
    at lombok.javac.JavacResolution.typeToJCTree(JavacResolution.java:308)
    at lombok.javac.JavacResolution.typeToJCTree0(JavacResolution.java:366)
    at lombok.javac.JavacResolution.typeToJCTree(JavacResolution.java:308)
    at lombok.javac.JavacResolution.genericsToJCTreeNodes(JavacResolution.java:412)
    at lombok.javac.JavacResolution.typeToJCTree0(JavacResolution.java:402)
    GOTO 10
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

No branches or pull requests

3 participants