Skip to content

Commit

Permalink
fix a bug with runtime downgrading and adapter classes
Browse files Browse the repository at this point in the history
  • Loading branch information
wagyourtail committed Jun 18, 2024
1 parent b2ba5f1 commit 927a5c0
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/main/java/xyz/wagyourtail/jvmdg/version/VersionProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ public static FullyQualifiedMemberNameAndDesc resolveStubTarget(Member member, R
String name;
List<Type> params = new ArrayList<>(Arrays.asList(Type.getArgumentTypes(method)));

Class<?>[] paramClasses = method.getParameterTypes();
for (int i = 0; i < params.size(); i++) {
Adapter a = paramClasses[i].getAnnotation(Adapter.class);
if (a != null) {
String aRef = a.value();
if (aRef.startsWith("L") && aRef.endsWith(";")) {
params.set(i, Type.getType(aRef));
} else {
params.set(i, Type.getObjectType(aRef));
}
}
}

Annotation[][] annotations = method.getParameterAnnotations();
for (int i = 0; i < params.size(); i++) {
Annotation[] param = annotations[i];
Expand Down Expand Up @@ -405,10 +418,10 @@ public MethodNode stubMethods(MethodNode method, ClassNode owner, Set<ClassNode>
if (insn instanceof MethodInsnNode) {
MethodInsnNode min = (MethodInsnNode) insn;
if (!min.owner.startsWith("[")) {
min.owner = stubClass(Type.getObjectType(min.owner)).getInternalName();
min.desc = stubClass(Type.getMethodType(min.desc)).getDescriptor();
getStubMapper(Type.getObjectType(min.owner), min.itf, memberResolver, superTypeResolver).transform(method, i, owner, extra, enableRuntime);
}
min.owner = stubClass(Type.getObjectType(min.owner)).getInternalName();
min.desc = stubClass(Type.getMethodType(min.desc)).getDescriptor();
} else if (insn instanceof TypeInsnNode) {
TypeInsnNode tin = (TypeInsnNode) insn;
MethodInsnNode min = stubTypeInsnNode(tin);
Expand Down

0 comments on commit 927a5c0

Please sign in to comment.