Enum Class JavaFeature
- All Implemented Interfaces:
Serializable,Comparable<JavaFeature>,java.lang.constant.Constable
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
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionJEP 482. -
Method Summary
Modifier and TypeMethodDescriptionlonggetName()char[][]booleanbooleanisSupported(long comp, boolean preview) booleanisSupported(String comp, boolean preview) booleanisSupported(CompilerOptions options) booleanmatchesCompliance(CompilerOptions options) static JavaFeatureReturns the enum constant of this class with the specified name.static JavaFeature[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
SWITCH_EXPRESSIONS
-
TEXT_BLOCKS
-
PATTERN_MATCHING_IN_INSTANCEOF
-
RECORDS
-
SEALED_CLASSES
-
PATTERN_MATCHING_IN_SWITCH
-
RECORD_PATTERNS
-
UNNAMMED_PATTERNS_AND_VARS
-
IMPLICIT_CLASSES_AND_INSTANCE_MAIN_METHODS
-
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
-
MODULE_IMPORTS
-
MARKDOWN_COMMENTS
-
-
Method Details
-
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
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 nameNullPointerException- if the argument is null
-
isPreview
public boolean isPreview() -
getName
-
getCompliance
public long getCompliance() -
getRestrictedKeywords
public char[][] getRestrictedKeywords() -
isSupported
-
isSupported
public boolean isSupported(long comp, boolean preview) -
isSupported
-
matchesCompliance
-