[
https://issues.apache.org/jira/browse/IO-819?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17783789#comment-17783789
]
Stephan Markwalder commented on IO-819:
---------------------------------------
I'm not an expert for Android and its build tools, but maybe the following
information helps someone else with more know-how.
Looking a little bit deeper into the stacktrace, there is this information:
{code:java}
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed
to complete, origin:
/Users/pranshu/.gradle/caches/transforms-3/7cdc58ab883977f6fa537449bff40fa0/transformed/jetified-commons-io-2.15.0.jar:org/apache/commons/io/FileCleaningTracker$Reaper.class
at Version.fakeStackEntry(Version_4.0.52.java:0)
at
com.android.tools.r8.internal.vk.a(R8_4.0.52_5a340ca2823c7e792fe09805c75f749b9d398d230bc0518bb54ae9b6b50addbe:75)
at [...] {code}
The issue seems to be related to processing the class file
{{{}org/apache/commons/io/FileCleaningTracker$Reaper.class{}}}.
The inner class {{Reaper}} in {{FileCleaningTracker}} is rather simple:
[https://github.com/apache/commons-io/blob/rel/commons-io-2.15.0/src/main/java/org/apache/commons/io/FileCleaningTracker.java#L53-L82]
The last change to this file was done almost 5 months ago in June 2023. This
was before the release of Commons IO 2.14.0 in September 2023. If I decompile
the class files from Commons IO 2.14.0 and 2.15.0, the source code looks
identical.
But the binary class files are not identical. The one for 2.14.0 is 1614 bytes
in size, while the one for 2.15.0 has a size of 1644 bytes (+30 bytes). This
could be explained by the fact that the build for 2.14.0 was running Maven on
Java 17 and the build for 2.15.0 on Java 21, both presumably using the Java
compiler shipped with these Java versions. However, both builds were correctly
targeting Java 8 (class file version 52).
If I use {{javap}} to dump the content of the class files (with all extra flags
to include as much information as possible), the constructor for inner class
{{Reaper}} seems to have some extra metadata associated with its method
parameters.
2.14.0:
{noformat}
org.apache.commons.io.FileCleaningTracker$Reaper(org.apache.commons.io.FileCleaningTracker);
descriptor: (Lorg/apache/commons/io/FileCleaningTracker;)V
flags: (0x0000)
Code:
[...]{noformat}
2.15.0:
{noformat}
org.apache.commons.io.FileCleaningTracker$Reaper(org.apache.commons.io.FileCleaningTracker);
descriptor: (Lorg/apache/commons/io/FileCleaningTracker;)V
flags: (0x0000)
Code:
[...]
MethodParameters:
Name Flags
<no name> final synthetic{noformat}
If you look at the source code, you can see that the inner class has only a
no-arg constructor. But the binary code actually expects the method to receive
a reference to an instance of the outer class. I assume this is how instances
of inner classes get to know their parent/outer instance. This is a synthetic
parameter without a defined name (see the "<no name>" above). I assume that
this "missing" name is what breaks your Android build. If Android's Jetifier
tries to process the content of the class file, it doesn't expect to find a
nameless parameter. Similar issues have been reported for other tools, even for
components of the JDK itself (see
[JDK-8304837|https://bugs.openjdk.org/browse/JDK-8304837] for an example). If
my assumption would be true, you will have to wait for an update of Android's
Jetifier to have this issue fixed.
> Commons IO v2.15.0 is breaking android builds
> ---------------------------------------------
>
> Key: IO-819
> URL: https://issues.apache.org/jira/browse/IO-819
> Project: Commons IO
> Issue Type: Bug
> Affects Versions: 2.15.0
> Environment: java --version
> openjdk 11.0.21 2023-10-17 LTS
> OpenJDK Runtime Environment Zulu11.68+17-CA (build 11.0.21+9-LTS)
> OpenJDK 64-Bit Server VM Zulu11.68+17-CA (build 11.0.21+9-LTS, mixed mode)
>
> Mac OS 14.1 on Apple Silicon
> Reporter: Pranshu
> Priority: Major
> Attachments: Screenshot 2023-10-27 at 00.07.46.png, stacktrace.txt
>
>
> Hey we are using commons +commons-io:commons-io+ java package in out React
> Native app on the android side.
> Apparently the recently releases version v2.15.0 is breaking android builds,
> whereas versions <= v2.14.0 works well.
> Steps to Repro
> 1. Create a RN app
> npx react-native init CommonsIORepro
> 2. Add commons-io dep android/{*}app{*}/build.gradle
> dependencies{
> implementation "commons-io:commons-io:2.15.0"
> }
>
> 3. yarn run start
> 4. In a new terminal - yarn run android
--
This message was sent by Atlassian Jira
(v8.20.10#820010)