diff options
Diffstat (limited to 'org.jacoco.core/src/org/jacoco/core/runtime')
17 files changed, 211 insertions, 342 deletions
diff --git a/org.jacoco.core/src/org/jacoco/core/runtime/AbstractRuntime.java b/org.jacoco.core/src/org/jacoco/core/runtime/AbstractRuntime.java index 388e3e4f..7d417b2d 100644 --- a/org.jacoco.core/src/org/jacoco/core/runtime/AbstractRuntime.java +++ b/org.jacoco.core/src/org/jacoco/core/runtime/AbstractRuntime.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.runtime; @@ -32,7 +33,7 @@ public abstract class AbstractRuntime implements IRuntime { /** * Creates a random session identifier. - * + * * @return random session identifier */ public static String createRandomId() { diff --git a/org.jacoco.core/src/org/jacoco/core/runtime/AgentOptions.java b/org.jacoco.core/src/org/jacoco/core/runtime/AgentOptions.java index 60f03c0a..2bf1b394 100644 --- a/org.jacoco.core/src/org/jacoco/core/runtime/AgentOptions.java +++ b/org.jacoco.core/src/org/jacoco/core/runtime/AgentOptions.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.runtime; @@ -26,7 +27,7 @@ import java.util.regex.Pattern; /** * Utility to create and parse options for the runtime agent. Options are * represented as a string in the following format: - * + * * <pre> * key1=value1,key2=value2,key3=value3 * </pre> @@ -53,7 +54,7 @@ public final class AgentOptions { /** * Wildcard expression for class names that should be included for code * coverage. Default is <code>*</code> (all classes included). - * + * * @see WildcardMatcher */ public static final String INCLUDES = "includes"; @@ -61,7 +62,7 @@ public final class AgentOptions { /** * Wildcard expression for class names that should be excluded from code * coverage. Default is the empty string (no exclusions). - * + * * @see WildcardMatcher */ public static final String EXCLUDES = "excludes"; @@ -72,7 +73,7 @@ public final class AgentOptions { * loader which full qualified name matches this expression will be ignored * for code coverage regardless of all other filtering settings. Default is * <code>sun.reflect.DelegatingClassLoader</code>. - * + * * @see WildcardMatcher */ public static final String EXCLCLASSLOADER = "exclclassloader"; @@ -106,7 +107,7 @@ public final class AgentOptions { /** * Specifies the output mode. Default is {@link OutputMode#file}. - * + * * @see OutputMode#file * @see OutputMode#tcpserver * @see OutputMode#tcpclient @@ -204,7 +205,7 @@ public final class AgentOptions { /** * New instance parsed from the given option string. - * + * * @param optionstr * string to parse or <code>null</code> */ @@ -219,8 +220,8 @@ public final class AgentOptions { } final String key = entry.substring(0, pos); if (!VALID_OPTIONS.contains(key)) { - throw new IllegalArgumentException(format( - "Unknown agent option \"%s\".", key)); + throw new IllegalArgumentException( + format("Unknown agent option \"%s\".", key)); } final String value = entry.substring(pos + 1); @@ -233,7 +234,7 @@ public final class AgentOptions { /** * New instance read from the given {@link Properties} object. - * + * * @param properties * {@link Properties} object to read configuration options from */ @@ -260,7 +261,7 @@ public final class AgentOptions { /** * Returns the output file location. - * + * * @return output file location */ public String getDestfile() { @@ -269,7 +270,7 @@ public final class AgentOptions { /** * Sets the output file location. - * + * * @param destfile * output file location */ @@ -279,7 +280,7 @@ public final class AgentOptions { /** * Returns whether the output should be appended to an existing file. - * + * * @return <code>true</code>, when the output should be appended */ public boolean getAppend() { @@ -288,7 +289,7 @@ public final class AgentOptions { /** * Sets whether the output should be appended to an existing file. - * + * * @param append * <code>true</code>, when the output should be appended */ @@ -298,7 +299,7 @@ public final class AgentOptions { /** * Returns the wildcard expression for classes to include. - * + * * @return wildcard expression for classes to include * @see WildcardMatcher */ @@ -308,7 +309,7 @@ public final class AgentOptions { /** * Sets the wildcard expression for classes to include. - * + * * @param includes * wildcard expression for classes to include * @see WildcardMatcher @@ -319,7 +320,7 @@ public final class AgentOptions { /** * Returns the wildcard expression for classes to exclude. - * + * * @return wildcard expression for classes to exclude * @see WildcardMatcher */ @@ -329,7 +330,7 @@ public final class AgentOptions { /** * Sets the wildcard expression for classes to exclude. - * + * * @param excludes * wildcard expression for classes to exclude * @see WildcardMatcher @@ -340,7 +341,7 @@ public final class AgentOptions { /** * Returns the wildcard expression for excluded class loaders. - * + * * @return expression for excluded class loaders * @see WildcardMatcher */ @@ -350,7 +351,7 @@ public final class AgentOptions { /** * Sets the wildcard expression for excluded class loaders. - * + * * @param expression * expression for excluded class loaders * @see WildcardMatcher @@ -362,7 +363,7 @@ public final class AgentOptions { /** * Returns whether classes from the bootstrap classloader should be * instrumented. - * + * * @return <code>true</code> if classes from the bootstrap classloader * should be instrumented */ @@ -373,7 +374,7 @@ public final class AgentOptions { /** * Sets whether classes from the bootstrap classloader should be * instrumented. - * + * * @param include * <code>true</code> if bootstrap classes should be instrumented */ @@ -383,7 +384,7 @@ public final class AgentOptions { /** * Returns whether classes without source location should be instrumented. - * + * * @return <code>true</code> if classes without source location should be * instrumented */ @@ -393,7 +394,7 @@ public final class AgentOptions { /** * Sets whether classes without source location should be instrumented. - * + * * @param include * <code>true</code> if classes without source location should be * instrumented @@ -404,7 +405,7 @@ public final class AgentOptions { /** * Returns the session identifier. - * + * * @return session identifier */ public String getSessionId() { @@ -413,7 +414,7 @@ public final class AgentOptions { /** * Sets the session identifier. - * + * * @param id * session identifier */ @@ -423,7 +424,7 @@ public final class AgentOptions { /** * Returns whether coverage data should be dumped on exit. - * + * * @return <code>true</code> if coverage data will be written on VM exit */ public boolean getDumpOnExit() { @@ -432,7 +433,7 @@ public final class AgentOptions { /** * Sets whether coverage data should be dumped on exit. - * + * * @param dumpOnExit * <code>true</code> if coverage data should be written on VM * exit @@ -445,7 +446,7 @@ public final class AgentOptions { * Returns the port on which to listen to when the output is * <code>tcpserver</code> or the port to connect to when output is * <code>tcpclient</code>. - * + * * @return port to listen on or connect to */ public int getPort() { @@ -455,7 +456,7 @@ public final class AgentOptions { /** * Sets the port on which to listen to when output is <code>tcpserver</code> * or the port to connect to when output is <code>tcpclient</code> - * + * * @param port * port to listen on or connect to */ @@ -468,7 +469,7 @@ public final class AgentOptions { * Gets the hostname or IP address to listen to when output is * <code>tcpserver</code> or connect to when output is * <code>tcpclient</code> - * + * * @return Hostname or IP address */ public String getAddress() { @@ -479,7 +480,7 @@ public final class AgentOptions { * Sets the hostname or IP address to listen to when output is * <code>tcpserver</code> or connect to when output is * <code>tcpclient</code> - * + * * @param address * Hostname or IP address */ @@ -489,7 +490,7 @@ public final class AgentOptions { /** * Returns the output mode - * + * * @return current output mode */ public OutputMode getOutput() { @@ -502,7 +503,7 @@ public final class AgentOptions { /** * Sets the output mode - * + * * @param output * Output mode */ @@ -512,7 +513,7 @@ public final class AgentOptions { /** * Sets the output mode - * + * * @param output * Output mode */ @@ -523,7 +524,7 @@ public final class AgentOptions { /** * Returns the location of the directory where class files should be dumped * to. - * + * * @return dump location or <code>null</code> (no dumps) */ public String getClassDumpDir() { @@ -532,7 +533,7 @@ public final class AgentOptions { /** * Sets the directory where class files should be dumped to. - * + * * @param location * dump location or <code>null</code> (no dumps) */ @@ -542,7 +543,7 @@ public final class AgentOptions { /** * Returns whether the agent exposes functionality via JMX. - * + * * @return <code>true</code>, when JMX is enabled */ public boolean getJmx() { @@ -551,7 +552,7 @@ public final class AgentOptions { /** * Sets whether the agent should expose functionality via JMX. - * + * * @param jmx * <code>true</code> if JMX should be enabled */ @@ -589,7 +590,7 @@ public final class AgentOptions { /** * Generate required JVM argument based on current configuration and * supplied agent jar location. - * + * * @param agentJarFile * location of the JaCoCo Agent Jar * @return Argument to pass to create new VM with coverage enabled @@ -601,7 +602,7 @@ public final class AgentOptions { /** * Generate required quoted JVM argument based on current configuration and * supplied agent jar location. - * + * * @param agentJarFile * location of the JaCoCo Agent Jar * @return Quoted argument to pass to create new VM with coverage enabled @@ -615,7 +616,7 @@ public final class AgentOptions { * prepends it to the given argument command line. If a agent with the same * JAR file is already specified this parameter is removed from the existing * command line. - * + * * @param arguments * existing command line arguments or <code>null</code> * @param agentJarFile diff --git a/org.jacoco.core/src/org/jacoco/core/runtime/CommandLineSupport.java b/org.jacoco.core/src/org/jacoco/core/runtime/CommandLineSupport.java index 1f7fafc2..534fb243 100644 --- a/org.jacoco.core/src/org/jacoco/core/runtime/CommandLineSupport.java +++ b/org.jacoco.core/src/org/jacoco/core/runtime/CommandLineSupport.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.runtime; @@ -25,7 +26,7 @@ final class CommandLineSupport { /** * Quotes a single command line argument if necessary. - * + * * @param arg * command line argument * @return quoted argument @@ -47,7 +48,7 @@ final class CommandLineSupport { /** * Builds a single command line string from the given argument list. * Arguments are quoted when necessary. - * + * * @param args * command line arguments * @return combined command line @@ -68,7 +69,7 @@ final class CommandLineSupport { /** * Splits a command line into single arguments and removes quotes if * present. - * + * * @param commandline * combined command line * @return list of arguments diff --git a/org.jacoco.core/src/org/jacoco/core/runtime/IExecutionDataAccessorGenerator.java b/org.jacoco.core/src/org/jacoco/core/runtime/IExecutionDataAccessorGenerator.java index 83df5744..b3dfe225 100644 --- a/org.jacoco.core/src/org/jacoco/core/runtime/IExecutionDataAccessorGenerator.java +++ b/org.jacoco.core/src/org/jacoco/core/runtime/IExecutionDataAccessorGenerator.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.runtime; @@ -28,12 +29,12 @@ public interface IExecutionDataAccessorGenerator { * process will embed this code into a method that is called on class * initialization. This method can be called at any time even outside the * target VM. - * + * * The generated code must push a <code>boolean[]</code> instance to the * operand stack. Except this result object the generated code must not make * any assumptions about the structure of the embedding method or class. The * generated code must not use or allocate local variables. - * + * * @param classid * identifier of the class * @param classname diff --git a/org.jacoco.core/src/org/jacoco/core/runtime/IRemoteCommandVisitor.java b/org.jacoco.core/src/org/jacoco/core/runtime/IRemoteCommandVisitor.java index 9057a4e4..ce2389ca 100644 --- a/org.jacoco.core/src/org/jacoco/core/runtime/IRemoteCommandVisitor.java +++ b/org.jacoco.core/src/org/jacoco/core/runtime/IRemoteCommandVisitor.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.runtime; @@ -20,7 +21,7 @@ public interface IRemoteCommandVisitor { /** * Requests a execution data dump with an optional reset. - * + * * @param dump * <code>true</code> if the dump should be executed * @param reset diff --git a/org.jacoco.core/src/org/jacoco/core/runtime/IRuntime.java b/org.jacoco.core/src/org/jacoco/core/runtime/IRuntime.java index ea055632..2ae60f41 100644 --- a/org.jacoco.core/src/org/jacoco/core/runtime/IRuntime.java +++ b/org.jacoco.core/src/org/jacoco/core/runtime/IRuntime.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.runtime; @@ -20,7 +21,7 @@ public interface IRuntime extends IExecutionDataAccessorGenerator { /** * Starts the coverage runtime. This method MUST be called before any class * instrumented for this runtime is loaded. - * + * * @param data * the execution data for this runtime * @throws Exception diff --git a/org.jacoco.core/src/org/jacoco/core/runtime/InjectedClassRuntime.java b/org.jacoco.core/src/org/jacoco/core/runtime/InjectedClassRuntime.java index ee7aa1ac..c362fb92 100644 --- a/org.jacoco.core/src/org/jacoco/core/runtime/InjectedClassRuntime.java +++ b/org.jacoco.core/src/org/jacoco/core/runtime/InjectedClassRuntime.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/runtime/LoggerRuntime.java b/org.jacoco.core/src/org/jacoco/core/runtime/LoggerRuntime.java index bef42030..1fc2b70f 100644 --- a/org.jacoco.core/src/org/jacoco/core/runtime/LoggerRuntime.java +++ b/org.jacoco.core/src/org/jacoco/core/runtime/LoggerRuntime.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.runtime; @@ -24,7 +25,7 @@ import org.objectweb.asm.Opcodes; * This {@link IRuntime} implementation uses the Java logging API to report * coverage data. * <p> - * + * * The implementation uses a dedicated log channel. Instrumented classes call * {@link Logger#log(Level, String, Object[])} with the class identifier in the * first slot of the parameter array. The runtime implements a {@link Handler} @@ -133,9 +134,7 @@ public class LoggerRuntime extends AbstractRuntime { // Stack[1]: Ljava/util/logging/Logger; // Stack[0]: [Ljava/lang/Object; - mv.visitMethodInsn( - Opcodes.INVOKEVIRTUAL, - "java/util/logging/Logger", + mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/util/logging/Logger", "log", "(Ljava/util/logging/Level;Ljava/lang/String;[Ljava/lang/Object;)V", false); diff --git a/org.jacoco.core/src/org/jacoco/core/runtime/ModifiedSystemClassRuntime.java b/org.jacoco.core/src/org/jacoco/core/runtime/ModifiedSystemClassRuntime.java index 5f2cc497..a7936715 100644 --- a/org.jacoco.core/src/org/jacoco/core/runtime/ModifiedSystemClassRuntime.java +++ b/org.jacoco.core/src/org/jacoco/core/runtime/ModifiedSystemClassRuntime.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.runtime; @@ -44,12 +45,12 @@ public class ModifiedSystemClassRuntime extends AbstractRuntime { /** * Creates a new runtime based on the given class and members. - * + * * @param systemClass * system class that contains the execution data * @param accessFieldName * name of the public static runtime access field - * + * */ public ModifiedSystemClassRuntime(final Class<?> systemClass, final String accessFieldName) { @@ -85,13 +86,13 @@ public class ModifiedSystemClassRuntime extends AbstractRuntime { * Creates a new {@link ModifiedSystemClassRuntime} using the given class as * the data container. Member is created with internal default name. The * given class must not have been loaded before by the agent. - * + * * @param inst * instrumentation interface * @param className * VM name of the class to use * @return new runtime instance - * + * * @throws ClassNotFoundException * id the given class can not be found */ @@ -104,7 +105,7 @@ public class ModifiedSystemClassRuntime extends AbstractRuntime { * Creates a new {@link ModifiedSystemClassRuntime} using the given class as * the data container. The given class must not have been loaded before by * the agent. - * + * * @param inst * instrumentation interface * @param className @@ -112,7 +113,7 @@ public class ModifiedSystemClassRuntime extends AbstractRuntime { * @param accessFieldName * name of the added runtime access field * @return new runtime instance - * + * * @throws ClassNotFoundException * if the given class can not be found */ @@ -120,10 +121,10 @@ public class ModifiedSystemClassRuntime extends AbstractRuntime { final String className, final String accessFieldName) throws ClassNotFoundException { final ClassFileTransformer transformer = new ClassFileTransformer() { - public byte[] transform(final ClassLoader loader, - final String name, final Class<?> classBeingRedefined, - final ProtectionDomain protectionDomain, final byte[] source) - throws IllegalClassFormatException { + public byte[] transform(final ClassLoader loader, final String name, + final Class<?> classBeingRedefined, + final ProtectionDomain protectionDomain, + final byte[] source) throws IllegalClassFormatException { if (name.equals(className)) { return instrument(source, accessFieldName); } @@ -136,15 +137,16 @@ public class ModifiedSystemClassRuntime extends AbstractRuntime { try { clazz.getField(accessFieldName); } catch (final NoSuchFieldException e) { - throw new RuntimeException(format( - "Class %s could not be instrumented.", className), e); + throw new RuntimeException( + format("Class %s could not be instrumented.", className), + e); } return new ModifiedSystemClassRuntime(clazz, accessFieldName); } /** * Adds the static data field to the given class definition. - * + * * @param source * class definition source * @param accessFieldName @@ -169,9 +171,10 @@ public class ModifiedSystemClassRuntime extends AbstractRuntime { private static void createDataField(final ClassVisitor visitor, final String dataField) { - visitor.visitField(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC - | Opcodes.ACC_SYNTHETIC | Opcodes.ACC_TRANSIENT, dataField, - ACCESS_FIELD_TYPE, null, null); + visitor.visitField( + Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC | Opcodes.ACC_SYNTHETIC + | Opcodes.ACC_TRANSIENT, + dataField, ACCESS_FIELD_TYPE, null, null); } } diff --git a/org.jacoco.core/src/org/jacoco/core/runtime/OfflineInstrumentationAccessGenerator.java b/org.jacoco.core/src/org/jacoco/core/runtime/OfflineInstrumentationAccessGenerator.java index a5e88b60..78ef3064 100644 --- a/org.jacoco.core/src/org/jacoco/core/runtime/OfflineInstrumentationAccessGenerator.java +++ b/org.jacoco.core/src/org/jacoco/core/runtime/OfflineInstrumentationAccessGenerator.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.runtime; @@ -22,8 +23,8 @@ import org.objectweb.asm.Opcodes; * obtain probe arrays. This generator is designed for offline instrumentation * only. */ -public class OfflineInstrumentationAccessGenerator implements - IExecutionDataAccessorGenerator { +public class OfflineInstrumentationAccessGenerator + implements IExecutionDataAccessorGenerator { private final String runtimeClassName; @@ -37,7 +38,7 @@ public class OfflineInstrumentationAccessGenerator implements /** * Creates a new instance with the given runtime class name for testing * purposes - * + * * @param runtimeClassName * VM name of the runtime class */ diff --git a/org.jacoco.core/src/org/jacoco/core/runtime/RemoteControlReader.java b/org.jacoco.core/src/org/jacoco/core/runtime/RemoteControlReader.java index 46fb6d2c..0f4b1cb3 100644 --- a/org.jacoco.core/src/org/jacoco/core/runtime/RemoteControlReader.java +++ b/org.jacoco.core/src/org/jacoco/core/runtime/RemoteControlReader.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.runtime; @@ -25,7 +26,7 @@ public class RemoteControlReader extends ExecutionDataReader { /** * Create a new read based on the given input stream. - * + * * @param input * input stream to read commands from * @throws IOException @@ -50,7 +51,7 @@ public class RemoteControlReader extends ExecutionDataReader { /** * Sets an listener for agent commands. - * + * * @param visitor * visitor to retrieve agent commands */ diff --git a/org.jacoco.core/src/org/jacoco/core/runtime/RemoteControlWriter.java b/org.jacoco.core/src/org/jacoco/core/runtime/RemoteControlWriter.java index 8534471f..6e8b5cde 100644 --- a/org.jacoco.core/src/org/jacoco/core/runtime/RemoteControlWriter.java +++ b/org.jacoco.core/src/org/jacoco/core/runtime/RemoteControlWriter.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.runtime; @@ -19,8 +20,8 @@ import org.jacoco.core.data.ExecutionDataWriter; /** * {@link ExecutionDataWriter} with commands added for runtime remote control. */ -public class RemoteControlWriter extends ExecutionDataWriter implements - IRemoteCommandVisitor { +public class RemoteControlWriter extends ExecutionDataWriter + implements IRemoteCommandVisitor { /** Block identifier to confirm successful command execution. */ public static final byte BLOCK_CMDOK = 0x20; @@ -30,7 +31,7 @@ public class RemoteControlWriter extends ExecutionDataWriter implements /** * Creates a new writer based on the given output stream. - * + * * @param output * stream to write commands to * @throws IOException @@ -43,7 +44,7 @@ public class RemoteControlWriter extends ExecutionDataWriter implements /** * Sends a confirmation that a commands has been successfully executed and * the response is completed. - * + * * @throws IOException * in case of problems with the remote connection */ diff --git a/org.jacoco.core/src/org/jacoco/core/runtime/RuntimeData.java b/org.jacoco.core/src/org/jacoco/core/runtime/RuntimeData.java index c0fbb654..00fb4b07 100644 --- a/org.jacoco.core/src/org/jacoco/core/runtime/RuntimeData.java +++ b/org.jacoco.core/src/org/jacoco/core/runtime/RuntimeData.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.runtime; @@ -61,7 +62,7 @@ public class RuntimeData { * execution data is collected. If no identifier is explicitly set a * identifier is generated from the host name and a random number. This * method can be called at any time. - * + * * @see #collect(IExecutionDataVisitor, ISessionInfoVisitor, boolean) * @param id * new session identifier @@ -72,7 +73,7 @@ public class RuntimeData { /** * Get the current a session identifier for this runtime. - * + * * @see #setSessionId(String) * @return current session identifier */ @@ -83,7 +84,7 @@ public class RuntimeData { /** * Collects the current execution data and writes it to the given * {@link IExecutionDataVisitor} object. - * + * * @param executionDataVisitor * handler to write coverage data to * @param sessionInfoVisitor @@ -119,7 +120,7 @@ public class RuntimeData { * Returns the coverage data for the class with the given identifier. If * there is no data available under the given id a new entry is created. * This is a synchronized access to the underlying store. - * + * * @param id * class identifier * @param name @@ -142,19 +143,19 @@ public class RuntimeData { * Retrieves the execution data for a given class. The passed * {@link Object} array instance is used for parameters and the return value * as follows. Call parameters: - * + * * <ul> * <li>args[0]: class id ({@link Long}) * <li>args[1]: vm class name ({@link String}) * <li>args[2]: probe count ({@link Integer}) * </ul> - * + * * Return value: - * + * * <ul> * <li>args[0]: execution data ({@link IExecutionData}) * </ul> - * + * * @param args * parameter array of length 3 */ @@ -169,7 +170,7 @@ public class RuntimeData { /** * In violation of the regular semantic of {@link Object#equals(Object)} * this implementation is used as the interface to the execution data store. - * + * * @param args * the arguments as an {@link Object} array * @return has no meaning @@ -188,7 +189,7 @@ public class RuntimeData { * Generates code that creates the argument array for the * {@link #getProbes(Object[])} method. The array instance is left on the * operand stack. The generated code requires a stack size of 5. - * + * * @param classid * class identifier * @param classname @@ -199,7 +200,8 @@ public class RuntimeData { * visitor to emit generated code */ public static void generateArgumentArray(final long classid, - final String classname, final int probecount, final MethodVisitor mv) { + final String classname, final int probecount, + final MethodVisitor mv) { mv.visitInsn(Opcodes.ICONST_3); mv.visitTypeInsn(Opcodes.ANEWARRAY, "java/lang/Object"); @@ -221,8 +223,8 @@ public class RuntimeData { mv.visitInsn(Opcodes.DUP); mv.visitInsn(Opcodes.ICONST_2); InstrSupport.push(mv, probecount); - mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Integer", - "valueOf", "(I)Ljava/lang/Integer;", false); + mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Integer", "valueOf", + "(I)Ljava/lang/Integer;", false); mv.visitInsn(Opcodes.AASTORE); } @@ -232,7 +234,7 @@ public class RuntimeData { * {@link Object} instance from the stack and pushes the probe array of type * <code>boolean[]</code> on the operand stack. The generated code requires * a stack size of 6. - * + * * @param classid * class identifier * @param classname @@ -243,7 +245,8 @@ public class RuntimeData { * visitor to emit generated code */ public static void generateAccessCall(final long classid, - final String classname, final int probecount, final MethodVisitor mv) { + final String classname, final int probecount, + final MethodVisitor mv) { // stack[0]: Ljava/lang/Object; generateArgumentArray(classid, classname, probecount, mv); diff --git a/org.jacoco.core/src/org/jacoco/core/runtime/SystemPropertiesRuntime.java b/org.jacoco.core/src/org/jacoco/core/runtime/SystemPropertiesRuntime.java index d7c338c8..97ec2af9 100644 --- a/org.jacoco.core/src/org/jacoco/core/runtime/SystemPropertiesRuntime.java +++ b/org.jacoco.core/src/org/jacoco/core/runtime/SystemPropertiesRuntime.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.runtime; @@ -19,7 +20,7 @@ import org.objectweb.asm.Opcodes; * through a special entry in the {@link System#getProperties()} hash table. The * advantage is, that the instrumented classes do not get dependencies to other * classes than the JRE library itself. - * + * * This runtime may cause problems in environments with security restrictions, * in applications that replace the system properties or in applications that * fail if non-String values are placed in the system properties. @@ -50,8 +51,8 @@ public class SystemPropertiesRuntime extends AbstractRuntime { // Stack[1]: Ljava/lang/String; // Stack[0]: Ljava/util/Properties; - mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/util/Properties", - "get", "(Ljava/lang/Object;)Ljava/lang/Object;", false); + mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/util/Properties", "get", + "(Ljava/lang/Object;)Ljava/lang/Object;", false); // Stack[0]: Ljava/lang/Object; diff --git a/org.jacoco.core/src/org/jacoco/core/runtime/URLStreamHandlerRuntime.java b/org.jacoco.core/src/org/jacoco/core/runtime/URLStreamHandlerRuntime.java deleted file mode 100644 index 55f9c874..00000000 --- a/org.jacoco.core/src/org/jacoco/core/runtime/URLStreamHandlerRuntime.java +++ /dev/null @@ -1,149 +0,0 @@ -/******************************************************************************* - * 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.runtime; - -import java.io.IOException; -import java.lang.reflect.Field; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLStreamHandler; -import java.util.Map; - -import org.jacoco.core.internal.instr.InstrSupport; -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; - -/** - * This {@link IRuntime} implementation registers a special - * {@link URLStreamHandler} to process coverage data. The handler is not - * actually used for opening a URL, but to get access to the runtime object. - */ -public class URLStreamHandlerRuntime extends AbstractRuntime { - - private static final String PROTOCOLPREFIX = "jacoco-"; - - private final String protocol; - - private Map<String, URLStreamHandler> handlers; - - /** - * Creates a new runtime. - */ - public URLStreamHandlerRuntime() { - super(); - protocol = PROTOCOLPREFIX + Integer.toHexString(hashCode()); - } - - @Override - public void startup(final RuntimeData data) throws Exception { - super.startup(data); - handlers = getHandlersReference(); - handlers.put(protocol, handler); - } - - private Map<String, URLStreamHandler> getHandlersReference() - throws Exception { - final Field field = URL.class.getDeclaredField("handlers"); - field.setAccessible(true); - @SuppressWarnings("unchecked") - final Map<String, URLStreamHandler> map = (Map<String, URLStreamHandler>) field - .get(null); - return map; - } - - public void shutdown() { - handlers.remove(protocol); - } - - public int generateDataAccessor(final long classid, final String classname, - final int probecount, final MethodVisitor mv) { - - // The data accessor performs the following steps: - // - // final URL url = new URL(protocol, null, ""); - // final URLConnection connection = url.openConnection(); - // final Object[] args = new Object[3]; - // args[0] = Long.valueOf(classid); - // args[1] = classname; - // args[2] = Integer.valueOf(probecount); - // connection.equals(args); - // final byte[] probedata = (byte[]) args[0]; - - RuntimeData.generateArgumentArray(classid, classname, probecount, mv); - mv.visitInsn(Opcodes.DUP); - - // Stack[1]: [Ljava/lang/Object; - // Stack[0]: [Ljava/lang/Object; - - mv.visitTypeInsn(Opcodes.NEW, "java/net/URL"); - mv.visitInsn(Opcodes.DUP); - mv.visitLdcInsn(protocol); - mv.visitInsn(Opcodes.ACONST_NULL); - mv.visitLdcInsn(""); - mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/net/URL", "<init>", - "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", - false); - - // Stack[2]: [Ljava/net/URL; - // Stack[1]: [Ljava/lang/Object; - // Stack[0]: [Ljava/lang/Object; - - mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/net/URL", - "openConnection", "()Ljava/net/URLConnection;", false); - - // Stack[2]: [Ljava/net/URLConnection; - // Stack[1]: [Ljava/lang/Object; - // Stack[0]: [Ljava/lang/Object; - - mv.visitInsn(Opcodes.SWAP); - - // Stack[2]: [Ljava/lang/Object; - // Stack[1]: [Ljava/net/URLConnection; - // Stack[0]: [Ljava/lang/Object; - - mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Object", "equals", - "(Ljava/lang/Object;)Z", false); - - // Stack[1]: Z; - // Stack[0]: [Ljava/lang/Object; - - mv.visitInsn(Opcodes.POP); - - // Stack[0]: [Ljava/lang/Object; - - mv.visitInsn(Opcodes.ICONST_0); - mv.visitInsn(Opcodes.AALOAD); - mv.visitTypeInsn(Opcodes.CHECKCAST, InstrSupport.DATAFIELD_DESC); - - return 7; - } - - private final URLStreamHandler handler = new URLStreamHandler() { - @Override - protected URLConnection openConnection(final URL u) throws IOException { - return connection; - } - }; - - private final URLConnection connection = new URLConnection(null) { - @Override - public void connect() throws IOException { - throw new AssertionError(); - } - - @Override - public boolean equals(final Object obj) { - return data.equals(obj); - } - }; - -} diff --git a/org.jacoco.core/src/org/jacoco/core/runtime/WildcardMatcher.java b/org.jacoco.core/src/org/jacoco/core/runtime/WildcardMatcher.java index 91feaa66..b12255db 100644 --- a/org.jacoco.core/src/org/jacoco/core/runtime/WildcardMatcher.java +++ b/org.jacoco.core/src/org/jacoco/core/runtime/WildcardMatcher.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.runtime; @@ -25,7 +26,7 @@ public class WildcardMatcher { /** * Creates a new matcher with the given expression. - * + * * @param expression * wildcard expressions */ @@ -63,7 +64,7 @@ public class WildcardMatcher { /** * Matches the given string against the expressions of this matcher. - * + * * @param s * string to test * @return <code>true</code>, if the expression matches diff --git a/org.jacoco.core/src/org/jacoco/core/runtime/package-info.java b/org.jacoco.core/src/org/jacoco/core/runtime/package-info.java index 1ac7cccb..85f792a1 100644 --- a/org.jacoco.core/src/org/jacoco/core/runtime/package-info.java +++ b/org.jacoco.core/src/org/jacoco/core/runtime/package-info.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 - * + * *******************************************************************************/ /** |