Skip to content

Commit

Permalink
actually fix it
Browse files Browse the repository at this point in the history
  • Loading branch information
wagyourtail committed Jun 18, 2024
1 parent 927a5c0 commit 1112b78
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions src/main/java/xyz/wagyourtail/jvmdg/version/VersionProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,33 +47,41 @@ public static void main(String[] args) {
System.out.println(Type.getType(boolean.class).getDescriptor());
}

public static FullyQualifiedMemberNameAndDesc resolveStubTarget(Member member, Ref ref) {
public FullyQualifiedMemberNameAndDesc resolveStubTarget(Member member, Ref ref) {
if (member instanceof Method) {
Method method = (Method) member;
Type owner;
String name;
List<Type> params = new ArrayList<>(Arrays.asList(Type.getArgumentTypes(method)));

Annotation[][] annotations = method.getParameterAnnotations();
for (int i = 0; i < params.size(); i++) {
Annotation[] param = annotations[i];
for (Annotation a : param) {
if (a instanceof Coerce) {
Coerce c = (Coerce) a;
params.set(i, Type.getType(c.value()));
}
}
}

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();
Type t;
if (aRef.startsWith("L") && aRef.endsWith(";")) {
params.set(i, Type.getType(aRef));
t = Type.getType(aRef);
} else {
params.set(i, Type.getObjectType(aRef));
t = Type.getObjectType(aRef);
}
}
}

Annotation[][] annotations = method.getParameterAnnotations();
for (int i = 0; i < params.size(); i++) {
Annotation[] param = annotations[i];
for (Annotation a : param) {
if (a instanceof Coerce) {
Coerce c = (Coerce) a;
params.set(i, Type.getType(c.value()));
for (VersionProvider versionProvider : downgrader.versionProviders(this.outputVersion)) {
if (versionProvider.classStubs.containsKey(t)) {
params.set(i, t);
break;
}
}
}
}
Expand Down Expand Up @@ -417,11 +425,11 @@ public MethodNode stubMethods(MethodNode method, ClassNode owner, Set<ClassNode>
AbstractInsnNode insn = method.instructions.get(i);
if (insn instanceof MethodInsnNode) {
MethodInsnNode min = (MethodInsnNode) insn;
min.owner = stubClass(Type.getObjectType(min.owner)).getInternalName();
min.desc = stubClass(Type.getMethodType(min.desc)).getDescriptor();
if (!min.owner.startsWith("[")) {
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 1112b78

Please sign in to comment.