Skip to content

Commit

Permalink
Update to ASM 7.1 in logger usage check (elastic#52742)
Browse files Browse the repository at this point in the history
The logger usage check uses its own version of ASM to inspect class
files for logging usages. Master was updated to support java 11
compilation in elastic#40754. However, 7.x still used ASM 5, which could not
read newer java bytecode versions. This commit bumps ASM in 7.x used in
the logger usage check.

closes elastic#52408
  • Loading branch information
rjernst committed Mar 17, 2020
1 parent 3fc3509 commit 95f9cb1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 3 additions & 1 deletion test/logger-usage/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
*/

dependencies {
compile 'org.ow2.asm:asm-debug-all:5.0.4' // use asm-debug-all as asm-all is broken
compile 'org.ow2.asm:asm:7.1'
compile 'org.ow2.asm:asm-tree:7.1'
compile 'org.ow2.asm:asm-analysis:7.1'
compile "org.apache.logging.log4j:log4j-api:${versions.log4j}"
testCompile project(":test:framework")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ private static class ClassChecker extends ClassVisitor {
private final Predicate<String> methodsToCheck;

ClassChecker(Consumer<WrongLoggerUsage> wrongUsageCallback, Predicate<String> methodsToCheck) {
super(Opcodes.ASM5);
super(Opcodes.ASM7);
this.wrongUsageCallback = wrongUsageCallback;
this.methodsToCheck = methodsToCheck;
}
Expand Down Expand Up @@ -222,7 +222,7 @@ private static class MethodChecker extends MethodVisitor {
private boolean ignoreChecks;

MethodChecker(String className, int access, String name, String desc, Consumer<WrongLoggerUsage> wrongUsageCallback) {
super(Opcodes.ASM5, new MethodNode(access, name, desc, null, null));
super(Opcodes.ASM7, new MethodNode(access, name, desc, null, null));
this.className = className;
this.wrongUsageCallback = wrongUsageCallback;
}
Expand Down Expand Up @@ -503,6 +503,10 @@ private static final class IntegerConstantBasicValue extends IntMinMaxTrackingBa
}

private static final class PlaceHolderStringInterpreter extends BasicInterpreter {
PlaceHolderStringInterpreter() {
super(Opcodes.ASM7);
}

@Override
public BasicValue newOperation(AbstractInsnNode insnNode) throws AnalyzerException {
if (insnNode.getOpcode() == Opcodes.LDC) {
Expand All @@ -527,6 +531,10 @@ public BasicValue merge(BasicValue value1, BasicValue value2) {
}

private static final class ArraySizeInterpreter extends BasicInterpreter {
ArraySizeInterpreter() {
super(Opcodes.ASM7);
}

@Override
public BasicValue newOperation(AbstractInsnNode insnNode) throws AnalyzerException {
switch (insnNode.getOpcode()) {
Expand Down

0 comments on commit 95f9cb1

Please sign in to comment.