On Fri, 6 Mar 2026 14:13:01 GMT, Sean Mullan <[email protected]> wrote:

>> @seanjmullan I've filed one, let me know if this is what you were looking 
>> for.  Thank you.
>
> I also recommend updating the `@throws InvalidKeyException` to state that it 
> is also thrown if the offset is negative. For example:
> 
> "if offset is negative, or the given key material is <code>null</code>, or 
> starting at <code>offset</code> inclusive, is shorter than 8 bytes."
> 
> Arguably, throwing `IllegalArgumentException` is more appropriate, but I 
> think that would have a higher compatibility risk since it would be a new 
> exception thrown (even though DES/DESede really shouldn't be used much 
> anymore).

Actually, on second thought, these methods already throw 
`ArrayIndexOutOfBoundsException` when the offset is negative, right?

Therefore I think it is better to throw that instead of `InvalidKeyException` 
and add that to the javadoc. This would also align it with `SecretKeySpec` 
which throws AIOBE for negative offsets. This is the existing behavior of this 
class so the compatibility risk should be low.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/30069#discussion_r2896028729

Reply via email to