JDK-8235371 : ElementScannerN, N > 9 should scan type parameters
  • Type: CSR
  • Component: core-libs
  • Sub-Component: javax.lang.model
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 14
  • Submitted: 2019-12-05
  • Updated: 2019-12-05
  • Resolved: 2019-12-05
Related Reports
CSR :  
Description
Summary
-------
Define `ElementScanner14` to visit type parameters; surprisingly, type parameters and not visited by the previously available scanners.

Problem
-------

Surprising behavior in `javax.lang.model` utility classes. At least one scanner class with the new functionality was written as part of the `javac` implementation.

Solution
--------

Add overrides for the methods visiting executables and types to visit type parameters, if present.

Specification
-------------

    --- old/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner14.java	2019-12-04 19:16:42.857000999 -0800
    +++ new/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner14.java	2019-12-04 19:16:42.601000999 -0800
    @@ -121,6 +123,48 @@
         }
     
         /**
    +     * {@inheritDoc}
    +     *
    +     * @implSpec This implementation scans the type parameters, if
    +     * any, and then the enclosed elements.
    +     * 
    +     *
    +     * @param e  {@inheritDoc}
    +     * @param p  {@inheritDoc}
    +     * @return the result of scanning
    +     */
    +    @Override
    +    public R visitType(TypeElement e, P p) {
    +        return scan(createScanningList(e, e.getEnclosedElements()), p);
    +    }
    +
    +    /**
    +     * {@inheritDoc}
    +     *
    +     * @implSpec This implementation first scans the type parameters, if any, and then
    +     * the parameters.
    +     *
    +     * @param e  {@inheritDoc}
    +     * @param p  {@inheritDoc}
    +     * @return the result of scanning
    +     */
    +    public R visitExecutable(ExecutableElement e, P p) {
    +        return scan(createScanningList(e, e.getParameters()), p);
    +    }
    +


Comments
Moving to Approved.
05-12-2019

Adding [~mcimadamore] as a reviewer based on compiler-dev review: https://mail.openjdk.java.net/pipermail/compiler-dev/2019-December/013998.html
05-12-2019