Enum Class JavaFeature

java.lang.Object
java.lang.Enum<JavaFeature>
org.aspectj.org.eclipse.jdt.internal.compiler.impl.JavaFeature
All Implemented Interfaces:
Serializable, Comparable<JavaFeature>, java.lang.constant.Constable

public enum JavaFeature extends Enum<JavaFeature>
An internal enumeration of all Java language features that were introduced as standard feature or preview feature from Java 15. The idea is to have one location where the applicability of a feature, such as version supported in, whether or not a preview, what are the restricted keywords introduced by a feature etc. This is expected to be updated every time there's a new Java version and the change is expected to be one of the following kinds:
  • The preview feature continues to be a preview in the next version
  • The preview feature is upgraded to a standard feature
  • The preview feature is removed
Author:
jay
  • Enum Constant Details

    • SWITCH_EXPRESSIONS

      public static final JavaFeature SWITCH_EXPRESSIONS
    • TEXT_BLOCKS

      public static final JavaFeature TEXT_BLOCKS
    • PATTERN_MATCHING_IN_INSTANCEOF

      public static final JavaFeature PATTERN_MATCHING_IN_INSTANCEOF
    • RECORDS

      public static final JavaFeature RECORDS
    • SEALED_CLASSES

      public static final JavaFeature SEALED_CLASSES
    • PATTERN_MATCHING_IN_SWITCH

      public static final JavaFeature PATTERN_MATCHING_IN_SWITCH
    • RECORD_PATTERNS

      public static final JavaFeature RECORD_PATTERNS
    • UNNAMMED_PATTERNS_AND_VARS

      public static final JavaFeature UNNAMMED_PATTERNS_AND_VARS
    • IMPLICIT_CLASSES_AND_INSTANCE_MAIN_METHODS

      public static final JavaFeature IMPLICIT_CLASSES_AND_INSTANCE_MAIN_METHODS
    • FLEXIBLE_CONSTRUCTOR_BODIES

      public static final JavaFeature FLEXIBLE_CONSTRUCTOR_BODIES
      JEP 482. Some locations only check if compliance is sufficient to use this feature, to leave checking for actual enablement for later. This is done so we can report that a preview feature could potentially kick in even when it is disabled.
      Initial check in ConstructorDeclaration.resolveStatements();
      At 23 we always call enterEarlyConstructionContext() to enable many downstream analyses.
      Check actual support only when a "late constructor" has been found.
      Similar for analyseCode() and generateCode().
      Differentiate error messages based on enablement:
      • AllocationExpression.checkEarlyConstructionContext()
      • ExplicitConstructorCall.resolve(BlockScope)
      • ThisReference.checkAccess(BlockScope, ReferenceBinding)
      Main checks during resolve: Reference.checkFieldAccessInEarlyConstructionContext()
      applies all strategy variants from above
      Individual exceptions from old rules
      • MethodScope.findField()
      • Scope.getBinding(char[], int, InvocationSite, boolean)
      Main code gen change in TypeDeclaration.manageEnclosingInstanceAccessIfNecessary()
      Only if feature is actually supported, we will generate special synthetic args and fields
      Uses some feature-specific help from BlockScope.getEmulationPath()
    • PRIMITIVES_IN_PATTERNS

      public static final JavaFeature PRIMITIVES_IN_PATTERNS
    • MODULE_IMPORTS

      public static final JavaFeature MODULE_IMPORTS
    • MARKDOWN_COMMENTS

      public static final JavaFeature MARKDOWN_COMMENTS
  • Method Details

    • values

      public static JavaFeature[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static JavaFeature valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • isPreview

      public boolean isPreview()
    • getName

      public String getName()
    • getCompliance

      public long getCompliance()
    • getRestrictedKeywords

      public char[][] getRestrictedKeywords()
    • isSupported

      public boolean isSupported(CompilerOptions options)
    • isSupported

      public boolean isSupported(long comp, boolean preview)
    • isSupported

      public boolean isSupported(String comp, boolean preview)
    • matchesCompliance

      public boolean matchesCompliance(CompilerOptions options)