Skip to content

Commit

Permalink
Reduce deprecation warn logging to one entry per introspected class
Browse files Browse the repository at this point in the history
Closes gh-29563
  • Loading branch information
jhoeller committed Nov 24, 2022
1 parent 8391897 commit cbf25b7
Showing 1 changed file with 5 additions and 6 deletions.
Expand Up @@ -85,12 +85,7 @@ public String[] getParameterNames(Constructor<?> ctor) {
private String[] doGetParameterNames(Executable executable) {
Class<?> declaringClass = executable.getDeclaringClass();
Map<Executable, String[]> map = this.parameterNamesCache.computeIfAbsent(declaringClass, this::inspectClass);
String[] names = (map != NO_DEBUG_INFO_MAP ? map.get(executable) : null);
if (names != null && logger.isWarnEnabled()) {
logger.warn("Using deprecated '-debug' fallback for parameter name resolution. " +
"Compile the affected code with '-parameters' instead: " + executable);
}
return names;
return (map != NO_DEBUG_INFO_MAP ? map.get(executable) : null);
}

/**
Expand All @@ -115,6 +110,10 @@ private Map<Executable, String[]> inspectClass(Class<?> clazz) {
ClassReader classReader = new ClassReader(is);
Map<Executable, String[]> map = new ConcurrentHashMap<>(32);
classReader.accept(new ParameterNameDiscoveringVisitor(clazz, map), 0);
if (logger.isWarnEnabled()) {
logger.warn("Using deprecated '-debug' fallback for parameter name resolution. Compile the " +
"affected code with '-parameters' instead or avoid its introspection: " + clazz.getName());
}
return map;
}
catch (IOException ex) {
Expand Down

0 comments on commit cbf25b7

Please sign in to comment.