Skip to content

Commit

Permalink
Merge pull request #151 from FabricMC/merge/0.8.7
Browse files Browse the repository at this point in the history
Merge/0.8.7
  • Loading branch information
modmuss50 authored Jul 9, 2024
2 parents 2cd49e6 + 7f00ee3 commit 9aca17d
Show file tree
Hide file tree
Showing 47 changed files with 1,164 additions and 195 deletions.
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

0 comments on commit 9aca17d

Please sign in to comment.