qos-ch / slf4j

Simple Logging Facade for Java
http://www.slf4j.org
MIT License
2.35k stars 990 forks source link

JDK 18 version sanity check raising AbstractMethodError #303

Open Hc747 opened 2 years ago

Hc747 commented 2 years ago

Account for java.lang.AbstractMethodError in same clause of try-catch construct when performing version sanity check.

I.e.

Unexpected problem occured during version sanity check
Reported exception:
java.lang.AbstractMethodError: Receiver class org.apache.logging.slf4j.SLF4JServiceProvider does not define or inherit an implementation of the resolved method 'abstract java.lang.String getRequestedApiVersion()' of interface org.slf4j.spi.SLF4JServiceProvider.
    at org.slf4j.LoggerFactory.versionSanityCheck(LoggerFactory.java:297)
    at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:141)
    at org.slf4j.LoggerFactory.getProvider(LoggerFactory.java:421)
    at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:407)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:356)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:382)
    at io.micronaut.runtime.Micronaut.<clinit>(Micronaut.java:50)
hazendaz commented 2 years ago

@Hc747 What slf4j are you using?

ceki commented 2 years ago

How is this related to JDK 18? I do not think it is.

Which logging back-end are you using? Is it log4j 2.18 or earlier?

Hc747 commented 2 years ago

@Hc747 What slf4j are you using?

My configuration is as follows:

Oracle OpenJDK 18.0.2.1+1-1
slf4j_version=2.0.0
log4j2_version=2.18.0
api "org.slf4j:slf4j-api:$slf4j_version"
api "org.apache.logging.log4j:log4j-api:$log4j2_version"
implementation "org.apache.logging.log4j:log4j-slf4j18-impl:$log4j2_version"
implementation "org.apache.logging.log4j:log4j-core:$log4j2_version"
Hc747 commented 2 years ago

How is this related to JDK 18? I do not think it is.

Which logging back-end are you using? Is it log4j 2.18 or earlier?

Might be related to JDK 18 as the invocation throws an AbstractMethodError rather than a NoSuchFieldError - not sure if this behaviour was changed in JDK 18, but it clearly deviates from the expected behaviour, as we arrive in the component of the try-catch clause that catches all exceptions.

ceki commented 2 years ago

I think this issue is related to log4j2 version 2.18.0 which does not yet fully support SLF4J 2.0.

See also LOG4J2-3370