jacoco classid have compatibility problems

Anonymous
2012-08-06
2013-04-24
  • Anonymous - 2012-08-06

    jacoco classid have compatibility problems  for ant,maven and eclipse,because different tools compiler generated class are different. which cause these tools generated jacoco coverage file merge wrong coverage report:(

    The problem code in
    org.jacoco.core.analysis.Analyzer.analyzeClass:CRC64.checksum(classReader.b)
    1. ant without -g the " checksum  " different with maven and eclipse
    2. ant with -g the "checksum" same as maven,but diff with eclipse
    3. There no way make eclipse compiled class has same classid with ant or maven
    Use "className" checksum as classid will solve the problem:

    Analyzer:
    public void analyzeClass(final ClassReader reader) {
    final ClassVisitor visitor = createAnalyzingVisitor(CRC64
    .checksum(reader.getClassName().getBytes()));
    reader.accept(visitor, 0);
    }

    Instrumenter:
    public byte instrument(final ClassReader reader) {
    final ClassWriter writer = new ClassWriter(reader, 0);
    final ClassVisitor visitor = createInstrumentingVisitor(
    CRC64.checksum(reader.getClassName().getBytes()), writer);
    reader.accept(visitor, ClassReader.EXPAND_FRAMES);
    return writer.toByteArray();
    }

     
  • Anonymous - 2012-08-06

    The jacoco agent also need chang for classid code:

    org.jacoco.agent.rt_3vqbej.core.instr.Instrumenter

     
  • Marc R. Hoffmann

    JaCoCo analyses class files at runtime and inserts probes at particular places. Probes are simply enumerated (0, 1, 2, …). At analysis time the same algorithm is applied to class files which will result in the same probes and all coverage figures (line coverage, instruction, branches etc) are derived from the probes. If the class at runtime is different from the class at analysis time (which is typically the case if you use different compilers e.g. JDK vs. Eclipse) this will typically result in different probes.

    So just using the class name will result in unexpected coverage data and in internal errors (IndexOutOfBounds etc).

    Best regards,
    -marc

     
  • qxo

    qxo - 2012-08-14

    In my tests,not find the problem: same java file,using different compilers ( sun jdk ,ibm jdk ) and different tools (ant,maven,eclipse)

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks