public class SerializationMembers implements Caching {

    private static final Method NO_METHOD = (new Object() {
        private void noMethod() {
        }
    }).getClass().getDeclaredMethods()[0];

}

图片

Comment From: bclozel

Is this failing at runtime in a native image? Given the deterministic nature of this reflection it might be inlined already by GraalVM. This looks like a 3rd party library, have you tried contributing reachability metadata to it?

Comment From: wangliang181230

Have you tried contributing reachability metadata to it?

I only register like this:

try {
    Class<?> clazz = Class.forName("com.thoughtworks.xstream.core.util.SerializationMembers$1");
    hints.reflection().registerType(clazz, MemberCategory.INVOKE_DECLARED_METHODS);
} catch (ClassNotFoundException e) {
    LOGGER.warn("`com.thoughtworks.xstream.core.util.SerializationMembers$1` not found.");
}

But it has no effect, and the log is not printed.

Comment From: bclozel

What do you mean it has no effect? Are you seeing a failure at runtime? Maybe try running your application with the tracing agent to get the proper metadata entry?

In any case, I don't think you should be contributing metadata for xstream using Spring's RuntimeHints API - this should be contributed by the library itself, or the reachability metadata repository. I'm closing this issue as a result.