Skip to content

Commit

Permalink
Merge branch 'master' into issue-471
Browse files Browse the repository at this point in the history
  • Loading branch information
Godin committed Dec 14, 2016
2 parents aa533dc + 055e8e4 commit cf60ebd
Show file tree
Hide file tree
Showing 18 changed files with 44 additions and 36 deletions.
Expand Up @@ -142,7 +142,7 @@ public void testInvalidVersion() throws IOException {
buffer.write(ExecutionDataWriter.BLOCK_HEADER);
buffer.write(0xC0);
buffer.write(0xC0);
final char version = ExecutionDataWriter.FORMAT_VERSION - 1;
final char version = (char) (ExecutionDataWriter.FORMAT_VERSION - 1);
buffer.write(version >> 8);
buffer.write(version & 0xFF);
createReader().read();
Expand Down
Expand Up @@ -13,7 +13,6 @@

import static org.junit.Assert.assertNull;

import org.jacoco.core.JaCoCo;
import org.junit.Before;
import org.junit.Test;
import org.objectweb.asm.ClassVisitor;
Expand All @@ -29,7 +28,7 @@ public class ClassInstrumenterTest implements IProbeArrayStrategy {
@Before
public void setup() {
instrumenter = new ClassInstrumenter(this, new ClassVisitor(
JaCoCo.ASM_API_VERSION) {
InstrSupport.ASM_API_VERSION) {
});
}

Expand All @@ -50,7 +49,7 @@ public void testInstrumentInstrumentedClass2() {
@Test
public void testNoMethodVisitor() {
instrumenter = new ClassInstrumenter(this, new ClassVisitor(
JaCoCo.ASM_API_VERSION) {
InstrSupport.ASM_API_VERSION) {
@Override
public MethodVisitor visitMethod(int access, String name,
String desc, String signature, String[] exceptions) {
Expand Down
Expand Up @@ -15,7 +15,6 @@
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import org.jacoco.core.JaCoCo;
import org.jacoco.core.internal.instr.InstrSupport;
import org.jacoco.core.test.TargetLoader;
import org.junit.After;
Expand Down Expand Up @@ -66,7 +65,7 @@ public void testDataAccessor() throws InstantiationException,
public void testNoLocalVariablesInDataAccessor()
throws InstantiationException, IllegalAccessException {
runtime.generateDataAccessor(1001, "Target", 5, new MethodVisitor(
JaCoCo.ASM_API_VERSION) {
InstrSupport.ASM_API_VERSION) {
@Override
public void visitVarInsn(int opcode, int var) {
fail("No usage of local variables allowed.");
Expand Down
Expand Up @@ -28,9 +28,9 @@

import java.io.IOException;

import org.jacoco.core.JaCoCo;
import org.jacoco.core.instr.Instrumenter;
import org.jacoco.core.internal.Java9Support;
import org.jacoco.core.internal.instr.InstrSupport;
import org.jacoco.core.runtime.IRuntime;
import org.jacoco.core.runtime.SystemPropertiesRuntime;
import org.junit.Test;
Expand Down Expand Up @@ -102,12 +102,12 @@ private void testVersion(int version, boolean frames) throws IOException {
private void assertFrames(byte[] source, boolean expected) {
final boolean[] hasFrames = new boolean[] { false };
new ClassReader(Java9Support.downgradeIfRequired(source)).accept(
new ClassVisitor(JaCoCo.ASM_API_VERSION) {
new ClassVisitor(InstrSupport.ASM_API_VERSION) {

@Override
public MethodVisitor visitMethod(int access, String name,
String desc, String signature, String[] exceptions) {
return new MethodVisitor(JaCoCo.ASM_API_VERSION) {
return new MethodVisitor(InstrSupport.ASM_API_VERSION) {

@Override
public void visitFrame(int type, int nLocal,
Expand Down
Expand Up @@ -20,6 +20,7 @@
import org.jacoco.core.JaCoCo;
import org.jacoco.core.instr.Instrumenter;
import org.jacoco.core.internal.Java9Support;
import org.jacoco.core.internal.instr.InstrSupport;
import org.jacoco.core.runtime.IRuntime;
import org.jacoco.core.runtime.SystemPropertiesRuntime;
import org.jacoco.core.test.TargetLoader;
Expand Down Expand Up @@ -56,15 +57,15 @@ public class FramesTest {
*/
private static class MaxStackEliminator extends ClassVisitor {
public MaxStackEliminator(ClassVisitor cv) {
super(JaCoCo.ASM_API_VERSION, cv);
super(InstrSupport.ASM_API_VERSION, cv);
}

@Override
public MethodVisitor visitMethod(int access, String name, String desc,
String signature, String[] exceptions) {
final MethodVisitor mv = super.visitMethod(access, name, desc,
signature, exceptions);
return new MethodVisitor(JaCoCo.ASM_API_VERSION, mv) {
return new MethodVisitor(InstrSupport.ASM_API_VERSION, mv) {
@Override
public void visitMaxs(int maxStack, int maxLocals) {
super.visitMaxs(-1, maxLocals);
Expand Down Expand Up @@ -93,7 +94,7 @@ private byte[] calculateFrames(byte[] source) {
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);

// Adjust Version to 1.6 to enable frames:
rc.accept(new ClassVisitor(JaCoCo.ASM_API_VERSION, cw) {
rc.accept(new ClassVisitor(InstrSupport.ASM_API_VERSION, cw) {

@Override
public void visit(int version, int access, String name,
Expand Down
5 changes: 0 additions & 5 deletions org.jacoco.core/src/org/jacoco/core/JaCoCo.java
Expand Up @@ -13,8 +13,6 @@

import java.util.ResourceBundle;

import org.objectweb.asm.Opcodes;

/**
* Static Meta information about JaCoCo.
*/
Expand All @@ -29,9 +27,6 @@ public final class JaCoCo {
/** Name of the runtime package of this build */
public static final String RUNTIMEPACKAGE;

/** ASM API version */
public static final int ASM_API_VERSION = Opcodes.ASM5;

static {
final ResourceBundle bundle = ResourceBundle
.getBundle("org.jacoco.core.jacoco");
Expand Down
Expand Up @@ -24,7 +24,12 @@ public class ExecutionDataWriter implements ISessionInfoVisitor,
IExecutionDataVisitor {

/** File format version, will be incremented for each incompatible change. */
public static final char FORMAT_VERSION = 0x1007;
public static final char FORMAT_VERSION;

static {
// Runtime initialize to ensure javac does not inline the value.
FORMAT_VERSION = 0x1007;
}

/** Magic number in header for file format identification. */
public static final char MAGIC_NUMBER = 0xC0C0;
Expand Down
Expand Up @@ -11,7 +11,7 @@
*******************************************************************************/
package org.jacoco.core.internal.flow;

import org.jacoco.core.JaCoCo;
import org.jacoco.core.internal.instr.InstrSupport;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.commons.AnalyzerAdapter;
Expand Down Expand Up @@ -44,7 +44,7 @@ public class ClassProbesAdapter extends ClassVisitor implements
*/
public ClassProbesAdapter(final ClassProbesVisitor cv,
final boolean trackFrames) {
super(JaCoCo.ASM_API_VERSION, cv);
super(InstrSupport.ASM_API_VERSION, cv);
this.cv = cv;
this.trackFrames = trackFrames;
}
Expand Down
Expand Up @@ -11,7 +11,7 @@
*******************************************************************************/
package org.jacoco.core.internal.flow;

import org.jacoco.core.JaCoCo;
import org.jacoco.core.internal.instr.InstrSupport;
import org.objectweb.asm.ClassVisitor;

/**
Expand All @@ -34,7 +34,7 @@ public ClassProbesVisitor() {
* optional next visitor in chain
*/
public ClassProbesVisitor(final ClassVisitor cv) {
super(JaCoCo.ASM_API_VERSION, cv);
super(InstrSupport.ASM_API_VERSION, cv);
}

/**
Expand Down
Expand Up @@ -11,7 +11,7 @@
*******************************************************************************/
package org.jacoco.core.internal.flow;

import org.jacoco.core.JaCoCo;
import org.jacoco.core.internal.instr.InstrSupport;
import org.objectweb.asm.Handle;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
Expand Down Expand Up @@ -62,7 +62,7 @@ public static void markLabels(final MethodNode method) {
* Create new instance.
*/
public LabelFlowAnalyzer() {
super(JaCoCo.ASM_API_VERSION);
super(InstrSupport.ASM_API_VERSION);
}

@Override
Expand Down
Expand Up @@ -14,7 +14,7 @@
import java.util.HashMap;
import java.util.Map;

import org.jacoco.core.JaCoCo;
import org.jacoco.core.internal.instr.InstrSupport;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
Expand Down Expand Up @@ -44,7 +44,7 @@ public final class MethodProbesAdapter extends MethodVisitor {
*/
public MethodProbesAdapter(final MethodProbesVisitor probesVisitor,
final IProbeIdGenerator idGenerator) {
super(JaCoCo.ASM_API_VERSION, probesVisitor);
super(InstrSupport.ASM_API_VERSION, probesVisitor);
this.probesVisitor = probesVisitor;
this.idGenerator = idGenerator;
this.tryCatchProbeLabels = new HashMap<Label, Label>();
Expand Down
Expand Up @@ -11,7 +11,7 @@
*******************************************************************************/
package org.jacoco.core.internal.flow;

import org.jacoco.core.JaCoCo;
import org.jacoco.core.internal.instr.InstrSupport;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;

Expand All @@ -35,7 +35,7 @@ public MethodProbesVisitor() {
* optional next visitor in chain
*/
public MethodProbesVisitor(final MethodVisitor mv) {
super(JaCoCo.ASM_API_VERSION, mv);
super(InstrSupport.ASM_API_VERSION, mv);
}

/**
Expand Down
Expand Up @@ -11,7 +11,7 @@
*******************************************************************************/
package org.jacoco.core.internal.flow;

import org.jacoco.core.JaCoCo;
import org.jacoco.core.internal.instr.InstrSupport;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.commons.JSRInlinerAdapter;
Expand All @@ -33,7 +33,7 @@ class MethodSanitizer extends JSRInlinerAdapter {
MethodSanitizer(final MethodVisitor mv, final int access,
final String name, final String desc, final String signature,
final String[] exceptions) {
super(JaCoCo.ASM_API_VERSION, mv, access, name, desc, signature,
super(InstrSupport.ASM_API_VERSION, mv, access, name, desc, signature,
exceptions);
}

Expand Down
Expand Up @@ -11,7 +11,6 @@
*******************************************************************************/
package org.jacoco.core.internal.instr;

import org.jacoco.core.JaCoCo;
import org.objectweb.asm.Handle;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
Expand All @@ -27,7 +26,7 @@ class DuplicateFrameEliminator extends MethodVisitor {
private boolean instruction;

public DuplicateFrameEliminator(final MethodVisitor mv) {
super(JaCoCo.ASM_API_VERSION, mv);
super(InstrSupport.ASM_API_VERSION, mv);
instruction = true;
}

Expand Down
Expand Up @@ -24,6 +24,9 @@ public final class InstrSupport {
private InstrSupport() {
}

/** ASM API version */
public static final int ASM_API_VERSION = Opcodes.ASM5;

// === Data Field ===

/**
Expand Down
Expand Up @@ -11,7 +11,6 @@
*******************************************************************************/
package org.jacoco.core.internal.instr;

import org.jacoco.core.JaCoCo;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
Expand Down Expand Up @@ -56,7 +55,7 @@ class ProbeInserter extends MethodVisitor implements IProbeInserter {
*/
ProbeInserter(final int access, final String name, final String desc, final MethodVisitor mv,
final IProbeArrayStrategy arrayStrategy) {
super(JaCoCo.ASM_API_VERSION, mv);
super(InstrSupport.ASM_API_VERSION, mv);
this.clinit = InstrSupport.CLINIT_NAME.equals(name);
this.arrayStrategy = arrayStrategy;
int pos = (Opcodes.ACC_STATIC & access) == 0 ? 1 : 0;
Expand Down
Expand Up @@ -19,8 +19,8 @@
import java.lang.reflect.Field;
import java.security.ProtectionDomain;

import org.jacoco.core.JaCoCo;
import org.jacoco.core.internal.Java9Support;
import org.jacoco.core.internal.instr.InstrSupport;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
Expand Down Expand Up @@ -156,7 +156,7 @@ public static byte[] instrument(final byte[] source,
final String accessFieldName) {
final ClassReader reader = new ClassReader(Java9Support.downgradeIfRequired(source));
final ClassWriter writer = new ClassWriter(reader, 0);
reader.accept(new ClassVisitor(JaCoCo.ASM_API_VERSION, writer) {
reader.accept(new ClassVisitor(InstrSupport.ASM_API_VERSION, writer) {

@Override
public void visitEnd() {
Expand Down
8 changes: 8 additions & 0 deletions org.jacoco.doc/docroot/doc/changes.html
Expand Up @@ -20,8 +20,16 @@ <h1>Change History</h1>

<h2>Snapshot Build @qualified.bundle.version@ (@build.date@)</h2>

<h3>Fixed Bugs</h3>
<ul>
<li><code>ExecutionDataWriter.FORMAT_VERSION</code> is not a compile-time constant
(GitHub <a href="https://github.com/jacoco/jacoco/issues/474">#474</a>).</li>
</ul>

<h3>API Changes</h3>
<ul>
<li><code>JaCoCo.ASM_API_VERSION</code> removed
(GitHub <a href="https://github.com/jacoco/jacoco/issues/474">#474</a>).</li>
<li><code>URLStreamHandlerRuntime</code> removed
(GitHub <a href="https://github.com/jacoco/jacoco/issues/471">#471</a>).</li>
</ul>
Expand Down

0 comments on commit cf60ebd

Please sign in to comment.