[ 
https://issues.apache.org/jira/browse/KARAF-6385?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jean-Baptiste Onofré updated KARAF-6385:
----------------------------------------
    Fix Version/s: 4.2.7
                   4.3.0

> WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will 
> impact performance.
> ----------------------------------------------------------------------------------------------
>
>                 Key: KARAF-6385
>                 URL: https://issues.apache.org/jira/browse/KARAF-6385
>             Project: Karaf
>          Issue Type: Bug
>          Components: karaf
>         Environment: Karaf 4.3.0 + Java 11
>            Reporter: Xtra Coder
>            Assignee: Jean-Baptiste Onofré
>            Priority: Major
>             Fix For: 4.3.0, 4.2.7
>
>
> I've tried using Karaf 4.3.0 built from sources (to fix another issue) and on 
> Java 11 now am always getting following message in console: 
> {code:java}
> WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will 
> impact performance.
> {code}
> It appears it comes from log4j (specifically [this 
> line|https://github.com/apache/logging-log4j2/blob/master/log4j-api/src/main/java/org/apache/logging/log4j/util/StackLocator.java#L78])
>  and is raised because on Java 11 reflection from Java8 does not work and 
> "org.ops4j.pax.logging" does not include java9-compatible classes most 
> probably because of [this issue|https://github.com/bndtools/bnd/issues/2227].
> This message does not appear in Karaf 4.2.6 and after some debugging I see 
> this is happening because in 4.2.6 version of "org.ops4j.pax.logging" is 
> 1.10.2 and code goes through [this 
> line|https://github.com/ops4j/org.ops4j.pax.logging/blob/paxlogging-1.10.x/pax-logging-log4j2/src/main/java/org/ops4j/pax/logging/log4j2/internal/PaxAppenderProxy.java#L61]:
>  
>  _getServices() returns null and therefore event.getLocationInformation() is 
> not invoked_
> {code:java}
>     public void doAppend( PaxLoggingEvent event )
>     {
>         if (count != getTrackingCount()) {
>             count = getTrackingCount();
>             appenders = getServices();
>         }
>         if (appenders != null && appenders.length > 0) {
>             // Bug in Karaf, as it expects the source to be available
>             event.getLocationInformation();
>             for (Object appender : appenders) {
>                 ((PaxAppender) appender).doAppend(event);
>             }
>         }
>     }
> {code}
> In "org.ops4j.pax.logging" v1.11.0 (included in 4.3.0) code goes through 
> [this 
> line|https://github.com/ops4j/org.ops4j.pax.logging/blob/master/pax-logging-api/src/main/java/org/ops4j/pax/logging/spi/support/PaxAppenderProxy.java#L67]:
>  
>  _because getServices(<empty array>) returns that same empty array, code 
> falls into 'if' with that empty array and event.getLocationInformation(); is 
> called (what throws the subject WARNING), whereas its output is not used 
> because list of appenders is empty - no event.getLocationInformation() == no 
> WARNING_
> {code:java}
>         @Override
>     public void doAppend(PaxLoggingEvent event) {
>         if (count != getTrackingCount()) {
>             count = getTrackingCount();
>             appenders = getServices(new PaxAppender[0]);
>         }
>         if (appenders != null) {
>             // Bug in Karaf, as it expects the source to be available
>             event.getLocationInformation();
>             for (PaxAppender appender : appenders) {
>                 appender.doAppend(event);
>             }
>         }
>     }
> {code}
> So ... it seems it is bug in "org.ops4j.pax.logging" v1.11.0 and it is to 
> early to include it into Karaf.
>  



--
This message was sent by Atlassian Jira
(v8.3.2#803003)

Reply via email to