From 73dbd131c166368b9ceb7b96f1b4073afbaef7d8 Mon Sep 17 00:00:00 2001 From: Rafael Winterhalter Date: Tue, 24 Sep 2024 00:10:12 +0200 Subject: [PATCH] Avoid use of modern Java API. --- .../src/main/java/net/bytebuddy/build/Plugin.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/byte-buddy-dep/src/main/java/net/bytebuddy/build/Plugin.java b/byte-buddy-dep/src/main/java/net/bytebuddy/build/Plugin.java index bba932badf..3cda1fc6e1 100644 --- a/byte-buddy-dep/src/main/java/net/bytebuddy/build/Plugin.java +++ b/byte-buddy-dep/src/main/java/net/bytebuddy/build/Plugin.java @@ -3426,7 +3426,8 @@ public void close() { } /** - * A sink that stores all elements in a memory map. + * A sink that stores all elements in a memory map. In case of multi-release jars, this memory + * storage aims to retain the non-versioned class file. */ @HashCodeAndEqualsPlugin.Enhance class InMemory implements Target, Sink { @@ -3482,7 +3483,10 @@ public void store(Map binaryRepresentations) { */ public void store(int version, Map binaryRepresentations) throws IOException { for (Map.Entry entry : binaryRepresentations.entrySet()) { - storage.putIfAbsent(entry.getKey().getInternalName() + CLASS_FILE_EXTENSION, entry.getValue()); + String name = entry.getKey().getInternalName() + CLASS_FILE_EXTENSION; + if (!storage.containsKey(name)) { + storage.put(name, entry.getValue()); + } } }