aboutsummaryrefslogtreecommitdiff
path: root/org.jacoco.core/src/org/jacoco/core/runtime/ModifiedSystemClassRuntime.java
diff options
context:
space:
mode:
Diffstat (limited to 'org.jacoco.core/src/org/jacoco/core/runtime/ModifiedSystemClassRuntime.java')
-rw-r--r--org.jacoco.core/src/org/jacoco/core/runtime/ModifiedSystemClassRuntime.java47
1 files changed, 25 insertions, 22 deletions
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);
}
}