From 00cae1cc88773a5238809130841b6a6b7eb63614 Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Tue, 18 Feb 2020 12:50:44 +0000 Subject: Reland "Turn on the instrumentation by default for the java code in APEXes" This reverts commit c021ea0b3543d4ff64b16414c0276b96dc5b2c4b. Bug: 149353192 Change-Id: I2b1c0736202de26c5ea88c0ab14574bd7207a5fb Test: N/A (this is a clean revert) forward fix will be followed --- java/java.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'java/java.go') diff --git a/java/java.go b/java/java.go index 462dba809..b33cb2aa3 100644 --- a/java/java.go +++ b/java/java.go @@ -1519,6 +1519,11 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) { j.headerJarFile = j.implementationJarFile } + // Force enable the instrumentation for java code that is built for APEXes + if android.DirectlyInAnyApex(ctx, ctx.ModuleName()) && !j.IsForPlatform() { + j.properties.Instrument = true + } + if j.shouldInstrument(ctx) { outputFile = j.instrument(ctx, flags, outputFile, jarName) } -- cgit v1.2.3-59-g8ed1b From 93e57a0b862beabdd11b8dac342167ea7f7c7b76 Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Fri, 21 Feb 2020 16:04:53 +0900 Subject: Expect added members for instrumented modules hiddenapi expects that all members in a class to have corresponding hidden API flags. However, this can't be satisfied when the java module having the class is instrumented; JaCoCo added a few number of synthetic members. In this case, give 'no-force-assign-all' option to the hidden api tool so that it doesn't complain about the synthetic methods. Also, disabling instrumenting jacocoagent itself, because it doesn't make sense. Exempt-From-Owner-Approval: PS3 fixes a typo in a comment. PS2 got ORV. Bug: 149353192 Test: SKIP_ABI_CHECKS=true EMMA_INSTRUMENT=true EMMA_INSTRUMENT_FRAMEWORK=true SKIP_BOOT_JARS_CHECK=true m out/soong/.intermediates/external/apache-xml/apache-xml/android_common_com.android.art.debug/hiddenapi/unaligned/unaligned.jar Change-Id: Ibaf383c439945ab664e885af319548b56e2c8cb6 --- java/hiddenapi.go | 12 ++++++++++++ java/java.go | 7 +++++-- 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'java/java.go') diff --git a/java/hiddenapi.go b/java/hiddenapi.go index 6020aba6e..8f34714d3 100644 --- a/java/hiddenapi.go +++ b/java/hiddenapi.go @@ -159,9 +159,21 @@ func hiddenAPIEncodeDex(ctx android.ModuleContext, output android.WritablePath, tmpOutput = android.PathForModuleOut(ctx, "hiddenapi", "unaligned", "unaligned.jar") tmpDir = android.PathForModuleOut(ctx, "hiddenapi", "unaligned") } + + enforceHiddenApiFlagsToAllMembers := true // If frameworks/base doesn't exist we must be building with the 'master-art' manifest. // Disable assertion that all methods/fields have hidden API flags assigned. if !ctx.Config().FrameworksBaseDirExists(ctx) { + enforceHiddenApiFlagsToAllMembers = false + } + // b/149353192: when a module is instrumented, jacoco adds synthetic members + // $jacocoData and $jacocoInit. Since they don't exist when building the hidden API flags, + // don't complain when we don't find hidden API flags for the synthetic members. + if j, ok := ctx.Module().(*Library); ok && j.shouldInstrument(ctx) { + enforceHiddenApiFlagsToAllMembers = false + } + + if !enforceHiddenApiFlagsToAllMembers { hiddenapiFlags = "--no-force-assign-all" } diff --git a/java/java.go b/java/java.go index b33cb2aa3..b3aca4989 100644 --- a/java/java.go +++ b/java/java.go @@ -1519,8 +1519,11 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) { j.headerJarFile = j.implementationJarFile } - // Force enable the instrumentation for java code that is built for APEXes - if android.DirectlyInAnyApex(ctx, ctx.ModuleName()) && !j.IsForPlatform() { + // Force enable the instrumentation for java code that is built for APEXes ... + // except for the jacocoagent itself (because instrumenting jacocoagent using jacocoagent + // doesn't make sense) + isJacocoAgent := ctx.ModuleName() == "jacocoagent" + if android.DirectlyInAnyApex(ctx, ctx.ModuleName()) && !isJacocoAgent && !j.IsForPlatform() { j.properties.Instrument = true } -- cgit v1.2.3-59-g8ed1b