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

StackOverflow in derivingConfig when @Data annotation is used #102

Open
etherandrius opened this issue Jul 2, 2022 · 1 comment
Open

Comments

@etherandrius
Copy link

Issue

Code that overflows here

  private Stream<Function<DeriveConfig, DeriveConfig>> deriveConfigs(TypeElement typeElement, Element element,
      HashSet<AnnotationMirror> seenAnnotations) {
    return element.getAnnotationMirrors().stream().sequential().filter(a -> !seenAnnotations.contains(a)).flatMap(a -> {
      seenAnnotations.add(a);
      return concat(deriveConfigs(typeElement, a.getAnnotationType().asElement(), seenAnnotations),
          annotationConfig(typeElement, a));
    });
  }

In the code above you can see HasSet is used, however AnnotationMirror link does declare hashCode method.

Proof:
image

  • You can see that the seenAnnotations set contains many duplicate values (highlighted in yellow)
  • and; that .hashCode() call on the Retention policy returns a random hashCode every time.

How I found it

Looking at language server logs.
image

Affect

I'm not too familiar with derive4j, take below with a grain of salt:

  • This issue does not affect code gen.
  • I believe the issue leads to miss-configured classPaths
@etherandrius etherandrius changed the title StackOverflow exception when derivingConfig when @Data annotation is used StackOverflow in derivingConfig when @Data annotation is used Jul 2, 2022
@etherandrius
Copy link
Author

Also, this only happens when using eclipse java compiler. Bug does not happen if using javac compiler

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

1 participant