Skip to content

Instantly share code, notes, and snippets.

@christianwimmer
Created May 21, 2019 20:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christianwimmer/1527b77bfdcad5384a7b461afe39fb31 to your computer and use it in GitHub Desktop.
Save christianwimmer/1527b77bfdcad5384a7b461afe39fb31 to your computer and use it in GitHub Desktop.
public class HelloReflection {
public static void foo() {
System.out.println("Running foo");
}
public static void bar() {
System.out.println("Running bar");
}
public static void main(String[] args) {
for (String arg : args) {
try {
HelloReflection.class.getMethod(arg).invoke(null);
} catch (ReflectiveOperationException ex) {
System.out.println("Exception running " + arg + ": " + ex.getClass().getSimpleName());
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment