diff --git a/jdk/src/share/classes/java/lang/ClassLoader.java b/jdk/src/share/classes/java/lang/ClassLoader.java index 9aeb53e324e..4fde2ba53a8 100644 --- a/jdk/src/share/classes/java/lang/ClassLoader.java +++ b/jdk/src/share/classes/java/lang/ClassLoader.java @@ -48,7 +48,7 @@ import java.security.cert.Certificate; import java.util.*; import java.util.concurrent.ConcurrentHashMap; - +import java.util.function.Function; /** * A class loader is an object that is responsible for loading classes. The * class ClassLoader is an abstract class. Given the new_pkg) != new_pkg) { + + Function getNewPkg = new Function() { + @Override + public java.lang.Object apply(java.lang.Object t) { + return new_pkg; + } + }; + + if (packages.computeIfAbsent(name, getNewPkg) != new_pkg) { throw new IllegalArgumentException(name); } return pkg; diff --git a/jdk/test/java/lang/invoke/lambda/LogGeneratedClassesTest.java b/jdk/test/java/lang/invoke/lambda/LogGeneratedClassesTest.java index a169a3db283..33acc50d667 100644 --- a/jdk/test/java/lang/invoke/lambda/LogGeneratedClassesTest.java +++ b/jdk/test/java/lang/invoke/lambda/LogGeneratedClassesTest.java @@ -125,8 +125,7 @@ public void testLogging() throws IOException { "-Djava.security.manager", "com.example.TestLambda"); // dump/com/example + 2 class files - // dump/java/lang + 1 class file - assertEquals(Files.walk(Paths.get("dump")).count(), 8, "Two lambda captured"); + assertEquals(Files.walk(Paths.get("dump")).count(), 5, "Two lambda captured"); tr.assertZero("Should still return 0"); } @@ -237,8 +236,7 @@ public void testLoggingException() throws IOException { .count(), 2, "show error each capture"); // dumpLong/com/example/nosense/nosense - // dumpLong/java/lang + 1 file - assertEquals(Files.walk(Paths.get("dumpLong")).count(), 8, "Two lambda captured failed to log"); + assertEquals(Files.walk(Paths.get("dumpLong")).count(), 5, "Two lambda captured failed to log"); tr.assertZero("Should still return 0"); } }