On Thu, 21 May 2026 14:13:19 GMT, Anthony Scarpino <[email protected]>
wrote:
>> src/java.base/share/classes/java/security/PEMDecoder.java line 326:
>>
>>> 324: * @param is {@code InputStream} containing PEM data
>>> 325: * @return a {@code BinaryEncodable}
>>> 326: * @throws IOException if an I/O error occurs or PEM syntax is
>>> invalid
>>
>> “PEMDecoder.decode(InputStream) and decode(InputStream, Class): clarify
>> which errors are reported as IllegalArgumentException vs. IOException when
>> PEM syntax is invalid, since both phrases (‘decoding fails’ and ‘PEM syntax
>> is invalid’) currently overlap.”
>>
>> For example
>>
>> @TestCase
>> @TestedStatement(source = "decode(InputStream, Class)", value =
>> "Throws: IOException - if an I/O error occurs or PEM syntax is
>> invalid")
>> public void decodeWithType_InputStream_invalidSyntax_IOEx() throws
>> IOException {
>> String invalidSyntax =
>> "-----BEGIN PUBLIC KEY-----\n" +
>> "!!!NOT-BASE64!!!\n" +
>> "-----END PUBLIC KEY-----\n";
>> try (ByteArrayInputStream bais = new
>> ByteArrayInputStream(invalidSyntax.getBytes(ISO_8859_1))) {
>> Assert.assertThrows(() -> PEMDecoder.of().decode(bais,
>> PublicKey.class), IOException.class);
>> }
>> }
>
> Legacy PEM, such as encrypted RSA PRIVATE KEY, has non-Base64 characters and
> is valid. PEM syntax is the header and footer, not the content which is used
> during decoding or stored in a PEM.class. I don't see this as overlapping.
Thanks for clarifying.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/29640#discussion_r3281879630