Created
July 24, 2017 20:31
-
-
Save dogmatic69/09671ae2a86d1abee81780ba3e6a8d92 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
private Object loadClass(String className, Object arg) { | |
Class classToLoad = null; | |
try { | |
classToLoad = Class.forName(className); | |
} catch (ClassNotFoundException e) { | |
Debugger.out(e); | |
return null; | |
} | |
Class[] types = {Double.TYPE, this.getClass()}; | |
Constructor constructor = null; | |
try { | |
constructor = classToLoad.getConstructor(types); | |
} catch (NoSuchMethodException e) { | |
Debugger.out(e); | |
return null; | |
} | |
Object[] parameters = {arg, this}; | |
Object classInstance = null; | |
try { | |
classInstance = constructor.newInstance(arg); | |
} catch (InvocationTargetException e) { | |
Debugger.out(e); | |
return null; | |
} catch (IllegalAccessException e) { | |
Debugger.out(e); | |
return null; | |
} catch (InstantiationException e) { | |
Debugger.out(e); | |
return null; | |
} | |
return classInstance; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment