New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 843307 link

Starred by 6 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Feature



Sign in to add a comment

Code coverage of Java

Project Member Reported by wychen@chromium.org, May 15 2018

Issue description

It would be quite useful if Java can also be included in the code coverage tools. I understand that the underlying technology is quite different, so this wouldn't be easy to implement.
 

Comment 1 by awdf@chromium.org, Jun 13 2018

Cc: nyquist@chromium.org jbudorick@chromium.org
Labels: Hotlist-CodeHealth
I recently came across https://chromium.googlesource.com/chromium/src/+/master/build/android/docs/coverage.md but following the instructions I got a compile error when I tried to build with coverage enabled.

I then discovered that in fact we do have 'coverage' bots on the internal clank tree, which have been failing with precisely the same error as I get for who-knows-how-long:

https://uberchromegw.corp.google.com/i/internal.client.clank/builders/coverage-phone
https://uberchromegw.corp.google.com/i/internal.client.clank/builders/coverage-tablet

I was sheriff yesterday but these failures did not show up in Sheriff-O-Matic otherwise I might have looked at them!

Comment 2 by awdf@chromium.org, Jun 13 2018

Cc: amaralp@chromium.org agrieve@chromium.org mlamouri@chromium.org
+agrieve, who it seems fixed these bots last, and current Clank build sheriffs FYI.

Here is the compile failure from the most recent build - it appears to be in r8 code during dexing:

FAILED: gen/chrome/android/third_party/compositor_animator/compositor_animator_java.dex.jar 
python ../../build/android/gyp/dex.py --depfile gen/chrome/android/third_party/compositor_animator/compositor_animator_java__dex.d --dex-path gen/chrome/android/third_party/compositor_animator/compositor_animator_java.dex.jar lib.java/chrome/android/third_party/compositor_animator/compositor_animator_java.jar --d8-jar-path ../../third_party/r8/lib/d8.jar
Traceback (most recent call last):
  File "../../build/android/gyp/dex.py", line 209, in <module>
    sys.exit(main(sys.argv[1:]))
  File "../../build/android/gyp/dex.py", line 205, in main
    depfile_deps=input_paths)
  File "/b/build/slave/coverage-phone/build/src/build/android/gyp/util/build_utils.py", line 628, in CallAndWriteDepfileIfStale
    pass_changes=True)
  File "/b/build/slave/coverage-phone/build/src/build/android/gyp/util/md5_check.py", line 87, in CallAndRecordIfStale
    function(*args)
  File "/b/build/slave/coverage-phone/build/src/build/android/gyp/util/build_utils.py", line 611, in on_stale_md5
    function(*args)
  File "../../build/android/gyp/dex.py", line 192, in on_stale_md5_callback
    _RunD8(dex_cmd, paths, options.dex_path)
  File "../../build/android/gyp/dex.py", line 138, in _RunD8
    build_utils.CheckOutput(dex_cmd, print_stderr=False)
  File "/b/build/slave/coverage-phone/build/src/build/android/gyp/util/build_utils.py", line 210, in CheckOutput
    raise CalledProcessError(cwd, args, stdout + stderr)
util.build_utils.CalledProcessError: Command failed: ( cd /b/build/slave/coverage-phone/build/src/out/Debug; java -jar ../../third_party/r8/lib/d8.jar --output gen/chrome/android/third_party/compositor_animator/compositor_animator_java.dex.jar lib.java/chrome/android/third_party/compositor_animator/compositor_animator_java.jar )
Warning in lib.java/chrome/android/third_party/compositor_animator/compositor_animator_java.jar:org/chromium/chrome/browser/compositor/animation/FloatProperty.class:
  Type `java.lang.reflect.Array` was not found, it is required for default or static interface methods desugaring of `boolean[][] org.chromium.chrome.browser.compositor.animation.FloatProperty.$VRi()`
Warning in lib.java/chrome/android/third_party/compositor_animator/compositor_animator_java.jar:org/chromium/chrome/browser/compositor/animation/FloatProperty.class:
  Type `com.vladium.emma.rt.RT` was not found, it is required for default or static interface methods desugaring of `boolean[][] org.chromium.chrome.browser.compositor.animation.FloatProperty.$VRi()`
Compilation failed with an internal error.
java.lang.UnsupportedOperationException
	at java.util.AbstractList.add(AbstractList.java:148)
	at java.util.AbstractList.add(AbstractList.java:108)
	at com.android.tools.r8.ir.conversion.JarState$LocalsAtOffset.addEnd(JarState.java:111)
	at com.android.tools.r8.ir.conversion.JarState.populateLocalsAtTable(JarState.java:363)
	at com.android.tools.r8.ir.conversion.JarState.<init>(JarState.java:320)
	at com.android.tools.r8.ir.conversion.JarSourceCode.<init>(JarSourceCode.java:209)
	at com.android.tools.r8.graph.JarCode.internalBuild(JarCode.java:144)
	at com.android.tools.r8.graph.JarCode.internalBuildWithLocals(JarCode.java:126)
	at com.android.tools.r8.graph.JarCode.buildIR(JarCode.java:101)
	at com.android.tools.r8.graph.DexEncodedMethod.buildIR(DexEncodedMethod.java:221)
	at com.android.tools.r8.ir.conversion.IRConverter.rewriteCode(IRConverter.java:523)
	at com.android.tools.r8.ir.conversion.IRConverter.convertMethodToDex(IRConverter.java:331)
	at com.android.tools.r8.ir.conversion.IRConverter$$Lambda$23/1201004330.accept(Unknown Source)
	at com.android.tools.r8.graph.DexClass.forEachMethodThrowing(DexClass.java:133)
	at com.android.tools.r8.ir.conversion.IRConverter.lambda$convertClassesToDex$2(IRConverter.java:318)
	at com.android.tools.r8.ir.conversion.IRConverter$$Lambda$22/1740000325.call(Unknown Source)
	at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1689)
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)


Owner: estevenson@chromium.org
Status: Assigned (was: Untriaged)
I can take a look at the current failure
Hmm, doesn't seem to be caused d8 desugaring - passing the --no-desugaring slightly changes the error:

[18/18] ACTION //chrome/android/third_party/compositor_animator:compositor_animator_java__dex(//build/toolchain/android:android_clang_arm)
FAILED: gen/chrome/android/third_party/compositor_animator/compositor_animator_java.dex.jar 
python ../../build/android/gyp/dex.py --depfile gen/chrome/android/third_party/compositor_animator/compositor_animator_java__dex.d --dex-path gen/chrome/android/third_party/compositor_animator/compositor_animator_java.dex.jar lib.java/chrome/android/third_party/compositor_animator/compositor_animator_java.jar --d8-jar-path ../../third_party/r8/lib/d8.jar
Traceback (most recent call last):
  File "../../build/android/gyp/dex.py", line 209, in <module>
    sys.exit(main(sys.argv[1:]))
  File "../../build/android/gyp/dex.py", line 205, in main
    depfile_deps=input_paths)
  File "/usr/local/google/code/clankium/src/build/android/gyp/util/build_utils.py", line 628, in CallAndWriteDepfileIfStale
    pass_changes=True)
  File "/usr/local/google/code/clankium/src/build/android/gyp/util/md5_check.py", line 87, in CallAndRecordIfStale
    function(*args)
  File "/usr/local/google/code/clankium/src/build/android/gyp/util/build_utils.py", line 611, in on_stale_md5
    function(*args)
  File "../../build/android/gyp/dex.py", line 192, in on_stale_md5_callback
    _RunD8(dex_cmd, paths, options.dex_path)
  File "../../build/android/gyp/dex.py", line 138, in _RunD8
    build_utils.CheckOutput(dex_cmd, print_stderr=False)
  File "/usr/local/google/code/clankium/src/build/android/gyp/util/build_utils.py", line 210, in CheckOutput
    raise CalledProcessError(cwd, args, stdout + stderr)
util.build_utils.CalledProcessError: Command failed: ( cd /usr/local/google/code/clankium/src/out/Debug; java -jar ../../third_party/r8/lib/d8.jar --no-desugaring --output gen/chrome/android/third_party/compositor_animator/compositor_animator_java.dex.jar lib.java/chrome/android/third_party/compositor_animator/compositor_animator_java.jar )
Compilation failed with an internal error.
java.lang.UnsupportedOperationException
	at java.util.AbstractList.add(AbstractList.java:148)
	at java.util.AbstractList.add(AbstractList.java:108)
	at com.android.tools.r8.ir.conversion.JarState$LocalsAtOffset.addEnd(JarState.java:111)
	at com.android.tools.r8.ir.conversion.JarState.populateLocalsAtTable(JarState.java:363)
	at com.android.tools.r8.ir.conversion.JarState.<init>(JarState.java:320)
	at com.android.tools.r8.ir.conversion.JarSourceCode.<init>(JarSourceCode.java:209)
	at com.android.tools.r8.graph.JarCode.internalBuild(JarCode.java:144)
	at com.android.tools.r8.graph.JarCode.internalBuildWithLocals(JarCode.java:126)
	at com.android.tools.r8.graph.JarCode.buildIR(JarCode.java:101)
	at com.android.tools.r8.graph.DexEncodedMethod.buildIR(DexEncodedMethod.java:221)
	at com.android.tools.r8.ir.conversion.IRConverter.rewriteCode(IRConverter.java:523)
	at com.android.tools.r8.ir.conversion.IRConverter.convertMethodToDex(IRConverter.java:331)
	at com.android.tools.r8.graph.DexClass.forEachMethodThrowing(DexClass.java:133)
	at com.android.tools.r8.ir.conversion.IRConverter.lambda$convertClassesToDex$2(IRConverter.java:318)
	at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1430)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

ninja: build stopped: subcommand failed.

Not really sure what is happening here. Filed a bug b/110164501 with d8 to see.
Fixed here https://r8-review.googlesource.com/c/r8/+/24240.

Planning to wait until 1.2 goes to stable and then I'll update the jar from https://mvnrepository.com/artifact/com.android.tools/r8. 
Issue 863387 has been merged into this issue.
Project Member

Comment 8 by bugdroid1@chromium.org, Oct 3

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/bf9f06ecd6399fec7931fa6b6af02d6261c10600

commit bf9f06ecd6399fec7931fa6b6af02d6261c10600
Author: Eric Stevenson <estevenson@chromium.org>
Date: Wed Oct 03 16:06:54 2018

Android: Update d8 to 1.2.48.

Includes fix for supporting asserts and invalid locals information.

Bug: 843307
Change-Id: Iec4ecb2981e8c895e728127179d3b0eb54f09b14
Reviewed-on: https://chromium-review.googlesource.com/c/1258963
Reviewed-by: agrieve <agrieve@chromium.org>
Commit-Queue: Eric Stevenson <estevenson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596239}
[modify] https://crrev.com/bf9f06ecd6399fec7931fa6b6af02d6261c10600/DEPS
[modify] https://crrev.com/bf9f06ecd6399fec7931fa6b6af02d6261c10600/third_party/r8/README.chromium
[modify] https://crrev.com/bf9f06ecd6399fec7931fa6b6af02d6261c10600/third_party/r8/cipd.yaml

This is great! I also reached out to clank-team yesterday regarding Java coverage.

Do we want to switch to Jacoco or stick with emma?
(Jacoco is developed to replace emma)
Owner: ----
Status: Available (was: Assigned)
Followed the steps at https://chromium.googlesource.com/chromium/src/+/master/build/android/docs/coverage.md and confirmed that with the d8 fix coverage is working now (locally at least).

Seems like we'd want to update to Jacoco if we're planning on making coverage useful for developers. I can probably help with any build changes we need to make to get coverage working.
Cc: estevenson@chromium.org

Sign in to add a comment