aboutsummaryrefslogtreecommitdiff
path: root/org.jacoco.core/src/org/jacoco/core/internal
diff options
context:
space:
mode:
Diffstat (limited to 'org.jacoco.core/src/org/jacoco/core/internal')
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/ContentTypeDetector.java47
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/InputStreams.java11
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/Pack200Streams.java194
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/BundleCoverageImpl.java21
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/ClassAnalyzer.java27
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/ClassCoverageImpl.java28
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/CounterImpl.java26
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/Instruction.java51
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/InstructionsBuilder.java23
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/LineImpl.java25
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/MethodAnalyzer.java20
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/MethodCoverageCalculator.java24
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/MethodCoverageImpl.java22
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/PackageCoverageImpl.java19
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/SourceFileCoverageImpl.java19
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/SourceNodeImpl.java29
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/StringPool.java19
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/AbstractMatcher.java13
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/AnnotationGeneratedFilter.java11
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/BridgeFilter.java32
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/EnumEmptyConstructorFilter.java11
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/EnumFilter.java11
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/Filters.java22
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/FinallyFilter.java15
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/IFilter.java11
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/IFilterContext.java102
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/IFilterOutput.java13
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinCoroutineFilter.java53
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinDefaultArgumentsFilter.java95
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinDefaultMethodsFilter.java46
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinGeneratedFilter.java14
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinInlineFilter.java20
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinLateinitFilter.java24
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinNotNullOperatorFilter.java14
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinUnsafeCastOperatorFilter.java37
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinWhenFilter.java19
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinWhenStringFilter.java44
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/PrivateEmptyNoArgConstructorFilter.java11
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/RecordsFilter.java89
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/StringSwitchFilter.java (renamed from org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/StringSwitchEcjFilter.java)26
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/StringSwitchJavacFilter.java15
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/SynchronizedFilter.java11
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/SyntheticFilter.java32
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/TryWithResourcesEcjFilter.java11
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/TryWithResourcesJavac11Filter.java13
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/TryWithResourcesJavacFilter.java13
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/data/CRC64.java15
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/data/CompactDataInput.java21
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/data/CompactDataOutput.java21
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/flow/ClassProbesAdapter.java22
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/flow/ClassProbesVisitor.java17
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/flow/FrameSnapshot.java18
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/flow/IFrame.java15
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/flow/IProbeIdGenerator.java15
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/flow/LabelFlowAnalyzer.java15
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/flow/LabelInfo.java47
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/flow/MethodProbesAdapter.java25
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/flow/MethodProbesVisitor.java25
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/flow/MethodSanitizer.java19
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/instr/ClassFieldProbeArrayStrategy.java20
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/instr/ClassInstrumenter.java18
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/instr/CondyProbeArrayStrategy.java13
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/instr/DuplicateFrameEliminator.java13
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/instr/IProbeArrayStrategy.java17
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/instr/IProbeInserter.java15
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/instr/InstrSupport.java25
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/instr/InterfaceFieldProbeArrayStrategy.java14
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/instr/LocalProbeArrayStrategy.java13
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/instr/MethodInstrumenter.java18
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/instr/NoneProbeArrayStrategy.java13
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeArrayStrategyFactory.java13
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeCounter.java16
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeInserter.java33
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/instr/SignatureRemover.java22
74 files changed, 1198 insertions, 773 deletions
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/ContentTypeDetector.java b/org.jacoco.core/src/org/jacoco/core/internal/ContentTypeDetector.java
index 74574ecc..f07528ad 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/ContentTypeDetector.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/ContentTypeDetector.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal;
@@ -15,8 +16,6 @@ import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
-import org.objectweb.asm.Opcodes;
-
/**
* Detector for content types of binary streams based on a magic headers.
*/
@@ -47,7 +46,7 @@ public class ContentTypeDetector {
* Creates a new detector based on the given input. To process the complete
* original input afterwards use the stream returned by
* {@link #getInputStream()}.
- *
+ *
* @param in
* input to read the header from
* @throws IOException
@@ -72,24 +71,14 @@ public class ContentTypeDetector {
case PACK200FILE:
return PACK200FILE;
case CLASSFILE:
- // also verify version to distinguish from Mach Object files:
- switch (readInt(in)) {
- case Opcodes.V1_1:
- case Opcodes.V1_2:
- case Opcodes.V1_3:
- case Opcodes.V1_4:
- case Opcodes.V1_5:
- case Opcodes.V1_6:
- case Opcodes.V1_7:
- case Opcodes.V1_8:
- case Opcodes.V9:
- case Opcodes.V10:
- case Opcodes.V11:
- case Opcodes.V11 | Opcodes.V_PREVIEW:
- case Opcodes.V12:
- case Opcodes.V12 | Opcodes.V_PREVIEW:
- case (Opcodes.V12 + 1):
- case (Opcodes.V12 + 1) | Opcodes.V_PREVIEW:
+ // Mach-O fat/universal binaries have the same magic header as Java
+ // class files, number of architectures is stored in unsigned 4
+ // bytes in the same place and in the same big-endian order as major
+ // and minor version of class file. Hopefully on practice number of
+ // architectures in single executable is less than 45, which is
+ // major version of Java 1.1 class files:
+ final int majorVersion = readInt(in) & 0xFFFF;
+ if (majorVersion >= 45) {
return CLASSFILE;
}
}
@@ -106,7 +95,7 @@ public class ContentTypeDetector {
/**
* Returns an input stream instance to read the complete content (including
* the header) of the underlying stream.
- *
+ *
* @return input stream containing the complete content
*/
public InputStream getInputStream() {
@@ -115,7 +104,7 @@ public class ContentTypeDetector {
/**
* Returns the detected file type.
- *
+ *
* @return file type
*/
public int getType() {
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/InputStreams.java b/org.jacoco.core/src/org/jacoco/core/internal/InputStreams.java
index 93f86f67..7cd104b7 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/InputStreams.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/InputStreams.java
@@ -1,9 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/Pack200Streams.java b/org.jacoco.core/src/org/jacoco/core/internal/Pack200Streams.java
index eae4fdfa..b9539ef3 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/Pack200Streams.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/Pack200Streams.java
@@ -1,78 +1,116 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.core.internal;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.FilterInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.jar.JarInputStream;
-import java.util.jar.JarOutputStream;
-import java.util.jar.Pack200;
-
-/**
- * Internal wrapper for the weird Pack200 Java API to allow usage with streams.
- */
-public final class Pack200Streams {
-
- /**
- * Unpack a stream in Pack200 format into a stream in JAR/ZIP format.
- *
- * @param input
- * stream in Pack200 format
- * @return stream in JAR/ZIP format
- * @throws IOException
- * in case of errors with the streams
- */
- public static InputStream unpack(final InputStream input)
- throws IOException {
- final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
- final JarOutputStream jar = new JarOutputStream(buffer);
- Pack200.newUnpacker().unpack(new NoCloseInput(input), jar);
- jar.finish();
- return new ByteArrayInputStream(buffer.toByteArray());
- }
-
- /**
- * Packs a buffer in JAR/ZIP format into a stream in Pack200 format.
- *
- * @param source
- * source in JAR/ZIP format
- * @param output
- * stream in Pack200 format
- * @throws IOException
- * in case of errors with the streams
- */
- public static void pack(final byte[] source, final OutputStream output)
- throws IOException {
- final JarInputStream jar = new JarInputStream(new ByteArrayInputStream(
- source));
- Pack200.newPacker().pack(jar, output);
- }
-
- private static class NoCloseInput extends FilterInputStream {
- protected NoCloseInput(final InputStream in) {
- super(in);
- }
-
- @Override
- public void close() throws IOException {
- // do not close the underlying stream
- }
- }
-
- private Pack200Streams() {
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.core.internal;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.FilterInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.util.jar.JarInputStream;
+import java.util.jar.JarOutputStream;
+
+/**
+ * Internal wrapper for the weird Pack200 Java API to allow usage with streams.
+ */
+public final class Pack200Streams {
+
+ /**
+ * Unpack a stream in Pack200 format into a stream in JAR/ZIP format.
+ *
+ * @param input
+ * stream in Pack200 format
+ * @return stream in JAR/ZIP format
+ * @throws IOException
+ * in case of errors with the streams
+ */
+ @SuppressWarnings("resource")
+ public static InputStream unpack(final InputStream input)
+ throws IOException {
+ final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+ final JarOutputStream jar = new JarOutputStream(buffer);
+ try {
+ final Object unpacker = Class.forName("java.util.jar.Pack200")
+ .getMethod("newUnpacker").invoke(null);
+ Class.forName("java.util.jar.Pack200$Unpacker")
+ .getMethod("unpack", InputStream.class,
+ JarOutputStream.class)
+ .invoke(unpacker, new NoCloseInput(input), jar);
+ } catch (ClassNotFoundException e) {
+ throw newIOException(e);
+ } catch (NoSuchMethodException e) {
+ throw newIOException(e);
+ } catch (IllegalAccessException e) {
+ throw newIOException(e);
+ } catch (InvocationTargetException e) {
+ throw newIOException(e.getCause());
+ }
+ jar.finish();
+ return new ByteArrayInputStream(buffer.toByteArray());
+ }
+
+ /**
+ * Packs a buffer in JAR/ZIP format into a stream in Pack200 format.
+ *
+ * @param source
+ * source in JAR/ZIP format
+ * @param output
+ * stream in Pack200 format
+ * @throws IOException
+ * in case of errors with the streams
+ */
+ @SuppressWarnings("resource")
+ public static void pack(final byte[] source, final OutputStream output)
+ throws IOException {
+ final JarInputStream jar = new JarInputStream(
+ new ByteArrayInputStream(source));
+ try {
+ final Object packer = Class.forName("java.util.jar.Pack200")
+ .getMethod("newPacker").invoke(null);
+ Class.forName("java.util.jar.Pack200$Packer")
+ .getMethod("pack", JarInputStream.class, OutputStream.class)
+ .invoke(packer, jar, output);
+ } catch (ClassNotFoundException e) {
+ throw newIOException(e);
+ } catch (NoSuchMethodException e) {
+ throw newIOException(e);
+ } catch (IllegalAccessException e) {
+ throw newIOException(e);
+ } catch (InvocationTargetException e) {
+ throw newIOException(e.getCause());
+ }
+ }
+
+ private static IOException newIOException(final Throwable cause) {
+ final IOException exception = new IOException();
+ exception.initCause(cause);
+ return exception;
+ }
+
+ private static class NoCloseInput extends FilterInputStream {
+ protected NoCloseInput(final InputStream in) {
+ super(in);
+ }
+
+ @Override
+ public void close() throws IOException {
+ // do not close the underlying stream
+ }
+ }
+
+ private Pack200Streams() {
+ }
+
+}
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/BundleCoverageImpl.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/BundleCoverageImpl.java
index 9c6fcefc..8e799153 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/BundleCoverageImpl.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/BundleCoverageImpl.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.analysis;
@@ -28,14 +29,14 @@ import org.jacoco.core.analysis.ISourceFileCoverage;
/**
* Implementation of {@link IBundleCoverage}.
*/
-public class BundleCoverageImpl extends CoverageNodeImpl implements
- IBundleCoverage {
+public class BundleCoverageImpl extends CoverageNodeImpl
+ implements IBundleCoverage {
private final Collection<IPackageCoverage> packages;
/**
* Creates a new instance of a bundle with the given name.
- *
+ *
* @param name
* name of this bundle
* @param packages
@@ -51,7 +52,7 @@ public class BundleCoverageImpl extends CoverageNodeImpl implements
/**
* Creates a new instance of a bundle with the given name. The packages are
* calculated from the given classes and source files.
- *
+ *
* @param name
* name of this bundle
* @param classes
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/ClassAnalyzer.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/ClassAnalyzer.java
index a18ee7ed..c42c7eea 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/ClassAnalyzer.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/ClassAnalyzer.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.analysis;
@@ -21,6 +22,7 @@ import org.jacoco.core.internal.flow.ClassProbesVisitor;
import org.jacoco.core.internal.flow.MethodProbesVisitor;
import org.jacoco.core.internal.instr.InstrSupport;
import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Attribute;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.tree.MethodNode;
@@ -37,13 +39,15 @@ public class ClassAnalyzer extends ClassProbesVisitor
private final Set<String> classAnnotations = new HashSet<String>();
+ private final Set<String> classAttributes = new HashSet<String>();
+
private String sourceDebugExtension;
private final IFilter filter;
/**
* Creates a new analyzer that builds coverage data for a class.
- *
+ *
* @param coverage
* coverage node for the analyzed class data
* @param probes
@@ -76,6 +80,11 @@ public class ClassAnalyzer extends ClassProbesVisitor
}
@Override
+ public void visitAttribute(final Attribute attribute) {
+ classAttributes.add(attribute.type);
+ }
+
+ @Override
public void visitSource(final String source, final String debug) {
coverage.setSourceFileName(stringPool.get(source));
sourceDebugExtension = debug;
@@ -146,6 +155,10 @@ public class ClassAnalyzer extends ClassProbesVisitor
return classAnnotations;
}
+ public Set<String> getClassAttributes() {
+ return classAttributes;
+ }
+
public String getSourceFileName() {
return coverage.getSourceFileName();
}
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/ClassCoverageImpl.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/ClassCoverageImpl.java
index 444a81ed..f91c8f67 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/ClassCoverageImpl.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/ClassCoverageImpl.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.analysis;
@@ -20,7 +21,8 @@ import org.jacoco.core.analysis.IMethodCoverage;
/**
* Implementation of {@link IClassCoverage}.
*/
-public class ClassCoverageImpl extends SourceNodeImpl implements IClassCoverage {
+public class ClassCoverageImpl extends SourceNodeImpl
+ implements IClassCoverage {
private final long id;
private final boolean noMatch;
@@ -32,7 +34,7 @@ public class ClassCoverageImpl extends SourceNodeImpl implements IClassCoverage
/**
* Creates a class coverage data object with the given parameters.
- *
+ *
* @param name
* VM name of the class
* @param id
@@ -51,7 +53,7 @@ public class ClassCoverageImpl extends SourceNodeImpl implements IClassCoverage
/**
* Add a method to this class.
- *
+ *
* @param method
* method data to add
*/
@@ -68,7 +70,7 @@ public class ClassCoverageImpl extends SourceNodeImpl implements IClassCoverage
/**
* Sets the VM signature of the class.
- *
+ *
* @param signature
* VM signature of the class (may be <code>null</code>)
*/
@@ -78,7 +80,7 @@ public class ClassCoverageImpl extends SourceNodeImpl implements IClassCoverage
/**
* Sets the VM name of the superclass.
- *
+ *
* @param superName
* VM name of the super class (may be <code>null</code>, i.e.
* <code>java/lang/Object</code>)
@@ -89,7 +91,7 @@ public class ClassCoverageImpl extends SourceNodeImpl implements IClassCoverage
/**
* Sets the VM names of implemented/extended interfaces.
- *
+ *
* @param interfaces
* VM names of implemented/extended interfaces
*/
@@ -99,7 +101,7 @@ public class ClassCoverageImpl extends SourceNodeImpl implements IClassCoverage
/**
* Sets the name of the corresponding source file for this class.
- *
+ *
* @param sourceFileName
* name of the source file
*/
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/CounterImpl.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/CounterImpl.java
index e166c626..0ff6d78b 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/CounterImpl.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/CounterImpl.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.analysis;
@@ -22,7 +23,8 @@ public abstract class CounterImpl implements ICounter {
/** Max counter value for which singletons are created */
private static final int SINGLETON_LIMIT = 30;
- private static final CounterImpl[][] SINGLETONS = new CounterImpl[SINGLETON_LIMIT + 1][];
+ private static final CounterImpl[][] SINGLETONS = new CounterImpl[SINGLETON_LIMIT
+ + 1][];
static {
for (int i = 0; i <= SINGLETON_LIMIT; i++) {
@@ -74,7 +76,7 @@ public abstract class CounterImpl implements ICounter {
/**
* Factory method to retrieve a counter with the given number of items.
- *
+ *
* @param missed
* number of missed items
* @param covered
@@ -91,7 +93,7 @@ public abstract class CounterImpl implements ICounter {
/**
* Factory method to retrieve a clone of the given counter.
- *
+ *
* @param counter
* counter to copy
* @return counter instance
@@ -108,7 +110,7 @@ public abstract class CounterImpl implements ICounter {
/**
* Creates a new instance with the given numbers.
- *
+ *
* @param missed
* number of missed items
* @param covered
@@ -123,7 +125,7 @@ public abstract class CounterImpl implements ICounter {
* Returns a counter with values incremented by the numbers of the given
* counter. It is up to the implementation whether this counter instance is
* modified or a new instance is returned.
- *
+ *
* @param counter
* number of additional total and covered items
* @return counter instance with incremented values
@@ -136,7 +138,7 @@ public abstract class CounterImpl implements ICounter {
* Returns a counter with values incremented by the given numbers. It is up
* to the implementation whether this counter instance is modified or a new
* instance is returned.
- *
+ *
* @param missed
* number of missed items
* @param covered
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/Instruction.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/Instruction.java
index c5a1aaae..2e34bf03 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/Instruction.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/Instruction.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.analysis;
@@ -22,31 +23,31 @@ import org.jacoco.core.analysis.ICounter;
* outgoing branch. Each instruction has at least one branch, for example in
* case of a simple sequence of instructions (by convention branch 0). Instances
* of this class are used in two steps:
- *
- * <h3>Step 1: Building the CFG</h3>
- *
+ *
+ * <h2>Step 1: Building the CFG</h2>
+ *
* For each bytecode instruction of a method a {@link Instruction} instance is
* created. In correspondence with the CFG these instances are linked with each
* other with the <code>addBranch()</code> methods. The executions status is
* either directly derived from a probe which has been inserted in the execution
* flow ({@link #addBranch(boolean, int)}) or indirectly propagated along the
* CFG edges ({@link #addBranch(Instruction, int)}).
- *
- * <h3>Step 2: Querying the Coverage Status</h3>
- *
+ *
+ * <h2>Step 2: Querying the Coverage Status</h2>
+ *
* After all instructions have been created and linked each instruction knows
* its execution status and can be queried with:
- *
+ *
* <ul>
* <li>{@link #getLine()}</li>
* <li>{@link #getInstructionCounter()}</li>
* <li>{@link #getBranchCounter()}</li>
* </ul>
- *
+ *
* For the purpose of filtering instructions can be combined to new
* instructions. Note that these methods create new {@link Instruction}
* instances and do not modify the existing ones.
- *
+ *
* <ul>
* <li>{@link #merge(Instruction)}</li>
* <li>{@link #replaceBranches(Collection)}</li>
@@ -66,7 +67,7 @@ public class Instruction {
/**
* New instruction at the given line.
- *
+ *
* @param line
* source line this instruction belongs to
*/
@@ -81,10 +82,10 @@ public class Instruction {
* derived from the execution status of the target instruction. In case the
* branch is covered the status is propagated also to the predecessors of
* this instruction.
- *
+ *
* Note: This method is not idempotent and must be called exactly once for
* every branch.
- *
+ *
* @param target
* target instruction of this branch
* @param branch
@@ -103,10 +104,10 @@ public class Instruction {
* Adds a branch to this instruction which execution status is directly
* derived from a probe. In case the branch is covered the status is
* propagated also to the predecessors of this instruction.
- *
+ *
* Note: This method is not idempotent and must be called exactly once for
* every branch.
- *
+ *
* @param executed
* whether the corresponding probe has been executed
* @param branch
@@ -134,7 +135,7 @@ public class Instruction {
/**
* Returns the source line this instruction belongs to.
- *
+ *
* @return corresponding source line
*/
public int getLine() {
@@ -144,7 +145,7 @@ public class Instruction {
/**
* Merges information about covered branches of this instruction with
* another instruction.
- *
+ *
* @param other
* instruction to merge with
* @return new instance with merged branches
@@ -161,7 +162,7 @@ public class Instruction {
* Creates a copy of this instruction where all outgoing branches are
* replaced with the given instructions. The coverage status of the new
* instruction is derived from the status of the given instructions.
- *
+ *
* @param newBranches
* new branches to consider
* @return new instance with replaced branches
@@ -182,7 +183,7 @@ public class Instruction {
/**
* Returns the instruction coverage counter of this instruction. It is
* always 1 instruction which is covered or not.
- *
+ *
* @return the instruction coverage counter
*/
public ICounter getInstructionCounter() {
@@ -193,7 +194,7 @@ public class Instruction {
/**
* Returns the branch coverage counter of this instruction. Only
* instructions with at least 2 outgoing edges report branches.
- *
+ *
* @return the branch coverage counter
*/
public ICounter getBranchCounter() {
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/InstructionsBuilder.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/InstructionsBuilder.java
index b22d872a..a69f34c8 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/InstructionsBuilder.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/InstructionsBuilder.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.analysis;
@@ -46,7 +47,7 @@ class InstructionsBuilder {
/**
* The labels which mark the subsequent instructions.
- *
+ *
* Due to ASM issue #315745 there can be more than one label per instruction
*/
private final List<Label> currentLabel;
@@ -60,7 +61,7 @@ class InstructionsBuilder {
/**
* Creates a new builder instance which can be used to analyze a single
* method.
- *
+ *
* @param probes
* probe array of the corresponding class used to determine the
* coverage status of every instruction.
@@ -126,7 +127,7 @@ class InstructionsBuilder {
/**
* Adds a jump from the last added instruction.
- *
+ *
* @param target
* jump target
* @param branch
@@ -138,7 +139,7 @@ class InstructionsBuilder {
/**
* Adds a new probe for the last instruction.
- *
+ *
* @param probeId
* index in the probe array
* @param branch
@@ -152,7 +153,7 @@ class InstructionsBuilder {
/**
* Returns the status for all instructions of this method. This method must
* be called exactly once after the instructions have been added.
- *
+ *
* @return map of ASM instruction nodes to corresponding {@link Instruction}
* instances
*/
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/LineImpl.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/LineImpl.java
index 908bcb60..b504c510 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/LineImpl.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/LineImpl.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.analysis;
@@ -25,7 +26,8 @@ public abstract class LineImpl implements ILine {
/** Max branch counter value for which singletons are created */
private static final int SINGLETON_BRA_LIMIT = 4;
- private static final LineImpl[][][][] SINGLETONS = new LineImpl[SINGLETON_INS_LIMIT + 1][][][];
+ private static final LineImpl[][][][] SINGLETONS = new LineImpl[SINGLETON_INS_LIMIT
+ + 1][][][];
static {
for (int i = 0; i <= SINGLETON_INS_LIMIT; i++) {
@@ -82,8 +84,8 @@ public abstract class LineImpl implements ILine {
*/
private static final class Fix extends LineImpl {
public Fix(final int im, final int ic, final int bm, final int bc) {
- super(CounterImpl.getInstance(im, ic), CounterImpl.getInstance(bm,
- bc));
+ super(CounterImpl.getInstance(im, ic),
+ CounterImpl.getInstance(bm, bc));
}
@Override
@@ -100,14 +102,15 @@ public abstract class LineImpl implements ILine {
/** branch counter */
protected CounterImpl branches;
- private LineImpl(final CounterImpl instructions, final CounterImpl branches) {
+ private LineImpl(final CounterImpl instructions,
+ final CounterImpl branches) {
this.instructions = instructions;
this.branches = branches;
}
/**
* Adds the given counters to this line.
- *
+ *
* @param instructions
* instructions to add
* @param branches
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/MethodAnalyzer.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/MethodAnalyzer.java
index 1aaadf2e..547d6b36 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/MethodAnalyzer.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/MethodAnalyzer.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.analysis;
@@ -46,10 +47,9 @@ public class MethodAnalyzer extends MethodProbesVisitor {
for (final TryCatchBlockNode n : methodNode.tryCatchBlocks) {
n.accept(methodVisitor);
}
- currentNode = methodNode.instructions.getFirst();
- while (currentNode != null) {
- currentNode.accept(methodVisitor);
- currentNode = currentNode.getNext();
+ for (final AbstractInsnNode i : methodNode.instructions) {
+ currentNode = i;
+ i.accept(methodVisitor);
}
methodVisitor.visitEnd();
}
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/MethodCoverageCalculator.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/MethodCoverageCalculator.java
index ebe167a2..2906dd13 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/MethodCoverageCalculator.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/MethodCoverageCalculator.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.analysis;
@@ -19,7 +20,6 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import org.jacoco.core.analysis.ISourceFileCoverage;
import org.jacoco.core.analysis.ISourceNode;
import org.jacoco.core.internal.analysis.filter.IFilterOutput;
import org.objectweb.asm.tree.AbstractInsnNode;
@@ -39,11 +39,11 @@ class MethodCoverageCalculator implements IFilterOutput {
* Instructions that should be merged form disjoint sets. Coverage
* information from instructions of one set will be merged into
* representative instruction of set.
- *
+ *
* Each such set is represented as a singly linked list: each element except
* one references another element from the same set, element without
* reference - is a representative of this set.
- *
+ *
* This map stores reference (value) for elements of sets (key).
*/
private final Map<AbstractInsnNode, AbstractInsnNode> merged;
@@ -61,7 +61,7 @@ class MethodCoverageCalculator implements IFilterOutput {
/**
* Applies all specified filtering commands and calculates the resulting
* coverage.
- *
+ *
* @param coverage
* the result is added to this coverage node
*/
@@ -121,8 +121,8 @@ class MethodCoverageCalculator implements IFilterOutput {
private void ensureCapacity(final MethodCoverageImpl coverage) {
// Determine line range:
- int firstLine = ISourceFileCoverage.UNKNOWN_LINE;
- int lastLine = ISourceFileCoverage.UNKNOWN_LINE;
+ int firstLine = ISourceNode.UNKNOWN_LINE;
+ int lastLine = ISourceNode.UNKNOWN_LINE;
for (final Entry<AbstractInsnNode, Instruction> entry : instructions
.entrySet()) {
if (!ignored.contains(entry.getKey())) {
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/MethodCoverageImpl.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/MethodCoverageImpl.java
index aa7dccf0..b6ba4f95 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/MethodCoverageImpl.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/MethodCoverageImpl.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.analysis;
@@ -17,8 +18,8 @@ import org.jacoco.core.analysis.IMethodCoverage;
/**
* Implementation of {@link IMethodCoverage}.
*/
-public class MethodCoverageImpl extends SourceNodeImpl implements
- IMethodCoverage {
+public class MethodCoverageImpl extends SourceNodeImpl
+ implements IMethodCoverage {
private final String desc;
@@ -26,7 +27,7 @@ public class MethodCoverageImpl extends SourceNodeImpl implements
/**
* Creates a method coverage data object with the given parameters.
- *
+ *
* @param name
* name of the method
* @param desc
@@ -58,7 +59,8 @@ public class MethodCoverageImpl extends SourceNodeImpl implements
* branches have been incremented for this method coverage node.
*/
public void incrementMethodCounter() {
- final ICounter base = this.instructionCounter.getCoveredCount() == 0 ? CounterImpl.COUNTER_1_0
+ final ICounter base = this.instructionCounter.getCoveredCount() == 0
+ ? CounterImpl.COUNTER_1_0
: CounterImpl.COUNTER_0_1;
this.methodCounter = this.methodCounter.increment(base);
this.complexityCounter = this.complexityCounter.increment(base);
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/PackageCoverageImpl.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/PackageCoverageImpl.java
index 285ddd38..b9bad063 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/PackageCoverageImpl.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/PackageCoverageImpl.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.analysis;
@@ -21,8 +22,8 @@ import org.jacoco.core.analysis.ISourceFileCoverage;
/**
* Implementation of {@link IPackageCoverage}.
*/
-public class PackageCoverageImpl extends CoverageNodeImpl implements
- IPackageCoverage {
+public class PackageCoverageImpl extends CoverageNodeImpl
+ implements IPackageCoverage {
private final Collection<IClassCoverage> classes;
@@ -30,7 +31,7 @@ public class PackageCoverageImpl extends CoverageNodeImpl implements
/**
* Creates package node instance for a package with the given name.
- *
+ *
* @param name
* vm name of the package
* @param classes
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/SourceFileCoverageImpl.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/SourceFileCoverageImpl.java
index dc4483f5..fafce46c 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/SourceFileCoverageImpl.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/SourceFileCoverageImpl.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.analysis;
@@ -16,14 +17,14 @@ import org.jacoco.core.analysis.ISourceFileCoverage;
/**
* Implementation of {@link ISourceFileCoverage}.
*/
-public class SourceFileCoverageImpl extends SourceNodeImpl implements
- ISourceFileCoverage {
+public class SourceFileCoverageImpl extends SourceNodeImpl
+ implements ISourceFileCoverage {
private final String packagename;
/**
* Creates a source file data object with the given parameters.
- *
+ *
* @param name
* name of the source file
* @param packagename
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/SourceNodeImpl.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/SourceNodeImpl.java
index 3fa3d692..e577c55d 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/SourceNodeImpl.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/SourceNodeImpl.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.analysis;
@@ -28,7 +29,7 @@ public class SourceNodeImpl extends CoverageNodeImpl implements ISourceNode {
/**
* Create a new source node implementation instance.
- *
+ *
* @param elementType
* element type
* @param name
@@ -44,7 +45,7 @@ public class SourceNodeImpl extends CoverageNodeImpl implements ISourceNode {
* Make sure that the internal buffer can keep lines from first to last.
* While the buffer is also incremented automatically, this method allows
* optimization in case the total range is known in advance.
- *
+ *
* @param first
* first line number or {@link ISourceNode#UNKNOWN_LINE}
* @param last
@@ -75,16 +76,16 @@ public class SourceNodeImpl extends CoverageNodeImpl implements ISourceNode {
* Increments all counters by the values of the given child. When
* incrementing the line counter it is assumed that the child refers to the
* same source file.
- *
+ *
* @param child
* child node to add
*/
public void increment(final ISourceNode child) {
- instructionCounter = instructionCounter.increment(child
- .getInstructionCounter());
+ instructionCounter = instructionCounter
+ .increment(child.getInstructionCounter());
branchCounter = branchCounter.increment(child.getBranchCounter());
- complexityCounter = complexityCounter.increment(child
- .getComplexityCounter());
+ complexityCounter = complexityCounter
+ .increment(child.getComplexityCounter());
methodCounter = methodCounter.increment(child.getMethodCounter());
classCounter = classCounter.increment(child.getClassCounter());
final int firstLine = child.getFirstLine();
@@ -103,7 +104,7 @@ public class SourceNodeImpl extends CoverageNodeImpl implements ISourceNode {
* Increments instructions and branches by the given counter values. If a
* optional line number is specified the instructions and branches are added
* to the given line. The line counter is incremented accordingly.
- *
+ *
* @param instructions
* instructions to add
* @param branches
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/StringPool.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/StringPool.java
index 97e25aaa..8b646e9e 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/StringPool.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/StringPool.java
@@ -1,14 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
- * Brock Janiczak - analysis and concept
+ * Brock Janiczak - analysis and concept
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.analysis;
@@ -31,7 +32,7 @@ public final class StringPool {
/**
* Returns a normalized instance that is equal to the given {@link String} .
- *
+ *
* @param s
* any string or <code>null</code>
* @return normalized instance or <code>null</code>
@@ -52,7 +53,7 @@ public final class StringPool {
* Returns a modified version of the array with all string slots normalized.
* It is up to the implementation to replace strings in the array instance
* or return a new array instance.
- *
+ *
* @param arr
* String array or <code>null</code>
* @return normalized instance or <code>null</code>
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/AbstractMatcher.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/AbstractMatcher.java
index 38860a83..837278e9 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/AbstractMatcher.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/AbstractMatcher.java
@@ -1,9 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
@@ -34,7 +35,7 @@ abstract class AbstractMatcher {
final void firstIsALoad0(final MethodNode methodNode) {
cursor = methodNode.instructions.getFirst();
skipNonOpcodes();
- if (cursor.getOpcode() == Opcodes.ALOAD
+ if (cursor != null && cursor.getOpcode() == Opcodes.ALOAD
&& ((VarInsnNode) cursor).var == 0) {
return;
}
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/AnnotationGeneratedFilter.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/AnnotationGeneratedFilter.java
index d78444c0..1653fa27 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/AnnotationGeneratedFilter.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/AnnotationGeneratedFilter.java
@@ -1,9 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/BridgeFilter.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/BridgeFilter.java
new file mode 100644
index 00000000..bc23941b
--- /dev/null
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/BridgeFilter.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Evgeny Mandrikov - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.core.internal.analysis.filter;
+
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.MethodNode;
+
+/**
+ * Filters bridge methods.
+ */
+final class BridgeFilter implements IFilter {
+
+ public void filter(final MethodNode methodNode,
+ final IFilterContext context, final IFilterOutput output) {
+ if ((methodNode.access & Opcodes.ACC_BRIDGE) == 0) {
+ return;
+ }
+ output.ignore(methodNode.instructions.getFirst(),
+ methodNode.instructions.getLast());
+ }
+
+}
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/EnumEmptyConstructorFilter.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/EnumEmptyConstructorFilter.java
index 4a39d1e8..ae23c641 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/EnumEmptyConstructorFilter.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/EnumEmptyConstructorFilter.java
@@ -1,9 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/EnumFilter.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/EnumFilter.java
index 0c2eef58..faab0ad4 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/EnumFilter.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/EnumFilter.java
@@ -1,9 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/Filters.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/Filters.java
index 7a1053b5..484ccc00 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/Filters.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/Filters.java
@@ -1,9 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
@@ -27,24 +28,25 @@ public final class Filters implements IFilter {
/**
* Creates filter that combines all other filters.
- *
+ *
* @return filter that combines all other filters
*/
public static IFilter all() {
return new Filters(new EnumFilter(), new SyntheticFilter(),
- new SynchronizedFilter(), new TryWithResourcesJavac11Filter(),
+ new BridgeFilter(), new SynchronizedFilter(),
+ new TryWithResourcesJavac11Filter(),
new TryWithResourcesJavacFilter(),
new TryWithResourcesEcjFilter(), new FinallyFilter(),
new PrivateEmptyNoArgConstructorFilter(),
- new StringSwitchJavacFilter(), new StringSwitchEcjFilter(),
- new EnumEmptyConstructorFilter(),
+ new StringSwitchJavacFilter(), new StringSwitchFilter(),
+ new EnumEmptyConstructorFilter(), new RecordsFilter(),
new AnnotationGeneratedFilter(), new KotlinGeneratedFilter(),
new KotlinLateinitFilter(), new KotlinWhenFilter(),
new KotlinWhenStringFilter(),
new KotlinUnsafeCastOperatorFilter(),
new KotlinNotNullOperatorFilter(),
new KotlinDefaultArgumentsFilter(), new KotlinInlineFilter(),
- new KotlinCoroutineFilter());
+ new KotlinCoroutineFilter(), new KotlinDefaultMethodsFilter());
}
private Filters(final IFilter... filters) {
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/FinallyFilter.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/FinallyFilter.java
index b2e0b145..284d4322 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/FinallyFilter.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/FinallyFilter.java
@@ -1,9 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
@@ -26,7 +27,7 @@ import org.objectweb.asm.tree.VarInsnNode;
* Filters duplicates of finally blocks that compiler generates.
*
* To understand algorithm of filtering, consider following example:
- *
+ *
* <pre>
* try {
* if (x) {
@@ -44,7 +45,7 @@ import org.objectweb.asm.tree.VarInsnNode;
* There are 4 <b>distinct</b> points of exit out of these "try/catch/finally"
* blocks - three without exception, and one with Throwable if it is thrown
* prior to reaching first three points of exit.
- *
+ *
* "finally" block must be executed just before these points, so there must be 4
* copies of its bytecode instructions.
*
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/IFilter.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/IFilter.java
index b662ba4f..9f0a7589 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/IFilter.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/IFilter.java
@@ -1,9 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/IFilterContext.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/IFilterContext.java
index 8b97654d..992e3e8d 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/IFilterContext.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/IFilterContext.java
@@ -1,48 +1,54 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.core.internal.analysis.filter;
-
-import java.util.Set;
-
-/**
- * Context information provided to filters.
- */
-public interface IFilterContext {
-
- /**
- * @return vm name of the enclosing class
- */
- String getClassName();
-
- /**
- * @return vm name of the super class of the enclosing class
- */
- String getSuperClassName();
-
- /**
- * @return vm names of the class annotations of the enclosing class
- */
- Set<String> getClassAnnotations();
-
- /**
- * @return file name of the corresponding source file or <code>null</code>
- * if not available
- */
- String getSourceFileName();
-
- /**
- * @return value of SourceDebugExtension attribute or <code>null</code> if
- * not available
- */
- String getSourceDebugExtension();
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.core.internal.analysis.filter;
+
+import java.util.Set;
+
+/**
+ * Context information provided to filters.
+ */
+public interface IFilterContext {
+
+ /**
+ * @return vm name of the enclosing class
+ */
+ String getClassName();
+
+ /**
+ * @return vm name of the super class of the enclosing class
+ */
+ String getSuperClassName();
+
+ /**
+ * @return vm names of the class annotations of the enclosing class
+ */
+ Set<String> getClassAnnotations();
+
+ /**
+ * @return names of the class attributes
+ */
+ Set<String> getClassAttributes();
+
+ /**
+ * @return file name of the corresponding source file or <code>null</code>
+ * if not available
+ */
+ String getSourceFileName();
+
+ /**
+ * @return value of SourceDebugExtension attribute or <code>null</code> if
+ * not available
+ */
+ String getSourceDebugExtension();
+
+}
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/IFilterOutput.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/IFilterOutput.java
index 0f022201..93ad2eeb 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/IFilterOutput.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/IFilterOutput.java
@@ -1,9 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
@@ -35,7 +36,7 @@ public interface IFilterOutput {
/**
* Marks two instructions that should be merged during computation of
* coverage.
- *
+ *
* @param i1
* first instruction
* @param i2
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinCoroutineFilter.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinCoroutineFilter.java
index 66d450a3..4b850f33 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinCoroutineFilter.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinCoroutineFilter.java
@@ -1,9 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
@@ -19,6 +20,7 @@ import org.objectweb.asm.Type;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.JumpInsnNode;
import org.objectweb.asm.tree.LdcInsnNode;
+import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.TableSwitchInsnNode;
@@ -27,7 +29,11 @@ import org.objectweb.asm.tree.TableSwitchInsnNode;
*/
public final class KotlinCoroutineFilter implements IFilter {
- static boolean isLastArgumentContinuation(final MethodNode methodNode) {
+ static boolean isImplementationOfSuspendFunction(
+ final MethodNode methodNode) {
+ if (methodNode.name.startsWith("access$")) {
+ return false;
+ }
final Type methodType = Type.getMethodType(methodNode.desc);
final int lastArgument = methodType.getArgumentTypes().length - 1;
return lastArgument >= 0 && "kotlin.coroutines.Continuation".equals(
@@ -42,16 +48,41 @@ public final class KotlinCoroutineFilter implements IFilter {
}
new Matcher().match(methodNode, output);
-
+ new Matcher().matchOptimizedTailCall(methodNode, output);
}
private static class Matcher extends AbstractMatcher {
+
+ private void matchOptimizedTailCall(final MethodNode methodNode,
+ final IFilterOutput output) {
+ for (final AbstractInsnNode i : methodNode.instructions) {
+ cursor = i;
+ nextIs(Opcodes.DUP);
+ nextIsInvoke(Opcodes.INVOKESTATIC,
+ "kotlin/coroutines/intrinsics/IntrinsicsKt",
+ "getCOROUTINE_SUSPENDED", "()Ljava/lang/Object;");
+ nextIs(Opcodes.IF_ACMPNE);
+ nextIs(Opcodes.ARETURN);
+ nextIs(Opcodes.POP);
+ if (cursor != null) {
+ output.ignore(i.getNext(), cursor);
+ }
+ }
+ }
+
private void match(final MethodNode methodNode,
final IFilterOutput output) {
- cursor = methodNode.instructions.getFirst();
- nextIsInvoke(Opcodes.INVOKESTATIC,
- "kotlin/coroutines/intrinsics/IntrinsicsKt",
- "getCOROUTINE_SUSPENDED", "()Ljava/lang/Object;");
+ cursor = skipNonOpcodes(methodNode.instructions.getFirst());
+ if (cursor == null || cursor.getOpcode() != Opcodes.INVOKESTATIC) {
+ cursor = null;
+ } else {
+ final MethodInsnNode m = (MethodInsnNode) cursor;
+ if (!"kotlin/coroutines/intrinsics/IntrinsicsKt".equals(m.owner)
+ || !"getCOROUTINE_SUSPENDED".equals(m.name)
+ || !"()Ljava/lang/Object;".equals(m.desc)) {
+ cursor = null;
+ }
+ }
if (cursor == null) {
cursor = skipNonOpcodes(methodNode.instructions.getFirst());
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinDefaultArgumentsFilter.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinDefaultArgumentsFilter.java
index ef198447..b734d234 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinDefaultArgumentsFilter.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinDefaultArgumentsFilter.java
@@ -1,9 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
@@ -18,15 +19,16 @@ import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.JumpInsnNode;
+import org.objectweb.asm.tree.LdcInsnNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.VarInsnNode;
/**
* Filters branches that Kotlin compiler generates for default arguments.
- *
+ *
* For each default argument Kotlin compiler generates following bytecode to
* determine if it should be used or not:
- *
+ *
* <pre>
* ILOAD maskVar
* ICONST_x, BIPUSH, SIPUSH, LDC or LDC_W
@@ -35,16 +37,30 @@ import org.objectweb.asm.tree.VarInsnNode;
* default argument
* label:
* </pre>
- *
+ *
* Where <code>maskVar</code> is penultimate argument of synthetic method with
- * suffix "$default". And its value can't be zero - invocation with all
- * arguments uses original non synthetic method, thus <code>IFEQ</code>
- * instructions should be ignored.
+ * suffix "$default" or of synthetic constructor with last argument
+ * "kotlin.jvm.internal.DefaultConstructorMarker". And its value can't be zero -
+ * invocation with all arguments uses original non synthetic method, thus
+ * <code>IFEQ</code> instructions should be ignored.
*/
public final class KotlinDefaultArgumentsFilter implements IFilter {
- static boolean isDefaultArgumentsMethodName(final String methodName) {
- return methodName.endsWith("$default");
+ static boolean isDefaultArgumentsMethod(final MethodNode methodNode) {
+ return methodNode.name.endsWith("$default");
+ }
+
+ static boolean isDefaultArgumentsConstructor(final MethodNode methodNode) {
+ if (!"<init>".equals(methodNode.name)) {
+ return false;
+ }
+ final Type[] argumentTypes = Type.getMethodType(methodNode.desc)
+ .getArgumentTypes();
+ if (argumentTypes.length < 2) {
+ return false;
+ }
+ return "kotlin.jvm.internal.DefaultConstructorMarker"
+ .equals(argumentTypes[argumentTypes.length - 1].getClassName());
}
public void filter(final MethodNode methodNode,
@@ -52,24 +68,45 @@ public final class KotlinDefaultArgumentsFilter implements IFilter {
if ((methodNode.access & Opcodes.ACC_SYNTHETIC) == 0) {
return;
}
- if (!isDefaultArgumentsMethodName(methodNode.name)) {
- return;
- }
if (!KotlinGeneratedFilter.isKotlinClass(context)) {
return;
}
- new Matcher().match(methodNode, output);
+ if (isDefaultArgumentsMethod(methodNode)) {
+ new Matcher().match(methodNode, output, false);
+ } else if (isDefaultArgumentsConstructor(methodNode)) {
+ new Matcher().match(methodNode, output, true);
+ }
}
private static class Matcher extends AbstractMatcher {
public void match(final MethodNode methodNode,
- final IFilterOutput output) {
- cursor = methodNode.instructions.getFirst();
+ final IFilterOutput output, final boolean constructor) {
+ cursor = skipNonOpcodes(methodNode.instructions.getFirst());
+
+ nextIs(Opcodes.IFNULL);
+ nextIsType(Opcodes.NEW, "java/lang/UnsupportedOperationException");
+ nextIs(Opcodes.DUP);
+ nextIs(Opcodes.LDC);
+ if (cursor == null
+ || !(((LdcInsnNode) cursor).cst instanceof String)
+ || !(((String) ((LdcInsnNode) cursor).cst).startsWith(
+ "Super calls with default arguments not supported in this target"))) {
+ cursor = null;
+ }
+ nextIsInvoke(Opcodes.INVOKESPECIAL,
+ "java/lang/UnsupportedOperationException", "<init>",
+ "(Ljava/lang/String;)V");
+ nextIs(Opcodes.ATHROW);
+ if (cursor != null) {
+ output.ignore(methodNode.instructions.getFirst(), cursor);
+ next();
+ } else {
+ cursor = skipNonOpcodes(methodNode.instructions.getFirst());
+ }
final Set<AbstractInsnNode> ignore = new HashSet<AbstractInsnNode>();
- final int maskVar = Type.getMethodType(methodNode.desc)
- .getArgumentTypes().length - 2;
+ final int maskVar = maskVar(methodNode.desc, constructor);
while (true) {
if (cursor.getOpcode() != Opcodes.ILOAD) {
break;
@@ -92,6 +129,22 @@ public final class KotlinDefaultArgumentsFilter implements IFilter {
output.ignore(i, i);
}
}
+
+ private static int maskVar(final String desc,
+ final boolean constructor) {
+ int slot = 0;
+ if (constructor) {
+ // one slot for reference to current object
+ slot++;
+ }
+ final Type[] argumentTypes = Type.getMethodType(desc)
+ .getArgumentTypes();
+ final int penultimateArgument = argumentTypes.length - 2;
+ for (int i = 0; i < penultimateArgument; i++) {
+ slot += argumentTypes[i].getSize();
+ }
+ return slot;
+ }
}
}
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinDefaultMethodsFilter.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinDefaultMethodsFilter.java
new file mode 100644
index 00000000..50d6280e
--- /dev/null
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinDefaultMethodsFilter.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Evgeny Mandrikov - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.core.internal.analysis.filter;
+
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.MethodInsnNode;
+import org.objectweb.asm.tree.MethodNode;
+
+/**
+ * Filters methods that Kotlin compiler generates for non-overridden
+ * non-abstract methods of interfaces.
+ */
+final class KotlinDefaultMethodsFilter implements IFilter {
+
+ public void filter(final MethodNode methodNode,
+ final IFilterContext context, final IFilterOutput output) {
+ if (!KotlinGeneratedFilter.isKotlinClass(context)) {
+ return;
+ }
+ new Matcher().match(methodNode, output);
+ }
+
+ private static class Matcher extends AbstractMatcher {
+ private void match(final MethodNode methodNode,
+ final IFilterOutput output) {
+ firstIsALoad0(methodNode);
+ nextIs(Opcodes.INVOKESTATIC);
+ if (cursor != null && ((MethodInsnNode) cursor).owner
+ .endsWith("$DefaultImpls")) {
+ output.ignore(methodNode.instructions.getFirst(),
+ methodNode.instructions.getLast());
+ }
+ }
+ }
+
+}
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinGeneratedFilter.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinGeneratedFilter.java
index 129580a9..4ebc3707 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinGeneratedFilter.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinGeneratedFilter.java
@@ -1,9 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Nikolay Krasko - initial API and implementation
@@ -49,8 +50,7 @@ public class KotlinGeneratedFilter implements IFilter {
}
private boolean hasLineNumber(final MethodNode methodNode) {
- for (AbstractInsnNode i = methodNode.instructions
- .getFirst(); i != null; i = i.getNext()) {
+ for (final AbstractInsnNode i : methodNode.instructions) {
if (AbstractInsnNode.LINE == i.getType()) {
return true;
}
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinInlineFilter.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinInlineFilter.java
index 5666de2d..f3e7d6b9 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinInlineFilter.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinInlineFilter.java
@@ -1,9 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
@@ -46,8 +47,7 @@ public final class KotlinInlineFilter implements IFilter {
}
int line = 0;
- for (AbstractInsnNode i = methodNode.instructions
- .getFirst(); i != null; i = i.getNext()) {
+ for (final AbstractInsnNode i : methodNode.instructions) {
if (AbstractInsnNode.LINE == i.getType()) {
line = ((LineNumberNode) i).line;
}
@@ -92,7 +92,11 @@ public final class KotlinInlineFilter implements IFilter {
}
// LineSection
int min = Integer.MAX_VALUE;
- while (!"*E".equals(line = br.readLine())) {
+ while (true) {
+ line = br.readLine();
+ if (line.equals("*E") || line.equals("*S KotlinDebug")) {
+ break;
+ }
final Matcher m = LINE_INFO_PATTERN.matcher(line);
if (!m.matches()) {
throw new IllegalStateException(
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinLateinitFilter.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinLateinitFilter.java
index 12fe926c..a5e20265 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinLateinitFilter.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinLateinitFilter.java
@@ -1,9 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Fabian Mastenbroek - initial API and implementation
@@ -13,6 +14,7 @@ package org.jacoco.core.internal.analysis.filter;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.JumpInsnNode;
import org.objectweb.asm.tree.MethodNode;
/**
@@ -24,9 +26,8 @@ public class KotlinLateinitFilter implements IFilter {
public void filter(final MethodNode methodNode,
final IFilterContext context, final IFilterOutput output) {
final Matcher matcher = new Matcher();
- for (AbstractInsnNode i = methodNode.instructions
- .getFirst(); i != null; i = i.getNext()) {
- matcher.match(i, output);
+ for (final AbstractInsnNode node : methodNode.instructions) {
+ matcher.match(node, output);
}
}
@@ -44,6 +45,13 @@ public class KotlinLateinitFilter implements IFilter {
"throwUninitializedPropertyAccessException",
"(Ljava/lang/String;)V");
+ if (cursor != null
+ && skipNonOpcodes(cursor.getNext()) != skipNonOpcodes(
+ ((JumpInsnNode) start).label)) {
+ nextIs(Opcodes.ACONST_NULL);
+ nextIs(Opcodes.ATHROW);
+ }
+
if (cursor != null) {
output.ignore(start, cursor);
}
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinNotNullOperatorFilter.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinNotNullOperatorFilter.java
index 4dd223a3..dda54210 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinNotNullOperatorFilter.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinNotNullOperatorFilter.java
@@ -1,9 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
@@ -24,8 +25,7 @@ public final class KotlinNotNullOperatorFilter implements IFilter {
public void filter(final MethodNode methodNode,
final IFilterContext context, final IFilterOutput output) {
final Matcher matcher = new Matcher();
- for (AbstractInsnNode i = methodNode.instructions
- .getFirst(); i != null; i = i.getNext()) {
+ for (final AbstractInsnNode i : methodNode.instructions) {
matcher.match(i, output);
}
}
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinUnsafeCastOperatorFilter.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinUnsafeCastOperatorFilter.java
index c298e945..82522a8a 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinUnsafeCastOperatorFilter.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinUnsafeCastOperatorFilter.java
@@ -1,9 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
@@ -23,27 +24,29 @@ import org.objectweb.asm.tree.MethodNode;
*/
public final class KotlinUnsafeCastOperatorFilter implements IFilter {
- private static final String KOTLIN_TYPE_CAST_EXCEPTION = "kotlin/TypeCastException";
-
public void filter(final MethodNode methodNode,
final IFilterContext context, final IFilterOutput output) {
+ if (!KotlinGeneratedFilter.isKotlinClass(context)) {
+ return;
+ }
final Matcher matcher = new Matcher();
- for (AbstractInsnNode i = methodNode.instructions
- .getFirst(); i != null; i = i.getNext()) {
- matcher.match(i, output);
+ for (final AbstractInsnNode i : methodNode.instructions) {
+ matcher.match("kotlin/TypeCastException", i, output);
+ // Since Kotlin 1.4.0:
+ matcher.match("java/lang/NullPointerException", i, output);
}
}
private static class Matcher extends AbstractMatcher {
- public void match(final AbstractInsnNode start,
- final IFilterOutput output) {
+ public void match(final String exceptionType,
+ final AbstractInsnNode start, final IFilterOutput output) {
if (Opcodes.IFNONNULL != start.getOpcode()) {
return;
}
cursor = start;
-
- nextIsType(Opcodes.NEW, KOTLIN_TYPE_CAST_EXCEPTION);
+ final JumpInsnNode jumpInsnNode = (JumpInsnNode) cursor;
+ nextIsType(Opcodes.NEW, exceptionType);
nextIs(Opcodes.DUP);
nextIs(Opcodes.LDC);
if (cursor == null) {
@@ -54,13 +57,13 @@ public final class KotlinUnsafeCastOperatorFilter implements IFilter {
.startsWith("null cannot be cast to non-null type"))) {
return;
}
- nextIsInvoke(Opcodes.INVOKESPECIAL, KOTLIN_TYPE_CAST_EXCEPTION,
- "<init>", "(Ljava/lang/String;)V");
+ nextIsInvoke(Opcodes.INVOKESPECIAL, exceptionType, "<init>",
+ "(Ljava/lang/String;)V");
nextIs(Opcodes.ATHROW);
if (cursor == null) {
return;
}
- if (cursor.getNext() != ((JumpInsnNode) start).label) {
+ if (cursor.getNext() != jumpInsnNode.label) {
return;
}
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinWhenFilter.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinWhenFilter.java
index a229aa04..ba2fb95c 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinWhenFilter.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinWhenFilter.java
@@ -1,9 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
@@ -17,7 +18,6 @@ import java.util.Set;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode;
-import org.objectweb.asm.tree.InsnNode;
import org.objectweb.asm.tree.JumpInsnNode;
import org.objectweb.asm.tree.LabelNode;
import org.objectweb.asm.tree.LookupSwitchInsnNode;
@@ -37,15 +37,14 @@ public final class KotlinWhenFilter implements IFilter {
public void filter(final MethodNode methodNode,
final IFilterContext context, final IFilterOutput output) {
final Matcher matcher = new Matcher();
- for (AbstractInsnNode i = methodNode.instructions
- .getFirst(); i != null; i = i.getNext()) {
+ for (final AbstractInsnNode i : methodNode.instructions) {
matcher.match(i, output);
}
}
private static class Matcher extends AbstractMatcher {
void match(final AbstractInsnNode start, final IFilterOutput output) {
- if (start.getType() != InsnNode.LABEL) {
+ if (start.getType() != AbstractInsnNode.LABEL) {
return;
}
cursor = start;
@@ -92,7 +91,7 @@ public final class KotlinWhenFilter implements IFilter {
labels = ((TableSwitchInsnNode) switchNode).labels;
}
final Set<AbstractInsnNode> newTargets = new HashSet<AbstractInsnNode>();
- for (LabelNode label : labels) {
+ for (final LabelNode label : labels) {
newTargets.add(AbstractMatcher.skipNonOpcodes(label));
}
output.replaceBranches(switchNode, newTargets);
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinWhenStringFilter.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinWhenStringFilter.java
index fcccb550..5fd20874 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinWhenStringFilter.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinWhenStringFilter.java
@@ -1,9 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
@@ -32,8 +33,7 @@ public final class KotlinWhenStringFilter implements IFilter {
public void filter(final MethodNode methodNode,
final IFilterContext context, final IFilterOutput output) {
final Matcher matcher = new Matcher();
- for (AbstractInsnNode i = methodNode.instructions
- .getFirst(); i != null; i = i.getNext()) {
+ for (final AbstractInsnNode i : methodNode.instructions) {
matcher.match(i, output);
}
}
@@ -67,10 +67,14 @@ public final class KotlinWhenStringFilter implements IFilter {
hashCodes = tableSwitch.labels.size();
}
+ if (hashCodes == 0) {
+ return;
+ }
+
final Set<AbstractInsnNode> replacements = new HashSet<AbstractInsnNode>();
replacements.add(skipNonOpcodes(defaultLabel));
- for (int i = 0; i < hashCodes; i++) {
+ for (int i = 1; i <= hashCodes; i++) {
while (true) {
nextIsVar(Opcodes.ALOAD, "s");
nextIs(Opcodes.LDC);
@@ -79,18 +83,24 @@ public final class KotlinWhenStringFilter implements IFilter {
// jump to next comparison or default case
nextIs(Opcodes.IFEQ);
final JumpInsnNode jump = (JumpInsnNode) cursor;
- // jump to case
- nextIs(Opcodes.GOTO);
+ next();
if (cursor == null) {
return;
- }
-
- replacements
- .add(skipNonOpcodes(((JumpInsnNode) cursor).label));
-
- if (jump.label == defaultLabel) {
- // end of comparisons for same hashCode
+ } else if (cursor.getOpcode() == Opcodes.GOTO) {
+ // jump to case body
+ replacements.add(
+ skipNonOpcodes(((JumpInsnNode) cursor).label));
+ if (jump.label == defaultLabel) {
+ // end of comparisons for same hashCode
+ break;
+ }
+ } else if (i == hashCodes && jump.label == defaultLabel) {
+ // case body
+ replacements.add(cursor);
+ cursor = jump;
break;
+ } else {
+ return;
}
}
}
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/PrivateEmptyNoArgConstructorFilter.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/PrivateEmptyNoArgConstructorFilter.java
index 236ef712..4b22dc29 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/PrivateEmptyNoArgConstructorFilter.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/PrivateEmptyNoArgConstructorFilter.java
@@ -1,9 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/RecordsFilter.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/RecordsFilter.java
new file mode 100644
index 00000000..745848ba
--- /dev/null
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/RecordsFilter.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Evgeny Mandrikov - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.core.internal.analysis.filter;
+
+import org.objectweb.asm.Handle;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.InvokeDynamicInsnNode;
+import org.objectweb.asm.tree.MethodNode;
+
+/**
+ * Filters methods <code>toString</code>, <code>hashCode</code> and
+ * <code>equals</code> that compiler generates for records.
+ */
+public final class RecordsFilter implements IFilter {
+
+ public void filter(final MethodNode methodNode,
+ final IFilterContext context, final IFilterOutput output) {
+ if (!"java/lang/Record".equals(context.getSuperClassName())) {
+ return;
+ }
+ final Matcher matcher = new Matcher();
+ if (matcher.isEquals(methodNode) || matcher.isHashCode(methodNode)
+ || matcher.isToString(methodNode)) {
+ output.ignore(methodNode.instructions.getFirst(),
+ methodNode.instructions.getLast());
+ }
+ }
+
+ private static class Matcher extends AbstractMatcher {
+ boolean isToString(final MethodNode m) {
+ if (!"toString".equals(m.name)
+ || !"()Ljava/lang/String;".equals(m.desc)) {
+ return false;
+ }
+ firstIsALoad0(m);
+ nextIsInvokeDynamic("toString");
+ nextIs(Opcodes.ARETURN);
+ return cursor != null;
+ }
+
+ boolean isHashCode(final MethodNode m) {
+ if (!"hashCode".equals(m.name) || !"()I".equals(m.desc)) {
+ return false;
+ }
+ firstIsALoad0(m);
+ nextIsInvokeDynamic("hashCode");
+ nextIs(Opcodes.IRETURN);
+ return cursor != null;
+ }
+
+ boolean isEquals(final MethodNode m) {
+ if (!"equals".equals(m.name)
+ || !"(Ljava/lang/Object;)Z".equals(m.desc)) {
+ return false;
+ }
+ firstIsALoad0(m);
+ nextIs(Opcodes.ALOAD);
+ nextIsInvokeDynamic("equals");
+ nextIs(Opcodes.IRETURN);
+ return cursor != null;
+ }
+
+ private void nextIsInvokeDynamic(final String name) {
+ nextIs(Opcodes.INVOKEDYNAMIC);
+ if (cursor == null) {
+ return;
+ }
+ final InvokeDynamicInsnNode i = (InvokeDynamicInsnNode) cursor;
+ final Handle bsm = i.bsm;
+ if (name.equals(i.name)
+ && "java/lang/runtime/ObjectMethods".equals(bsm.getOwner())
+ && "bootstrap".equals(bsm.getName())) {
+ return;
+ }
+ cursor = null;
+ }
+ }
+
+}
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/StringSwitchEcjFilter.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/StringSwitchFilter.java
index e0aba35d..a78e253e 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/StringSwitchEcjFilter.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/StringSwitchFilter.java
@@ -1,9 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
@@ -25,15 +26,15 @@ import org.objectweb.asm.tree.VarInsnNode;
/**
* Filters code that is generated by ECJ for a <code>switch</code> statement
- * with a <code>String</code>.
+ * with a <code>String</code> and by Kotlin compiler 1.5 and above for a
+ * <code>when</code> expression with a <code>String</code>.
*/
-public final class StringSwitchEcjFilter implements IFilter {
+public final class StringSwitchFilter implements IFilter {
public void filter(final MethodNode methodNode,
final IFilterContext context, final IFilterOutput output) {
final Matcher matcher = new Matcher();
- for (AbstractInsnNode i = methodNode.instructions
- .getFirst(); i != null; i = i.getNext()) {
+ for (final AbstractInsnNode i : methodNode.instructions) {
matcher.match(i, output);
}
}
@@ -42,7 +43,8 @@ public final class StringSwitchEcjFilter implements IFilter {
public void match(final AbstractInsnNode start,
final IFilterOutput output) {
- if (Opcodes.ASTORE != start.getOpcode()) {
+ if (start.getOpcode() != /* ECJ */ Opcodes.ASTORE
+ && start.getOpcode() != /* Kotlin */ Opcodes.ALOAD) {
return;
}
cursor = start;
@@ -67,6 +69,10 @@ public final class StringSwitchEcjFilter implements IFilter {
hashCodes = tableSwitch.labels.size();
}
+ if (hashCodes == 0) {
+ return;
+ }
+
final Set<AbstractInsnNode> replacements = new HashSet<AbstractInsnNode>();
replacements.add(skipNonOpcodes(defaultLabel));
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/StringSwitchJavacFilter.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/StringSwitchJavacFilter.java
index 3033d9bc..a5baf34c 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/StringSwitchJavacFilter.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/StringSwitchJavacFilter.java
@@ -1,9 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
@@ -26,10 +27,8 @@ public final class StringSwitchJavacFilter implements IFilter {
public void filter(final MethodNode methodNode,
final IFilterContext context, final IFilterOutput output) {
- AbstractInsnNode i = methodNode.instructions.getFirst();
- while (i != null) {
+ for (final AbstractInsnNode i : methodNode.instructions) {
filter(i, output);
- i = i.getNext();
}
}
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/SynchronizedFilter.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/SynchronizedFilter.java
index 6341328f..abc9e45b 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/SynchronizedFilter.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/SynchronizedFilter.java
@@ -1,9 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/SyntheticFilter.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/SyntheticFilter.java
index 69c4092a..127f7b03 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/SyntheticFilter.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/SyntheticFilter.java
@@ -1,9 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
@@ -19,6 +20,11 @@ import org.objectweb.asm.tree.MethodNode;
*/
public final class SyntheticFilter implements IFilter {
+ private static boolean isScalaClass(final IFilterContext context) {
+ return context.getClassAttributes().contains("ScalaSig")
+ || context.getClassAttributes().contains("Scala");
+ }
+
public void filter(final MethodNode methodNode,
final IFilterContext context, final IFilterOutput output) {
if ((methodNode.access & Opcodes.ACC_SYNTHETIC) == 0) {
@@ -29,13 +35,25 @@ public final class SyntheticFilter implements IFilter {
return;
}
+ if (isScalaClass(context)) {
+ if (methodNode.name.startsWith("$anonfun$")) {
+ return;
+ }
+ }
+
if (KotlinGeneratedFilter.isKotlinClass(context)) {
if (KotlinDefaultArgumentsFilter
- .isDefaultArgumentsMethodName(methodNode.name)) {
+ .isDefaultArgumentsMethod(methodNode)) {
+ return;
+ }
+
+ if (KotlinDefaultArgumentsFilter
+ .isDefaultArgumentsConstructor(methodNode)) {
return;
}
- if (KotlinCoroutineFilter.isLastArgumentContinuation(methodNode)) {
+ if (KotlinCoroutineFilter
+ .isImplementationOfSuspendFunction(methodNode)) {
return;
}
}
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/TryWithResourcesEcjFilter.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/TryWithResourcesEcjFilter.java
index 94dea561..714ab223 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/TryWithResourcesEcjFilter.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/TryWithResourcesEcjFilter.java
@@ -1,9 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/TryWithResourcesJavac11Filter.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/TryWithResourcesJavac11Filter.java
index 7a20f74f..0b451750 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/TryWithResourcesJavac11Filter.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/TryWithResourcesJavac11Filter.java
@@ -1,9 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
@@ -55,7 +56,7 @@ public final class TryWithResourcesJavac11Filter implements IFilter {
* throw primaryExc;
* }
* </pre>
- *
+ *
* <code>null</code> check for resource is omitted when it is initialized
* using <code>new</code>
*/
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/TryWithResourcesJavacFilter.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/TryWithResourcesJavacFilter.java
index 23ecb0e6..c3a0fa32 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/TryWithResourcesJavacFilter.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/TryWithResourcesJavacFilter.java
@@ -1,9 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
@@ -47,7 +48,7 @@ public final class TryWithResourcesJavacFilter implements IFilter {
* compilation of source code that is described in <a href=
* "http://docs.oracle.com/javase/specs/jls/se8/html/jls-14.html#jls-14.20.3.1">JLS
* 14.20.3. try-with-resources</a>:
- *
+ *
* <pre>
* Resource r = ...;
* Throwable primaryExc = null;
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/data/CRC64.java b/org.jacoco.core/src/org/jacoco/core/internal/data/CRC64.java
index 620a46f0..b0e8a098 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/data/CRC64.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/data/CRC64.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.data;
@@ -16,7 +17,7 @@ import org.objectweb.asm.Opcodes;
/**
* CRC64 checksum calculator based on the polynom specified in ISO 3309. The
* implementation is based on the following publications:
- *
+ *
* <ul>
* <li>http://en.wikipedia.org/wiki/Cyclic_redundancy_check</li>
* <li>http://www.geocities.com/SiliconValley/Pines/8659/crc.htm</li>
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/data/CompactDataInput.java b/org.jacoco.core/src/org/jacoco/core/internal/data/CompactDataInput.java
index 945b2b64..2f4e2eee 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/data/CompactDataInput.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/data/CompactDataInput.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.data;
@@ -17,7 +18,7 @@ import java.io.InputStream;
/**
* Additional data input methods for compact storage of data structures.
- *
+ *
* @see CompactDataOutput
*/
public class CompactDataInput extends DataInputStream {
@@ -25,7 +26,7 @@ public class CompactDataInput extends DataInputStream {
/**
* Creates a new {@link CompactDataInput} that uses the specified underlying
* input stream.
- *
+ *
* @param in
* underlying input stream
*/
@@ -35,7 +36,7 @@ public class CompactDataInput extends DataInputStream {
/**
* Reads a variable length representation of an integer value.
- *
+ *
* @return read value
* @throws IOException
* if thrown by the underlying stream
@@ -50,7 +51,7 @@ public class CompactDataInput extends DataInputStream {
/**
* Reads a boolean array.
- *
+ *
* @return boolean array
* @throws IOException
* if thrown by the underlying stream
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/data/CompactDataOutput.java b/org.jacoco.core/src/org/jacoco/core/internal/data/CompactDataOutput.java
index 4d230f8e..ba52555e 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/data/CompactDataOutput.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/data/CompactDataOutput.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.data;
@@ -17,7 +18,7 @@ import java.io.OutputStream;
/**
* Additional data output methods for compact storage of data structures.
- *
+ *
* @see CompactDataInput
*/
public class CompactDataOutput extends DataOutputStream {
@@ -25,7 +26,7 @@ public class CompactDataOutput extends DataOutputStream {
/**
* Creates a new {@link CompactDataOutput} instance that writes data to the
* specified underlying output stream
- *
+ *
* @param out
* underlying output stream
*/
@@ -37,7 +38,7 @@ public class CompactDataOutput extends DataOutputStream {
* Writes a variable length representation of an integer value that reduces
* the number of written bytes for small positive values. Depending on the
* given value 1 to 5 bytes will be written to the underlying stream.
- *
+ *
* @param value
* value to write
* @throws IOException
@@ -55,7 +56,7 @@ public class CompactDataOutput extends DataOutputStream {
/**
* Writes a boolean array. Internally a sequence of boolean values is packed
* into single bits.
- *
+ *
* @param value
* boolean array
* @throws IOException
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/flow/ClassProbesAdapter.java b/org.jacoco.core/src/org/jacoco/core/internal/flow/ClassProbesAdapter.java
index 876a1351..3ed19a88 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/flow/ClassProbesAdapter.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/flow/ClassProbesAdapter.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.flow;
@@ -20,8 +21,8 @@ import org.objectweb.asm.commons.AnalyzerAdapter;
* A {@link org.objectweb.asm.ClassVisitor} that calculates probes for every
* method.
*/
-public class ClassProbesAdapter extends ClassVisitor implements
- IProbeIdGenerator {
+public class ClassProbesAdapter extends ClassVisitor
+ implements IProbeIdGenerator {
private static final MethodProbesVisitor EMPTY_METHOD_PROBES_VISITOR = new MethodProbesVisitor() {
};
@@ -36,7 +37,7 @@ public class ClassProbesAdapter extends ClassVisitor implements
/**
* Creates a new adapter that delegates to the given visitor.
- *
+ *
* @param cv
* instance to delegate to
* @param trackFrames
@@ -59,7 +60,8 @@ public class ClassProbesAdapter extends ClassVisitor implements
@Override
public final MethodVisitor visitMethod(final int access, final String name,
- final String desc, final String signature, final String[] exceptions) {
+ final String desc, final String signature,
+ final String[] exceptions) {
final MethodProbesVisitor methodProbes;
final MethodProbesVisitor mv = cv.visitMethod(access, name, desc,
signature, exceptions);
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/flow/ClassProbesVisitor.java b/org.jacoco.core/src/org/jacoco/core/internal/flow/ClassProbesVisitor.java
index 54817e80..f8325efc 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/flow/ClassProbesVisitor.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/flow/ClassProbesVisitor.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.flow;
@@ -29,7 +30,7 @@ public abstract class ClassProbesVisitor extends ClassVisitor {
/**
* New visitor instance that delegates to the given visitor.
- *
+ *
* @param cv
* optional next visitor in chain
*/
@@ -50,7 +51,7 @@ public abstract class ClassProbesVisitor extends ClassVisitor {
* is called just before {@link ClassVisitor#visitEnd()}. For interfaces
* this method is called before the first method (the static initializer) is
* emitted.
- *
+ *
* @param count
* total number of probes
*/
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/flow/FrameSnapshot.java b/org.jacoco.core/src/org/jacoco/core/internal/flow/FrameSnapshot.java
index a0c7449f..b8c819da 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/flow/FrameSnapshot.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/flow/FrameSnapshot.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.flow;
@@ -36,7 +37,7 @@ class FrameSnapshot implements IFrame {
/**
* Create a IFrame instance based on the given analyzer.
- *
+ *
* @param analyzer
* analyzer instance or <code>null</code>
* @param popCount
@@ -58,7 +59,8 @@ class FrameSnapshot implements IFrame {
* {@link MethodVisitor#visitFrame(int, int, Object[], int, Object[])}
* method.
*/
- private static Object[] reduce(final List<Object> source, final int popCount) {
+ private static Object[] reduce(final List<Object> source,
+ final int popCount) {
final List<Object> copy = new ArrayList<Object>(source);
final int size = source.size() - popCount;
copy.subList(size, source.size()).clear();
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/flow/IFrame.java b/org.jacoco.core/src/org/jacoco/core/internal/flow/IFrame.java
index 6079f443..5c10ae76 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/flow/IFrame.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/flow/IFrame.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.flow;
@@ -20,7 +21,7 @@ public interface IFrame {
/**
* Emits a frame event with the current content to the given visitor.
- *
+ *
* @param mv
* method visitor to emit frame event to
*/
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/flow/IProbeIdGenerator.java b/org.jacoco.core/src/org/jacoco/core/internal/flow/IProbeIdGenerator.java
index 6f3f1977..692fea03 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/flow/IProbeIdGenerator.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/flow/IProbeIdGenerator.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.flow;
@@ -18,7 +19,7 @@ public interface IProbeIdGenerator {
/**
* Returns the next unique probe id.
- *
+ *
* @return unique probe id
*/
int nextId();
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/flow/LabelFlowAnalyzer.java b/org.jacoco.core/src/org/jacoco/core/internal/flow/LabelFlowAnalyzer.java
index 0f0e4d33..f44d66da 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/flow/LabelFlowAnalyzer.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/flow/LabelFlowAnalyzer.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.flow;
@@ -27,7 +28,7 @@ public final class LabelFlowAnalyzer extends MethodVisitor {
/**
* Marks all labels of the method with control flow information.
- *
+ *
* @param method
* Method to mark labels
*/
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/flow/LabelInfo.java b/org.jacoco.core/src/org/jacoco/core/internal/flow/LabelInfo.java
index 85dc1d81..122d62b5 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/flow/LabelInfo.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/flow/LabelInfo.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.flow;
@@ -48,7 +49,7 @@ public final class LabelInfo {
/**
* Defines that the given label is a jump target.
- *
+ *
* @param label
* label to define
*/
@@ -64,7 +65,7 @@ public final class LabelInfo {
/**
* Defines that the given label is the possible successor of the previous
* instruction in the method.
- *
+ *
* @param label
* label to define
*/
@@ -81,7 +82,7 @@ public final class LabelInfo {
* to a certain label are: jump targets, exception handlers and normal
* control flow from its predecessor instruction (unless this is an
* unconditional jump or method exit).
- *
+ *
* @param label
* label to check
* @return <code>true</code> if the given multiple control paths lead to the
@@ -96,7 +97,7 @@ public final class LabelInfo {
* Checks whether this label is the possible successor of the previous
* instruction in the method. This is the case if the predecessor isn't a
* unconditional jump or method exit instruction.
- *
+ *
* @param label
* label to check
* @return <code>true</code> if the label is a possible instruction
@@ -109,7 +110,7 @@ public final class LabelInfo {
/**
* Mark a given label as the beginning of a line with method invocations.
- *
+ *
* @param label
* label to mark
*/
@@ -120,7 +121,7 @@ public final class LabelInfo {
/**
* Checks whether the a given label has been marked as a line with method
* invocations.
- *
+ *
* @param label
* label to check
* @return <code>true</code> if the label represents a line with method
@@ -133,7 +134,7 @@ public final class LabelInfo {
/**
* Determines whether the given label needs a probe to be inserted before.
- *
+ *
* @param label
* label to test
* @return <code>true</code> if a probe should be inserted before
@@ -146,7 +147,7 @@ public final class LabelInfo {
/**
* Mark a given label as done.
- *
+ *
* @param label
* label to mark
*/
@@ -156,7 +157,7 @@ public final class LabelInfo {
/**
* Resets the "done" status of a given label.
- *
+ *
* @param label
* label to reset
*/
@@ -169,7 +170,7 @@ public final class LabelInfo {
/**
* Resets the "done" status of all given labels.
- *
+ *
* @param labels
* labels to reset
*/
@@ -181,7 +182,7 @@ public final class LabelInfo {
/**
* Checks whether this label is marked as done.
- *
+ *
* @param label
* label to check
* @return <code>true</code> if this label is marked as done
@@ -193,7 +194,7 @@ public final class LabelInfo {
/**
* Sets the given probe id to the given label.
- *
+ *
* @param label
* label to assign a probe to
* @param id
@@ -205,7 +206,7 @@ public final class LabelInfo {
/**
* Returns the assigned probe id.
- *
+ *
* @param label
* label to check
* @return probe id or {@link #NO_PROBE} if no probe is assigned to the
@@ -219,7 +220,7 @@ public final class LabelInfo {
/**
* Defines an intermediate label for the given label. Such intermediate
* labels are required during instrumentation to add probes to jump targets.
- *
+ *
* @param label
* label to define for
* @param intermediate
@@ -233,7 +234,7 @@ public final class LabelInfo {
/**
* Returns the intermediate label for the given label if one has been
* defined.
- *
+ *
* @param label
* label to look for
* @return intermediate label or <code>null</code>
@@ -245,7 +246,7 @@ public final class LabelInfo {
/**
* Sets the instruction corresponding to this label.
- *
+ *
* @param label
* label to set the instruction for
* @param instruction
@@ -259,7 +260,7 @@ public final class LabelInfo {
/**
* Returns the corresponding instruction for the given label if one has been
* defined.
- *
+ *
* @param label
* label to look for
* @return corresponding instruction or <code>null</code>
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/flow/MethodProbesAdapter.java b/org.jacoco.core/src/org/jacoco/core/internal/flow/MethodProbesAdapter.java
index 40e20a3e..30253d02 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/flow/MethodProbesAdapter.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/flow/MethodProbesAdapter.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.flow;
@@ -36,7 +37,7 @@ public final class MethodProbesAdapter extends MethodVisitor {
/**
* Create a new adapter instance.
- *
+ *
* @param probesVisitor
* visitor to delegate to
* @param idGenerator
@@ -53,7 +54,7 @@ public final class MethodProbesAdapter extends MethodVisitor {
/**
* If an analyzer is set {@link IFrame} handles are calculated and emitted
* to the probes methods.
- *
+ *
* @param analyzer
* optional analyzer to set
*/
@@ -64,8 +65,8 @@ public final class MethodProbesAdapter extends MethodVisitor {
@Override
public void visitTryCatchBlock(final Label start, final Label end,
final Label handler, final String type) {
- probesVisitor.visitTryCatchBlock(getTryCatchLabel(start), getTryCatchLabel(end),
- handler, type);
+ probesVisitor.visitTryCatchBlock(getTryCatchLabel(start),
+ getTryCatchLabel(end), handler, type);
}
private Label getTryCatchLabel(Label label) {
@@ -154,8 +155,8 @@ public final class MethodProbesAdapter extends MethodVisitor {
public void visitTableSwitchInsn(final int min, final int max,
final Label dflt, final Label... labels) {
if (markLabels(dflt, labels)) {
- probesVisitor.visitTableSwitchInsnWithProbes(min, max, dflt,
- labels, frame(1));
+ probesVisitor.visitTableSwitchInsnWithProbes(min, max, dflt, labels,
+ frame(1));
} else {
probesVisitor.visitTableSwitchInsn(min, max, dflt, labels);
}
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/flow/MethodProbesVisitor.java b/org.jacoco.core/src/org/jacoco/core/internal/flow/MethodProbesVisitor.java
index 75e63555..b9073c4b 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/flow/MethodProbesVisitor.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/flow/MethodProbesVisitor.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.flow;
@@ -31,7 +32,7 @@ public abstract class MethodProbesVisitor extends MethodVisitor {
/**
* New visitor instance that delegates to the given visitor.
- *
+ *
* @param mv
* optional next visitor in chain
*/
@@ -42,7 +43,7 @@ public abstract class MethodProbesVisitor extends MethodVisitor {
/**
* Visits an unconditional probe that should be inserted at the current
* position.
- *
+ *
* @param probeId
* id of the probe to insert
*/
@@ -54,7 +55,7 @@ public abstract class MethodProbesVisitor extends MethodVisitor {
* Visits a jump instruction. A probe with the given id should be inserted
* in a way that it is executed only when the jump to the given label is
* executed.
- *
+ *
* @param opcode
* the opcode of the type instruction to be visited. This opcode
* is either IFEQ, IFNE, IFLT, IFGE, IFGT, IFLE, IF_ICMPEQ,
@@ -81,7 +82,7 @@ public abstract class MethodProbesVisitor extends MethodVisitor {
* Visits a zero operand instruction with a probe. This event is used only
* for instructions that terminate the method. Therefore the probe must be
* inserted before the actual instruction.
- *
+ *
* @param opcode
* the opcode of the instruction to be visited. This opcode is
* either IRETURN, LRETURN, FRETURN, DRETURN, ARETURN, RETURN or
@@ -100,7 +101,7 @@ public abstract class MethodProbesVisitor extends MethodVisitor {
* target labels will always have the same probe id within a call to this
* method. The probe id for each label can be obtained with
* {@link LabelInfo#getProbeId(Label)}.
- *
+ *
* @param min
* the minimum key value.
* @param max
@@ -128,7 +129,7 @@ public abstract class MethodProbesVisitor extends MethodVisitor {
* target labels will always have the same probe id within a call to this
* method. The probe id for each label can be obtained with
* {@link LabelInfo#getProbeId(Label)}.
- *
+ *
* @param dflt
* beginning of the default handler block.
* @param keys
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/flow/MethodSanitizer.java b/org.jacoco.core/src/org/jacoco/core/internal/flow/MethodSanitizer.java
index 92b08947..34c38004 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/flow/MethodSanitizer.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/flow/MethodSanitizer.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.flow;
@@ -18,7 +19,7 @@ import org.objectweb.asm.commons.JSRInlinerAdapter;
/**
* This method visitor fixes two potential issues with Java byte code:
- *
+ *
* <ul>
* <li>Remove JSR/RET instructions by inlining subroutines which are deprecated
* since Java 6. The RET statement complicates control flow analysis as the jump
@@ -30,8 +31,8 @@ import org.objectweb.asm.commons.JSRInlinerAdapter;
*/
class MethodSanitizer extends JSRInlinerAdapter {
- MethodSanitizer(final MethodVisitor mv, final int access,
- final String name, final String desc, final String signature,
+ MethodSanitizer(final MethodVisitor mv, final int access, final String name,
+ final String desc, final String signature,
final String[] exceptions) {
super(InstrSupport.ASM_API_VERSION, mv, access, name, desc, signature,
exceptions);
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/instr/ClassFieldProbeArrayStrategy.java b/org.jacoco.core/src/org/jacoco/core/internal/instr/ClassFieldProbeArrayStrategy.java
index 950be683..7a54b6d8 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/instr/ClassFieldProbeArrayStrategy.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/instr/ClassFieldProbeArrayStrategy.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.instr;
@@ -27,7 +28,8 @@ class ClassFieldProbeArrayStrategy implements IProbeArrayStrategy {
/**
* Frame stack with a single boolean array.
*/
- private static final Object[] FRAME_STACK_ARRZ = new Object[] { InstrSupport.DATAFIELD_DESC };
+ private static final Object[] FRAME_STACK_ARRZ = new Object[] {
+ InstrSupport.DATAFIELD_DESC };
/**
* Empty frame locals.
@@ -107,9 +109,9 @@ class ClassFieldProbeArrayStrategy implements IProbeArrayStrategy {
/**
* Generates the byte code to initialize the static coverage data field
* within this class.
- *
+ *
* The code will push the [Z data array on the operand stack.
- *
+ *
* @param mv
* generator to emit code to
*/
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/instr/ClassInstrumenter.java b/org.jacoco.core/src/org/jacoco/core/internal/instr/ClassInstrumenter.java
index 7d5e9759..476c9e34 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/instr/ClassInstrumenter.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/instr/ClassInstrumenter.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.instr;
@@ -28,7 +29,7 @@ public class ClassInstrumenter extends ClassProbesVisitor {
/**
* Emits a instrumented version of this class to the given class visitor.
- *
+ *
* @param probeArrayStrategy
* this strategy will be used to access the probe array
* @param cv
@@ -58,7 +59,8 @@ public class ClassInstrumenter extends ClassProbesVisitor {
@Override
public MethodProbesVisitor visitMethod(final int access, final String name,
- final String desc, final String signature, final String[] exceptions) {
+ final String desc, final String signature,
+ final String[] exceptions) {
InstrSupport.assertNotInstrumented(name, className);
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/instr/CondyProbeArrayStrategy.java b/org.jacoco.core/src/org/jacoco/core/internal/instr/CondyProbeArrayStrategy.java
index ca2fb60d..31cc97a9 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/instr/CondyProbeArrayStrategy.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/instr/CondyProbeArrayStrategy.java
@@ -1,9 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
@@ -11,9 +12,9 @@
*******************************************************************************/
package org.jacoco.core.internal.instr;
+import org.jacoco.core.runtime.IExecutionDataAccessorGenerator;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ConstantDynamic;
-import org.jacoco.core.runtime.IExecutionDataAccessorGenerator;
import org.objectweb.asm.Handle;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/instr/DuplicateFrameEliminator.java b/org.jacoco.core/src/org/jacoco/core/internal/instr/DuplicateFrameEliminator.java
index bc3e54bf..dfc88b44 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/instr/DuplicateFrameEliminator.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/instr/DuplicateFrameEliminator.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.instr;
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/instr/IProbeArrayStrategy.java b/org.jacoco.core/src/org/jacoco/core/internal/instr/IProbeArrayStrategy.java
index 5fe0cdca..9b24f9a6 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/instr/IProbeArrayStrategy.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/instr/IProbeArrayStrategy.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.instr;
@@ -23,7 +24,7 @@ public interface IProbeArrayStrategy {
/**
* Creates code that stores the probe array instance in the given variable.
- *
+ *
* @param mv
* visitor to create code
* @param clinit
@@ -37,7 +38,7 @@ public interface IProbeArrayStrategy {
/**
* Adds additional class members required by this strategy. This method is
* called after all original members of the class has been processed.
- *
+ *
* @param cv
* visitor to create fields and methods
* @param probeCount
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/instr/IProbeInserter.java b/org.jacoco.core/src/org/jacoco/core/internal/instr/IProbeInserter.java
index 2f8dab61..9b22ede4 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/instr/IProbeInserter.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/instr/IProbeInserter.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.instr;
@@ -19,7 +20,7 @@ interface IProbeInserter {
/**
* Inserts the probe with the given id.
- *
+ *
* @param id
* id of the probe to insert
*/
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/instr/InstrSupport.java b/org.jacoco.core/src/org/jacoco/core/internal/instr/InstrSupport.java
index 4d4e1ba1..c125112d 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/instr/InstrSupport.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/instr/InstrSupport.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.instr;
@@ -26,7 +27,7 @@ public final class InstrSupport {
}
/** ASM API version */
- public static final int ASM_API_VERSION = Opcodes.ASM7;
+ public static final int ASM_API_VERSION = Opcodes.ASM9;
// === Data Field ===
@@ -212,7 +213,7 @@ public final class InstrSupport {
/**
* Determines whether the given class file version requires stackmap frames.
- *
+ *
* @param version
* class file version
* @return <code>true</code> if frames are required
@@ -226,7 +227,7 @@ public final class InstrSupport {
* Ensures that the given member does not correspond to a internal member
* created by the instrumentation process. This would mean that the class is
* already instrumented.
- *
+ *
* @param member
* name of the member to check
* @param owner
@@ -248,7 +249,7 @@ public final class InstrSupport {
* Generates the instruction to push the given int value on the stack.
* Implementation taken from
* {@link org.objectweb.asm.commons.GeneratorAdapter#push(int)}.
- *
+ *
* @param mv
* visitor to emit the instruction
* @param value
@@ -276,9 +277,9 @@ public final class InstrSupport {
*/
public static ClassReader classReaderFor(final byte[] b) {
final int originalVersion = getMajorVersion(b);
- if (originalVersion == Opcodes.V12 + 1) {
+ if (originalVersion == Opcodes.V16 + 1) {
// temporarily downgrade version to bypass check in ASM
- setMajorVersion(Opcodes.V12, b);
+ setMajorVersion(Opcodes.V16, b);
}
final ClassReader classReader = new ClassReader(b);
setMajorVersion(originalVersion, b);
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/instr/InterfaceFieldProbeArrayStrategy.java b/org.jacoco.core/src/org/jacoco/core/internal/instr/InterfaceFieldProbeArrayStrategy.java
index bf855fea..decd234c 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/instr/InterfaceFieldProbeArrayStrategy.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/instr/InterfaceFieldProbeArrayStrategy.java
@@ -1,9 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
@@ -27,7 +28,8 @@ class InterfaceFieldProbeArrayStrategy implements IProbeArrayStrategy {
/**
* Frame stack with a single boolean array.
*/
- private static final Object[] FRAME_STACK_ARRZ = new Object[] { InstrSupport.DATAFIELD_DESC };
+ private static final Object[] FRAME_STACK_ARRZ = new Object[] {
+ InstrSupport.DATAFIELD_DESC };
/**
* Empty frame locals.
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/instr/LocalProbeArrayStrategy.java b/org.jacoco.core/src/org/jacoco/core/internal/instr/LocalProbeArrayStrategy.java
index 67068ed7..9e30703e 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/instr/LocalProbeArrayStrategy.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/instr/LocalProbeArrayStrategy.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.instr;
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/instr/MethodInstrumenter.java b/org.jacoco.core/src/org/jacoco/core/internal/instr/MethodInstrumenter.java
index 396368b5..7fcab58e 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/instr/MethodInstrumenter.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/instr/MethodInstrumenter.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.instr;
@@ -28,7 +29,7 @@ class MethodInstrumenter extends MethodProbesVisitor {
/**
* Create a new instrumenter instance for the given method.
- *
+ *
* @param mv
* next method visitor in the chain
* @param probeInserter
@@ -159,7 +160,8 @@ class MethodInstrumenter extends MethodProbesVisitor {
return intermediate;
}
- private void insertIntermediateProbe(final Label label, final IFrame frame) {
+ private void insertIntermediateProbe(final Label label,
+ final IFrame frame) {
final int probeId = LabelInfo.getProbeId(label);
if (probeId != LabelInfo.NO_PROBE && !LabelInfo.isDone(label)) {
mv.visitLabel(LabelInfo.getIntermediateLabel(label));
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/instr/NoneProbeArrayStrategy.java b/org.jacoco.core/src/org/jacoco/core/internal/instr/NoneProbeArrayStrategy.java
index b3a4186f..427678bf 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/instr/NoneProbeArrayStrategy.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/instr/NoneProbeArrayStrategy.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.instr;
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeArrayStrategyFactory.java b/org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeArrayStrategyFactory.java
index bc957b91..b2223768 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeArrayStrategyFactory.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeArrayStrategyFactory.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.instr;
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeCounter.java b/org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeCounter.java
index de223265..c41a9b35 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeCounter.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeCounter.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.instr;
@@ -30,7 +31,8 @@ class ProbeCounter extends ClassProbesVisitor {
@Override
public MethodProbesVisitor visitMethod(final int access, final String name,
- final String desc, final String signature, final String[] exceptions) {
+ final String desc, final String signature,
+ final String[] exceptions) {
if (!InstrSupport.CLINIT_NAME.equals(name)
&& (access & Opcodes.ACC_ABSTRACT) == 0) {
methods = true;
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 0cac8f8f..20794f60 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
@@ -1,20 +1,23 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
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
@@ -40,7 +43,7 @@ class ProbeInserter extends MethodVisitor implements IProbeInserter {
/**
* Creates a new {@link ProbeInserter}.
- *
+ *
* @param access
* access flags of the adapted method
* @param name
@@ -53,8 +56,8 @@ class ProbeInserter extends MethodVisitor implements IProbeInserter {
* callback to create the code that retrieves the reference to
* the probe array
*/
- ProbeInserter(final int access, final String name, final String desc, final MethodVisitor mv,
- final IProbeArrayStrategy arrayStrategy) {
+ ProbeInserter(final int access, final String name, final String desc,
+ final MethodVisitor mv, final IProbeArrayStrategy arrayStrategy) {
super(InstrSupport.ASM_API_VERSION, mv);
this.clinit = InstrSupport.CLINIT_NAME.equals(name);
this.arrayStrategy = arrayStrategy;
@@ -107,6 +110,18 @@ class ProbeInserter extends MethodVisitor implements IProbeInserter {
}
@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
// original stack size depending on the probe locations. The accessor
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/instr/SignatureRemover.java b/org.jacoco.core/src/org/jacoco/core/internal/instr/SignatureRemover.java
index 06994c0d..310dcc88 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/instr/SignatureRemover.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/instr/SignatureRemover.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.internal.instr;
@@ -47,7 +48,7 @@ public class SignatureRemover {
/**
* Defines whether this remover should be active. If it is not active it
* will not remove any entries.
- *
+ *
* @param active
* <code>true</code> if it should remove signature related
* entries.
@@ -58,7 +59,7 @@ public class SignatureRemover {
/**
* Checks whether a entry with the provided name should be ignored at all.
- *
+ *
* @param name
* path name of the entry in question
* @return true is the entry should be ignored
@@ -69,7 +70,7 @@ public class SignatureRemover {
/**
* Filters the content of the entry with the provided name if necessary.
- *
+ *
* @param name
* path name of the entry in question
* @param in
@@ -102,7 +103,8 @@ public class SignatureRemover {
}
private void filterManifestEntryAttributes(final Attributes attrs) {
- for (final Iterator<Object> i = attrs.keySet().iterator(); i.hasNext();) {
+ for (final Iterator<Object> i = attrs.keySet().iterator(); i
+ .hasNext();) {
if (String.valueOf(i.next()).endsWith(DIGEST_SUFFIX)) {
i.remove();
}