Skip to content

Commit

Permalink
Improve Reflection in GhidrathonScriptProvider (#9)
Browse files Browse the repository at this point in the history
Removes deprecated Java call to newInstance with reflective
instantiations
  • Loading branch information
rchildre3 committed Nov 3, 2022
1 parent b73048f commit 0a54fa1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/main/java/ghidrathon/GhidrathonScriptProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@ public String getExtension() {
public GhidraScript getScriptInstance(ResourceFile sourceFile, PrintWriter writer)
throws ClassNotFoundException, InstantiationException, IllegalAccessException {

Class<?> clazz = Class.forName(GhidrathonScript.class.getName());
GhidraScript script = (GhidraScript) clazz.newInstance();

GhidraScript script;
try {
script = GhidrathonScript.class.getDeclaredConstructor().newInstance();
} catch (ReflectiveOperationException reflectiveOperationException) {
throw new InstantiationException(reflectiveOperationException.getMessage());
}

script.setSourceFile(sourceFile);

return script;
Expand Down

0 comments on commit 0a54fa1

Please sign in to comment.