Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge/0.8.7 #151

Merged
merged 28 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a95dcd9
Bump version to 0.8.7-SNAPSHOT
Mumfrey May 14, 2024
902c343
Restore old findInitNodeFor used by MixinExtras, mark as deprecated
Mumfrey May 14, 2024
a13f0c0
Convert EXPAND_FRAMES ClassReader flag to tunable, default to 0
Mumfrey May 14, 2024
e212511
Replace zip-based ML legacy VirtualJar shim with inline SecureJar shim
Mumfrey May 15, 2024
54f3644
Don't create logger in MixinServiceAbstract ctor, updates #569
Mumfrey May 15, 2024
b04e6d6
Propagate argument offsets when applying Redirect, closes #544
Mumfrey May 16, 2024
0816867
Really only linear offsets are supported with base assumption
Mumfrey May 17, 2024
a2751aa
Apply injectors in discrete phases, ensure Redirects always go last(ish)
Mumfrey May 18, 2024
1f34ee9
Run all preinject operations before starting any actual injections
Mumfrey May 18, 2024
02bf3d2
Change: Add stack checking to old `Target#findInitNodeFor` overload a…
LlamaLad7 May 21, 2024
02d7470
Allow authors to specify order on injector annotations
Mumfrey May 24, 2024
1bae530
Merge remote-tracking branch 'origin/pr/667'
Mumfrey May 24, 2024
2d14c78
Fix bug with option flags from previous commit
Mumfrey Jun 7, 2024
a362aad
Fix AP file writer issue with non-file outputs, fixed #622
Mumfrey Jun 7, 2024
8f0bb79
Add fuzz and skip options to AfterInvoke, closes #653
Mumfrey Jun 20, 2024
d2105c6
Display correct node type in printLocals
Mumfrey Jun 20, 2024
017eecf
Propagate local context through compounds via decoration, closes #532
Mumfrey Jun 25, 2024
96e81bb
Use ClassReader flags tunable for metadata ClassNodes too, updates #671
Mumfrey Jul 4, 2024
0239904
Handle offset arg window correctly for ModifyArg injector, updates #544
Mumfrey Jul 5, 2024
0c79de4
Handle offset arg window correctly for ModifyArgs injector, updates #544
Mumfrey Jul 6, 2024
c8be3ca
Use InjectorOrder.DEFAULT for field, fixes third-party injector order
Mumfrey Jul 6, 2024
7d7d4dc
Properly handle empty args window and report name of the original method
Mumfrey Jul 6, 2024
4053421
Mixin 0.8.7 RELEASE
Mumfrey Jul 6, 2024
60aa12f
Revert "Use 0 as class reader flags in Modlauncher bytecode provider …
LlamaLad7 Jul 9, 2024
b20b9b3
Revert "Fix: Check the staticness of the original call not the curren…
LlamaLad7 Jul 9, 2024
96b758d
Revert "Fix/modifyarg(s) after redirect (#128)"
LlamaLad7 Jul 9, 2024
55670f2
Merge branch 'refs/heads/0.8.7' into merge/0.8.7
LlamaLad7 Jul 9, 2024
7f00ee3
Build: Bump version.
LlamaLad7 Jul 9, 2024
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
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ packaging=jar
description=Mixin (Fabric fork)
url=https://fabricmc.net
organization=FabricMC
buildVersion=0.14.0
upstreamMixinVersion=0.8.6
buildVersion=0.15.0
upstreamMixinVersion=0.8.7
buildType=RELEASE
asmVersion=9.6
legacyForgeAsmVersion=5.0.3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.URI;
import java.util.List;

import javax.annotation.processing.Filer;
import javax.tools.FileObject;
import javax.tools.StandardLocation;

Expand Down Expand Up @@ -129,7 +131,9 @@ public void write() {

try {
writer = this.newWriter(this.outRefMapFileName, "refmap");
this.refMapper.write(writer);
if (writer != null) {
this.refMapper.write(writer);
}
} catch (IOException ex) {
ex.printStackTrace();
} finally {
Expand All @@ -154,9 +158,26 @@ private PrintWriter newWriter(String fileName, String description) throws IOExce
return new PrintWriter(outFile);
}

FileObject outResource = this.ap.getProcessingEnvironment().getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", fileName);
this.ap.printMessage(MessageType.INFO, "Writing " + description + " to " + new File(outResource.toUri()).getAbsolutePath());
return new PrintWriter(outResource.openWriter());
try {
Filer filer = this.ap.getProcessingEnvironment().getFiler();
FileObject outResource = null;
try {
outResource = filer.createResource(StandardLocation.CLASS_OUTPUT, "", fileName);
} catch (Exception ex) {
// fileName is not a valid relative path?
outResource = filer.createResource(StandardLocation.CLASS_OUTPUT, "", new File(fileName).getName());
}

URI resourceUri = outResource.toUri();
String absolutePath = "file".equals(resourceUri.getScheme()) ? new File(resourceUri).getAbsolutePath() : resourceUri.toString();
PrintWriter writer = new PrintWriter(outResource.openWriter());
this.ap.printMessage(MessageType.INFO, "Writing " + description + " to (" + resourceUri.getScheme() + ") " + absolutePath);
return writer;
} catch (Exception ex) {
this.ap.printMessage(MessageType.ERROR, "Cannot write " + description + " to (" + fileName + "): " + ex.getClass().getName()
+ ": " + ex.getMessage());
return null;
}
}

/* (non-Javadoc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ public boolean isNotInterface() {
* @param other the TypeHandle to compare with
*/
public boolean isSuperTypeOf(TypeHandle other) {
List<TypeHandle> superTypes = new ArrayList<>();
List<TypeHandle> superTypes = new ArrayList<TypeHandle>();
if (other.getSuperclass() != null) {
superTypes.add(other.getSuperclass());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,16 @@ public ClassNode getClassNode(String className) throws ClassNotFoundException, I
*/
@Override
public ClassNode getClassNode(String className, boolean runTransformers) throws ClassNotFoundException, IOException {
return this.getClassNode(className, this.getClassBytes(className, true), ClassReader.EXPAND_FRAMES);
return this.getClassNode(className, this.getClassBytes(className, runTransformers), ClassReader.EXPAND_FRAMES);
}

/* (non-Javadoc)
* @see org.spongepowered.asm.service.IClassBytecodeProvider#getClassNode(
* java.lang.String, boolean, int)
*/
@Override
public ClassNode getClassNode(String className, boolean runTransformers, int flags) throws ClassNotFoundException, IOException {
return this.getClassNode(className, this.getClassBytes(className, runTransformers), flags);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public abstract class MixinBootstrap {
/**
* Subsystem version
*/
public static final String VERSION = "0.8.6";
public static final String VERSION = "0.8.7";

/**
* Transformer factory
Expand Down
113 changes: 86 additions & 27 deletions src/main/java/org/spongepowered/asm/mixin/MixinEnvironment.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.spongepowered.asm.launch.GlobalProperties;
import org.spongepowered.asm.launch.GlobalProperties.Keys;
import org.spongepowered.asm.launch.MixinBootstrap;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.extensibility.IEnvironmentTokenProvider;
import org.spongepowered.asm.mixin.injection.At;
Expand Down Expand Up @@ -330,7 +331,7 @@ public static enum Option {
/**
* Parent for environment settings
*/
ENVIRONMENT(Inherit.ALWAYS_FALSE, "env"),
ENVIRONMENT(Inherit.ALWAYS_FALSE, true, "env"),

/**
* Force refmap obf type when required
Expand Down Expand Up @@ -412,7 +413,20 @@ public static enum Option {
* Behaviour for initialiser injections, current supported options are
* "default" and "safe"
*/
INITIALISER_INJECTION_MODE("initialiserInjectionMode", "default");
INITIALISER_INJECTION_MODE("initialiserInjectionMode", "default"),

/**
* Parent for tunable settings
*/
TUNABLE(Inherit.ALWAYS_FALSE, true, "tunable"),

/**
* Tunable for the Mixin ClassReader behaviour, setting this option to
* <tt>true</tt> will cause the Mixin ClassReader to read mixin bytecode
* with {@link ClassReader#EXPAND_FRAMES} flag which restores the
* behaviour from versions 0.8.6 and below, newer versions default to 0.
*/
CLASSREADER_EXPAND_FRAMES(Option.TUNABLE, Inherit.INDEPENDENT, "classReaderExpandFrames", true, "false");

/**
* Type of inheritance for options
Expand Down Expand Up @@ -460,6 +474,11 @@ private enum Inherit {
*/
final Inherit inheritance;

/**
* Do not print this option in the masthead output
*/
final boolean isHidden;

/**
* Java property name
*/
Expand Down Expand Up @@ -488,6 +507,10 @@ private Option(Inherit inheritance, String property) {
this(null, inheritance, property, true);
}

private Option(Inherit inheritance, boolean hidden, String property) {
this(null, inheritance, hidden, property, true);
}

private Option(String property, boolean flag) {
this(null, property, flag);
}
Expand All @@ -500,29 +523,58 @@ private Option(Option parent, String property) {
this(parent, Inherit.INHERIT, property, true);
}

private Option(Option parent, boolean hidden, String property) {
this(parent, Inherit.INHERIT, hidden, property, true);
}

private Option(Option parent, Inherit inheritance, String property) {
this(parent, inheritance, property, true);
}

private Option(Option parent, Inherit inheritance, boolean hidden, String property) {
this(parent, inheritance, hidden, property, true);
}

private Option(Option parent, String property, boolean isFlag) {
this(parent, Inherit.INHERIT, property, isFlag, null);
}

private Option(Option parent, boolean hidden, String property, boolean isFlag) {
this(parent, Inherit.INHERIT, hidden, property, isFlag, null);
}

private Option(Option parent, Inherit inheritance, String property, boolean isFlag) {
this(parent, inheritance, property, isFlag, null);
}

private Option(Option parent, Inherit inheritance, boolean hidden, String property, boolean isFlag) {
this(parent, inheritance, hidden, property, isFlag, null);
}

private Option(Option parent, String property, String defaultStringValue) {
this(parent, Inherit.INHERIT, property, false, defaultStringValue);
}

private Option(Option parent, boolean hidden, String property, String defaultStringValue) {
this(parent, Inherit.INHERIT, hidden, property, false, defaultStringValue);
}

private Option(Option parent, Inherit inheritance, String property, String defaultStringValue) {
this(parent, inheritance, property, false, defaultStringValue);
}

private Option(Option parent, Inherit inheritance, boolean hidden, String property, String defaultStringValue) {
this(parent, inheritance, hidden, property, false, defaultStringValue);
}

private Option(Option parent, Inherit inheritance, String property, boolean isFlag, String defaultStringValue) {
this(parent, inheritance, false, property, isFlag, defaultStringValue);
}

private Option(Option parent, Inherit inheritance, boolean hidden, String property, boolean isFlag, String defaultStringValue) {
this.parent = parent;
this.inheritance = inheritance;
this.isHidden = hidden;
this.property = (parent != null ? parent.property : Option.PREFIX) + "." + property;
this.defaultValue = defaultStringValue;
this.isFlag = isFlag;
Expand Down Expand Up @@ -754,42 +806,42 @@ boolean isSupported() {
}

},

/**
* Java 19 or above is required
*/
JAVA_19(19, Opcodes.V19, LanguageFeatures.METHODS_IN_INTERFACES | LanguageFeatures.PRIVATE_SYNTHETIC_METHODS_IN_INTERFACES
| LanguageFeatures.PRIVATE_METHODS_IN_INTERFACES | LanguageFeatures.NESTING | LanguageFeatures.DYNAMIC_CONSTANTS
| LanguageFeatures.RECORDS | LanguageFeatures.SEALED_CLASSES) {

@Override
boolean isSupported() {
return JavaVersion.current() >= JavaVersion.JAVA_19 && ASM.isAtLeastVersion(9, 3);
}

},

/**
* Java 20 or above is required
*/
JAVA_20(20, Opcodes.V20, LanguageFeatures.METHODS_IN_INTERFACES | LanguageFeatures.PRIVATE_SYNTHETIC_METHODS_IN_INTERFACES
| LanguageFeatures.PRIVATE_METHODS_IN_INTERFACES | LanguageFeatures.NESTING | LanguageFeatures.DYNAMIC_CONSTANTS
| LanguageFeatures.RECORDS | LanguageFeatures.SEALED_CLASSES) {

@Override
boolean isSupported() {
return JavaVersion.current() >= JavaVersion.JAVA_20 && ASM.isAtLeastVersion(9, 4);
}

},

/**
* Java 21 or above is required
*/
JAVA_21(21, Opcodes.V21, LanguageFeatures.METHODS_IN_INTERFACES | LanguageFeatures.PRIVATE_SYNTHETIC_METHODS_IN_INTERFACES
| LanguageFeatures.PRIVATE_METHODS_IN_INTERFACES | LanguageFeatures.NESTING | LanguageFeatures.DYNAMIC_CONSTANTS
| LanguageFeatures.RECORDS | LanguageFeatures.SEALED_CLASSES) {

@Override
boolean isSupported() {
return JavaVersion.current() >= JavaVersion.JAVA_21 && ASM.isAtLeastVersion(9, 5);
Expand Down Expand Up @@ -980,7 +1032,7 @@ public static CompatibilityLevel requiredFor(int languageFeatures) {
}
return null;
}

/**
* Return the maximum compatibility level which is actually effective in
* the current runtime, taking into account the current JRE and ASM
Expand Down Expand Up @@ -1039,30 +1091,30 @@ static String getSupportedVersions() {
* features added in version 0.8.6 and higher.
*/
public static enum Feature {

/**
* Supports the <tt>unsafe</tt> flag on &#64;At annotations to
* facilitate hassle-free constructor injections.
*/
UNSAFE_INJECTION(true),

/**
* Support for the use of injector annotations in interface mixins
* Support for the use of injector annotations in interface mixins
*/
INJECTORS_IN_INTERFACE_MIXINS(false) {

INJECTORS_IN_INTERFACE_MIXINS {
@Override
public boolean isAvailable() {
return CompatibilityLevel.getMaxEffective().supports(LanguageFeatures.METHODS_IN_INTERFACES);
}

@Override
public boolean isEnabled() {
return MixinEnvironment.getCompatibilityLevel().supports(LanguageFeatures.METHODS_IN_INTERFACES);
}

};

/**
* Existence of the enum constant does not necessarily indicate that the
* feature is actually supported by this version, for example if
Expand All @@ -1072,30 +1124,34 @@ public boolean isEnabled() {
*/
private boolean enabled;

private Feature() {
this(false);
}

private Feature(boolean enabled) {
this.enabled = enabled;
}

/**
* Get whether this feature is available in the current runtime
* environment
*/
public boolean isAvailable() {
return true;
}

/**
* Get whether this feature is supported in the current environment and
* compatibility level
*/
public boolean isEnabled() {
return this.isAvailable() && this.enabled;
}

/**
* Convenience function which returns a Feature constant based on the
* feature id, but returns null instead of throwing an exception.
*
*
* @param featureId Feature ID (enum constant name) to check for
* @return Feature or null
*/
Expand All @@ -1113,27 +1169,27 @@ public static Feature get(String featureId) {
/**
* Check whether a particular feature exists in this mixin version, even
* if it's not currently available
*
*
* @param featureId Feature ID (enum constant name) to check for
* @return true if the feature exists
*/
public static boolean exists(String featureId) {
return Feature.get(featureId) != null;
}

/**
* Check whether a particular feature is available and enabled
*
*
* @param featureId Feature ID (enum constant name) to check for
* @return true if the feature is currently available
*/
public static boolean isActive(String featureId) {
Feature feature = Feature.get(featureId);
return feature != null && feature.isEnabled();
}

}

/**
* Wrapper for providing a natural sorting order for providers
*/
Expand Down Expand Up @@ -1315,6 +1371,9 @@ private void printHeader(Object version) {
printer.kv("Global Property Service Class", MixinService.getGlobalPropertyService().getClass().getName());
printer.kv("Logger Adapter Type", MixinService.getService().getLogger("mixin").getType()).hr();
for (Option option : Option.values()) {
if (option.isHidden) {
continue;
}
StringBuilder indent = new StringBuilder();
for (int i = 0; i < option.depth; i++) {
indent.append("- ");
Expand Down
Loading