Merge tag 'v0.8.0' from 'aosp/upstream-master' into master.

* 6a0c097f (tag: v0.8.0) Prepare release v0.8.0
* b9d1b54e Happy New Year 2018!
* 6f375769 Consolidate change log for 0.8.0 release (#632)
* 0c50b210 Restore exec files compatibility regarding Java 9 class files (#636)
* 7f7c246f Offline instrumentation should not damage module-info (#634)
* e050f194 Instrumentation should not damage structured locking (#627)
* 4c0b93e8 Fix ExecutionData.merge JavaDoc (#630)
* ff001947 Add filter for duplicates of finally blocks (#604)
* 00f06ecc Fix typos

Bug: 69463998
Test: m EMMA_INSTRUMENT=true EMMA_INSTRUMENT_FRAMEWORK=true SKIP_BOOT_JARS_CHECK=true WITH_DEXPREOPT=false tests
Change-Id: I00f3079bdbb0618141b4414cac0b83dcf9c0c2d5
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..a4c103c
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,86 @@
+//
+// Copyright (C) 2016 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+// Build jacoco-agent from sources for the platform
+//
+// Note: this is only intended to be used for the platform development. This is *not* intended
+// to be used in the SDK where apps can use the official jacoco release.
+java_library {
+    name: "jacocoagent",
+
+    srcs: [
+        "org.jacoco.core/src/**/*.java",
+        "org.jacoco.agent/src/**/*.java",
+        "org.jacoco.agent.rt/src/**/*.java",
+    ],
+
+    // Some Jacoco source files depend on classes that do not exist in Android.
+    // While these classes are not executed at runtime (because we use offline
+    // instrumentation), they will cause issues when compiling them with ART
+    // during dex pre-opting. Therefore, it would prevent from applying code
+    // coverage on classes in the bootclasspath (frameworks, services, ...) or
+    // system apps.
+    // Note: we still may need to update the source code to cut dependencies in
+    // mandatory jacoco classes.
+    exclude_srcs: [
+        "org.jacoco.core/src/org/jacoco/core/runtime/ModifiedSystemClassRuntime.java",
+        "org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/PreMain.java",
+        "org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/CoverageTransformer.java",
+        "org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/JmxRegistration.java",
+    ],
+
+    // In order to include Jacoco in core libraries, we cannot depend on
+    // anything in the bootclasspath (or we would create dependency cycle).
+    // Therefore we compile against the SDK android.jar which gives the same
+    // APIs Jacoco depends on.
+    sdk_version: "9",
+
+    // TODO(b/69671801): there's no bytecode on the device, so these shouldn't
+    // be necessary.
+    static_libs: [
+        "asm-6.0",
+        "asm-commons-6.0",
+        "asm-tree-6.0",
+    ],
+}
+
+// Build jacoco-cli from sources for the platform
+
+// TODO(jeffrygaston) it'd be nice to keep the build process and/or list of source files in sync with
+// what is defined in the pom.xml files, although it's probably much more trouble than it's worth
+java_library_host {
+    name: "jacoco-cli",
+
+    manifest: "org.jacoco.cli/src/MANIFEST.MF",
+
+    srcs: [
+        "org.jacoco.core/src/**/*.java",
+        "org.jacoco.report/src/**/*.java",
+        "org.jacoco.cli/src/**/*.java",
+    ],
+
+    java_resource_dirs: [
+        "org.jacoco.core/src",
+        "org.jacoco.report/src",
+    ],
+
+    static_libs: [
+        "asm-6.0",
+        "asm-commons-6.0",
+        "asm-tree-6.0",
+        "args4j-2.0.28",
+    ],
+}
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..c708fc7
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,21 @@
+#
+# Copyright (C) 2016 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+LOCAL_PATH := $(call my-dir)
+
+# include jacoco-cli in the dist directory to enable running it to generate a code-coverage report
+ifeq ($(EMMA_INSTRUMENT),true)
+$(call dist-for-goals, dist_files, $(HOST_OUT_JAVA_LIBRARIES)/jacoco-cli.jar)
+endif
diff --git a/MODULE_LICENSE_EPL b/MODULE_LICENSE_EPL
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/MODULE_LICENSE_EPL
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000..54fc346
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,14 @@
+License
+=======
+
+Copyright (c) 2009, 2015 Mountainminds GmbH & Co. KG and Contributors
+
+The JaCoCo Java Code Coverage Library and all included documentation is made
+available by Mountainminds GmbH & Co. KG, Munich. Except indicated below, the
+Content is provided to you under the terms and conditions of the Eclipse Public
+License Version 1.0 ("EPL"). A copy of the EPL is available at
+[http://www.eclipse.org/legal/epl-v10.html](http://www.eclipse.org/legal/epl-v10.html).
+
+Please visit
+[http://www.eclemma.org/jacoco/trunk/doc/license.html](http://www.eclemma.org/jacoco/trunk/doc/license.html)
+for the complete license information including third party licenses and trademarks.
diff --git a/README.android b/README.android
new file mode 100644
index 0000000..cad30c6
--- /dev/null
+++ b/README.android
@@ -0,0 +1,16 @@
+We build an equivalent of the jacoco-agent.jar which contains classes from org.jacoco.core,
+org.jacoco.agent and org.jacoco.agent.rt packages but also classes from asm 5.0.1.
+
+However, Jacoco depends on classes that do not exist in Android (java.lang.instrument.* or
+javax.management.*) for runtime instrumentation only. The ART compiler would reject those classes
+when they are either in the bootclasspath (core, frameworks, ...) or system apps.
+
+Since we only use offline instrumentation for code coverage (using Jack) and do not execute these
+classes at runtime, we simply not compile them here.
+
+We also need to modify the source code to cut dependencies to the classes that we exclude from the
+compilation. The changes are surrounded by "BEGIN android-change" and "END android-change". Here
+is the list of the changes:
+
+1) Remove the creation of JmxRegistration in org.jacoco.agent.rt.internal.Agent.
+2) Change default OutputMode to none in org.jacoco.core.runtime.AgentOptions
diff --git a/README.version b/README.version
new file mode 100644
index 0000000..0ef82ce
--- /dev/null
+++ b/README.version
@@ -0,0 +1,4 @@
+URL: https://github.com/jacoco/jacoco/tree/v0.7.5
+Version: v0.7.5
+BugComponent: 108682
+Owners: shertz
diff --git a/config.mk b/config.mk
new file mode 100644
index 0000000..d645621
--- /dev/null
+++ b/config.mk
@@ -0,0 +1,16 @@
+# Copyright (C) 2016 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+JACOCO_PACKAGE_NAME := org.jacoco.agent.rt.internal
+
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 661698a..667a7d0 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
@@ -121,7 +121,9 @@
 			output = createAgentOutput();
 			output.startup(options, data);
 			if (options.getJmx()) {
-				jmxRegistration = new JmxRegistration(this);
+// BEGIN android-change
+//				jmxRegistration = new JmxRegistration(this);
+// END android-change
 			}
 		} catch (final Exception e) {
 			logger.logExeption(e);
diff --git a/org.jacoco.cli/src/MANIFEST.MF b/org.jacoco.cli/src/MANIFEST.MF
new file mode 100644
index 0000000..bae94d5
--- /dev/null
+++ b/org.jacoco.cli/src/MANIFEST.MF
@@ -0,0 +1,2 @@
+Main-Class: org.jacoco.cli.internal.Main

+

diff --git a/org.jacoco.core/src/org/jacoco/core/jacoco.properties b/org.jacoco.core/src/org/jacoco/core/jacoco.properties
index 0949337..e2f9aca 100644
--- a/org.jacoco.core/src/org/jacoco/core/jacoco.properties
+++ b/org.jacoco.core/src/org/jacoco/core/jacoco.properties
@@ -1,3 +1,6 @@
-VERSION=$qualified.bundle.version$
-HOMEURL=$jacoco.home.url$
-RUNTIMEPACKAGE=$jacoco.runtime.package.name$
\ No newline at end of file
+#This file is supposed to be processed by Maven, but Android doesn't run Maven
+#So in Android we've filled in the resulting values below
+VERSION=0.7.10.201704181138.android
+HOMEURL=http://www.jacoco.org/jacoco
+RUNTIMEPACKAGE=org.jacoco.agent.rt.internal
+
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 1a9c971..46c108e 100644
--- a/org.jacoco.core/src/org/jacoco/core/runtime/AgentOptions.java
+++ b/org.jacoco.core/src/org/jacoco/core/runtime/AgentOptions.java
@@ -494,7 +494,10 @@
 	 */
 	public OutputMode getOutput() {
 		final String value = options.get(OUTPUT);
-		return value == null ? OutputMode.file : OutputMode.valueOf(value);
+// BEGIN android-change
+//		return value == null ? OutputMode.file : OutputMode.valueOf(value);
+		return value == null ? OutputMode.none : OutputMode.valueOf(value);
+// END android-change
 	}
 
 	/**