Feature into 'preview' features; the mapping is completely ad-hoc, so as to allow
for maximum flexibility, which allows to migrate preview feature into supported features with ease.
This class acts as a centralized point against which usages of preview features are reported by
clients (e.g. other javac classes). Internally, this class collects all such usages and generates
diagnostics to inform the user of such usages. Such diagnostics can be enabled using the
LintCategory#PREVIEW lint category, and are suppressible by usual means.
| Modifier and Type | Field and Description |
|---|---|
| private final boolean | enabled
flag: are preview features enabled |
| private final boolean | forcePreview
test flag: should all features be considered as preview features? |
| private final Log | |
| private final Map | majorVersionToSource
a mapping from classfile numbers to Java SE versions |
| private final Names | |
| protected static final Context. | |
| private final Source | |
| private final Set |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public boolean | Returns: true iff sym has been declared using a preview language featureSymbol to check sym)Check whether the given symbol has been declared using a preview language feature. |
| public JCDiagnostic. | Returns: the diagnostic.the feature for which the diagnostic has to be generated. featureGenerate an error key which captures the fact that a given preview feature could not be used due to the preview feature support being disabled. |
| public JCDiagnostic. | disabledError(JavaFileObject
the name of the classfile with preview features enabled classfile, int the major version found in the classfile. majorVersion)Generate an error key which captures the fact that a preview classfile cannot be loaded due to the preview feature support being disabled. |
| private Map | |
| public static Preview | |
| public boolean | |
| public boolean | |
| public void | markUsesPreview(JCDiagnostic.
the position at which the preview feature was used. posMark the current source file as using a preview feature. |
| public boolean | Returns: true ifs is participating in the preview of previewSymbolthe symbol table syms, Symbol the symbol depending on the preview symbol s, Symbol the preview symbol marked with @Preview previewSymbol)Returns true if |
| public boolean | Returns: true ifm is participating in the preview of previewSymbolthe symbol table syms, Symbol.the module to check mReturns true if module |
| public boolean | |
| public void | warnPreview(JCDiagnostic.
a flag to set on the diagnostic flag,the position at which the preview feature was used. pos, Source.the preview feature used. featureReport usage of a preview feature. |
| public void | warnPreview(JCDiagnostic.
a flag to set on the diagnostic flag,the position at which the preview feature was used. pos,the preview feature used. featureReport usage of a preview feature. |
| public void | warnPreview(JavaFileObject
the name of the classfile with preview features enabled classfile, int the major version found in the classfile. majorVersion)Report usage of a preview feature in classfile. |
| enabled | back to summary |
|---|---|
| private final boolean enabled flag: are preview features enabled | |
| forcePreview | back to summary |
|---|---|
| private final boolean forcePreview test flag: should all features be considered as preview features? | |
| log | back to summary |
|---|---|
| private final Log log | |
| majorVersionToSource | back to summary |
|---|---|
| private final Map<Integer, Source> majorVersionToSource a mapping from classfile numbers to Java SE versions | |
| names | back to summary |
|---|---|
| private final Names names | |
| previewKey | back to summary |
|---|---|
| protected static final Context. | |
| source | back to summary |
|---|---|
| private final Source source | |
| sourcesWithPreviewFeatures | back to summary |
|---|---|
| private final Set<JavaFileObject> sourcesWithPreviewFeatures | |
| Preview | back to summary |
|---|---|
protected Preview(Context context)
| |
| checkSourceLevel | back to summary |
|---|---|
| public void checkSourceLevel(JCDiagnostic. | |
| declaredUsingPreviewFeature | back to summary |
|---|---|
| public boolean declaredUsingPreviewFeature(Symbol sym) Check whether the given symbol has been declared using a preview language feature.
| |
| disabledError | back to summary |
|---|---|
| public JCDiagnostic. Generate an error key which captures the fact that a given preview feature could not be used due to the preview feature support being disabled.
| |
| disabledError | back to summary |
|---|---|
| public JCDiagnostic. Generate an error key which captures the fact that a preview classfile cannot be loaded due to the preview feature support being disabled.
| |
| initMajorVersionToSourceMap | back to summary |
|---|---|
| private Map | |
| instance | back to summary |
|---|---|
| public static Preview instance(Context context) | |
| isEnabled | back to summary |
|---|---|
| public boolean isEnabled() Are preview features enabled?
| |
| isPreview | back to summary |
|---|---|
| public boolean isPreview(Source. Is given feature a preview feature? | |
| markUsesPreview | back to summary |
|---|---|
| public void markUsesPreview(JCDiagnostic. Mark the current source file as using a preview feature. The corresponding classfile
will be generated with minor version
| |
| participatesInPreview | back to summary |
|---|---|
| public boolean participatesInPreview(Symtab syms, Symbol s, Symbol previewSymbol) Returns true if | |
| participatesInPreview | back to summary |
|---|---|
| public boolean participatesInPreview(Symtab syms, Symbol. Returns true if module
| |
| usesPreview | back to summary |
|---|---|
| public boolean usesPreview(JavaFileObject file) | |
| warnPreview | back to summary |
|---|---|
| public void warnPreview(JCDiagnostic. Report usage of a preview feature. Usages reported through this method will affect the set of sourcefiles with dependencies on preview features.
| |
| warnPreview | back to summary |
|---|---|
| public void warnPreview(JCDiagnostic. Report usage of a preview feature. Usages reported through this method will affect the set of sourcefiles with dependencies on preview features.
| |
| warnPreview | back to summary |
|---|---|
| public void warnPreview(JavaFileObject classfile, int majorVersion) Report usage of a preview feature in classfile.
| |