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

JBoss LoggerProviders Needs Runtime Hints in Native Image #33205

Closed
akefirad opened this issue Nov 15, 2022 · 2 comments
Closed

JBoss LoggerProviders Needs Runtime Hints in Native Image #33205

akefirad opened this issue Nov 15, 2022 · 2 comments
Labels
status: duplicate A duplicate of another issue

Comments

@akefirad
Copy link

JBoss logging framework detection logic is not straightforward and requires some hints to work properly in native images. The following is the minimum I could find:

public class JbossLoggerProvidersHints implements RuntimeHintsRegistrar {

    @Override
    public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
        if (ClassUtils.isPresent("org.jboss.logging.LoggerProviders", classLoader)) {
            registerHints(hints.reflection());
        }
    }

    private void registerHints(ReflectionHints hints) {
        hints.registerMethod(findServiceLoaderLoadMethod(), ExecutableMode.INVOKE);
        hints.registerType(LocationAwareLogger.class, INTROSPECT_DECLARED_METHODS, INVOKE_DECLARED_METHODS);
    }

    private Method findServiceLoaderLoadMethod() {
        return ReflectionUtils.findMethod(ServiceLoader.class, "load", Class.class, ClassLoader.class);
    }

}

This is needed when you add validation starter. Without the above hints, it falls back to JUL.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 15, 2022
@akefirad
Copy link
Author

On that note, I'm not sure if we can fix this during build time, since it's all about the org.jboss.logging.LoggerProviders#PROVIDER final static field.

@wilkinsona
Copy link
Member

Duplicates #33113 and the various issues to which it links.

@wilkinsona wilkinsona closed this as not planned Won't fix, can't repro, duplicate, stale Nov 15, 2022
@wilkinsona wilkinsona added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants