Thanks Evgeny for this minimal Example! AALOAD is a perfect hint.
I added it to our FramesTest and indeed it fails. I'll investigate.
Cheers,
-marc
On 2017-09-19 14:56, Evgeny Mandrikov wrote:
> Sorry, forgot to attach file, here it is.
>
> On Tuesday, September 19, 2017 at 2:53:28 PM UTC+2, Evgeny Mandrikov wrote:
>
>> Hi Marc,
>>
>> FYI:
>>
>> I tried to instrument class from this thread by JaCoCo 0.6.4, where we had
>> FrameTracker and got ClassCastException in it at line
>> https://github.com/jacoco/jacoco/blob/v0.6.4/org.jacoco.core/src/org/jacoco/core/internal/instr/FrameTracker.java#L253
>> [1] ("java.lang.Integer cannot be cast to java.lang.String"), i.e. during
>> processing of AALOAD instruction.
>>
>> We replaced our FrameTracker by ASM's AnalyzerAdapter that has another
>> implementation for AALOAD -
>> https://gitlab.ow2.org/asm/asm/blob/ASM_5_2/src/org/objectweb/asm/commons/AnalyzerAdapter.java#L665
>> [2]
>>
>> None of our existing tests touches else-branch of this implementation, while
>> it is touched by class from this thread. So I tried to build smaller example
>> that will also touch this line - you'll find it in attachment:
>>
>> * as said above - target class is not a reduction of class from this thread
>> * and actually code of target class has no sense
>> * however target class doesn't pass our FramesTest
>> * and test demonstrates pretty similar VerifyError ("Type 'java/lang/Object'
>> is not assignable to null") when executed with JDK 8u131
>> * to trigger VerifyError, target class must first be read and written back
>> by ASM ClassWriter.COMPUTE_FRAMES - this reflects statement that class from
>> this thread is a result of instrumentation by another tool, and this is what
>> happens in FramesTest
>>
>> Hope this simplifies hunting of root cause and together we'll finally find
>> it (hopefully not in our code :D)
>
> --
> You received this message because you are subscribed to the Google Groups
> "JaCoCo and EclEmma Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jacoco/34c8ae23-d518-43c7-8c87-951fe6b550a9%40googlegroups.com
> [3].
> For more options, visit https://groups.google.com/d/optout.
Links:
------
[1]
https://github.com/jacoco/jacoco/blob/v0.6.4/org.jacoco.core/src/org/jacoco/core/internal/instr/FrameTracker.java#L253
[2]
https://gitlab.ow2.org/asm/asm/blob/ASM_5_2/src/org/objectweb/asm/commons/AnalyzerAdapter.java#L665
[3]
https://groups.google.com/d/msgid/jacoco/34c8ae23-d518-43c7-8c87-951fe6b550a9%40googlegroups.com?utm_medium=email&utm_source=footer
--
You received this message because you are subscribed to the Google Groups
"JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jacoco/0b476ba4e81ca281d510aa5fb0e4e26b%40mountainminds.com.
For more options, visit https://groups.google.com/d/optout.
package org.jacoco.core.test;
import org.jacoco.core.instr.Instrumenter;
import org.jacoco.core.runtime.IRuntime;
import org.jacoco.core.runtime.SystemPropertiesRuntime;
import org.junit.Test;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
public class IssueTest {
public static class Target {
private static boolean b() {
return false;
}
public static void fun() {
Object[] a = null;
for (Object o : a) {
if (b()) {
b();
}
}
}
}
@Test
public void test() throws Exception {
final ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
new ClassReader(Target.class.getName()).accept(cw, 0);
final byte[] bytes = cw.toByteArray();
new TargetLoader().add(Target.class.getName(), bytes)
.getDeclaredMethods();
final IRuntime runtime = new SystemPropertiesRuntime();
final Instrumenter instrumenter = new Instrumenter(runtime);
final byte[] instrumented = instrumenter.instrument(bytes,
Target.class.getName());
new TargetLoader().add(Target.class.getName(), instrumented)
.getDeclaredMethods();
}
}