--- a/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java Mon Jul 28 10:22:10 2008 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java Fri Aug 01 15:23:18 2008 -0700
@@ -75,6 +75,7 @@
private final Name.Table names;
private final ClassReader reader;
+ private final Target target;
/** A symbol for the root package.
*/
@@ -144,6 +145,7 @@
public final Type suppressWarningsType;
public final Type inheritedType;
public final Type proprietaryType;
+ public final Type systemType;
/** The symbol representing the length field of an array.
*/
@@ -272,6 +274,55 @@
return reader.enterClass(names.fromString(s)).type;
}
+ public void synthesizeEmptyInterfaceIfMissing(final Type type) {
+ final Completer completer = type.tsym.completer;
+ if (completer != null) {
+ type.tsym.completer = new Completer() {
+ public void complete(Symbol sym) throws CompletionFailure {
+ try {
+ completer.complete(sym);
+ } catch (CompletionFailure e) {
+ sym.flags_field |= (PUBLIC | INTERFACE);
+ ((ClassType) sym.type).supertype_field = objectType;
+ }
+ }
+ };
+ }
+ }
+
+ public void synthesizeBoxTypeIfMissing(final Type type) {
+ ClassSymbol sym = reader.enterClass(boxedName[type.tag]);
+ final Completer completer = sym.completer;
+ if (completer != null) {
+ sym.completer = new Completer() {
+ public void complete(Symbol sym) throws CompletionFailure {
+ try {
+ completer.complete(sym);
+ } catch (CompletionFailure e) {
+ sym.flags_field |= PUBLIC;
+ ((ClassType) sym.type).supertype_field = objectType;
+ Name n = target.boxWithConstructors() ? names.init : names.valueOf;
+ MethodSymbol boxMethod =
+ new MethodSymbol(PUBLIC | STATIC,
+ n,
+ new MethodType(List.of(type), sym.type,
+ List.<Type>nil(), methodClass),
+ sym);
+ sym.members().enter(boxMethod);
+ MethodSymbol unboxMethod =
+ new MethodSymbol(PUBLIC,
+ type.tsym.name.append(names.Value), // x.intValue()
+ new MethodType(List.<Type>nil(), type,
+ List.<Type>nil(), methodClass),
+ sym);
+ sym.members().enter(unboxMethod);
+ }
+ }
+ };
+ }
+
+ }
+
/** Constructor; enters all predefined identifiers and operators
* into symbol table.
*/
@@ -279,6 +330,7 @@
context.put(symtabKey, this);
names = Name.Table.instance(context);
+ target = Target.instance(context);
// Create the unknown type
unknownType = new Type(TypeTags.UNKNOWN, null);
@@ -373,7 +425,7 @@
collectionsType = enterClass("java.util.Collections");
comparableType = enterClass("java.lang.Comparable");
arraysType = enterClass("java.util.Arrays");
- iterableType = Target.instance(context).hasIterable()
+ iterableType = target.hasIterable()
? enterClass("java.lang.Iterable")
: enterClass("java.util.Collection");
iteratorType = enterClass("java.util.Iterator");
@@ -383,6 +435,12 @@
deprecatedType = enterClass("java.lang.Deprecated");
suppressWarningsType = enterClass("java.lang.SuppressWarnings");
inheritedType = enterClass("java.lang.annotation.Inherited");
+ systemType = enterClass("java.lang.System");
+
+ synthesizeEmptyInterfaceIfMissing(cloneableType);
+ synthesizeEmptyInterfaceIfMissing(serializableType);
+ synthesizeBoxTypeIfMissing(doubleType);
+ synthesizeBoxTypeIfMissing(floatType);
// Enter a synthetic class that is used to mark Sun
// proprietary classes in ct.sym. This class does not have a