On Tue, 23 Feb 2021 01:47:48 GMT, Ziyi Luo <luoz...@openjdk.org> wrote:

> All of the "isAssignableFrom" checks in "engineGetKeySpec" appear to be 
> backwards in Java's KeyFactorySpi.engineGetKeySpec implementations. In most 
> cases, the requested KeySpec is equal to the concrete implementation so the 
> inversion does not matter. But there are few cases, as presented in the added 
> jtreg test, will cause unexpected behavior (e.g., ClassCastException rather 
> than an InvalidKeySpecException). The fix is trivial.
> 
> Co-author @SalusaSecondus

The fix itself makes sense and looks good to me.  However I think it will cause 
two other tests to break.  Please try running the following two tests with your 
changes and see if they fail for you as they did for me:
open/test/jdk/sun/security/rsa/TestKeyFactory.java
open/test/jdk/sun/security/rsa/pss/TestPSSKeySupport.java

Also just a minor nit: some of the modified files should have their copyright 
dates updated to 2021.

test/jdk/java/security/KeyFactory/KeyFactoryGetKeySpecForInvalidSpec.java line 
2:

> 1: /*
> 2:  * Copyright (c) 2011, Amazon.com, Inc. or its affiliates. All rights 
> reserved.

Nit: Should this be 2021?

test/jdk/java/security/KeyFactory/KeyFactoryGetKeySpecForInvalidSpec.java line 
27:

> 25:  * @test
> 26:  * @bug 8254717
> 27:  * @summary Two users facing implications caused by "isAssignableFrom" 
> checks in "engineGetKeySpec" being backwards.

Nit: I think standard practice is to have the summary be the synopsis from 
JDK-8254717 (isAssignableFrom checks in KeyFactorySpi.engineGetKeySpec appear 
to be backwards).

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

PR: https://git.openjdk.java.net/jdk/pull/2682

Reply via email to