Skip to content

Commit

Permalink
Fix parent sourced classes not pulling in nested classes
Browse files Browse the repository at this point in the history
  • Loading branch information
sfPlayer1 committed Dec 10, 2021
1 parent 17385ec commit 5ce7ce7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public final class FabricLoaderImpl extends net.fabricmc.loader.FabricLoader {

public static final int ASM_VERSION = Opcodes.ASM9;

public static final String VERSION = "0.12.10";
public static final String VERSION = "0.12.11";
public static final String MOD_ID = "fabricloader";

public static final String CACHE_DIR_NAME = ".fabric"; // relative to game dir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
import java.nio.file.Path;
import java.security.CodeSource;
import java.security.cert.Certificate;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.jar.Manifest;

Expand Down Expand Up @@ -71,6 +73,7 @@ static class Metadata {
private IMixinTransformer mixinTransformer;
private boolean transformInitialized = false;
private final Map<URL, String[]> allowedPrefixes = new ConcurrentHashMap<>();
private final Set<String> parentSourcedClasses = Collections.newSetFromMap(new ConcurrentHashMap<>());

KnotClassDelegate(boolean isDevelopment, EnvType envType, KnotClassLoaderInterface itf, GameProvider provider) {
this.isDevelopment = isDevelopment;
Expand Down Expand Up @@ -133,9 +136,24 @@ Class<?> tryLoadClass(String name, boolean allowFromParent) throws ClassNotFound
}
}

if (!allowFromParent && !parentSourcedClasses.isEmpty()) {
int pos = name.length();

while ((pos = name.lastIndexOf('$', pos - 1)) > 0) {
if (parentSourcedClasses.contains(name.substring(0, pos))) {
allowFromParent = true;
break;
}
}
}

byte[] input = getPostMixinClassByteArray(name, allowFromParent);
if (input == null) return null;

if (allowFromParent) {
parentSourcedClasses.add(name);
}

KnotClassDelegate.Metadata metadata = getMetadata(name, itf.getResource(LoaderUtil.getClassFileName(name)));

int pkgDelimiterPos = name.lastIndexOf('.');
Expand Down

0 comments on commit 5ce7ce7

Please sign in to comment.