Skip to content

Commit 98df868

Browse files
committed
Many small fixes:
- Fix "Found Illegal Access from Minecraft to Quilt Loader" warning for AppletMain on older versions of minecraft from an applet. - Add QuiltPluginContext.pluginOption() to retrieve the original ModLoadOption which the plugin is from. - Improve loaders error handling when plugins fail to load, and the error gui fails to open by including a link to the original crash report (or the crash report text if it failed to save). This is better than before, where the latest crash report would only have an error relating to the error gui. - Fix EntrypointContainer.getDefinition() always returning the empty string. - Add the method "requiresPackageAccessFix" to GameProvider, which is used instead of a blind cast to MappingConfigurationImpl in QuiltTransformer to call it. - Improve QuiltTransformer logic to not skip reflective fixes if no other transform is selected. - Add the system property "loader.transform.kotlin_metadata_remap.disable" to allow disabling the kotlin metadata remapper, as it's a bit buggy at the moment.
1 parent e914db3 commit 98df868

File tree

14 files changed

+92
-17
lines changed

14 files changed

+92
-17
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ group = org.quiltmc
55
description = The mod loading component of Quilt
66
url = https://github.com/quiltmc/quilt-loader
77
# Don't forget to change this in QuiltLoaderImpl as well
8-
quilt_loader = 0.29.0-beta.6
8+
quilt_loader = 0.29.0-beta.7
99

1010
# Fabric & Quilt Libraries
1111
asm = 9.7.1

minecraft/src/main/java/org/quiltmc/loader/impl/game/minecraft/applet/AppletMain.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
import java.io.File;
44

5+
import org.quiltmc.loader.impl.util.QuiltLoaderInternal;
6+
import org.quiltmc.loader.impl.util.QuiltLoaderInternalType;
7+
8+
@QuiltLoaderInternal(QuiltLoaderInternalType.LEGACY_NO_WARN)
59
public final class AppletMain {
610
private AppletMain() { }
711

src/main/java/org/quiltmc/loader/api/plugin/QuiltPluginContext.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ public interface QuiltPluginContext {
5454
* {@link Class#getResource(String)}. */
5555
Path pluginPath();
5656

57+
/** @return The original {@link ModLoadOption} that this plugin is loaded from. */
58+
ModLoadOption pluginOption();
59+
5760
// ##############
5861
// # Operations #
5962
// ##############

src/main/java/org/quiltmc/loader/impl/QuiltLoaderImpl.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public final class QuiltLoaderImpl {
131131

132132
public static final int ASM_VERSION = Opcodes.ASM9;
133133

134-
public static final String VERSION = "0.29.0-beta.6";
134+
public static final String VERSION = "0.29.0-beta.7";
135135
public static final String MOD_ID = "quilt_loader";
136136
public static final String DEFAULT_MODS_DIR = "mods";
137137
public static final String DEFAULT_CACHE_DIR = ".cache";
@@ -728,7 +728,15 @@ private ModSolveResult runPlugins() {
728728
System.exit(1);
729729
throw new Error("System.exit(1) Failed!");
730730
} catch (Exception e) {
731-
throw new Error(e);
731+
if (crashReportFile == null) {
732+
StringBuilder text = new StringBuilder();
733+
text.append("Failed to open the error gui, and also failed to write the original crash report!\n\n");
734+
text.append(fullCrashText);
735+
throw new Error(text.toString(), e);
736+
} else {
737+
throw new Error("Failed to open the error gui - please see the original crash report "
738+
+ crashReportFile, e);
739+
}
732740
}
733741
}
734742

src/main/java/org/quiltmc/loader/impl/entrypoint/EntrypointContainerImpl.java

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,40 @@
2828
public class EntrypointContainerImpl<T> implements EntrypointContainer<T> {
2929
private final ModContainer container;
3030
private final Supplier<T> entrypointSupplier;
31+
private final String definition;
3132
private T instance;
3233

3334
/**
34-
* Create EntrypointContainer with lazy init.
35+
* @deprecated As this version omits the {@link #getDefinition()} field.
3536
*/
37+
@Deprecated
3638
public EntrypointContainerImpl(ModContainer container, Supplier<T> entrypointSupplier) {
39+
this(container, "", entrypointSupplier);
40+
}
41+
42+
/**
43+
* Create EntrypointContainer with lazy init.
44+
*/
45+
public EntrypointContainerImpl(ModContainer container, String definition, Supplier<T> entrypointSupplier) {
3746
this.container = container;
47+
this.definition = definition;
3848
this.entrypointSupplier = entrypointSupplier;
3949
}
4050

4151
/**
42-
* Create EntrypointContainer without lazy init.
52+
* @deprecated As this version omits the {@link #getDefinition()} field.
4353
*/
54+
@Deprecated
4455
public EntrypointContainerImpl(ModContainer container, T instance) {
56+
this(container, "", instance);
57+
}
58+
59+
/**
60+
* Create EntrypointContainer without lazy init.
61+
*/
62+
public EntrypointContainerImpl(ModContainer container, String definition, T instance) {
4563
this.container = container;
64+
this.definition = definition;
4665
this.entrypointSupplier = null;
4766
this.instance = instance;
4867
}
@@ -61,4 +80,9 @@ public synchronized T getEntrypoint() {
6180
public ModContainer getProvider() {
6281
return container;
6382
}
83+
84+
@Override
85+
public String getDefinition() {
86+
return definition;
87+
}
6488
}

src/main/java/org/quiltmc/loader/impl/entrypoint/EntrypointStorage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public <T> List<EntrypointContainer<T>> getEntrypointContainers(String key, Clas
222222
T instance = entry.getOrCreate(type);
223223
if (instance == null) continue;
224224

225-
container = new EntrypointContainerImpl<>(entry.getModContainer(), instance);
225+
container = new EntrypointContainerImpl<>(entry.getModContainer(), entry.getDefinition(), instance);
226226
} catch (Throwable t) {
227227
QuiltEntrypointException e2 = new QuiltEntrypointException(key, entry.getModContainer().metadata().id(), t);
228228
if (exc == null) {
@@ -234,7 +234,7 @@ public <T> List<EntrypointContainer<T>> getEntrypointContainers(String key, Clas
234234
continue;
235235
}
236236
} else {
237-
container = new EntrypointContainerImpl<>(entry.getModContainer(), () -> {
237+
container = new EntrypointContainerImpl<>(entry.getModContainer(), entry.getDefinition(), () -> {
238238
try {
239239
return entry.getOrCreate(type);
240240
} catch (Exception | LinkageError ex) {

src/main/java/org/quiltmc/loader/impl/game/GameProvider.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import org.quiltmc.loader.impl.util.QuiltLoaderInternalType;
2929
import org.quiltmc.loader.impl.entrypoint.GameTransformer;
3030
import org.quiltmc.loader.impl.metadata.qmj.InternalModMetadata;
31-
31+
import org.quiltmc.loader.impl.transformer.PackageAccessFixer;
3232
import org.quiltmc.loader.impl.launch.common.QuiltLauncher;
3333

3434
import org.quiltmc.loader.impl.util.Arguments;
@@ -48,6 +48,19 @@ public interface GameProvider {
4848
* The mapping configuration for the game. Unobfuscated games should use {@link EmptyMappingConfiguration}.
4949
*/
5050
MappingConfiguration getMappingConfiguration();
51+
52+
/** @return True if the game itself (identified by {@link #getGameId()}) should be fully access-widend by
53+
* {@link PackageAccessFixer}. This is normally only useful if your mappings moves classes between packages,
54+
* and doesn't widen private members. */
55+
default boolean requiresPackageAccessFix() {
56+
// Compatibility code - we need this to always run
57+
MappingConfiguration mappingConfig = getMappingConfiguration();
58+
if (mappingConfig instanceof MappingConfigurationImpl) {
59+
return ((MappingConfigurationImpl) mappingConfig).requiresPackageAccessHack();
60+
}
61+
return false;
62+
}
63+
5164
boolean requiresUrlClassLoader();
5265

5366
boolean isEnabled();

src/main/java/org/quiltmc/loader/impl/game/MappingConfiguration.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.quiltmc.loader.impl.util.QuiltLoaderInternalType;
2525

2626
import java.util.List;
27+
2728
@ApiStatus.Experimental
2829
@QuiltLoaderInternal(QuiltLoaderInternalType.LEGACY_EXPOSED) // only accessible to people implementing GameProviders
2930
public interface MappingConfiguration {

src/main/java/org/quiltmc/loader/impl/plugin/BuiltinPluginContext.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.nio.file.Path;
2020

2121
import org.quiltmc.loader.api.plugin.QuiltLoaderPlugin;
22+
import org.quiltmc.loader.api.plugin.solver.ModLoadOption;
2223
import org.quiltmc.loader.impl.util.QuiltLoaderInternal;
2324
import org.quiltmc.loader.impl.util.QuiltLoaderInternalType;
2425

@@ -37,6 +38,11 @@ public Path pluginPath() {
3738
throw new UnsupportedOperationException("Builtin plugins don't support pluginPath()");
3839
}
3940

41+
@Override
42+
public ModLoadOption pluginOption() {
43+
throw new UnsupportedOperationException("Builtin plugins don't support pluginOption()");
44+
}
45+
4046
@Override
4147
public QuiltLoaderPlugin plugin() {
4248
return plugin;

src/main/java/org/quiltmc/loader/impl/plugin/QuiltPluginContextImpl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ public Path pluginPath() {
6868
return pluginPath;
6969
}
7070

71+
@Override
72+
public ModLoadOption pluginOption() {
73+
return optionFrom;
74+
}
75+
7176
Map<String, LoaderValue> unload() {
7277
Map<String, LoaderValue> data = new HashMap<>();
7378

src/main/java/org/quiltmc/loader/impl/transformer/KotlinMetadataRemapper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ private String remapCandidate(String candidate) {
8686
}
8787
} catch (IllegalArgumentException e) {
8888
// ASM's remapper currently throws this if the candidate is an invalid method desc / desc / class
89+
// TODO: Reimplement this in a way that won't generate exceptions!
8990
Log.warn(LogCategory.CACHE, "Encountered an invalid / unknown Kotlin metdata annotation value '" + candidate + "' in " + currentName, e);
9091
} catch (Throwable t) {
9192
String msg = "While processing a kotlin metadata annotation value '" + candidate + "' in " + currentName;

src/main/java/org/quiltmc/loader/impl/transformer/QuiltTransformer.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.jetbrains.annotations.Nullable;
2626
import org.quiltmc.loader.api.plugin.solver.ModLoadOption;
2727
import org.quiltmc.loader.impl.QuiltLoaderImpl;
28+
import org.quiltmc.loader.impl.game.GameProvider;
2829
import org.quiltmc.loader.impl.game.MappingConfigurationImpl;
2930
import org.quiltmc.loader.impl.launch.common.QuiltLauncherBase;
3031
import org.quiltmc.loader.impl.util.QuiltLoaderInternal;
@@ -39,13 +40,14 @@
3940
@QuiltLoaderInternal(QuiltLoaderInternalType.NEW_INTERNAL)
4041
final class QuiltTransformer {
4142
public static byte @Nullable [] transform(boolean isDevelopment, EnvType envType, TransformCache cache, AccessWidener accessWidener, String name, ModLoadOption mod, byte[] bytes) {
42-
boolean isGameClass = mod.id().equals(QuiltLoaderImpl.INSTANCE.getGameProvider().getGameId());
43-
boolean transformAccess = isGameClass && ((MappingConfigurationImpl) QuiltLauncherBase.getLauncher().getMappingConfiguration()).requiresPackageAccessHack();
43+
GameProvider gameProvider = QuiltLoaderImpl.INSTANCE.getGameProvider();
44+
boolean isGameClass = mod.id().equals(gameProvider.getGameId());
45+
boolean transformAccess = isGameClass && gameProvider.requiresPackageAccessFix();
4446
boolean strip = !isGameClass || isDevelopment;
4547
boolean applyAccessWidener = isGameClass && accessWidener.getTargets().contains(name);
46-
boolean reflectiveFixes = !isGameClass;
48+
boolean reflectiveFixes = !isGameClass && !Boolean.getBoolean(SystemProperties.DISABLE_REFLECTIVE_FIXES);
4749

48-
if (!transformAccess && !strip && !applyAccessWidener) {
50+
if (!transformAccess && !strip && !applyAccessWidener && !reflectiveFixes) {
4951
return bytes;
5052
}
5153

@@ -113,7 +115,7 @@ final class QuiltTransformer {
113115
visitorCount++;
114116
}
115117

116-
if (reflectiveFixes && !Boolean.getBoolean(SystemProperties.DISABLE_REFLECTIVE_FIXES)) {
118+
if (reflectiveFixes) {
117119
visitor = new ReflectiveFixer(QuiltLoaderImpl.ASM_VERSION, visitor);
118120
visitorCount++;
119121
}

src/main/java/org/quiltmc/loader/impl/transformer/RuntimeModRemapper.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,16 @@ public void remap(TransformCache cache) {
119119
}
120120
Set<InputTag> remapMixins = new HashSet<>();
121121

122-
TinyRemapper remapper = TinyRemapper.newRemapper()
122+
TinyRemapper.Builder remapBuilder = TinyRemapper.newRemapper()
123123
.withMappings(TinyUtils.createMappingProvider(mappingConfiguration.getMappings(), "intermediary", mappingConfiguration.getTargetNamespace()))
124124
.renameInvalidLocals(false)
125-
.extension(new MixinExtension(remapMixins::contains))
126-
.extraPreApplyVisitor(KotlinMetadataRemapper::new)
127-
.build();
125+
.extension(new MixinExtension(remapMixins::contains));
126+
127+
if (!Boolean.getBoolean(SystemProperties.DISABLE_KOTLIN_METADATA_REMAP)) {
128+
remapBuilder.extraPreApplyVisitor(KotlinMetadataRemapper::new);
129+
}
130+
131+
TinyRemapper remapper = remapBuilder.build();
128132

129133
try {
130134
remap0(cache, launcher, remapMixins, remapper);

src/main/java/org/quiltmc/loader/impl/util/SystemProperties.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.quiltmc.loader.impl.filesystem.QuiltBasePath;
2424
import org.quiltmc.loader.impl.filesystem.QuiltClassPath;
2525
import org.quiltmc.loader.impl.filesystem.QuiltMapFileSystem;
26+
import org.quiltmc.loader.impl.transformer.KotlinMetadataRemapper;
2627

2728
@QuiltLoaderInternal(QuiltLoaderInternalType.LEGACY_EXPOSED)
2829
public final class SystemProperties {
@@ -117,6 +118,9 @@ private SystemProperties() {}
117118
/** Prevents loader from transforming classes with ReflectiveFixer */
118119
public static final String DISABLE_REFLECTIVE_FIXES = "loader.transform.reflective_fixes.disable";
119120

121+
/** Disables {@link KotlinMetadataRemapper}. */
122+
public static final String DISABLE_KOTLIN_METADATA_REMAP = "loader.transform.kotlin_metadata_remap.disable";
123+
120124
// ##############
121125
// # Validation #
122126
// ##############

0 commit comments

Comments
 (0)