[lworld] RFR: JDK 8251107 [lworld] test lworld-values/TopInterfaceNegativeTest.java needs scrubbing

Srikanth Adayapalam sadayapalam at openjdk.java.net
Wed Aug 5 05:15:26 UTC 2020


On Wed, 5 Aug 2020 05:08:27 GMT, Srikanth Adayapalam <sadayapalam at openjdk.org> wrote:

>> Test was somewhat out of date and still using InlineObject.
>
> I think the test still using the withdrawn InlineObject is a red herring. The golden files account for this already and
> capture suitable errors for those uses of the non-existent interface.
> The real trouble is due to an error NOT being emitted in line 33 of the TopInterfaceNegativeTest.java:
> 
> Given:
> 
> static inline class V2 implements InlineObject {}
> 
> void foo(V2 v) {
>         if (v instanceof IdentityObject)  // line 33
>             throw new AssertionError("Expected inline object but found identity object");
>     }
> 
> v instanceof IdentityObject is patently false and can be ascertained at compile time to be patently false thereby
> resulting an error message:
> TopInterfaceNegativeTest.java:33:13: compiler.err.prob.found.req: (compiler.misc.inconvertible.types:
> TopInterfaceNegativeTest.V2, java.lang.IdentityObject)
> Given 'v' is type V2 and that is a final class, we known all the interfaces implemented by v and so can evaluate at
> compile time whether the instanceof is patently bogus -
> Now with the change for sealing of projections, this error is not emitted anymore and that is the reason for the
> failure.
> The error is valid and should be restored.

Here is a smaller test case: without the change for sealing this elicits an error

public inline class X {
    boolean b = new X() instanceof IdentityObject;
}

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

PR: https://git.openjdk.java.net/valhalla/pull/135



More information about the valhalla-dev mailing list