From d994f262142137052d9ad21fad6bfd42f6090bb8 Mon Sep 17 00:00:00 2001 From: comp500 Date: Mon, 8 Jun 2020 22:16:31 +0100 Subject: [PATCH] Fix classloading issues Fixes 1.16 loading from 1.15.2 --- build.gradle | 2 +- gradle.properties | 2 +- .../java/link/infra/jumploader/Jumploader.java | 2 +- .../jumploader/JumploaderClassLoader.java | 18 +++++++++++++++++- src/main/resources/fabric.mod.json | 2 +- 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index 9469902..101d5ed 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle' apply plugin: 'eclipse' apply plugin: 'maven-publish' -version = '1.0.6' +version = '1.0.7' group = 'link.infra.jumploader' // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = 'jumploader' diff --git a/gradle.properties b/gradle.properties index 1fa6a22..7772d76 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ modGroup=link.infra.jumploader -modVersion=1.0.6 +modVersion=1.0.7 modBaseName=jumploader diff --git a/src/main/java/link/infra/jumploader/Jumploader.java b/src/main/java/link/infra/jumploader/Jumploader.java index af5498a..2d19712 100644 --- a/src/main/java/link/infra/jumploader/Jumploader.java +++ b/src/main/java/link/infra/jumploader/Jumploader.java @@ -35,7 +35,7 @@ import java.util.Set; public class Jumploader implements ITransformationService { - public static final String VERSION = "1.0.6"; + public static final String VERSION = "1.0.7"; public static final String USER_AGENT = "Jumploader/" + VERSION; private final Logger LOGGER = LogManager.getLogger(); diff --git a/src/main/java/link/infra/jumploader/JumploaderClassLoader.java b/src/main/java/link/infra/jumploader/JumploaderClassLoader.java index e03d455..95849be 100644 --- a/src/main/java/link/infra/jumploader/JumploaderClassLoader.java +++ b/src/main/java/link/infra/jumploader/JumploaderClassLoader.java @@ -64,6 +64,22 @@ protected Class loadClass(String name, boolean resolve) throws ClassNotFoundE } } } - return super.loadClass(name, resolve); + // Prioritise classes from self to parent classloader + synchronized (getClassLoadingLock(name)) { + Class c = findLoadedClass(name); + if (c == null) { + try { + // Try to find from self + c = findClass(name); + } catch (ClassNotFoundException e) { + // If it failed, try the parent classloader + return super.loadClass(name, resolve); + } + } + if (resolve) { + resolveClass(c); + } + return c; + } } } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index bfea353..2c796ca 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, "id": "jumploader", - "version": "1.0.6", + "version": "1.0.7", "name": "Jumploader", "description": "Allows the use of Fabric mods in Twitch modpacks, by loading Fabric as if it were a Forge mod.",