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

Log warning when doing bytecode analysis #529

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
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
Loading