Skip to content

Instantly share code, notes, and snippets.

@luan-cestari
Created April 16, 2014 16:23
Show Gist options
  • Save luan-cestari/10902332 to your computer and use it in GitHub Desktop.
Save luan-cestari/10902332 to your computer and use it in GitHub Desktop.
Testing parameter getName (for bug/enhancement)
import java.util.Map;
import java.util.function.Function;
import java.lang.reflect.Parameter;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.TreeMap;
import java.util.Date;
public class Test {
public static void main(String[] args) {
final Method m;
try {
m = Test.class.getDeclaredMethod("methodName", Integer.class);
} catch (NoSuchMethodException nsme ) { throw new RuntimeException(nsme); }
final Parameter p = m.getParameters()[0];
final String key = p.getName();
System.out.println(key);
}
public void methodName(Integer parameterName){}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment