Android and Log4j

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Android and Log4j

Ralph Goers
Log4j added support for Java 9 by:
Converting the Log4j-API jar to a multi-release jar that includes support for StackWalker and the new Process Id support.
Adding a module-info.jar to the Log4j API jar.

We are now getting complaints from Android users (as well as a few others) that their tools no longer work with log4j. During development I ran into problems with OSGi. The problems seem to mostly revolve around the fact that they can’t deal with the classes for Java 9. I was surprised that Android is failing on the classes in META-INF/versions/9 as I had assumed that would be an invalid location for a class file prior to Java 9, but that seems not to be the case. The fact that module-info.java turns into a class file also seems to be a problem since the various tools are seeing it and having problems with it.

We have been discussing various ways to handle this in https://issues.apache.org/jira/browse/LOG4J2-2133 <https://issues.apache.org/jira/browse/LOG4J2-2133>. There seems to be a strong push to just remove the support for Java 9 since it is breaking so many things.

It seems impossible to have a module-info.java file in a jar that is going to be included in Android. If this had been a json file that was interpreted by the classloader or had a different file extension other than .class we wouldn’t be in this mess. We also need another mechanism to bring in our code that uses StackWalker as calling it via Reflection and emulating lambda expressions seems like it would be painful and slow.

Do you have any recommendations on how we can resolve this impasse?

Ralph
Reply | Threaded
Open this post in threaded view
|

Re: Android and Log4j

Remi Forax
Ask Google to fix dx,
dx should ignore the module-info.class and everything inside META-INF/versions (at least it's a first simple patch).

cheers,
Rémi

----- Mail original -----
> De: "Ralph Goers" <[hidden email]>
> À: "core-libs-dev" <[hidden email]>
> Envoyé: Dimanche 3 Décembre 2017 19:25:08
> Objet: Android and Log4j

> Log4j added support for Java 9 by:
> Converting the Log4j-API jar to a multi-release jar that includes support for
> StackWalker and the new Process Id support.
> Adding a module-info.jar to the Log4j API jar.
>
> We are now getting complaints from Android users (as well as a few others) that
> their tools no longer work with log4j. During development I ran into problems
> with OSGi. The problems seem to mostly revolve around the fact that they can’t
> deal with the classes for Java 9. I was surprised that Android is failing on
> the classes in META-INF/versions/9 as I had assumed that would be an invalid
> location for a class file prior to Java 9, but that seems not to be the case.
> The fact that module-info.java turns into a class file also seems to be a
> problem since the various tools are seeing it and having problems with it.
>
> We have been discussing various ways to handle this in
> https://issues.apache.org/jira/browse/LOG4J2-2133
> <https://issues.apache.org/jira/browse/LOG4J2-2133>. There seems to be a strong
> push to just remove the support for Java 9 since it is breaking so many things.
>
> It seems impossible to have a module-info.java file in a jar that is going to be
> included in Android. If this had been a json file that was interpreted by the
> classloader or had a different file extension other than .class we wouldn’t be
> in this mess. We also need another mechanism to bring in our code that uses
> StackWalker as calling it via Reflection and emulating lambda expressions seems
> like it would be painful and slow.
>
> Do you have any recommendations on how we can resolve this impasse?
>
> Ralph
Reply | Threaded
Open this post in threaded view
|

Re: Android and Log4j

Alan Bateman
In reply to this post by Ralph Goers
On 03/12/2017 18:25, Ralph Goers wrote:

> Log4j added support for Java 9 by:
> Converting the Log4j-API jar to a multi-release jar that includes support for StackWalker and the new Process Id support.
> Adding a module-info.jar to the Log4j API jar.
>
> We are now getting complaints from Android users (as well as a few others) that their tools no longer work with log4j. During development I ran into problems with OSGi. The problems seem to mostly revolve around the fact that they can’t deal with the classes for Java 9. I was surprised that Android is failing on the classes in META-INF/versions/9 as I had assumed that would be an invalid location for a class file prior to Java 9, but that seems not to be the case. The fact that module-info.java turns into a class file also seems to be a problem since the various tools are seeing it and having problems with it.
>
> :
>
> Do you have any recommendations on how we can resolve this impasse?
>
The Android tools should ignore class files in META/**, at least until
they are updated to work with multi-release JARs. Have you created a bug
for them to look at this issue?

-Alan
Reply | Threaded
Open this post in threaded view
|

Re: Android and Log4j

Uwe Schindler
Hi,

I'd also suggest to place the module-info.class inside the versions folder. So it should be ignored once the meta-inf bug is fixed.

Java 9 should also read the module info from the versioned folder.

Uwe


Am 3. Dezember 2017 20:19:34 MEZ schrieb Alan Bateman <[hidden email]>:

>On 03/12/2017 18:25, Ralph Goers wrote:
>> Log4j added support for Java 9 by:
>> Converting the Log4j-API jar to a multi-release jar that includes
>support for StackWalker and the new Process Id support.
>> Adding a module-info.jar to the Log4j API jar.
>>
>> We are now getting complaints from Android users (as well as a few
>others) that their tools no longer work with log4j. During development
>I ran into problems with OSGi. The problems seem to mostly revolve
>around the fact that they can’t deal with the classes for Java 9. I was
>surprised that Android is failing on the classes in META-INF/versions/9
>as I had assumed that would be an invalid location for a class file
>prior to Java 9, but that seems not to be the case. The fact that
>module-info.java turns into a class file also seems to be a problem
>since the various tools are seeing it and having problems with it.
>>
>> :
>>
>> Do you have any recommendations on how we can resolve this impasse?
>>
>The Android tools should ignore class files in META/**, at least until
>they are updated to work with multi-release JARs. Have you created a
>bug
>for them to look at this issue?
>
>-Alan

--
Uwe Schindler
Achterdiek 19, 28357 Bremen
https://www.thetaphi.de
Reply | Threaded
Open this post in threaded view
|

Re: Android and Log4j

Ralph Goers
In reply to this post by Alan Bateman


> On Dec 3, 2017, at 12:19 PM, Alan Bateman <[hidden email]> wrote:
>
> On 03/12/2017 18:25, Ralph Goers wrote:
>> Log4j added support for Java 9 by:
>> Converting the Log4j-API jar to a multi-release jar that includes support for StackWalker and the new Process Id support.
>> Adding a module-info.jar to the Log4j API jar.
>>
>> We are now getting complaints from Android users (as well as a few others) that their tools no longer work with log4j. During development I ran into problems with OSGi. The problems seem to mostly revolve around the fact that they can’t deal with the classes for Java 9. I was surprised that Android is failing on the classes in META-INF/versions/9 as I had assumed that would be an invalid location for a class file prior to Java 9, but that seems not to be the case. The fact that module-info.java turns into a class file also seems to be a problem since the various tools are seeing it and having problems with it.
>>
>> :
>>
>> Do you have any recommendations on how we can resolve this impasse?
>>
> The Android tools should ignore class files in META/**, at least until they are updated to work with multi-release JARs. Have you created a bug for them to look at this issue?

Yes, although I don’t develop for Android so I am not certain I created the issue correctly. https://issuetracker.google.com/u/1/issues/70118537 <https://issuetracker.google.com/u/1/issues/70118537>.

I also created https://issues.apache.org/jira/browse/FELIX-5592 <https://issues.apache.org/jira/browse/FELIX-5592> which relates to https://issues.apache.org/jira/browse/FELIX-5527 <https://issues.apache.org/jira/browse/FELIX-5527>. No activity has occurred on either of these issues.


Ralph

Reply | Threaded
Open this post in threaded view
|

Re: Android and Log4j

Martin Buchholz-3
In reply to this post by Remi Forax
On Sun, Dec 3, 2017 at 11:02 AM, Remi Forax <[hidden email]> wrote:

> Ask Google to fix dx,
> dx should ignore the module-info.class and everything inside
> META-INF/versions (at least it's a first simple patch).
>

Hi, I'm "Google", sort of.  Friends tell me that dx is getting fixed.
Reply | Threaded
Open this post in threaded view
|

Re: Android and Log4j

Martin Buchholz-3
Very latest Android Studio comes with two compilers, dx and d8.
https://developer.android.com/studio/preview/features/index.html
I hear that both compilers know to skip module-info files.

On Mon, Dec 4, 2017 at 12:03 PM, Martin Buchholz <[hidden email]>
wrote:

>
>
> On Sun, Dec 3, 2017 at 11:02 AM, Remi Forax <[hidden email]> wrote:
>
>> Ask Google to fix dx,
>> dx should ignore the module-info.class and everything inside
>> META-INF/versions (at least it's a first simple patch).
>>
>
> Hi, I'm "Google", sort of.  Friends tell me that dx is getting fixed.
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Android and Log4j

Remi Forax
In reply to this post by Martin Buchholz-3
Hi Google :)
great news.

Rémi

> De: "Martin Buchholz" <[hidden email]>
> À: "Remi Forax" <[hidden email]>
> Cc: "Ralph Goers" <[hidden email]>, "core-libs-dev"
> <[hidden email]>
> Envoyé: Lundi 4 Décembre 2017 21:03:23
> Objet: Re: Android and Log4j

> On Sun, Dec 3, 2017 at 11:02 AM, Remi Forax < [ mailto:[hidden email] |
> [hidden email] ] > wrote:

>> Ask Google to fix dx,
>> dx should ignore the module-info.class and everything inside META-INF/versions
>> (at least it's a first simple patch).

> Hi, I'm "Google", sort of. Friends tell me that dx is getting fixed.
Reply | Threaded
Open this post in threaded view
|

Re: Android and Log4j

Remi Forax
In reply to this post by Martin Buchholz-3
> De: "Martin Buchholz" <[hidden email]>
> À: "Remi Forax" <[hidden email]>
> Cc: "Ralph Goers" <[hidden email]>, "core-libs-dev"
> <[hidden email]>
> Envoyé: Mercredi 6 Décembre 2017 22:35:42
> Objet: Re: Android and Log4j

> Very latest Android Studio comes with two compilers, dx and d8.
> [ https://developer.android.com/studio/preview/features/index.html |
> https://developer.android.com/studio/preview/features/index.html ]
> I hear that both compilers know to skip module-info files.

I hope dx will die soon, i had to patch it once and i was messy, a register allocator is usually not a fun code but in case of dx, it is hidden by several layers of abstraction which made me cringe.

Rémi

> On Mon, Dec 4, 2017 at 12:03 PM, Martin Buchholz < [ mailto:[hidden email]
> | [hidden email] ] > wrote:

>> On Sun, Dec 3, 2017 at 11:02 AM, Remi Forax < [ mailto:[hidden email] |
>> [hidden email] ] > wrote:

>>> Ask Google to fix dx,
>>> dx should ignore the module-info.class and everything inside META-INF/versions
>>> (at least it's a first simple patch).

>> Hi, I'm "Google", sort of. Friends tell me that dx is getting fixed.
Reply | Threaded
Open this post in threaded view
|

Re: Android and Log4j

Martin Buchholz-3
I can neither confirm nor deny that dx is going to die, but it sure looks
like "Google" is replacing it with "D8".
https://android-developers.googleblog.com/2017/08/next-generation-dex-compiler-now-in.html

On Wed, Dec 6, 2017 at 2:03 PM, <[hidden email]> wrote:

>
>
> ------------------------------
>
> *De: *"Martin Buchholz" <[hidden email]>
> *À: *"Remi Forax" <[hidden email]>
> *Cc: *"Ralph Goers" <[hidden email]>, "core-libs-dev" <
> [hidden email]>
> *Envoyé: *Mercredi 6 Décembre 2017 22:35:42
> *Objet: *Re: Android and Log4j
>
> Very latest Android Studio comes with two compilers, dx and d8.
> https://developer.android.com/studio/preview/features/index.html
> I hear that both compilers know to skip module-info files.
>
>
> I hope dx will die soon, i had to patch it once and i was messy, a
> register allocator is usually not a fun code but in case of dx, it is
> hidden by several layers of abstraction which made me cringe.
>
> Rémi
>
>
>
> On Mon, Dec 4, 2017 at 12:03 PM, Martin Buchholz <[hidden email]>
> wrote:
>
>>
>>
>> On Sun, Dec 3, 2017 at 11:02 AM, Remi Forax <[hidden email]> wrote:
>>
>>> Ask Google to fix dx,
>>> dx should ignore the module-info.class and everything inside
>>> META-INF/versions (at least it's a first simple patch).
>>>
>>
>> Hi, I'm "Google", sort of.  Friends tell me that dx is getting fixed.
>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: Android and Log4j

Ralph Goers
In reply to this post by Martin Buchholz-3
Martin,

Do they also ignore the class files in META-INF/versions?

Ralph

> On Dec 6, 2017, at 2:35 PM, Martin Buchholz <[hidden email]> wrote:
>
> Very latest Android Studio comes with two compilers, dx and d8.
> https://developer.android.com/studio/preview/features/index.html <https://developer.android.com/studio/preview/features/index.html>
> I hear that both compilers know to skip module-info files.
>
> On Mon, Dec 4, 2017 at 12:03 PM, Martin Buchholz <[hidden email] <mailto:[hidden email]>> wrote:
>
>
> On Sun, Dec 3, 2017 at 11:02 AM, Remi Forax <[hidden email] <mailto:[hidden email]>> wrote:
> Ask Google to fix dx,
> dx should ignore the module-info.class and everything inside META-INF/versions (at least it's a first simple patch).
>
> Hi, I'm "Google", sort of.  Friends tell me that dx is getting fixed.
>
>