Created
May 21, 2019 20:44
-
-
Save christianwimmer/1527b77bfdcad5384a7b461afe39fb31 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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