Skip to content

Commit

Permalink
Replace anonymous with inner class in the redirect transformer to all…
Browse files Browse the repository at this point in the history
…ow public visibility

Trying to work around a weird crash in a dev env
  • Loading branch information
eigenraven committed Feb 15, 2023
1 parent 5163407 commit 8c59710
Showing 1 changed file with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,7 @@ public byte[] transform(String name, String transformedName, byte[] basicClass)
}
ClassReader reader = new ClassReader(basicClass);
ClassWriter writer = new ClassWriter(0);
ClassVisitor visitor = new ClassRemapper(writer, this) {

@Override
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
if (desc.equals(Type.getDescriptor(Lwjgl3Aware.class))) {
throw new Lwjgl3AwareException();
}
return super.visitAnnotation(desc, visible);
}
};
ClassVisitor visitor = new EscapingClassRemapper(writer);

try {
reader.accept(visitor, ClassReader.EXPAND_FRAMES);
Expand Down Expand Up @@ -80,6 +71,21 @@ public String map(String typeName) {
return typeName;
}

private static class Lwjgl3AwareException extends RuntimeException {
public static class Lwjgl3AwareException extends RuntimeException {
}

public class EscapingClassRemapper extends ClassRemapper {

public EscapingClassRemapper(ClassWriter writer) {
super(writer, LwjglRedirectTransformer.this);
}

@Override
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
if (desc.equals(Type.getDescriptor(Lwjgl3Aware.class))) {
throw new Lwjgl3AwareException();
}
return super.visitAnnotation(desc, visible);
}
}
}

0 comments on commit 8c59710

Please sign in to comment.