ritzow opened a new issue, #2449: URL: https://github.com/apache/logging-log4j2/issues/2449
## Description I believe that adding `extends java.util.function.Supplier<T>` to `log4j-api/src/main/java/org/apache/logging/log4j/util/Supplier.java` may have caused binary or source code incompatibility with code compiled with previous versions of log4j. I am getting an exception. `java.lang.AbstractMethodError: Receiver class org.opensearch.discovery.PeerFinder$Peer$1$$Lambda/0x00007f13d3743af8 does not define or inherit an implementation of the resolved method 'abstract java.lang.Object get()' of interface java.util.function.Supplier.` PeerFinder.Peer was compiled with an earlier version of log4j in which `MessageSupplier` did not inherit from `org.apache.logging.log4j.util.Supplier` and that class did not inherit from `java.util.function.Supplier`. I encountered this issue when using OpenSearch 2.13.0. Relevant commit: https://github.com/apache/logging-log4j2/commit/ffe06dd6507a64149e0e0bc3bbffaef575802fed ## Some assorted `javap` output: There's a lot more bytecode that could be inspected but I'm being lazy. The callsite in question: ``` invokedynamic #91, 0 // InvokeDynamic #3:get:(Lorg/opensearch/discovery/PeerFinder$Peer$1;)Lorg/apache/logging/log4j/util/MessageSupplier; ``` Bootstrap methods table: ``` 3: #178 REF_invokeStatic java/lang/invoke/LambdaMetafactory.metafactory:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; Method arguments: #168 ()Lorg/apache/logging/log4j/message/Message; #169 REF_invokeSpecial org/opensearch/discovery/PeerFinder$Peer$1.lambda$onFailure$0:()Lorg/apache/logging/log4j/message/Message; #168 ()Lorg/apache/logging/log4j/message/Message; ``` javap output for the latest beta 2 MessageSupplier: Notice that there is no method definition since it is now inherited from `java.util.Supplier`! That's why the metafactory can't find the `get` method! Here's the newest, offending `MessageSupplier` class. ``` Classfile /var/home/solomon/Downloads/MessageSupplier.class Last modified Feb 17, 2024; size 416 bytes SHA-256 checksum db9675cc665c17d2f99e71260492d7c9491770f1cbb0d17921c48064e3b6f4f2 Compiled from "MessageSupplier.java" public interface org.apache.logging.log4j.util.MessageSupplier extends java.util.function.Supplier<org.apache.logging.log4j.message.Message> minor version: 0 major version: 61 flags: (0x0601) ACC_PUBLIC, ACC_INTERFACE, ACC_ABSTRACT this_class: #1 // org/apache/logging/log4j/util/MessageSupplier super_class: #3 // java/lang/Object interfaces: 1, fields: 0, methods: 0, attributes: 4 Constant pool: #1 = Class #2 // org/apache/logging/log4j/util/MessageSupplier #2 = Utf8 org/apache/logging/log4j/util/MessageSupplier #3 = Class #4 // java/lang/Object #4 = Utf8 java/lang/Object #5 = Class #6 // java/util/function/Supplier #6 = Utf8 java/util/function/Supplier #7 = Utf8 Signature #8 = Utf8 Ljava/lang/Object;Ljava/util/function/Supplier<Lorg/apache/logging/log4j/message/Message;>; #9 = Utf8 SourceFile #10 = Utf8 MessageSupplier.java #11 = Utf8 Deprecated #12 = Utf8 RuntimeVisibleAnnotations #13 = Utf8 Ljava/lang/Deprecated; #14 = Utf8 forRemoval #15 = Integer 1 #16 = Utf8 since #17 = Utf8 3.0 { } Signature: #8 // Ljava/lang/Object;Ljava/util/function/Supplier<Lorg/apache/logging/log4j/message/Message;>; SourceFile: "MessageSupplier.java" Deprecated: true RuntimeVisibleAnnotations: 0: #13(#14=Z#15,#16=s#17) java.lang.Deprecated( forRemoval=true since="3.0" ) ``` Here's the previous version from log4j 2.23, notice that it has the get() method defined : ``` Classfile /var/home/solomon/Downloads/MessageSupplier.class Last modified Mar 6, 2024; size 202 bytes SHA-256 checksum c830019cc97f12778f0e0b8f7ffa9f58f2a50c2a788dd7da32c2d5edbcbe6621 Compiled from "MessageSupplier.java" public interface org.apache.logging.log4j.util.MessageSupplier minor version: 0 major version: 52 flags: (0x0601) ACC_PUBLIC, ACC_INTERFACE, ACC_ABSTRACT this_class: #1 // org/apache/logging/log4j/util/MessageSupplier super_class: #3 // java/lang/Object interfaces: 0, fields: 0, methods: 1, attributes: 1 Constant pool: #1 = Class #2 // org/apache/logging/log4j/util/MessageSupplier #2 = Utf8 org/apache/logging/log4j/util/MessageSupplier #3 = Class #4 // java/lang/Object #4 = Utf8 java/lang/Object #5 = Utf8 get #6 = Utf8 ()Lorg/apache/logging/log4j/message/Message; #7 = Utf8 SourceFile #8 = Utf8 MessageSupplier.java { public abstract org.apache.logging.log4j.message.Message get(); descriptor: ()Lorg/apache/logging/log4j/message/Message; flags: (0x0401) ACC_PUBLIC, ACC_ABSTRACT } SourceFile: "MessageSupplier.java" ``` ## Configuration **Version:** 3.0.0-beta2 **Operating system:** Linux **JDK:** Oracle Corporation/OpenJDK 64-Bit Server VM/22/22+36-2370 ## Logs ``` java.lang.AbstractMethodError: Receiver class org.opensearch.discovery.PeerFinder$Peer$1$$Lambda/0x00007f13d3743af8 does not define or inherit an implementation of the resolved method 'abstract java.lang.Object get()' of interface java.util.function.Supplier. at org.apache.logging.log4j.util.LambdaUtil.get(LambdaUtil.java:76) at org.apache.logging.log4j.spi.AbstractLogger.logMessage(AbstractLogger.java:2512) at org.apache.logging.log4j.spi.AbstractLogger.logIfEnabled(AbstractLogger.java:2246) at org.apache.logging.log4j.spi.AbstractLogger.debug(AbstractLogger.java:342) at org.opensearch.discovery.PeerFinder$Peer$1.onFailure(PeerFinder.java:443) at org.opensearch.discovery.HandshakingTransportAddressConnector$1$1.onFailure(HandshakingTransportAddressConnector.java:201) at org.opensearch.core.action.ActionListener$4.onFailure(ActionListener.java:192) at org.opensearch.action.support.ThreadedActionListener$2.doRun(ThreadedActionListener.java:93) at org.opensearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:913) at org.opensearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:52) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) at java.base/java.lang.Thread.run(Thread.java:1570) ``` ![image](https://github.com/apache/logging-log4j2/assets/11698787/cc73d9d0-a583-41db-81c6-f048ce9b0d1c) ## Reproduction I found this while trying to embed OpenSearch 2.13.0 into a java Maven project, with log4j 3.0.0-beta2. It's kind of annoying to set up, but I assume it could be done by calling the logger `debug` method with a lambda expression compiled with an earlier version of log4j. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@logging.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org