Use of UInt8/Unit16/UInt32 breaks android dex/D8 in Fire 2399

(Jon Nermut) #1

Apologies in advance if its already logged, couldn’t see it. (226.4 KB)

See the attached swift/cooper project. This is a distillation of a problem from a real project.

import java.util

class MyClass
    var sum1: UInt16 = 0
    var sum2: UInt16 = 0

print("The magic happens here.")
  1. Compile the code into a jar
  2. Run the Android D8 dexer over the jar, as it would in an android gradle script:
  3. It fails with an ArrayIndexOfBounds, looking at some type annotation
  4. Happens also with use of other UInt types, and with them as local var as well as properties
  5. Doesn’t happen with signed types
thebeast:Debug jon$ ~/.android-sdk/build-tools/28.0.3/d8 consoleapplication888.jar 

Compilation failed with an internal error.

java.lang.ArrayIndexOutOfBoundsException: 2304

at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(
at java.util.concurrent.ForkJoinTask.doExec(
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(
at java.util.concurrent.ForkJoinPool.runWorker(
thebeast:Debug jon$

This was on android build tools 28.0.3, Fire 2399

(RemObjects) #2

Thanks, logged as bugs://82616

(Carlo Kok) #3

d8? Is that something new?

(Jon Nermut) #4

Relatively new. It’s the replacement for dx.jar and is the default dexer now (since Android 28 I think).
Has in general much better error messages, but not in this case.
I had to hook up the Eclipse debugger up to work out which methods were at fault, then tracked it down to UInt16 vars inside the method.
It’s blowing up in creating it’s model of the class/method before it does the dexing.

(Carlo Kok) #5

Seems Local variable annotations aren’t written correctly in some cases. DEX completely ignores this, and so does Java, which is why I never spotted it before. I’ll push a fix for this, thanks for the report.

1 Like
(RemObjects) #6

bugs://82616 got closed with status fixed.

(Jon Nermut) #7

Thanks. Just FYI I later found the same issue with UInt64 as a return type for a method. Although thinking about it that method must have implicit local vars of that type too.

(Carlo Kok) #8

yeah it’s not the result type itself, it’s the implied result variable.

(marc hoffman) #9

Btw, we (experimentally) support using D8 from the standard build tool chain, set the UseD8 to true.