Skip to content

Commit

Permalink
Use Class.forName first, then normal call to loadHook
Browse files Browse the repository at this point in the history
  • Loading branch information
LunNova committed Feb 8, 2016
1 parent a6ebf4a commit 578af54
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/main/java/me/nallar/modpatcher/ModPatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ private static void addToCurrentClassLoader() {
invalidClasses.removeIf(ModPatcher::removeModPatcherEntries);
negativeResources.removeIf(ModPatcher::removeModPatcherEntries);

log.trace("Loaded class: " + lcl.findClass("me.nallar.modpatcher.ModPatcherLoadHook"));
log.trace("Loaded class: " + Class.forName(MODPATCHER_PACKAGE + ".ModPatcherLoadHook"));
} else {
Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
method.setAccessible(true);
Expand Down Expand Up @@ -273,10 +273,11 @@ private static void checkClassLoading() {

private static void checkClassLoading(boolean load) {
try {
Class.forName(MODPATCHER_PACKAGE + ".ModPatcherLoadHook");
ModPatcherLoadHook.loadHook(requiredVersion, getModPatcherRelease(), API_VERSION);
} catch (NoClassDefFoundError e) {
} catch (ClassNotFoundException | NoClassDefFoundError e) {
if (!load)
throw e;
throw new Error(e);

loadModPatcher();
}
Expand Down

0 comments on commit 578af54

Please sign in to comment.