diff --git a/graalvm-hint-annotations/src/main/java/io/goodforgod/graalvm/hint/annotation/NativeImageOptions.java b/graalvm-hint-annotations/src/main/java/io/goodforgod/graalvm/hint/annotation/NativeImageOptions.java index 7abda25..1fad983 100644 --- a/graalvm-hint-annotations/src/main/java/io/goodforgod/graalvm/hint/annotation/NativeImageOptions.java +++ b/graalvm-hint-annotations/src/main/java/io/goodforgod/graalvm/hint/annotation/NativeImageOptions.java @@ -33,9 +33,13 @@ public enum NativeImageOptions { ENABLE_URL_PROTOCOLS("--enable-url-protocols"), ALLOW_INCOMPLETE_CLASSPATH("--allow-incomplete-classpath"), REPORT_UNSUPPORTED("--report-unsupported-elements-at-runtime"), + EXIT_HANDLERS("--install-exit-handlers"), + STATIC("--static"), + STATIC_WITH_DYNAMIC("-H:+StaticExecutableWithDynamicLibC"), QUICK_BUILD("-Ob"), MAX_COMPATIBILITY("-march=compatibility"), MAX_PERFORMANCE("-march=native"), + UNLOCK_EXPERIMENTAL("-H:+UnlockExperimentalVMOptions"), BUILD_REPORT("-H:+BuildReport"), USE_LLVM("-H:CompilerBackend=llvm"), INLINE_BEFORE_ANALYSIS("-H:+InlineBeforeAnalysis"), diff --git a/graalvm-hint-processor/src/main/java/io/goodforgod/graalvm/hint/processor/AbstractAccessHintProcessor.java b/graalvm-hint-processor/src/main/java/io/goodforgod/graalvm/hint/processor/AbstractAccessHintProcessor.java index 207898f..47dfc82 100644 --- a/graalvm-hint-processor/src/main/java/io/goodforgod/graalvm/hint/processor/AbstractAccessHintProcessor.java +++ b/graalvm-hint-processor/src/main/java/io/goodforgod/graalvm/hint/processor/AbstractAccessHintProcessor.java @@ -62,7 +62,7 @@ public int hashCode() { protected abstract String getFileName(); - protected abstract Collection getGraalAccessForAnnotatedElement(TypeElement element); + protected abstract List getAccessForElement(TypeElement element); protected Set getAnnotatedTypeElements(RoundEnvironment roundEnv) { final Class[] classes = getSupportedAnnotations().toArray(Class[]::new); @@ -77,16 +77,26 @@ public boolean process(Set annotations, RoundEnvironment try { final Set types = getAnnotatedTypeElements(roundEnv); - final List accesses = types.stream() - .flatMap(element -> getGraalAccessForAnnotatedElement(element).stream()) - .distinct() - .sorted() - .collect(Collectors.toList()); - - final String configJson = getAccessConfigJson(accesses); - final HintOrigin origin = HintUtils.getHintOrigin(roundEnv, processingEnv); - final HintFile file = origin.getFileWithRelativePath(getFileName()); - return HintUtils.writeConfigFile(file, configJson, processingEnv); + + final Map> accessHints = new HashMap<>(); + for (TypeElement type : types) { + final List typeAccesses = getAccessForElement(type); + if (!typeAccesses.isEmpty()) { + final HintOrigin origin = HintUtils.getHintOrigin(type, processingEnv); + final Set accesses = accessHints.computeIfAbsent(origin, k -> new LinkedHashSet<>()); + accesses.addAll(typeAccesses); + } + } + + for (var entry : accessHints.entrySet()) { + final String configJson = getAccessConfigJson(entry.getValue()); + final HintFile file = entry.getKey().getFileWithRelativePath(getFileName()); + if (!HintUtils.writeConfigFile(file, configJson, processingEnv)) { + return false; + } + } + + return true; } catch (Exception e) { processingEnv.getMessager().printMessage(Diagnostic.Kind.WARNING, e.getMessage()); e.printStackTrace(); diff --git a/graalvm-hint-processor/src/main/java/io/goodforgod/graalvm/hint/processor/AbstractHintProcessor.java b/graalvm-hint-processor/src/main/java/io/goodforgod/graalvm/hint/processor/AbstractHintProcessor.java index a451bbb..1e46f67 100644 --- a/graalvm-hint-processor/src/main/java/io/goodforgod/graalvm/hint/processor/AbstractHintProcessor.java +++ b/graalvm-hint-processor/src/main/java/io/goodforgod/graalvm/hint/processor/AbstractHintProcessor.java @@ -29,14 +29,14 @@ public Set getSupportedOptions() { @Override public SourceVersion getSupportedSourceVersion() { SourceVersion sourceVersion = SourceVersion.latest(); - if (sourceVersion.ordinal() <= 19) { + if (sourceVersion.ordinal() <= 22) { if (sourceVersion.ordinal() >= 11) { return sourceVersion; } else { return SourceVersion.RELEASE_11; } } else { - return SourceVersion.values()[19]; + return SourceVersion.values()[22]; } } } diff --git a/graalvm-hint-processor/src/main/java/io/goodforgod/graalvm/hint/processor/DynamicProxyHintParser.java b/graalvm-hint-processor/src/main/java/io/goodforgod/graalvm/hint/processor/DynamicProxyHintParser.java index 77a1644..c64db43 100644 --- a/graalvm-hint-processor/src/main/java/io/goodforgod/graalvm/hint/processor/DynamicProxyHintParser.java +++ b/graalvm-hint-processor/src/main/java/io/goodforgod/graalvm/hint/processor/DynamicProxyHintParser.java @@ -16,7 +16,6 @@ * * @author Anton Kurako (GoodforGod) * @see DynamicProxyHint - * @author Anton Kurako (GoodforGod) * @since 07.04.2022 */ final class DynamicProxyHintParser implements OptionParser { @@ -34,59 +33,74 @@ public List getInterfaces() { } } + private static final class DynamicProxy { + + private final List resources = new ArrayList<>(); + private final List files = new ArrayList<>(); + private final List configurations = new ArrayList<>(); + } + @Override public List> getSupportedAnnotations() { return List.of(DynamicProxyHint.class); } @Override - public List getOptions(RoundEnvironment roundEnv, ProcessingEnvironment processingEnv) { + public List