Fixed
Status Update
Comments
js...@google.com <js...@google.com>
js...@google.com <js...@google.com> #2
Thank you for the report, along with the sample. I can reproduce the issue in a much simpler setting: https://r8-review.googlesource.com/c/r8/+/38520/1
js...@google.com <js...@google.com> #3
The fix is awfully simple. :p While it's under review, you can use attached r8.jar, which is built with https://r8-review.googlesource.com/c/r8/+/38520/3 on ToT.
Or, another workaround is to provide the following keep rule:
-assumevalues class android.os.Build$VERSION {
int SDK_INT return 22;
}
or some other min API you want (but constant, not range). The issue is, we're synthesizing such rule:
https://r8.googlesource.com/r8/+/refs/heads/master/src/main/java/com/android/tools/r8/R8.java#310
where range <min_api>..INT_MAX is used. Then, it's flown to `com.badlogic.gdx.backends.android.AndroidInputFactory.newAndroidInput` and meet operation of a certain constant and that range raises NPE.
Or, another workaround is to provide the following keep rule:
-assumevalues class android.os.Build$VERSION {
int SDK_INT return 22;
}
or some other min API you want (but constant, not range). The issue is, we're synthesizing such rule:
where range <min_api>..INT_MAX is used. Then, it's flown to `com.badlogic.gdx.backends.android.AndroidInputFactory.newAndroidInput` and meet operation of a certain constant and that range raises NPE.
js...@google.com <js...@google.com> #4
ze...@google.com <ze...@google.com> #5
It looks like this has not been cherry-picked to 1.5. Is that intentional?
ze...@google.com <ze...@google.com> #6
ap...@google.com <ap...@google.com> #7
Project: r8
Branch: d8-1.5
commit ee9b886184c753ca53c1cbb0766871272e5541ba
Author: Ian Zerny <zerny@google.com>
Date: Wed Jul 10 17:45:23 2019
Version 1.5.60
Cherry pick: Check other lattice element type before casting.
CL:https://r8-review.googlesource.com/c/r8/+/38520
Bug: 132897042
Change-Id: If7b87ac08f33a64e7de556e22c38fc560779fce4
M src/main/java/com/android/tools/r8/Version.java
M src/main/java/com/android/tools/r8/ir/analysis/constant/ConstLatticeElement.java
A src/test/java/com/android/tools/r8/ir/analysis/constant/B132897042.java
https://r8-review.googlesource.com/40470
Branch: d8-1.5
commit ee9b886184c753ca53c1cbb0766871272e5541ba
Author: Ian Zerny <zerny@google.com>
Date: Wed Jul 10 17:45:23 2019
Version 1.5.60
Cherry pick: Check other lattice element type before casting.
CL:
Bug: 132897042
Change-Id: If7b87ac08f33a64e7de556e22c38fc560779fce4
M src/main/java/com/android/tools/r8/Version.java
M src/main/java/com/android/tools/r8/ir/analysis/constant/ConstLatticeElement.java
A src/test/java/com/android/tools/r8/ir/analysis/constant/B132897042.java
Description
Current version is: 1.4.94 (build 390954928f0db9c3b888a367f7f128ce3bbfb160 from go/r8bot (luci-r8-ci-archive-0-5g74)).
...
Caused by: java.lang.NullPointerException
at
at com.android.tools.r8.ir.analysis.constant.SparseConditionalConstantPropagation.visitPhi(SparseConditionalConstantPropagation.java:137)
at com.android.tools.r8.ir.analysis.constant.SparseConditionalConstantPropagation.run(SparseConditionalConstantPropagation.java:55)
at com.android.tools.r8.ir.conversion.IRConverter.rewriteCode(IRConverter.java:961)
at com.android.tools.r8.ir.conversion.IRConverter.processMethod(IRConverter.java:805)
at com.android.tools.r8.ir.conversion.IRConverter.lambda$optimize$5(IRConverter.java:551)
at com.android.tools.r8.ir.conversion.CallGraph.lambda$forEachMethod$6(CallGraph.java:468)
This occurs only when optimization is applied. It appears to be encountering this specifically if block splitting is applied to com.badlogic.gdx.backends.android.AndroidInputFactory.newAndroidInput.
Since the Java bytecode that causes this is produced by a proprietary transform that is nontrivial to set up, I've attached a zip file containing two jars and some rules. You can reproduce the issue by invoking R8 in the following manner:
java -jar [path to r8 jar] --pg-conf dontshrink.txt --pg-conf proguard-android-optimize.txt-3.4.0 --lib 3.jar --lib [path to android.jar] 0.jar
I most recently used a local build of r8 using the master branch, commit 559e5b3b1e112e12e31e7f46f48d2a3d004176a9.