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

The following examples show how to use io.quarkus.deployment.builditem.nativeimage.ReflectiveHierarchyIgnoreWarningBuildItem. 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 File: KogitoAssetsProcessor.java    From kogito-runtimes with 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 File: SpringWebProcessor.java    From quarkus with 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 File: KeycloakAdminClientProcessor.java    From quarkus with 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 File: ReflectiveHierarchyStep.java    From quarkus with 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
Source File: ConsulClientSupportProcessor.java    From camel-quarkus with Apache License 2.0 4 votes vote down vote up
@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 File: ResteasyQuteProcessor.java    From quarkus with 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 File: ReflectiveHierarchyStep.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@BuildStep
public ReflectiveHierarchyIgnoreWarningBuildItem ignoreJavaClassWarnings() {
    return new ReflectiveHierarchyIgnoreWarningBuildItem(ReflectiveHierarchyBuildItem.IgnoreWhiteListedPredicate.INSTANCE);
}
 
Example #8
Source File: ReflectiveHierarchyStep.java    From quarkus with 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());
    }
}