JDK-8193367 : annotated type variables bounds crash javac
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 9,10
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2017-12-12
  • Updated: 2022-01-11
  • Resolved: 2019-01-26
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11
11.0.9-oracleFixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Description
The following code crashes the compiler:

import java.lang.annotation.ElementType;
import java.lang.annotation.Target;

class TestAnno {

    @Target(value = {ElementType.TYPE_USE})
    @interface A{}

    class Sup<X, Y> { }

    class Sub<U extends @A V, @A V extends String> extends Sup<U, V> { }
}

This is a reduced test case obtained from this:
https://github.com/wildfly/typeannotation-test/blob/master/src/main/java/test/VExample.java#L117
Comments
URL: https://hg.openjdk.java.net/jdk-updates/jdk11u/rev/796a0f3db99b User: clanger Date: 2020-07-29 08:06:34 +0000
29-07-2020

Fix request (11u) -- will label after testing completed. I would like to downport this for parity with 11.0.9-oracle. I had to do some simple adaptions: http://mail.openjdk.java.net/pipermail/jdk-updates-dev/2020-July/003524.html
19-07-2020

URL: http://hg.openjdk.java.net/jdk/jdk/rev/a772e65727c5 User: bsrbnd Date: 2019-01-26 15:01:30 +0000
26-01-2019

Approvals: http://mail.openjdk.java.net/pipermail/compiler-dev/2019-January/012903.html http://mail.openjdk.java.net/pipermail/compiler-dev/2019-January/012904.html
26-01-2019

Partial review (would need some consolidation): http://mail.openjdk.java.net/pipermail/compiler-dev/2018-June/012042.html
20-09-2018

The problem is that when attribution set the bounds of a type variable, it does so on the unannotated tvar - that means that annotated references to that same tvar will have the bound field unset, and, as such will end up crashing when the method Types.getBound is called on them. Types.getBound should probably go back to the unannotated type. Or, we could restrict access to the 'bound' field, and virtualize access in the cloned type var.
12-12-2017