From 6c62355297e378224d8fba1dd1c26d75b7ed998b Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov <138671+Godin@users.noreply.github.com> Date: Tue, 11 Jun 2019 18:16:52 +0200 Subject: ProbeInserter should update indexes of local variables in annotations (#894) --- .../src/org/jacoco/core/internal/instr/ProbeInserter.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'org.jacoco.core/src/org') diff --git a/org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeInserter.java b/org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeInserter.java index 63fbf765..0a03c69e 100644 --- a/org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeInserter.java +++ b/org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeInserter.java @@ -11,10 +11,12 @@ *******************************************************************************/ package org.jacoco.core.internal.instr; +import org.objectweb.asm.AnnotationVisitor; import org.objectweb.asm.Label; import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; +import org.objectweb.asm.TypePath; /** * Internal utility to add probes into the control flow of a method. The code @@ -111,6 +113,18 @@ class ProbeInserter extends MethodVisitor implements IProbeInserter { mv.visitLocalVariable(name, desc, signature, start, end, map(index)); } + @Override + public AnnotationVisitor visitLocalVariableAnnotation(final int typeRef, + final TypePath typePath, final Label[] start, final Label[] end, + final int[] index, final String descriptor, final boolean visible) { + final int[] newIndex = new int[index.length]; + for (int i = 0; i < newIndex.length; i++) { + newIndex[i] = map(index[i]); + } + return mv.visitLocalVariableAnnotation(typeRef, typePath, start, end, + newIndex, descriptor, visible); + } + @Override public void visitMaxs(final int maxStack, final int maxLocals) { // Max stack size of the probe code is 3 which can add to the -- cgit v1.2.3