On Fri, 11 Oct 2024 11:46:40 GMT, Eirik Bjørsnøs <eir...@openjdk.org> wrote:

> Please review this PR which adds test coverage for the case where 
> `URLClassLoader.defineClass` fails with a `ClassFormatError` _and_ the CRC32 
> checksum of the class file byte array did not match the CRC32 value stated in 
> the JAR file's CEN header.
> 
> In such cases, an `IOException` with the message _"CRC error while extracting 
> entry from JAR file"_ is added as a suppressed exception to the 
> `ClassFormatError`.
> 
> Adding a test documents this unspecified, but long-standing behavior.
> 
> For good measure, the test also covers the existing behavior of the module 
> system class loader. Since the module system does not add similar suppressed 
> exception on a CRC32 mismatch, this test mostly serves the purpose of 
> documentation. 
> 
> The test is parameterized, as such it covers all eight combinations of 
> {URLClassLoader/module class loader, valid/invalid class data, valid/invalid 
> CRC checksum}.
> 
> Should any of the class loaders change behavior in the future (with or 
> without intent), this test will notice and may need to be updated to document 
> the new behavior. Otherwise, it will catch unintended regressions.
> 
> Testing: This is a test-only enhancement PR, no existing tests are updated.

This pull request has been closed without being integrated.

-------------

PR: https://git.openjdk.org/jdk/pull/21469

Reply via email to