jdk
8c4901f9 - 8349545: ClassLoader.definePackage() throws IllegalArgumentException if package already defined

Commit
11 hours ago
8349545: ClassLoader.definePackage() throws IllegalArgumentException if package already defined Concurent calls to `ClassLoader.definePackage()` can yield `IllegalArgumentException`s if the package is already defined. Some built-in class loaders, like `URLClassLoader`, already handle this case, but custom class loaders (would) have to handle this case. This change updates the logic of `CL.definePackage` to not throw an IAE if the "redefined" package is equal to the already defined one. To enable this, `NamedPackage`, `Package` and `Package$VersionInfo` implement `hashCode`+`equals`, with the special handling to not involve a `URLStreamHandler` when comparing `VersionInfo.sealBase`. Tests added in `jdk/java/lang/Package/PackageDefineTest.java` (+ pulling up the `TestClassLoader` from `PackageDefineTest`).
Author
Committer
Parents
Loading