mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 19:44:41 +02:00
Merge
This commit is contained in:
commit
1cf7cebcc8
6 changed files with 39 additions and 37 deletions
|
@ -51,16 +51,16 @@ import com.sun.tools.javac.parser.DocCommentScanner;
|
||||||
* or deletion without notice.</b>
|
* or deletion without notice.</b>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class JavaCompiler extends com.sun.tools.javac.main.JavaCompiler {
|
public class AptJavaCompiler extends com.sun.tools.javac.main.JavaCompiler {
|
||||||
/** The context key for the compiler. */
|
/** The context key for the compiler. */
|
||||||
protected static final Context.Key<JavaCompiler> compilerKey =
|
protected static final Context.Key<AptJavaCompiler> compilerKey =
|
||||||
new Context.Key<JavaCompiler>();
|
new Context.Key<AptJavaCompiler>();
|
||||||
|
|
||||||
/** Get the JavaCompiler instance for this context. */
|
/** Get the JavaCompiler instance for this context. */
|
||||||
public static JavaCompiler instance(Context context) {
|
public static AptJavaCompiler instance(Context context) {
|
||||||
JavaCompiler instance = context.get(compilerKey);
|
AptJavaCompiler instance = context.get(compilerKey);
|
||||||
if (instance == null)
|
if (instance == null)
|
||||||
instance = new JavaCompiler(context);
|
instance = new AptJavaCompiler(context);
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ public class JavaCompiler extends com.sun.tools.javac.main.JavaCompiler {
|
||||||
|
|
||||||
/** Construct a new compiler from a shared context.
|
/** Construct a new compiler from a shared context.
|
||||||
*/
|
*/
|
||||||
public JavaCompiler(Context context) {
|
public AptJavaCompiler(Context context) {
|
||||||
super(preRegister(context));
|
super(preRegister(context));
|
||||||
|
|
||||||
context.put(compilerKey, this);
|
context.put(compilerKey, this);
|
|
@ -421,7 +421,7 @@ public class Main {
|
||||||
},
|
},
|
||||||
new AptOption("-version", "opt.version") {
|
new AptOption("-version", "opt.version") {
|
||||||
boolean process(String option) {
|
boolean process(String option) {
|
||||||
Bark.printLines(out, ownName + " " + JavaCompiler.version());
|
Bark.printLines(out, ownName + " " + AptJavaCompiler.version());
|
||||||
return super.process(option);
|
return super.process(option);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1111,11 +1111,11 @@ public class Main {
|
||||||
}
|
}
|
||||||
int exitCode = EXIT_OK;
|
int exitCode = EXIT_OK;
|
||||||
|
|
||||||
JavaCompiler comp = null;
|
AptJavaCompiler comp = null;
|
||||||
try {
|
try {
|
||||||
context.put(Bark.outKey, out);
|
context.put(Bark.outKey, out);
|
||||||
|
|
||||||
comp = JavaCompiler.instance(context);
|
comp = AptJavaCompiler.instance(context);
|
||||||
if (comp == null)
|
if (comp == null)
|
||||||
return EXIT_SYSERR;
|
return EXIT_SYSERR;
|
||||||
|
|
||||||
|
@ -1184,7 +1184,7 @@ public class Main {
|
||||||
*/
|
*/
|
||||||
void bugMessage(Throwable ex) {
|
void bugMessage(Throwable ex) {
|
||||||
Bark.printLines(out, getLocalizedString("msg.bug",
|
Bark.printLines(out, getLocalizedString("msg.bug",
|
||||||
JavaCompiler.version()));
|
AptJavaCompiler.version()));
|
||||||
ex.printStackTrace(out);
|
ex.printStackTrace(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ public class FilerImpl implements Filer {
|
||||||
|
|
||||||
private final Options opts;
|
private final Options opts;
|
||||||
private final DeclarationMaker declMaker;
|
private final DeclarationMaker declMaker;
|
||||||
private final com.sun.tools.apt.main.JavaCompiler comp;
|
private final com.sun.tools.apt.main.AptJavaCompiler comp;
|
||||||
|
|
||||||
// Platform's default encoding
|
// Platform's default encoding
|
||||||
private final static String DEFAULT_ENCODING =
|
private final static String DEFAULT_ENCODING =
|
||||||
|
@ -177,7 +177,7 @@ public class FilerImpl implements Filer {
|
||||||
opts = Options.instance(context);
|
opts = Options.instance(context);
|
||||||
declMaker = DeclarationMaker.instance(context);
|
declMaker = DeclarationMaker.instance(context);
|
||||||
bark = Bark.instance(context);
|
bark = Bark.instance(context);
|
||||||
comp = com.sun.tools.apt.main.JavaCompiler.instance(context);
|
comp = com.sun.tools.apt.main.AptJavaCompiler.instance(context);
|
||||||
roundOver = false;
|
roundOver = false;
|
||||||
this.filesCreated = comp.getAggregateGenFiles();
|
this.filesCreated = comp.getAggregateGenFiles();
|
||||||
|
|
||||||
|
|
|
@ -245,7 +245,7 @@ public class Type implements PrimitiveType {
|
||||||
public String argtypes(boolean varargs) {
|
public String argtypes(boolean varargs) {
|
||||||
List<Type> args = getParameterTypes();
|
List<Type> args = getParameterTypes();
|
||||||
if (!varargs) return args.toString();
|
if (!varargs) return args.toString();
|
||||||
StringBuffer buf = new StringBuffer();
|
StringBuilder buf = new StringBuilder();
|
||||||
while (args.tail.nonEmpty()) {
|
while (args.tail.nonEmpty()) {
|
||||||
buf.append(args.head);
|
buf.append(args.head);
|
||||||
args = args.tail;
|
args = args.tail;
|
||||||
|
@ -935,7 +935,7 @@ public class Type implements PrimitiveType {
|
||||||
|
|
||||||
public static class TypeVar extends Type implements TypeVariable {
|
public static class TypeVar extends Type implements TypeVariable {
|
||||||
|
|
||||||
/** The bound of this type variable; set from outside.
|
/** The upper bound of this type variable; set from outside.
|
||||||
* Must be nonempty once it is set.
|
* Must be nonempty once it is set.
|
||||||
* For a bound, `bound' is the bound type itself.
|
* For a bound, `bound' is the bound type itself.
|
||||||
* Multiple bounds are expressed as a single class type which has the
|
* Multiple bounds are expressed as a single class type which has the
|
||||||
|
@ -946,6 +946,12 @@ public class Type implements PrimitiveType {
|
||||||
* points to the first class or interface bound.
|
* points to the first class or interface bound.
|
||||||
*/
|
*/
|
||||||
public Type bound = null;
|
public Type bound = null;
|
||||||
|
|
||||||
|
/** The lower bound of this type variable.
|
||||||
|
* TypeVars don't normally have a lower bound, so it is normally set
|
||||||
|
* to syms.botType.
|
||||||
|
* Subtypes, such as CapturedType, may provide a different value.
|
||||||
|
*/
|
||||||
public Type lower;
|
public Type lower;
|
||||||
|
|
||||||
public TypeVar(Name name, Symbol owner, Type lower) {
|
public TypeVar(Name name, Symbol owner, Type lower) {
|
||||||
|
@ -965,10 +971,12 @@ public class Type implements PrimitiveType {
|
||||||
return v.visitTypeVar(this, s);
|
return v.visitTypeVar(this, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Type getUpperBound() { return bound; }
|
public Type getUpperBound() { return bound; }
|
||||||
|
|
||||||
int rank_field = -1;
|
int rank_field = -1;
|
||||||
|
|
||||||
|
@Override
|
||||||
public Type getLowerBound() {
|
public Type getLowerBound() {
|
||||||
return lower;
|
return lower;
|
||||||
}
|
}
|
||||||
|
@ -992,7 +1000,6 @@ public class Type implements PrimitiveType {
|
||||||
*/
|
*/
|
||||||
public static class CapturedType extends TypeVar {
|
public static class CapturedType extends TypeVar {
|
||||||
|
|
||||||
public Type lower;
|
|
||||||
public WildcardType wildcard;
|
public WildcardType wildcard;
|
||||||
|
|
||||||
public CapturedType(Name name,
|
public CapturedType(Name name,
|
||||||
|
@ -1012,10 +1019,6 @@ public class Type implements PrimitiveType {
|
||||||
return v.visitCapturedType(this, s);
|
return v.visitCapturedType(this, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type getLowerBound() {
|
|
||||||
return lower;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCaptured() {
|
public boolean isCaptured() {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -641,7 +641,7 @@ public class Types {
|
||||||
if (!set.remove(new SingletonType(x)))
|
if (!set.remove(new SingletonType(x)))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return (set.size() == 0);
|
return (set.isEmpty());
|
||||||
}
|
}
|
||||||
return t.tsym == s.tsym
|
return t.tsym == s.tsym
|
||||||
&& visit(t.getEnclosingType(), s.getEnclosingType())
|
&& visit(t.getEnclosingType(), s.getEnclosingType())
|
||||||
|
@ -838,26 +838,26 @@ public class Types {
|
||||||
return isSameType(t, s);
|
return isSameType(t, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void debugContainsType(WildcardType t, Type s) {
|
// void debugContainsType(WildcardType t, Type s) {
|
||||||
System.err.println();
|
// System.err.println();
|
||||||
System.err.format(" does %s contain %s?%n", t, s);
|
// System.err.format(" does %s contain %s?%n", t, s);
|
||||||
System.err.format(" %s U(%s) <: U(%s) %s = %s%n",
|
// System.err.format(" %s U(%s) <: U(%s) %s = %s%n",
|
||||||
upperBound(s), s, t, U(t),
|
// upperBound(s), s, t, U(t),
|
||||||
t.isSuperBound()
|
// t.isSuperBound()
|
||||||
|| isSubtypeNoCapture(upperBound(s), U(t)));
|
// || isSubtypeNoCapture(upperBound(s), U(t)));
|
||||||
System.err.format(" %s L(%s) <: L(%s) %s = %s%n",
|
// System.err.format(" %s L(%s) <: L(%s) %s = %s%n",
|
||||||
L(t), t, s, lowerBound(s),
|
// L(t), t, s, lowerBound(s),
|
||||||
t.isExtendsBound()
|
// t.isExtendsBound()
|
||||||
|| isSubtypeNoCapture(L(t), lowerBound(s)));
|
// || isSubtypeNoCapture(L(t), lowerBound(s)));
|
||||||
System.err.println();
|
// System.err.println();
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean visitWildcardType(WildcardType t, Type s) {
|
public Boolean visitWildcardType(WildcardType t, Type s) {
|
||||||
if (s.tag >= firstPartialTag)
|
if (s.tag >= firstPartialTag)
|
||||||
return containedBy(s, t);
|
return containedBy(s, t);
|
||||||
else {
|
else {
|
||||||
// debugContainsType(t, s);
|
// debugContainsType(t, s);
|
||||||
return isSameWildcard(t, s)
|
return isSameWildcard(t, s)
|
||||||
|| isCaptureOf(s, t)
|
|| isCaptureOf(s, t)
|
||||||
|| ((t.isExtendsBound() || isSubtypeNoCapture(L(t), lowerBound(s))) &&
|
|| ((t.isExtendsBound() || isSubtypeNoCapture(L(t), lowerBound(s))) &&
|
||||||
|
|
|
@ -197,7 +197,7 @@ public class Resolve {
|
||||||
}
|
}
|
||||||
return (checkInner == false || c.type.getEnclosingType() == Type.noType) ?
|
return (checkInner == false || c.type.getEnclosingType() == Type.noType) ?
|
||||||
isAccessible :
|
isAccessible :
|
||||||
isAccessible & isAccessible(env, c.type.getEnclosingType(), checkInner);
|
isAccessible && isAccessible(env, c.type.getEnclosingType(), checkInner);
|
||||||
}
|
}
|
||||||
//where
|
//where
|
||||||
/** Is given class a subclass of given base class, or an inner class
|
/** Is given class a subclass of given base class, or an inner class
|
||||||
|
@ -234,7 +234,6 @@ public class Resolve {
|
||||||
}
|
}
|
||||||
public boolean isAccessible(Env<AttrContext> env, Type site, Symbol sym, boolean checkInner) {
|
public boolean isAccessible(Env<AttrContext> env, Type site, Symbol sym, boolean checkInner) {
|
||||||
if (sym.name == names.init && sym.owner != site.tsym) return false;
|
if (sym.name == names.init && sym.owner != site.tsym) return false;
|
||||||
ClassSymbol sub;
|
|
||||||
switch ((short)(sym.flags() & AccessFlags)) {
|
switch ((short)(sym.flags() & AccessFlags)) {
|
||||||
case PRIVATE:
|
case PRIVATE:
|
||||||
return
|
return
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue