Java Code Examples for io.quarkus.deployment.builditem.nativeimage.ReflectiveHierarchyIgnoreWarningBuildItem

The following examples show how to use io.quarkus.deployment.builditem.nativeimage.ReflectiveHierarchyIgnoreWarningBuildItem. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: kogito-runtimes   Source File: KogitoAssetsProcessor.java    License: Apache License 2.0 5 votes vote down vote up
@BuildStep
public List<ReflectiveHierarchyIgnoreWarningBuildItem> reflectiveDMNREST() {
    List<ReflectiveHierarchyIgnoreWarningBuildItem> result = new ArrayList<>();
    result.add(new ReflectiveHierarchyIgnoreWarningBuildItem(createDotName("org.kie.api.builder.Message$Level")));
    result.add(new ReflectiveHierarchyIgnoreWarningBuildItem(createDotName("org.kie.dmn.api.core.DMNContext")));
    result.add(new ReflectiveHierarchyIgnoreWarningBuildItem(createDotName("org.kie.dmn.api.core.DMNDecisionResult")));
    result.add(new ReflectiveHierarchyIgnoreWarningBuildItem(
            createDotName("org.kie.dmn.api.core.DMNDecisionResult$DecisionEvaluationStatus")));
    result.add(new ReflectiveHierarchyIgnoreWarningBuildItem(createDotName("org.kie.dmn.api.core.DMNMessage")));
    result.add(new ReflectiveHierarchyIgnoreWarningBuildItem(createDotName("org.kie.dmn.api.core.DMNMessage$Severity")));
    result.add(new ReflectiveHierarchyIgnoreWarningBuildItem(createDotName("org.kie.dmn.api.core.DMNMessageType")));
    result.add(
            new ReflectiveHierarchyIgnoreWarningBuildItem(createDotName("org.kie.dmn.api.feel.runtime.events.FEELEvent")));
    return result;
}
 
Example 2
Source Project: quarkus   Source File: SpringWebProcessor.java    License: Apache License 2.0 5 votes vote down vote up
@BuildStep
public void ignoreReflectionHierarchy(BuildProducer<ReflectiveHierarchyIgnoreWarningBuildItem> ignore) {
    ignore.produce(new ReflectiveHierarchyIgnoreWarningBuildItem(
            new ReflectiveHierarchyIgnoreWarningBuildItem.DotNameExclusion(RESPONSE_ENTITY)));
    ignore.produce(
            new ReflectiveHierarchyIgnoreWarningBuildItem(new ReflectiveHierarchyIgnoreWarningBuildItem.DotNameExclusion(
                    DotName.createSimple("org.springframework.util.MimeType"))));
    ignore.produce(
            new ReflectiveHierarchyIgnoreWarningBuildItem(new ReflectiveHierarchyIgnoreWarningBuildItem.DotNameExclusion(
                    DotName.createSimple("org.springframework.util.MultiValueMap"))));
}
 
Example 3
Source Project: quarkus   Source File: KeycloakAdminClientProcessor.java    License: Apache License 2.0 5 votes vote down vote up
@BuildStep
ReflectiveHierarchyIgnoreWarningBuildItem marker(BuildProducer<AdditionalApplicationArchiveMarkerBuildItem> prod) {
    prod.produce(new AdditionalApplicationArchiveMarkerBuildItem("org/keycloak/admin/client/"));
    prod.produce(new AdditionalApplicationArchiveMarkerBuildItem("org/keycloak/representations"));
    return new ReflectiveHierarchyIgnoreWarningBuildItem(new ReflectiveHierarchyIgnoreWarningBuildItem.DotNameExclusion(
            DotName.createSimple(MultivaluedHashMap.class.getName())));
}
 
Example 4
Source Project: quarkus   Source File: ReflectiveHierarchyStep.java    License: Apache License 2.0 5 votes vote down vote up
private void removeIgnored(Map<DotName, Set<String>> unindexedClasses,
        List<ReflectiveHierarchyIgnoreWarningBuildItem> ignored) {
    if (ignored.isEmpty()) {
        return;
    }
    // the final predicate ignores a DotName if and only if at least one of the predicates indicates that warning should be ignored
    Predicate<DotName> finalPredicate = ignored.stream().map(ReflectiveHierarchyIgnoreWarningBuildItem::getPredicate)
            .reduce(x -> false, Predicate::or);
    Set<DotName> unindexedDotNames = new HashSet<>(unindexedClasses.keySet());
    for (DotName unindexedDotName : unindexedDotNames) {
        if (finalPredicate.test(unindexedDotName)) {
            unindexedClasses.remove(unindexedDotName);
        }
    }
}
 
Example 5
@BuildStep
void ignoredOnReflectiveHierarchyRegistration(BuildProducer<ReflectiveHierarchyIgnoreWarningBuildItem> ignored) {
    ignored.produce(new ReflectiveHierarchyIgnoreWarningBuildItem(DOT_NAME_IMMUTABLE_LIST));
    ignored.produce(new ReflectiveHierarchyIgnoreWarningBuildItem(DOT_NAME_IMMUTABLE_MAP));
}
 
Example 6
Source Project: quarkus   Source File: ResteasyQuteProcessor.java    License: Apache License 2.0 4 votes vote down vote up
@BuildStep
ReflectiveHierarchyIgnoreWarningBuildItem ignoreReflectiveWarning() {
    return new ReflectiveHierarchyIgnoreWarningBuildItem(new ReflectiveHierarchyIgnoreWarningBuildItem.DotNameExclusion(
            DotName.createSimple(TemplateInstance.class.getName())));
}
 
Example 7
Source Project: quarkus   Source File: ReflectiveHierarchyStep.java    License: Apache License 2.0 4 votes vote down vote up
@BuildStep
public ReflectiveHierarchyIgnoreWarningBuildItem ignoreJavaClassWarnings() {
    return new ReflectiveHierarchyIgnoreWarningBuildItem(ReflectiveHierarchyBuildItem.IgnoreWhiteListedPredicate.INSTANCE);
}
 
Example 8
Source Project: quarkus   Source File: ReflectiveHierarchyStep.java    License: Apache License 2.0 4 votes vote down vote up
@BuildStep
public void build(CombinedIndexBuildItem combinedIndexBuildItem,
        List<ReflectiveHierarchyBuildItem> hierarchy,
        List<ReflectiveHierarchyIgnoreWarningBuildItem> ignored,
        List<ReflectiveClassFinalFieldsWritablePredicateBuildItem> finalFieldsWritablePredicates,
        BuildProducer<ReflectiveClassBuildItem> reflectiveClass) throws Exception {
    Set<DotName> processedReflectiveHierarchies = new HashSet<>();
    Map<DotName, Set<String>> unindexedClasses = new TreeMap<>();

    Predicate<ClassInfo> finalFieldsWritable = (c) -> false; // no need to make final fields writable by default
    if (!finalFieldsWritablePredicates.isEmpty()) {
        // create a predicate that returns true if any of the predicates says that final fields need to be writable
        finalFieldsWritable = finalFieldsWritablePredicates
                .stream()
                .map(ReflectiveClassFinalFieldsWritablePredicateBuildItem::getPredicate)
                .reduce(c -> false, Predicate::or);
    }

    for (ReflectiveHierarchyBuildItem i : hierarchy) {
        addReflectiveHierarchy(combinedIndexBuildItem,
                i,
                i.hasSource() ? i.getSource() : i.getType().name().toString(),
                i.getType(),
                processedReflectiveHierarchies,
                unindexedClasses,
                finalFieldsWritable, reflectiveClass);
    }

    removeIgnored(unindexedClasses, ignored);

    if (!unindexedClasses.isEmpty()) {
        StringBuilder unindexedClassesWarn = new StringBuilder();
        for (Entry<DotName, Set<String>> unindexedClassEntry : unindexedClasses.entrySet()) {
            if (unindexedClassesWarn.length() != 0) {
                unindexedClassesWarn.append("\n");
            }
            unindexedClassesWarn.append("\t- ").append(unindexedClassEntry.getKey());
            unindexedClassesWarn.append(" (source");
            if (unindexedClassEntry.getValue().size() > 1) {
                unindexedClassesWarn.append("s");
            }
            unindexedClassesWarn.append(": ");
            unindexedClassesWarn.append(String.join(", ", unindexedClassEntry.getValue().toArray(new String[0])));
            unindexedClassesWarn.append(")");
        }
        log.warnf(
                "Unable to properly register the hierarchy of the following classes for reflection as they are not in the Jandex index:%n%s"
                        + "%nConsider adding them to the index either by creating a Jandex index "
                        + "for your dependency via the Maven plugin, an empty META-INF/beans.xml or quarkus.index-dependency properties.\");.",
                unindexedClassesWarn.toString());
    }
}