Skip to content

Commit

Permalink
Log warning when doing bytecode analysis (#529)
Browse files Browse the repository at this point in the history
  • Loading branch information
basil committed Apr 23, 2024
1 parent f9955b3 commit 2fdf1a5
Showing 1 changed file with 12 additions and 0 deletions.
Expand Up @@ -39,6 +39,10 @@
import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
* An ASM-based implementation of Paranamer. It relies on debug information compiled
Expand All @@ -53,7 +57,10 @@
*/
final class BytecodeReadingParanamer {

private static final ConcurrentMap<String, Object> ALREADY_LOGGED = new ConcurrentHashMap();
private static final String[] EMPTY_NAMES = new String[0];
private static final Logger LOGGER = Logger.getLogger(BytecodeReadingParanamer.class.getName());
private static final Object PLACEHOLDER = new Object();

private static final Map<String, String> primitives = new HashMap<>() {
{
Expand All @@ -69,6 +76,11 @@ final class BytecodeReadingParanamer {
};

static String[] lookupParameterNames(Executable executable) throws IOException {
String genericString = executable.toGenericString();
if (ALREADY_LOGGED.putIfAbsent(genericString, PLACEHOLDER) == null) {
LOGGER.log(Level.WARNING, "Looking up parameter names for {0}; update plugin to a version created with a newer harness", genericString);
}

Class<?>[] types = executable.getParameterTypes();
Class<?> declaringClass = executable.getDeclaringClass();
String name = executable instanceof Constructor ? "<init>" : executable.getName();
Expand Down

0 comments on commit 2fdf1a5

Please sign in to comment.