Skip to content

Commit

Permalink
Fix: Properly handle arrays when checking if members are owned by mix…
Browse files Browse the repository at this point in the history
…ins.

No longer throws when a method call is on an array.

Closes #147
  • Loading branch information
LlamaLad7 committed Oct 30, 2024
1 parent 0b6875f commit c516fb7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,15 @@ public void setHandle(int tag, String owner, String name, String desc, boolean i
*/
public abstract void setDesc(String desc);

/**
* Whether the owner of this member is a mixin.
* @return Whether the owner of this member is a mixin.
*/
public boolean ownerIsMixin() {
String owner = getOwner();
return !owner.startsWith("[") && ClassInfo.forName(owner).isMixin();
}

@Override
public String toString() {
return String.format("%s for %s.%s%s%s", Bytecode.getOpcodeName(this.getOpcode()), this.getOwner(), this.getName(), this.isField() ? ":" : "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ private void transformMethodRef(MethodNode method, Iterator<AbstractInsnNode> it
} else if (this.detachedSuper || this.inheritsFromMixin) {
if (methodRef.getOpcode() == Opcodes.INVOKESPECIAL) {
this.updateStaticBinding(method, methodRef);
} else if (methodRef.getOpcode() == Opcodes.INVOKEVIRTUAL && ClassInfo.forName(methodRef.getOwner()).isMixin()) {
} else if (methodRef.getOpcode() == Opcodes.INVOKEVIRTUAL && methodRef.ownerIsMixin()) {
this.updateDynamicBinding(method, methodRef);
}
}
Expand Down Expand Up @@ -903,7 +903,7 @@ private void updateBinding(MethodNode method, MemberRef methodRef, Traversal tra
+ " but is mixin.");
}
methodRef.setOwner(superMethod.getImplementor().getName());
} else if (ClassInfo.forName(methodRef.getOwner()).isMixin()) {
} else if (methodRef.ownerIsMixin()) {
throw new MixinTransformerError("Error resolving " + methodRef + " in " + this);
}
}
Expand Down

0 comments on commit c516fb7

Please sign in to comment.