mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 11:04:34 +02:00
8010179: Remove transitional target values from javac
Reviewed-by: jjg, mcimadamore
This commit is contained in:
parent
49d55f9300
commit
479d5c83b0
6 changed files with 13 additions and 280 deletions
|
@ -4009,8 +4009,7 @@ public class Attr extends JCTree.Visitor {
|
|||
// Enums may not be extended by source-level classes
|
||||
if (st.tsym != null &&
|
||||
((st.tsym.flags_field & Flags.ENUM) != 0) &&
|
||||
((c.flags_field & (Flags.ENUM | Flags.COMPOUND)) == 0) &&
|
||||
!target.compilerBootstrap(c)) {
|
||||
((c.flags_field & (Flags.ENUM | Flags.COMPOUND)) == 0)) {
|
||||
log.error(env.tree.pos(), "enum.types.not.extensible");
|
||||
}
|
||||
attribClassBody(env, c);
|
||||
|
|
|
@ -2604,11 +2604,6 @@ public class Lower extends TreeTranslator {
|
|||
|
||||
enumDefs.appendList(otherDefs.toList());
|
||||
tree.defs = enumDefs.toList();
|
||||
|
||||
// Add the necessary members for the EnumCompatibleMode
|
||||
if (target.compilerBootstrap(tree.sym)) {
|
||||
addEnumCompatibleMembers(tree);
|
||||
}
|
||||
}
|
||||
// where
|
||||
private MethodSymbol systemArraycopyMethod;
|
||||
|
@ -2657,30 +2652,6 @@ public class Lower extends TreeTranslator {
|
|||
olderasure.getReturnType(),
|
||||
olderasure.getThrownTypes(),
|
||||
syms.methodClass);
|
||||
|
||||
if (target.compilerBootstrap(m.owner)) {
|
||||
// Initialize synthetic name field
|
||||
Symbol nameVarSym = lookupSynthetic(names.fromString("$name"),
|
||||
tree.sym.owner.members());
|
||||
JCIdent nameIdent = make.Ident(nameParam.sym);
|
||||
JCIdent id1 = make.Ident(nameVarSym);
|
||||
JCAssign newAssign = make.Assign(id1, nameIdent);
|
||||
newAssign.type = id1.type;
|
||||
JCExpressionStatement nameAssign = make.Exec(newAssign);
|
||||
nameAssign.type = id1.type;
|
||||
tree.body.stats = tree.body.stats.prepend(nameAssign);
|
||||
|
||||
// Initialize synthetic ordinal field
|
||||
Symbol ordinalVarSym = lookupSynthetic(names.fromString("$ordinal"),
|
||||
tree.sym.owner.members());
|
||||
JCIdent ordIdent = make.Ident(ordParam.sym);
|
||||
id1 = make.Ident(ordinalVarSym);
|
||||
newAssign = make.Assign(id1, ordIdent);
|
||||
newAssign.type = id1.type;
|
||||
JCExpressionStatement ordinalAssign = make.Exec(newAssign);
|
||||
ordinalAssign.type = id1.type;
|
||||
tree.body.stats = tree.body.stats.prepend(ordinalAssign);
|
||||
}
|
||||
}
|
||||
|
||||
JCMethodDecl prevMethodDef = currentMethodDef;
|
||||
|
@ -3888,168 +3859,4 @@ public class Lower extends TreeTranslator {
|
|||
}
|
||||
return translated.toList();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// The following contributed by Borland for bootstrapping purposes
|
||||
//////////////////////////////////////////////////////////////
|
||||
private void addEnumCompatibleMembers(JCClassDecl cdef) {
|
||||
make_at(null);
|
||||
|
||||
// Add the special enum fields
|
||||
VarSymbol ordinalFieldSym = addEnumOrdinalField(cdef);
|
||||
VarSymbol nameFieldSym = addEnumNameField(cdef);
|
||||
|
||||
// Add the accessor methods for name and ordinal
|
||||
MethodSymbol ordinalMethodSym = addEnumFieldOrdinalMethod(cdef, ordinalFieldSym);
|
||||
MethodSymbol nameMethodSym = addEnumFieldNameMethod(cdef, nameFieldSym);
|
||||
|
||||
// Add the toString method
|
||||
addEnumToString(cdef, nameFieldSym);
|
||||
|
||||
// Add the compareTo method
|
||||
addEnumCompareTo(cdef, ordinalFieldSym);
|
||||
}
|
||||
|
||||
private VarSymbol addEnumOrdinalField(JCClassDecl cdef) {
|
||||
VarSymbol ordinal = new VarSymbol(PRIVATE|FINAL|SYNTHETIC,
|
||||
names.fromString("$ordinal"),
|
||||
syms.intType,
|
||||
cdef.sym);
|
||||
cdef.sym.members().enter(ordinal);
|
||||
cdef.defs = cdef.defs.prepend(make.VarDef(ordinal, null));
|
||||
return ordinal;
|
||||
}
|
||||
|
||||
private VarSymbol addEnumNameField(JCClassDecl cdef) {
|
||||
VarSymbol name = new VarSymbol(PRIVATE|FINAL|SYNTHETIC,
|
||||
names.fromString("$name"),
|
||||
syms.stringType,
|
||||
cdef.sym);
|
||||
cdef.sym.members().enter(name);
|
||||
cdef.defs = cdef.defs.prepend(make.VarDef(name, null));
|
||||
return name;
|
||||
}
|
||||
|
||||
private MethodSymbol addEnumFieldOrdinalMethod(JCClassDecl cdef, VarSymbol ordinalSymbol) {
|
||||
// Add the accessor methods for ordinal
|
||||
Symbol ordinalSym = lookupMethod(cdef.pos(),
|
||||
names.ordinal,
|
||||
cdef.type,
|
||||
List.<Type>nil());
|
||||
|
||||
Assert.check(ordinalSym instanceof MethodSymbol);
|
||||
|
||||
JCStatement ret = make.Return(make.Ident(ordinalSymbol));
|
||||
cdef.defs = cdef.defs.append(make.MethodDef((MethodSymbol)ordinalSym,
|
||||
make.Block(0L, List.of(ret))));
|
||||
|
||||
return (MethodSymbol)ordinalSym;
|
||||
}
|
||||
|
||||
private MethodSymbol addEnumFieldNameMethod(JCClassDecl cdef, VarSymbol nameSymbol) {
|
||||
// Add the accessor methods for name
|
||||
Symbol nameSym = lookupMethod(cdef.pos(),
|
||||
names._name,
|
||||
cdef.type,
|
||||
List.<Type>nil());
|
||||
|
||||
Assert.check(nameSym instanceof MethodSymbol);
|
||||
|
||||
JCStatement ret = make.Return(make.Ident(nameSymbol));
|
||||
|
||||
cdef.defs = cdef.defs.append(make.MethodDef((MethodSymbol)nameSym,
|
||||
make.Block(0L, List.of(ret))));
|
||||
|
||||
return (MethodSymbol)nameSym;
|
||||
}
|
||||
|
||||
private MethodSymbol addEnumToString(JCClassDecl cdef,
|
||||
VarSymbol nameSymbol) {
|
||||
Symbol toStringSym = lookupMethod(cdef.pos(),
|
||||
names.toString,
|
||||
cdef.type,
|
||||
List.<Type>nil());
|
||||
|
||||
JCTree toStringDecl = null;
|
||||
if (toStringSym != null)
|
||||
toStringDecl = TreeInfo.declarationFor(toStringSym, cdef);
|
||||
|
||||
if (toStringDecl != null)
|
||||
return (MethodSymbol)toStringSym;
|
||||
|
||||
JCStatement ret = make.Return(make.Ident(nameSymbol));
|
||||
|
||||
JCTree resTypeTree = make.Type(syms.stringType);
|
||||
|
||||
MethodType toStringType = new MethodType(List.<Type>nil(),
|
||||
syms.stringType,
|
||||
List.<Type>nil(),
|
||||
cdef.sym);
|
||||
toStringSym = new MethodSymbol(PUBLIC,
|
||||
names.toString,
|
||||
toStringType,
|
||||
cdef.type.tsym);
|
||||
toStringDecl = make.MethodDef((MethodSymbol)toStringSym,
|
||||
make.Block(0L, List.of(ret)));
|
||||
|
||||
cdef.defs = cdef.defs.prepend(toStringDecl);
|
||||
cdef.sym.members().enter(toStringSym);
|
||||
|
||||
return (MethodSymbol)toStringSym;
|
||||
}
|
||||
|
||||
private MethodSymbol addEnumCompareTo(JCClassDecl cdef, VarSymbol ordinalSymbol) {
|
||||
Symbol compareToSym = lookupMethod(cdef.pos(),
|
||||
names.compareTo,
|
||||
cdef.type,
|
||||
List.of(cdef.sym.type));
|
||||
|
||||
Assert.check(compareToSym instanceof MethodSymbol);
|
||||
|
||||
JCMethodDecl compareToDecl = (JCMethodDecl) TreeInfo.declarationFor(compareToSym, cdef);
|
||||
|
||||
ListBuffer<JCStatement> blockStatements = new ListBuffer<JCStatement>();
|
||||
|
||||
JCModifiers mod1 = make.Modifiers(0L);
|
||||
Name oName = names.fromString("o");
|
||||
JCVariableDecl par1 = make.Param(oName, cdef.type, compareToSym);
|
||||
|
||||
JCIdent paramId1 = make.Ident(names.java_lang_Object);
|
||||
paramId1.type = cdef.type;
|
||||
paramId1.sym = par1.sym;
|
||||
|
||||
((MethodSymbol)compareToSym).params = List.of(par1.sym);
|
||||
|
||||
JCIdent par1UsageId = make.Ident(par1.sym);
|
||||
JCIdent castTargetIdent = make.Ident(cdef.sym);
|
||||
JCTypeCast cast = make.TypeCast(castTargetIdent, par1UsageId);
|
||||
cast.setType(castTargetIdent.type);
|
||||
|
||||
Name otherName = names.fromString("other");
|
||||
|
||||
VarSymbol otherVarSym = new VarSymbol(mod1.flags,
|
||||
otherName,
|
||||
cdef.type,
|
||||
compareToSym);
|
||||
JCVariableDecl otherVar = make.VarDef(otherVarSym, cast);
|
||||
blockStatements.append(otherVar);
|
||||
|
||||
JCIdent id1 = make.Ident(ordinalSymbol);
|
||||
|
||||
JCIdent fLocUsageId = make.Ident(otherVarSym);
|
||||
JCExpression sel = make.Select(fLocUsageId, ordinalSymbol);
|
||||
JCBinary bin = makeBinary(MINUS, id1, sel);
|
||||
JCReturn ret = make.Return(bin);
|
||||
blockStatements.append(ret);
|
||||
JCMethodDecl compareToMethod = make.MethodDef((MethodSymbol)compareToSym,
|
||||
make.Block(0L,
|
||||
blockStatements.toList()));
|
||||
compareToMethod.params = List.of(par1);
|
||||
cdef.defs = cdef.defs.append(compareToMethod);
|
||||
|
||||
return (MethodSymbol)compareToSym;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////
|
||||
// The above contributed by Borland for bootstrapping purposes
|
||||
//////////////////////////////////////////////////////////////
|
||||
}
|
||||
|
|
|
@ -473,44 +473,6 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
|||
null, //make.Block(0, Tree.emptyList.prepend(make.Return(make.Ident(names._null)))),
|
||||
null);
|
||||
memberEnter(valueOf, env);
|
||||
|
||||
// the remaining members are for bootstrapping only
|
||||
if (!target.compilerBootstrap(tree.sym)) return;
|
||||
|
||||
// public final int ordinal() { return ???; }
|
||||
JCMethodDecl ordinal = make.at(tree.pos).
|
||||
MethodDef(make.Modifiers(Flags.PUBLIC|Flags.FINAL),
|
||||
names.ordinal,
|
||||
make.Type(syms.intType),
|
||||
List.<JCTypeParameter>nil(),
|
||||
List.<JCVariableDecl>nil(),
|
||||
List.<JCExpression>nil(),
|
||||
null,
|
||||
null);
|
||||
memberEnter(ordinal, env);
|
||||
|
||||
// public final String name() { return ???; }
|
||||
JCMethodDecl name = make.
|
||||
MethodDef(make.Modifiers(Flags.PUBLIC|Flags.FINAL),
|
||||
names._name,
|
||||
make.Type(syms.stringType),
|
||||
List.<JCTypeParameter>nil(),
|
||||
List.<JCVariableDecl>nil(),
|
||||
List.<JCExpression>nil(),
|
||||
null,
|
||||
null);
|
||||
memberEnter(name, env);
|
||||
|
||||
// public int compareTo(E other) { return ???; }
|
||||
MethodSymbol compareTo = new
|
||||
MethodSymbol(Flags.PUBLIC,
|
||||
names.compareTo,
|
||||
new MethodType(List.of(tree.sym.type),
|
||||
syms.intType,
|
||||
List.<Type>nil(),
|
||||
syms.methodClass),
|
||||
tree.sym);
|
||||
memberEnter(make.MethodDef(compareTo, null), env);
|
||||
}
|
||||
|
||||
public void visitTopLevel(JCCompilationUnit tree) {
|
||||
|
@ -936,7 +898,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
|||
Type supertype =
|
||||
(tree.extending != null)
|
||||
? attr.attribBase(tree.extending, baseEnv, true, false, true)
|
||||
: ((tree.mods.flags & Flags.ENUM) != 0 && !target.compilerBootstrap(c))
|
||||
: ((tree.mods.flags & Flags.ENUM) != 0)
|
||||
? attr.attribBase(enumBase(tree.pos, c), baseEnv,
|
||||
true, false, false)
|
||||
: (c.fullname == names.java_lang_Object)
|
||||
|
@ -949,16 +911,6 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
|||
ListBuffer<Type> all_interfaces = null; // lazy init
|
||||
Set<Type> interfaceSet = new HashSet<Type>();
|
||||
List<JCExpression> interfaceTrees = tree.implementing;
|
||||
if ((tree.mods.flags & Flags.ENUM) != 0 && target.compilerBootstrap(c)) {
|
||||
// add interface Comparable<T>
|
||||
interfaceTrees =
|
||||
interfaceTrees.prepend(make.Type(new ClassType(syms.comparableType.getEnclosingType(),
|
||||
List.of(c.type),
|
||||
syms.comparableType.tsym)));
|
||||
// add interface Serializable
|
||||
interfaceTrees =
|
||||
interfaceTrees.prepend(make.Type(syms.serializableType));
|
||||
}
|
||||
for (JCExpression iface : interfaceTrees) {
|
||||
Type i = attr.attribBase(iface, baseEnv, false, true, true);
|
||||
if (i.hasTag(CLASS)) {
|
||||
|
@ -1401,8 +1353,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
|||
if (c.type != syms.objectType)
|
||||
stats = stats.prepend(SuperCall(make, typarams, params, based));
|
||||
if ((c.flags() & ENUM) != 0 &&
|
||||
(types.supertype(c.type).tsym == syms.enumSym ||
|
||||
target.compilerBootstrap(c))) {
|
||||
(types.supertype(c.type).tsym == syms.enumSym)) {
|
||||
// constructors of true enums are private
|
||||
flags = (flags & ~AccessFlags) | PRIVATE | GENERATEDCONSTR;
|
||||
} else
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2013, 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
|
||||
|
@ -48,17 +48,6 @@ public enum Target {
|
|||
/** J2SE1.4 = Merlin. */
|
||||
JDK1_4("1.4", 48, 0),
|
||||
|
||||
/** Support for the JSR14 prototype compiler (targeting 1.4 VMs
|
||||
* augmented with a few support classes). This is a transitional
|
||||
* option that will not be supported in the product. */
|
||||
JSR14("jsr14", 48, 0),
|
||||
|
||||
/** The following are undocumented transitional targets that we
|
||||
* had used to test VM fixes in update releases. We do not
|
||||
* promise to retain support for them. */
|
||||
JDK1_4_1("1.4.1", 48, 0),
|
||||
JDK1_4_2("1.4.2", 48, 0),
|
||||
|
||||
/** Tiger. */
|
||||
JDK1_5("1.5", 49, 0),
|
||||
|
||||
|
@ -175,23 +164,23 @@ public enum Target {
|
|||
return compareTo(JDK1_5) >= 0;
|
||||
}
|
||||
|
||||
/** Beginning in -target 1.4.2, we make synthetic variables
|
||||
/** Beginning in -target 1.5, we make synthetic variables
|
||||
* package-private instead of private. This is to prevent the
|
||||
* necessity of access methods, which effectively relax the
|
||||
* protection of the field but bloat the class files and affect
|
||||
* execution.
|
||||
*/
|
||||
public boolean usePrivateSyntheticFields() {
|
||||
return compareTo(JDK1_4_2) < 0;
|
||||
return compareTo(JDK1_5) < 0;
|
||||
}
|
||||
|
||||
/** Sometimes we need to create a field to cache a value like a
|
||||
* class literal of the assertions flag. In -target 1.4.2 and
|
||||
* class literal of the assertions flag. In -target 1.5 and
|
||||
* later we create a new synthetic class for this instead of
|
||||
* using the outermost class. See 4401576.
|
||||
*/
|
||||
public boolean useInnerCacheClass() {
|
||||
return compareTo(JDK1_4_2) >= 0;
|
||||
return compareTo(JDK1_5) >= 0;
|
||||
}
|
||||
|
||||
/** Return true if cldc-style stack maps need to be generated. */
|
||||
|
@ -276,7 +265,7 @@ public enum Target {
|
|||
* See 4468823
|
||||
*/
|
||||
public boolean classLiteralsNoInit() {
|
||||
return compareTo(JDK1_4_2) >= 0;
|
||||
return compareTo(JDK1_5) >= 0;
|
||||
}
|
||||
|
||||
/** Although we may not have support for class literals, when we
|
||||
|
@ -300,22 +289,10 @@ public enum Target {
|
|||
return compareTo(JDK1_5) >= 0;
|
||||
}
|
||||
|
||||
/** For bootstrapping javac only, we do without java.lang.Enum if
|
||||
* necessary.
|
||||
*/
|
||||
public boolean compilerBootstrap(Symbol c) {
|
||||
return
|
||||
this == JSR14 &&
|
||||
(c.flags() & Flags.ENUM) != 0 &&
|
||||
c.flatName().toString().startsWith("com.sun.tools.")
|
||||
// && !Target.class.getSuperclass().getName().equals("java.lang.Enum")
|
||||
;
|
||||
}
|
||||
|
||||
/** In J2SE1.5.0, we introduced the "EnclosingMethod" attribute
|
||||
* for improved reflection support.
|
||||
*/
|
||||
public boolean hasEnclosingMethodAttribute() {
|
||||
return compareTo(JDK1_5) >= 0 || this == JSR14;
|
||||
return compareTo(JDK1_5) >= 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2013, 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
|
||||
|
@ -26,7 +26,7 @@
|
|||
* @bug 4249112 4785453
|
||||
* @summary Verify that implicit member modifiers are set correctly.
|
||||
*
|
||||
* @compile/ref=MemberModifiers.out -source 1.4 -target 1.4.2 -Xlint:-options -XDdumpmodifiers=cfm MemberModifiers.java
|
||||
* @compile/ref=MemberModifiers.out -source 1.4 -target 1.5 -Xlint:-options -XDdumpmodifiers=cfm MemberModifiers.java
|
||||
*/
|
||||
|
||||
// Currently, we check only that members of final classes are not final.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2013, 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
|
||||
|
@ -106,7 +106,6 @@ public class ProfileOptionTest {
|
|||
for (Target t: Target.values()) {
|
||||
switch (t) {
|
||||
case JDK1_1: case JDK1_2: // no equivalent -source
|
||||
case JDK1_4_1: case JDK1_4_2: case JSR14: // transitional values
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue