diff options
author | Allen Hair <allenhair@google.com> | 2022-03-22 17:50:58 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-03-22 17:50:58 +0000 |
commit | 18a980206d62b715d1bb9a0b411413b2d0d5ee6f (patch) | |
tree | e68ce50b1fc964c12a1eb020ca8b2483ff2955d4 /org.jacoco.core/src/org/jacoco/core/internal/analysis | |
parent | cf92214db05a512b30c7c8f842855208ae450580 (diff) | |
parent | 2f01fe494ff8b031970daf329253df53ef60dde3 (diff) | |
download | jacoco-18a980206d62b715d1bb9a0b411413b2d0d5ee6f.tar.gz |
Merge "Update jacoco to 0.8.7." am: 46c6f6b353 am: 7398ddd230 am: 2f01fe494ft_frc_odp_330442040t_frc_odp_330442000t_frc_ase_330444010android-13.0.0_r83android-13.0.0_r82android-13.0.0_r81android-13.0.0_r80android-13.0.0_r79android-13.0.0_r78android-13.0.0_r77android-13.0.0_r76android-13.0.0_r75android-13.0.0_r74android-13.0.0_r73android-13.0.0_r72android-13.0.0_r71android-13.0.0_r70android-13.0.0_r69android-13.0.0_r68android-13.0.0_r67android-13.0.0_r66android-13.0.0_r65android-13.0.0_r64android-13.0.0_r63android-13.0.0_r62android-13.0.0_r61android-13.0.0_r60android-13.0.0_r59android-13.0.0_r58android-13.0.0_r57android-13.0.0_r56android-13.0.0_r54android-13.0.0_r53android-13.0.0_r52android-13.0.0_r51android-13.0.0_r50android-13.0.0_r49android-13.0.0_r48android-13.0.0_r47android-13.0.0_r46android-13.0.0_r45android-13.0.0_r44android-13.0.0_r43android-13.0.0_r42android-13.0.0_r41android-13.0.0_r40android-13.0.0_r39android-13.0.0_r38android-13.0.0_r37android-13.0.0_r36android-13.0.0_r35android-13.0.0_r34android-13.0.0_r33android-13.0.0_r32aml_go_odp_330912000aml_go_ads_330915100aml_go_ads_330915000aml_go_ads_330913000android13-qpr3-s9-releaseandroid13-qpr3-s8-releaseandroid13-qpr3-s7-releaseandroid13-qpr3-s6-releaseandroid13-qpr3-s5-releaseandroid13-qpr3-s4-releaseandroid13-qpr3-s3-releaseandroid13-qpr3-s2-releaseandroid13-qpr3-s14-releaseandroid13-qpr3-s13-releaseandroid13-qpr3-s12-releaseandroid13-qpr3-s11-releaseandroid13-qpr3-s10-releaseandroid13-qpr3-s1-releaseandroid13-qpr3-releaseandroid13-qpr3-c-s8-releaseandroid13-qpr3-c-s7-releaseandroid13-qpr3-c-s6-releaseandroid13-qpr3-c-s5-releaseandroid13-qpr3-c-s4-releaseandroid13-qpr3-c-s3-releaseandroid13-qpr3-c-s2-releaseandroid13-qpr3-c-s12-releaseandroid13-qpr3-c-s11-releaseandroid13-qpr3-c-s10-releaseandroid13-qpr3-c-s1-releaseandroid13-qpr2-s9-releaseandroid13-qpr2-s8-releaseandroid13-qpr2-s7-releaseandroid13-qpr2-s6-releaseandroid13-qpr2-s5-releaseandroid13-qpr2-s3-releaseandroid13-qpr2-s2-releaseandroid13-qpr2-s12-releaseandroid13-qpr2-s11-releaseandroid13-qpr2-s10-releaseandroid13-qpr2-s1-releaseandroid13-qpr2-releaseandroid13-qpr2-b-s1-releaseandroid13-mainline-go-adservices-releaseandroid13-frc-odp-releaseandroid13-devandroid13-d4-s2-releaseandroid13-d4-s1-releaseandroid13-d4-releaseandroid13-d3-s1-release
Original change: https://android-review.googlesource.com/c/platform/external/jacoco/+/2015697
Change-Id: Ie848d2ff33b291aa64d065bf2e3ede1dbd861b97
Diffstat (limited to 'org.jacoco.core/src/org/jacoco/core/internal/analysis')
43 files changed, 764 insertions, 417 deletions
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; |