Skip to content

Commit

Permalink
Use ClassReader flags tunable for metadata ClassNodes too, updates #671
Browse files Browse the repository at this point in the history
  • Loading branch information
Mumfrey committed Jul 4, 2024
1 parent 017eecf commit 96e81bb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ private class Callback extends InsnList {
List<String> argNames = null;

if (locals != null) {
int baseArgIndex = CallbackInjector.this.isStatic() ? 0 : 1;
int baseArgIndex = target.isStatic ? 0 : 1;
argNames = new ArrayList<String>();
for (int l = 0; l <= locals.length; l++) {
if (l == this.frameSize) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

import org.spongepowered.asm.logging.Level;
import org.spongepowered.asm.logging.ILogger;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
Expand All @@ -50,6 +51,7 @@
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.MixinEnvironment.Option;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.gen.Invoker;
Expand Down Expand Up @@ -2002,7 +2004,8 @@ public static ClassInfo forName(String className) {
ClassInfo info = ClassInfo.cache.get(className);
if (info == null) {
try {
ClassNode classNode = MixinService.getService().getBytecodeProvider().getClassNode(className);
int flags = MixinEnvironment.getCurrentEnvironment().getOption(Option.CLASSREADER_EXPAND_FRAMES) ? ClassReader.EXPAND_FRAMES : 0;
ClassNode classNode = MixinService.getService().getBytecodeProvider().getClassNode(className, true, flags);
info = new ClassInfo(classNode);
} catch (Exception ex) {
ClassInfo.logger.catching(Level.TRACE, ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,15 @@ public String getReturnType() {
*/
public void setModifiers(MethodNode method) {
String returnType = SignaturePrinter.getTypeName(Type.getReturnType(method.desc), false, this.fullyQualified);
String staticType = (method.access & Opcodes.ACC_STATIC) != 0 ? "static " : "";
if ((method.access & Opcodes.ACC_PUBLIC) != 0) {
this.setModifiers("public " + returnType);
this.setModifiers("public " + staticType + returnType);
} else if ((method.access & Opcodes.ACC_PROTECTED) != 0) {
this.setModifiers("protected " + returnType);
this.setModifiers("protected " + staticType + returnType);
} else if ((method.access & Opcodes.ACC_PRIVATE) != 0) {
this.setModifiers("private " + returnType);
this.setModifiers("private " + staticType + returnType);
} else {
this.setModifiers(returnType);
this.setModifiers(staticType + returnType);
}
}

Expand Down

0 comments on commit 96e81bb

Please sign in to comment.