Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/main/java/cc/irori/hyinit/mixin/HyinitClassLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundE
c = originalLoader.loadClass(name);
} else if (name.startsWith("java.")) {
c = PLATFORM_CLASS_LOADER.loadClass(name);
} else if (isParentDelegated(name)) {
c = originalLoader.loadClass(name);
} else {
c = tryLoadClass(name, false);

Expand Down Expand Up @@ -407,6 +409,18 @@ private Metadata getMetadata(Path sourcePath) {
});
}

private static final Set<String> PARENT_DELEGATED =
Set.of("org.objectweb.asm.", "org.spongepowered.asm.", "com.llamalad7.mixinextras.");

private static boolean isParentDelegated(String name) {
for (String prefix : PARENT_DELEGATED) {
if (name.startsWith(prefix)) {
return true;
}
}
return false;
}

private static final Set<String> TRANSFORM_EXCLUSIONS = Set.of(
"java.",
"javax.",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package cc.irori.hyinit.mixin.impl;

import cc.irori.hyinit.HyinitLogger;
import cc.irori.hyinit.shared.SourceMetaStore;
import cc.irori.hyinit.shared.SourceMetadata;
import cc.irori.hyinit.util.LoaderUtil;
Expand All @@ -25,6 +26,14 @@ public MixinPluginClassLoader(URL[] urls, ClassLoader parent) {
super(urls, parent);
}

@Inject(method = "loadLocalClass", at = @At("HEAD"), cancellable = true)
private void hyinit$guardNullClassName(String name, CallbackInfoReturnable<Class<?>> cir) {
if (name == null) {
HyinitLogger.get().warn("Skipping loadLocalClass with null class name");
cir.setReturnValue(null);
}
}

// OrbisGuard compatibility:
// When the same class is present in both the earlyplugin jar and the mod jar, prioritize the mod's.
// To do this, we need to check the SourceMetadata of the loaded class.
Expand Down