JDK-8222424 : Provide mechanism to query preview feature status for annotation processors
  • Type: CSR
  • Component: core-libs
  • Sub-Component: javax.annotation.processing
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 13
  • Submitted: 2019-04-12
  • Updated: 2019-05-16
  • Resolved: 2019-04-12
Related Reports
CSR :  
Description
Summary
-------

Provide a method on `ProcessingEnvironment` to allow the whether or not preview features are enabled to be determined.

Problem
-------

When generating code, a sophisticated annotation processor could benefit from knowing whether or not preview language feature are available.

Solution
--------

Provide a predicated on `ProcessingEnvironment` to return whether or not preview features are enabled.

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

    +    /**
    +     * Returns {@code true} if <em>preview features</em> are enabled
    +     * and {@code false} otherwise.
    +     * @return whether or not preview features are enabled
    +     *
    +     * @implSpec The default implementation of this method returns
    +     * {@code false}.
    +     *
    +     * @since 13
    +     */
    +    default boolean isPreviewEnabled() {
    +        return false;
    +    }


Comments
Thanks for the typo corrections in the review Jon. Moving to Approved.
12-04-2019