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

workaround ecj StackOverflowError #104

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
workaround ecj StackOverflowError
AnnotationMirror's hashCode is buggy in ecj, but equals seems to work.
  • Loading branch information
rzpt committed Dec 1, 2022
commit 60e58d1135e8ee8f0473643a3916a26c3022a639
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
package org.derive4j.processor;

import com.squareup.javapoet.ClassName;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
Expand Down Expand Up @@ -191,7 +191,7 @@ public Object visitArray(List<? extends AnnotationValue> vals, Void aVoid) {
}

Optional<P2<TypeElement, DeriveConfig>> findDeriveConfig(TypeElement typeElement) {
return deriveConfigs(typeElement, typeElement, new HashSet<>()).reduce(Function::andThen)
return deriveConfigs(typeElement, typeElement, new ArrayList<>()).reduce(Function::andThen)
.map(customConfig -> P2s.P2(typeElement, customConfig.apply(defaultConfig(typeElement))));
}

Expand All @@ -217,7 +217,7 @@ private Stream<Function<DeriveConfig, DeriveConfig>> annotationConfig(TypeElemen
}

private Stream<Function<DeriveConfig, DeriveConfig>> deriveConfigs(TypeElement typeElement, Element element,
HashSet<AnnotationMirror> seenAnnotations) {
List<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),
Expand Down