RFR: 8365288: PEMDecoder should throw ClassCastException [v4]

Weijun Wang weijun at openjdk.org
Thu Aug 28 16:38:46 UTC 2025


On Thu, 28 Aug 2025 16:20:01 GMT, Anthony Scarpino <ascarpino at openjdk.org> wrote:

>> This bug fix is to change PEMDecoder.decode(..., Class<>) using PKCS8EncodedKeySpec and X509EncodedKeySpec will throw an IllegalArgumentException when the decoded data does not match. It should be ClassCastException.
>> 
>> Thanks
>> 
>> Tony
>
> Anthony Scarpino has updated the pull request incrementally with one additional commit since the last revision:
> 
>   add EKS-related non-supported classes to CCE

Looks good. Just two small nits.

src/java.base/share/classes/java/security/PEMDecoder.java line 440:

> 438:                         .getKeySpec(key, X509EncodedKeySpec.class);
> 439:                 } else {
> 440:                     throw new ClassCastException("Invalid KeySpec.");

No need for a period at the end of exception message.

src/java.base/share/classes/java/security/PEMDecoder.java line 444:

> 442:             } catch (InvalidKeySpecException e) {
> 443:                 throw new ClassCastException("Invalid KeySpec " +
> 444:                     "specified: " + tClass.getName() +" for key " +

Add a space after `+`.

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

PR Review: https://git.openjdk.org/jdk/pull/26734#pullrequestreview-3165649491
PR Review Comment: https://git.openjdk.org/jdk/pull/26734#discussion_r2307951072
PR Review Comment: https://git.openjdk.org/jdk/pull/26734#discussion_r2307952775


More information about the security-dev mailing list