Skip to content

Commit

Permalink
fix some downgrade warnings when running on old java
Browse files Browse the repository at this point in the history
  • Loading branch information
wagyourtail committed Aug 1, 2024
1 parent d23316b commit 087f0c7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
8 changes: 8 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ plugins {
application
id("io.github.sgtsilvio.gradle.metadata") version "0.5.0"
id("com.gradleup.nmcp") version "0.0.7"
id("org.gradle.test-retry") version "1.5.10"
}

allprojects {
Expand All @@ -17,6 +18,7 @@ allprojects {
apply(plugin = "maven-publish")
apply(plugin = "io.github.sgtsilvio.gradle.metadata")
apply(plugin = "com.gradleup.nmcp")
apply(plugin = "org.gradle.test-retry")

metadata {
url.set("https://github.com/unimined/JvmDowngrader")
Expand Down Expand Up @@ -78,6 +80,12 @@ allprojects {
}
}

tasks.test {
retry {
maxRetries = 3
}
}

signing {
useInMemoryPgpKeys(findProperty("signingKey") as String?, findProperty("signingPassword") as String?)
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/xyz/wagyourtail/jvmdg/ClassDowngrader.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,10 @@ public List<Pair<Type, Boolean>> getSupertypes(int version, Type type, Set<Strin
if (stream == null) return null;
ClassReader reader = new ClassReader(stream);
List<Pair<Type, Boolean>> types = new ArrayList<>();
types.add(new Pair<>(Type.getObjectType(reader.getSuperName()), Boolean.FALSE));
int vers = reader.readShort(6);
types.add(new Pair<>(stubClass(vers, Type.getObjectType(reader.getSuperName()), warnings), Boolean.FALSE));
for (String anInterface : reader.getInterfaces()) {
types.add(new Pair<>(Type.getObjectType(anInterface), Boolean.TRUE));
types.add(new Pair<>(stubClass(vers, Type.getObjectType(anInterface), warnings), Boolean.TRUE));
}
return types;
}
Expand Down
20 changes: 19 additions & 1 deletion src/main/java/xyz/wagyourtail/jvmdg/version/VersionProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,8 @@ public MethodInsnNode stubTypeInsnNode(TypeInsnNode insn, Set<String> warnings)
}
break;
default:
insn.desc = stub.getFirst().getInternalName();
}
insn.desc = stub.getFirst().getInternalName();
return null;
}
coverage.warnClass(t, warnings);
Expand Down Expand Up @@ -951,6 +951,24 @@ public ClassNode stubClasses(ClassNode clazz, boolean enableRuntime, Set<String>
}
}

// innerclass
if (clazz.innerClasses != null) {
for (InnerClassNode inner : clazz.innerClasses) {
type = Type.getObjectType(inner.name);
if (classStubs.containsKey(type)) {
Pair<Type, Pair<Class<?>, Adapter>> stub = classStubs.get(type);
inner.name = stub.getFirst().getInternalName();
}
if (inner.outerName != null) {
type = Type.getObjectType(inner.outerName);
if (classStubs.containsKey(type)) {
Pair<Type, Pair<Class<?>, Adapter>> stub = classStubs.get(type);
inner.outerName = stub.getFirst().getInternalName();
}
}
}
}

if (!removedInterfaces.isEmpty()) {
List<String> removed = new ArrayList<>();
for (String removedInterface : removedInterfaces) {
Expand Down

0 comments on commit 087f0c7

Please sign in to comment.