Skip to content

Commit

Permalink
8173605: Remove support for source and target 1.7 option in javac
Browse files Browse the repository at this point in the history
Reviewed-by: vromero
  • Loading branch information
jddarcy committed Sep 1, 2022
1 parent 7c2f299 commit 2d18dda
Show file tree
Hide file tree
Showing 156 changed files with 182 additions and 4,570 deletions.
Expand Up @@ -163,7 +163,7 @@ private Source(String name) {
this.name = name;
}

public static final Source MIN = Source.JDK7;
public static final Source MIN = Source.JDK8;

private static final Source MAX = values()[values().length - 1];

Expand Down Expand Up @@ -207,26 +207,15 @@ public Target requiredTarget() {
*/
public enum Feature {

DIAMOND(JDK7, Fragments.FeatureDiamond, DiagKind.NORMAL),
DIAMOND(MIN, Fragments.FeatureDiamond, DiagKind.NORMAL), // Used in Analyzer
MODULES(JDK9, Fragments.FeatureModules, DiagKind.PLURAL),
EFFECTIVELY_FINAL_VARIABLES_IN_TRY_WITH_RESOURCES(JDK9, Fragments.FeatureVarInTryWithResources, DiagKind.PLURAL),
DEPRECATION_ON_IMPORT(MIN, JDK8),
POLY(JDK8),
LAMBDA(JDK8, Fragments.FeatureLambda, DiagKind.PLURAL),
METHOD_REFERENCES(JDK8, Fragments.FeatureMethodReferences, DiagKind.PLURAL),
DEFAULT_METHODS(JDK8, Fragments.FeatureDefaultMethods, DiagKind.PLURAL),
STATIC_INTERFACE_METHODS(JDK8, Fragments.FeatureStaticIntfMethods, DiagKind.PLURAL),
STATIC_INTERFACE_METHODS_INVOKE(JDK8, Fragments.FeatureStaticIntfMethodInvoke, DiagKind.PLURAL),
STRICT_METHOD_CLASH_CHECK(JDK8),
EFFECTIVELY_FINAL_IN_INNER_CLASSES(JDK8),
TYPE_ANNOTATIONS(JDK8, Fragments.FeatureTypeAnnotations, DiagKind.PLURAL),
ANNOTATIONS_AFTER_TYPE_PARAMS(JDK8, Fragments.FeatureAnnotationsAfterTypeParams, DiagKind.PLURAL),
REPEATED_ANNOTATIONS(JDK8, Fragments.FeatureRepeatableAnnotations, DiagKind.PLURAL),
INTERSECTION_TYPES_IN_CAST(JDK8, Fragments.FeatureIntersectionTypesInCast, DiagKind.PLURAL),
GRAPH_INFERENCE(JDK8),
FUNCTIONAL_INTERFACE_MOST_SPECIFIC(JDK8),
POST_APPLICABILITY_VARARGS_ACCESS_CHECK(JDK8),
MAP_CAPTURES_TO_BOUNDS(MIN, JDK7),
GRAPH_INFERENCE(JDK8), // Used in Analyzer
PRIVATE_SAFE_VARARGS(JDK9),
DIAMOND_WITH_ANONYMOUS_CLASS_CREATION(JDK9, Fragments.FeatureDiamondAndAnonClass, DiagKind.NORMAL),
UNDERSCORE_IDENTIFIER(MIN, JDK8),
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -2125,21 +2125,6 @@ public void setBounds(InferenceBound ib, List<Type> newBounds) {

/** add a bound of a given kind - this might trigger listener notification */
public final void addBound(InferenceBound ib, Type bound, Types types) {
// Per JDK-8075793: in pre-8 sources, follow legacy javac behavior
// when capture variables are inferred as bounds: for lower bounds,
// map to the capture variable's upper bound; for upper bounds,
// if the capture variable has a lower bound, map to that type
if (types.mapCapturesToBounds) {
switch (ib) {
case LOWER:
bound = types.cvarUpperBound(bound);
break;
case UPPER:
Type altBound = types.cvarLowerBound(bound);
if (!altBound.hasTag(TypeTag.BOT)) bound = altBound;
break;
}
}
addBound(ib, bound, types, false);
}

Expand Down
Expand Up @@ -92,8 +92,6 @@ public class Types {
final Symtab syms;
final JavacMessages messages;
final Names names;
final boolean allowDefaultMethods;
final boolean mapCapturesToBounds;
final Check chk;
final Enter enter;
JCDiagnostic.Factory diags;
Expand All @@ -115,8 +113,6 @@ protected Types(Context context) {
syms = Symtab.instance(context);
names = Names.instance(context);
Source source = Source.instance(context);
allowDefaultMethods = Feature.DEFAULT_METHODS.allowedInSource(source);
mapCapturesToBounds = Feature.MAP_CAPTURES_TO_BOUNDS.allowedInSource(source);
chk = Check.instance(context);
enter = Enter.instance(context);
capturedName = names.fromString("<captured wildcard>");
Expand Down Expand Up @@ -3126,11 +3122,9 @@ private MethodSymbol firstUnimplementedAbstractImpl(ClassSymbol impl, ClassSymbo
MethodSymbol implmeth = absmeth.implementation(impl, this, true);
if (implmeth == null || implmeth == absmeth) {
//look for default implementations
if (allowDefaultMethods) {
MethodSymbol prov = interfaceCandidates(impl.type, absmeth).head;
if (prov != null && prov.overrides(absmeth, impl, this, true)) {
implmeth = prov;
}
MethodSymbol prov = interfaceCandidates(impl.type, absmeth).head;
if (prov != null && prov.overrides(absmeth, impl, this, true)) {
implmeth = prov;
}
}
if (implmeth == null || implmeth == absmeth) {
Expand Down
Expand Up @@ -101,7 +101,6 @@ public static Annotate instance(Context context) {
private final Types types;

private final Attribute theUnfinishedDefaultValue;
private final boolean allowRepeatedAnnos;
private final String sourceName;

protected Annotate(Context context) {
Expand All @@ -124,7 +123,6 @@ protected Annotate(Context context) {
theUnfinishedDefaultValue = new Attribute.Error(syms.errType);

Source source = Source.instance(context);
allowRepeatedAnnos = Feature.REPEATED_ANNOTATIONS.allowedInSource(source);
sourceName = source.name;

blockCount = 1;
Expand Down Expand Up @@ -347,9 +345,6 @@ private <T extends Attribute.Compound> void annotateNow(Symbol toAnnotate,

if (a.type.isErroneous() || a.type.tsym.isAnnotationType()) {
if (annotated.containsKey(a.type.tsym)) {
if (!allowRepeatedAnnos) {
log.error(DiagnosticFlag.SOURCE_LEVEL, a.pos(), Feature.REPEATED_ANNOTATIONS.error(sourceName));
}
ListBuffer<T> l = annotated.get(a.type.tsym);
l = l.append(c);
annotated.put(a.type.tsym, l);
Expand Down
33 changes: 5 additions & 28 deletions src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
Expand Up @@ -167,10 +167,7 @@ protected Attr(Context context) {

Source source = Source.instance(context);
allowPoly = Feature.POLY.allowedInSource(source);
allowTypeAnnos = Feature.TYPE_ANNOTATIONS.allowedInSource(source);
allowLambda = Feature.LAMBDA.allowedInSource(source);
allowDefaultMethods = Feature.DEFAULT_METHODS.allowedInSource(source);
allowStaticInterfaceMethods = Feature.STATIC_INTERFACE_METHODS.allowedInSource(source);
allowReifiableTypesInInstanceof = Feature.REIFIABLE_TYPES_INSTANCEOF.allowedInSource(source);
allowRecords = Feature.RECORDS.allowedInSource(source);
allowPatternSwitch = (preview.isEnabled() || !preview.isPreview(Feature.PATTERN_SWITCH)) &&
Expand All @@ -193,22 +190,10 @@ protected Attr(Context context) {
*/
boolean allowPoly;

/** Switch: support type annotations.
*/
boolean allowTypeAnnos;

/** Switch: support lambda expressions ?
*/
boolean allowLambda;

/** Switch: support default methods ?
*/
boolean allowDefaultMethods;

/** Switch: static interface methods enabled?
*/
boolean allowStaticInterfaceMethods;

/** Switch: reifiable types in instanceof enabled?
*/
boolean allowReifiableTypesInInstanceof;
Expand Down Expand Up @@ -4462,10 +4447,6 @@ public void visitSelect(JCFieldAccess tree) {
tree.pos(), site, sym.name, true);
}
}
if (!allowStaticInterfaceMethods && sitesym.isInterface() &&
sym.isStatic() && sym.kind == MTH) {
log.error(DiagnosticFlag.SOURCE_LEVEL, tree.pos(), Feature.STATIC_INTERFACE_METHODS_INVOKE.error(sourceName));
}
} else if (sym.kind != ERR &&
(sym.flags() & STATIC) != 0 &&
sym.name != names._class) {
Expand Down Expand Up @@ -5571,9 +5552,7 @@ private void attribClassBody(Env<AttrContext> env, ClassSymbol c) {
// are compatible (i.e. no two define methods with same arguments
// yet different return types). (JLS 8.4.8.3)
chk.checkCompatibleSupertypes(tree.pos(), c.type);
if (allowDefaultMethods) {
chk.checkDefaultMethodClashes(tree.pos(), c.type);
}
chk.checkDefaultMethodClashes(tree.pos(), c.type);
}

// Check that class does not import the same parameterized interface
Expand Down Expand Up @@ -5629,13 +5608,11 @@ private void attribClassBody(Env<AttrContext> env, ClassSymbol c) {
&& !c.isAnonymous()) {
chk.checkSerialStructure(tree, c);
}
if (allowTypeAnnos) {
// Correctly organize the positions of the type annotations
typeAnnotations.organizeTypeAnnotationsBodies(tree);
// Correctly organize the positions of the type annotations
typeAnnotations.organizeTypeAnnotationsBodies(tree);

// Check type annotations applicability rules
validateTypeAnnotations(tree, false);
}
// Check type annotations applicability rules
validateTypeAnnotations(tree, false);
}
// where
/** get a diagnostic position for an attribute of Type t, or null if attribute missing */
Expand Down
Expand Up @@ -2724,7 +2724,6 @@ public boolean test(Symbol s) {
void checkPotentiallyAmbiguousOverloads(DiagnosticPosition pos, Type site,
MethodSymbol msym1, MethodSymbol msym2) {
if (msym1 != msym2 &&
Feature.DEFAULT_METHODS.allowedInSource(source) &&
lint.isEnabled(LintCategory.OVERLOADS) &&
(msym1.flags() & POTENTIALLY_AMBIGUOUS) == 0 &&
(msym2.flags() & POTENTIALLY_AMBIGUOUS) == 0) {
Expand Down
17 changes: 0 additions & 17 deletions src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java
Expand Up @@ -210,7 +210,6 @@ public class Flow {
private final JCDiagnostic.Factory diags;
private Env<AttrContext> attrEnv;
private Lint lint;
private final boolean allowEffectivelyFinalInInnerClasses;

public static Flow instance(Context context) {
Flow instance = context.get(flowKey);
Expand Down Expand Up @@ -335,7 +334,6 @@ protected Flow(Context context) {
rs = Resolve.instance(context);
diags = JCDiagnostic.Factory.instance(context);
Source source = Source.instance(context);
allowEffectivelyFinalInInnerClasses = Feature.EFFECTIVELY_FINAL_IN_INNER_CLASSES.allowedInSource(source);
}

/**
Expand Down Expand Up @@ -3073,12 +3071,6 @@ void checkEffectivelyFinal(DiagnosticPosition pos, VarSymbol sym) {
sym.pos < currentTree.getStartPosition()) {
switch (currentTree.getTag()) {
case CLASSDEF:
if (!allowEffectivelyFinalInInnerClasses) {
if ((sym.flags() & FINAL) == 0) {
reportInnerClsNeedsFinalError(pos, sym);
}
break;
}
case PATTERNCASELABEL:
case LAMBDA:
if ((sym.flags() & (EFFECTIVELY_FINAL | FINAL)) == 0) {
Expand All @@ -3099,10 +3091,6 @@ void letInit(JCTree tree) {
((VarSymbol)sym).pos < currentTree.getStartPosition()) {
switch (currentTree.getTag()) {
case CLASSDEF:
if (!allowEffectivelyFinalInInnerClasses) {
reportInnerClsNeedsFinalError(tree, sym);
break;
}
case CASE:
case LAMBDA:
reportEffectivelyFinalError(tree, sym);
Expand All @@ -3121,11 +3109,6 @@ void reportEffectivelyFinalError(DiagnosticPosition pos, Symbol sym) {
log.error(pos, Errors.CantRefNonEffectivelyFinalVar(sym, diags.fragment(subKey)));
}

void reportInnerClsNeedsFinalError(DiagnosticPosition pos, Symbol sym) {
log.error(pos,
Errors.LocalVarAccessedFromIclsNeedsFinal(sym));
}

/*************************************************************************
* Visitor methods for statements and definitions
*************************************************************************/
Expand Down
Expand Up @@ -106,10 +106,8 @@ public class Resolve {
ModuleFinder moduleFinder;
Types types;
JCDiagnostic.Factory diags;
public final boolean allowFunctionalInterfaceMostSpecific;
public final boolean allowModules;
public final boolean allowRecords;
public final boolean checkVarargsAccessAfterResolution;
private final boolean compactMethodDiags;
private final boolean allowLocalVariableTypeInference;
private final boolean allowYieldStatement;
Expand Down Expand Up @@ -145,11 +143,8 @@ protected Resolve(Context context) {
options.isUnset(Option.XDIAGS) && options.isUnset("rawDiagnostics");
verboseResolutionMode = VerboseResolutionMode.getVerboseResolutionMode(options);
Target target = Target.instance(context);
allowFunctionalInterfaceMostSpecific = Feature.FUNCTIONAL_INTERFACE_MOST_SPECIFIC.allowedInSource(source);
allowLocalVariableTypeInference = Feature.LOCAL_VARIABLE_TYPE_INFERENCE.allowedInSource(source);
allowYieldStatement = Feature.SWITCH_EXPRESSION.allowedInSource(source);
checkVarargsAccessAfterResolution =
Feature.POST_APPLICABILITY_VARARGS_ACCESS_CHECK.allowedInSource(source);
polymorphicSignatureScope = WriteableScope.create(syms.noSymbol);
allowModules = Feature.MODULES.allowedInSource(source);
allowRecords = Feature.RECORDS.allowedInSource(source);
Expand Down Expand Up @@ -915,7 +910,7 @@ public void argumentsAcceptable(final Env<AttrContext> env,
super.argumentsAcceptable(env, deferredAttrContext, argtypes, formals, warn);
// should we check varargs element type accessibility?
if (deferredAttrContext.phase.isVarargsRequired()) {
if (deferredAttrContext.mode == AttrMode.CHECK || !checkVarargsAccessAfterResolution) {
if (deferredAttrContext.mode == AttrMode.CHECK) {
varargsAccessible(env, types.elemtype(formals.last()), deferredAttrContext.inferenceContext);
}
}
Expand Down Expand Up @@ -1170,9 +1165,8 @@ public MostSpecificCheckContext(DeferredAttrContext deferredAttrContext, Warner
}

public boolean compatible(Type found, Type req, Warner warn) {
if (allowFunctionalInterfaceMostSpecific &&
unrelatedFunctionalInterfaces(found, req) &&
(actual != null && actual.getTag() == DEFERRED)) {
if (unrelatedFunctionalInterfaces(found, req) &&
(actual != null && actual.getTag() == DEFERRED)) {
DeferredType dt = (DeferredType) actual;
JCTree speculativeTree = dt.speculativeTree(deferredAttrContext);
if (speculativeTree != deferredAttr.stuckTree) {
Expand Down