Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Why did the Class Name of the Lambda class change starting from JDK21?

linghengqianAug 18 2024
import org.junit.jupiter.api.Test;

public class LambdaTest {
    @Test
    void test() {
        Runnable runnable = () -> System.out.println("Aloha World!");
        System.out.println(runnable.getClass().getName());
    }
}
  • But starting from JDK21, this unit test prints `org.apache.shardingsphere.elasticjob.kernel.internal.setup.LambdaTest$$Lambda/0x00007f04bc0ad7d8`.
  • One difference this makes is that I can no longer use `$$Lambda$` to match it.
  • I can only see similar changes on the GraalVM side at https://github.com/oracle/graal/pull/7775 , but there is no indication of which JEP this was introduced in. Is there any direct JDK21 documentation that explains this change?
This post has been answered by dvohra21 on Sep 1 2024
Jump to Answer
Comments
Post Details
Added on Aug 18 2024
3 comments
119 views