aboutsummaryrefslogtreecommitdiffstats
path: root/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal
diff options
context:
space:
mode:
authorHaibo Huang <hhb@google.com>2019-05-19 22:01:33 -0700
committerandroid-build-merger <android-build-merger@google.com>2019-05-19 22:01:33 -0700
commit8e37ff147009b16f4dd904bcc32714990e5cf22a (patch)
tree4378ac3ee1730f6cfbe0b9120f3d54e7570c86a0 /org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal
parent93068ff728a7916816e7bbf832b05c717a106c26 (diff)
parent0f0b5ebf8685e3b0544afa451e39e3fd3fbc304b (diff)
downloadplatform_external_jacoco-android10-mainline-networking-release.tar.gz
platform_external_jacoco-android10-mainline-networking-release.tar.bz2
platform_external_jacoco-android10-mainline-networking-release.zip
am: 0f0b5ebf86 Change-Id: Ice1512bc21409270a58b7542bce06745db99af6c
Diffstat (limited to 'org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal')
-rw-r--r--org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/Agent.java2
-rw-r--r--org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/ClassFileDumper.java2
-rw-r--r--org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/ConfigLoader.java2
-rw-r--r--org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/CoverageTransformer.java2
-rw-r--r--org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/IExceptionLogger.java4
-rw-r--r--org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/JmxRegistration.java2
-rw-r--r--org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/Offline.java2
-rw-r--r--org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/PreMain.java57
-rw-r--r--org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/output/FileOutput.java2
-rw-r--r--org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/output/IAgentOutput.java9
-rw-r--r--org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/output/NoneOutput.java2
-rw-r--r--org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/output/TcpClientOutput.java2
-rw-r--r--org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/output/TcpConnection.java2
-rw-r--r--org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/output/TcpServerOutput.java2
14 files changed, 73 insertions, 19 deletions
diff --git a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/Agent.java b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/Agent.java
index b4dd0c10..b6debe1f 100644
--- a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/Agent.java
+++ b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/Agent.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors
+ * 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
diff --git a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/ClassFileDumper.java b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/ClassFileDumper.java
index 18aad17f..56f74c29 100644
--- a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/ClassFileDumper.java
+++ b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/ClassFileDumper.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors
+ * 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
diff --git a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/ConfigLoader.java b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/ConfigLoader.java
index dcedd52e..9020c2fc 100644
--- a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/ConfigLoader.java
+++ b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/ConfigLoader.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors
+ * 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
diff --git a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/CoverageTransformer.java b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/CoverageTransformer.java
index 29395b15..ef3300cd 100644
--- a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/CoverageTransformer.java
+++ b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/CoverageTransformer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors
+ * 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
diff --git a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/IExceptionLogger.java b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/IExceptionLogger.java
index 6e5c1292..82cd19bd 100644
--- a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/IExceptionLogger.java
+++ b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/IExceptionLogger.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors
+ * 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
@@ -32,6 +32,6 @@ public interface IExceptionLogger {
* @param ex
* exception to log
*/
- public void logExeption(Exception ex);
+ void logExeption(Exception ex);
}
diff --git a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/JmxRegistration.java b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/JmxRegistration.java
index 418af537..6c49c0c1 100644
--- a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/JmxRegistration.java
+++ b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/JmxRegistration.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors
+ * 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
diff --git a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/Offline.java b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/Offline.java
index 7eac19fa..69a9909e 100644
--- a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/Offline.java
+++ b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/Offline.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors
+ * 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
diff --git a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/PreMain.java b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/PreMain.java
index 538f7a46..205fa5b6 100644
--- a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/PreMain.java
+++ b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/PreMain.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors
+ * 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
@@ -12,9 +12,13 @@
package org.jacoco.agent.rt.internal;
import java.lang.instrument.Instrumentation;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
import org.jacoco.core.runtime.AgentOptions;
import org.jacoco.core.runtime.IRuntime;
+import org.jacoco.core.runtime.InjectedClassRuntime;
import org.jacoco.core.runtime.ModifiedSystemClassRuntime;
/**
@@ -52,7 +56,58 @@ public final class PreMain {
private static IRuntime createRuntime(final Instrumentation inst)
throws Exception {
+
+ if (redefineJavaBaseModule(inst)) {
+ return new InjectedClassRuntime(Object.class, "$JaCoCo");
+ }
+
return ModifiedSystemClassRuntime.createFor(inst, "java/lang/UnknownError");
}
+ /**
+ * Opens {@code java.base} module for {@link InjectedClassRuntime} when
+ * executed on Java 9 JREs or higher.
+ *
+ * @return <code>true</code> when running on Java 9 or higher,
+ * <code>false</code> otherwise
+ * @throws Exception
+ * if unable to open
+ */
+ private static boolean redefineJavaBaseModule(
+ final Instrumentation instrumentation) throws Exception {
+ try {
+ Class.forName("java.lang.Module");
+ } catch (final ClassNotFoundException e) {
+ return false;
+ }
+
+ Instrumentation.class.getMethod("redefineModule", //
+ Class.forName("java.lang.Module"), //
+ Set.class, //
+ Map.class, //
+ Map.class, //
+ Set.class, //
+ Map.class //
+ ).invoke(instrumentation, // instance
+ getModule(Object.class), // module
+ Collections.emptySet(), // extraReads
+ Collections.emptyMap(), // extraExports
+ Collections.singletonMap("java.lang",
+ Collections.singleton(
+ getModule(InjectedClassRuntime.class))), // extraOpens
+ Collections.emptySet(), // extraUses
+ Collections.emptyMap() // extraProvides
+ );
+ return true;
+ }
+
+ /**
+ * @return {@code cls.getModule()}
+ */
+ private static Object getModule(final Class<?> cls) throws Exception {
+ return Class.class //
+ .getMethod("getModule") //
+ .invoke(cls);
+ }
+
}
diff --git a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/output/FileOutput.java b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/output/FileOutput.java
index 64ae607e..dde78609 100644
--- a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/output/FileOutput.java
+++ b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/output/FileOutput.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors
+ * 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
diff --git a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/output/IAgentOutput.java b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/output/IAgentOutput.java
index ce8e5ddc..b3d0e17d 100644
--- a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/output/IAgentOutput.java
+++ b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/output/IAgentOutput.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors
+ * 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
@@ -33,8 +33,7 @@ public interface IAgentOutput {
* @throws Exception
* in case startup fails
*/
- public void startup(final AgentOptions options, final RuntimeData data)
- throws Exception;
+ void startup(AgentOptions options, RuntimeData data) throws Exception;
/**
* Shutdown the agent controller and clean up any resources it has created.
@@ -42,7 +41,7 @@ public interface IAgentOutput {
* @throws Exception
* in case shutdown fails
*/
- public void shutdown() throws Exception;
+ void shutdown() throws Exception;
/**
* Write all execution data in the runtime to a location determined by the
@@ -53,6 +52,6 @@ public interface IAgentOutput {
* @throws IOException
* in case writing fails
*/
- public void writeExecutionData(boolean reset) throws IOException;
+ void writeExecutionData(boolean reset) throws IOException;
}
diff --git a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/output/NoneOutput.java b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/output/NoneOutput.java
index 83a5fdc4..85a00556 100644
--- a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/output/NoneOutput.java
+++ b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/output/NoneOutput.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors
+ * 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
diff --git a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/output/TcpClientOutput.java b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/output/TcpClientOutput.java
index 4f69eed4..a3b027fd 100644
--- a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/output/TcpClientOutput.java
+++ b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/output/TcpClientOutput.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors
+ * 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
diff --git a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/output/TcpConnection.java b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/output/TcpConnection.java
index 06590aa2..ccba1f22 100644
--- a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/output/TcpConnection.java
+++ b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/output/TcpConnection.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors
+ * 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
diff --git a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/output/TcpServerOutput.java b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/output/TcpServerOutput.java
index 038d81ad..eeaf4a34 100644
--- a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/output/TcpServerOutput.java
+++ b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/output/TcpServerOutput.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors
+ * 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