Skip to content

Commit

Permalink
Fix unsafe operations in tests
Browse files Browse the repository at this point in the history
ci skip
  • Loading branch information
ThexXTURBOXx committed Aug 9, 2021
1 parent ddc7e3b commit cdf7bf9
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.TryCatchBlockNode;
import org.objectweb.asm.tree.analysis.Analyzer;
import org.objectweb.asm.tree.analysis.BasicValue;
import org.objectweb.asm.tree.analysis.BasicVerifier;
import org.objectweb.asm.tree.analysis.Frame;
import org.objectweb.asm.tree.analysis.Value;
import org.objectweb.asm.util.CheckClassAdapter;
import org.objectweb.asm.util.Printer;
import org.objectweb.asm.util.Textifier;
Expand Down Expand Up @@ -192,17 +194,17 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO
buf.setAccessible(true);
}

static void printAnalyzerResult(MethodNode method, Analyzer a, final PrintWriter pw)
static <T extends Value> void printAnalyzerResult(MethodNode method, Analyzer<T> a, final PrintWriter pw)
throws IllegalArgumentException, IllegalAccessException {
Frame[] frames = a.getFrames();
Frame<T>[] frames = a.getFrames();
Textifier t = new Textifier();
TraceMethodVisitor mv = new TraceMethodVisitor(t);
String format = "%05d %-" + (method.maxStack + method.maxLocals + 6) + "s|%s";
for (int j = 0; j < method.instructions.size(); ++j) {
method.instructions.get(j).accept(mv);

StringBuffer s = new StringBuffer();
Frame f = frames[j];
Frame<T> f = frames[j];
if (f == null) {
s.append('?');
} else {
Expand Down Expand Up @@ -250,7 +252,7 @@ public static void verify(final ClassReader cr, PrintWriter out) throws
}

BasicVerifier verifier = new BasicVerifier();
Analyzer a = new Analyzer(verifier);
Analyzer<BasicValue> a = new Analyzer<>(verifier);
try {
a.analyze(cn.name, method);
} catch (Exception e) {
Expand Down

0 comments on commit cdf7bf9

Please sign in to comment.