6574134: Allow for alternative implementation of Name Table with garbage collection of name bytes
Reviewed-by: darcy, mcimadamore
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/AptEnv.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/apt/mirror/AptEnv.java Tue Sep 16 18:35:18 2008 -0700
@@ -33,7 +33,7 @@
import com.sun.tools.javac.comp.Attr;
import com.sun.tools.javac.comp.Enter;
import com.sun.tools.javac.util.Context;
-import com.sun.tools.javac.util.Name;
+import com.sun.tools.javac.util.Names;
/**
@@ -42,7 +42,7 @@
public class AptEnv {
- public Name.Table names; // javac's name table
+ public Names names; // javac's name table
public Symtab symtab; // javac's predefined symbols
public Types jctypes; // javac's type utilities
public Enter enter; // javac's enter phase
@@ -66,7 +66,7 @@
private AptEnv(Context context) {
context.put(aptEnvKey, this);
- names = Name.Table.instance(context);
+ names = Names.instance(context);
symtab = Symtab.instance(context);
jctypes = Types.instance(context);
enter = Enter.instance(context);
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Attribute.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Attribute.java Tue Sep 16 18:35:18 2008 -0700
@@ -166,7 +166,7 @@
first = false;
Name name = value.fst.name;
- if (len > 1 || name != name.table.value) {
+ if (len > 1 || name != name.table.names.value) {
buf.append(name);
buf.append('=');
}
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java Tue Sep 16 18:35:18 2008 -0700
@@ -145,7 +145,7 @@
assert shared == 0;
if (table != next.table) return next;
while (elems != null) {
- int hash = elems.sym.name.index & hashMask;
+ int hash = elems.sym.name.hashCode() & hashMask;
Entry e = table[hash];
assert e == elems : elems.sym;
table[hash] = elems.shadowed;
@@ -180,7 +180,7 @@
private void copy(Entry e) {
if (e.sym != null) {
copy(e.shadowed);
- int hash = e.sym.name.index & hashMask;
+ int hash = e.sym.name.hashCode() & hashMask;
e.shadowed = table[hash];
table[hash] = e;
}
@@ -206,7 +206,7 @@
assert shared == 0;
// Temporarily disabled (bug 6460352):
// if (nelems * 3 >= hashMask * 2) dble();
- int hash = sym.name.index & hashMask;
+ int hash = sym.name.hashCode() & hashMask;
Entry e = makeEntry(sym, table[hash], elems, s, origin);
table[hash] = e;
elems = e;
@@ -227,9 +227,9 @@
if (e.scope == null) return;
// remove e from table and shadowed list;
- Entry te = table[sym.name.index & hashMask];
+ Entry te = table[sym.name.hashCode() & hashMask];
if (te == e)
- table[sym.name.index & hashMask] = e.shadowed;
+ table[sym.name.hashCode() & hashMask] = e.shadowed;
else while (true) {
if (te.shadowed == e) {
te.shadowed = e.shadowed;
@@ -279,7 +279,7 @@
* for regular entries.
*/
public Entry lookup(Name name) {
- Entry e = table[name.index & hashMask];
+ Entry e = table[name.hashCode() & hashMask];
while (e.scope != null && e.sym.name != name)
e = e.shadowed;
return e;
@@ -400,7 +400,7 @@
}
public Entry lookup(Name name) {
- Entry e = table[name.index & hashMask];
+ Entry e = table[name.hashCode() & hashMask];
while (e.scope != null &&
(e.sym.name != name ||
/* Since an inner class will show up in package and
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java Tue Sep 16 18:35:18 2008 -0700
@@ -146,14 +146,14 @@
* the default package; otherwise, the owner symbol is returned
*/
public Symbol location() {
- if (owner.name == null || (owner.name.len == 0 && owner.kind != PCK)) {
+ if (owner.name == null || (owner.name.isEmpty() && owner.kind != PCK)) {
return null;
}
return owner;
}
public Symbol location(Type site, Types types) {
- if (owner.name == null || owner.name.len == 0) {
+ if (owner.name == null || owner.name.isEmpty()) {
return location();
}
if (owner.type.tag == CLASS) {
@@ -177,7 +177,7 @@
*/
public Type externalType(Types types) {
Type t = erasure(types);
- if (name == name.table.init && owner.hasOuterInstance()) {
+ if (name == name.table.names.init && owner.hasOuterInstance()) {
Type outerThisType = types.erasure(owner.type.getEnclosingType());
return new MethodType(t.getParameterTypes().prepend(outerThisType),
t.getReturnType(),
@@ -212,7 +212,7 @@
/** Is this symbol a constructor?
*/
public boolean isConstructor() {
- return name == name.table.init;
+ return name == name.table.names.init;
}
/** The fully qualified name of this symbol.
@@ -501,7 +501,7 @@
|| (owner.kind == TYP && owner.type.tag == TYPEVAR)
)) return name;
Name prefix = owner.getQualifiedName();
- if (prefix == null || prefix == prefix.table.empty)
+ if (prefix == null || prefix == prefix.table.names.empty)
return name;
else return prefix.append('.', name);
}
@@ -516,7 +516,7 @@
) return name;
char sep = owner.kind == TYP ? '$' : '.';
Name prefix = owner.flatName();
- if (prefix == null || prefix == prefix.table.empty)
+ if (prefix == null || prefix == prefix.table.names.empty)
return name;
else return prefix.append(sep, name);
}
@@ -737,7 +737,7 @@
}
public String className() {
- if (name.len == 0)
+ if (name.isEmpty())
return
Log.getLocalizedString("anonymous.class", flatname);
else
@@ -1011,7 +1011,7 @@
if ((flags() & BLOCK) != 0) {
return owner.name.toString();
} else {
- String s = (name == name.table.init)
+ String s = (name == name.table.names.init)
? owner.name.toString()
: name.toString();
if (type != null) {
@@ -1208,9 +1208,9 @@
}
public ElementKind getKind() {
- if (name == name.table.init)
+ if (name == name.table.names.init)
return ElementKind.CONSTRUCTOR;
- else if (name == name.table.clinit)
+ else if (name == name.table.names.clinit)
return ElementKind.STATIC_INIT;
else
return ElementKind.METHOD;
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java Tue Sep 16 18:35:18 2008 -0700
@@ -73,7 +73,7 @@
public final Type botType = new BottomType();
public final JCNoType voidType = new JCNoType(TypeTags.VOID);
- private final Name.Table names;
+ private final Names names;
private final ClassReader reader;
private final Target target;
@@ -328,7 +328,7 @@
protected Symtab(Context context) throws CompletionFailure {
context.put(symtabKey, this);
- names = Name.Table.instance(context);
+ names = Names.instance(context);
target = Target.instance(context);
// Create the unknown type
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Type.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Type.java Tue Sep 16 18:35:18 2008 -0700
@@ -599,14 +599,14 @@
}
//where
private String className(Symbol sym, boolean longform) {
- if (sym.name.len == 0 && (sym.flags() & COMPOUND) != 0) {
+ if (sym.name.isEmpty() && (sym.flags() & COMPOUND) != 0) {
StringBuffer s = new StringBuffer(supertype_field.toString());
for (List<Type> is=interfaces_field; is.nonEmpty(); is = is.tail) {
s.append("&");
s.append(is.head.toString());
}
return s.toString();
- } else if (sym.name.len == 0) {
+ } else if (sym.name.isEmpty()) {
String s;
ClassType norm = (ClassType) tsym.type;
if (norm == null) {
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java Tue Sep 16 18:35:18 2008 -0700
@@ -67,7 +67,7 @@
new Context.Key<Types>();
final Symtab syms;
- final Name.Table names;
+ final Names names;
final boolean allowBoxing;
final ClassReader reader;
final Source source;
@@ -86,7 +86,7 @@
protected Types(Context context) {
context.put(typesKey, this);
syms = Symtab.instance(context);
- names = Name.Table.instance(context);
+ names = Names.instance(context);
allowBoxing = Source.instance(context).allowBoxing();
reader = ClassReader.instance(context);
source = Source.instance(context);
@@ -2213,7 +2213,7 @@
ClassType cls = (ClassType)t;
if (cls.rank_field < 0) {
Name fullname = cls.tsym.getQualifiedName();
- if (fullname == fullname.table.java_lang_Object)
+ if (fullname == names.java_lang_Object)
cls.rank_field = 0;
else {
int r = rank(supertype(cls));
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Annotate.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Annotate.java Tue Sep 16 18:35:18 2008 -0700
@@ -55,7 +55,7 @@
final TreeMaker make;
final Log log;
final Symtab syms;
- final Name.Table names;
+ final Names names;
final Resolve rs;
final Types types;
final ConstFold cfolder;
@@ -67,7 +67,7 @@
make = TreeMaker.instance(context);
log = Log.instance(context);
syms = Symtab.instance(context);
- names = Name.Table.instance(context);
+ names = Names.instance(context);
rs = Resolve.instance(context);
types = Types.instance(context);
cfolder = ConstFold.instance(context);
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Tue Sep 16 18:35:18 2008 -0700
@@ -68,7 +68,7 @@
protected static final Context.Key<Attr> attrKey =
new Context.Key<Attr>();
- final Name.Table names;
+ final Names names;
final Log log;
final Symtab syms;
final Resolve rs;
@@ -92,7 +92,7 @@
protected Attr(Context context) {
context.put(attrKey, this);
- names = Name.Table.instance(context);
+ names = Names.instance(context);
log = Log.instance(context);
syms = Symtab.instance(context);
rs = Resolve.instance(context);
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Tue Sep 16 18:35:18 2008 -0700
@@ -56,7 +56,7 @@
protected static final Context.Key<Check> checkKey =
new Context.Key<Check>();
- private final Name.Table names;
+ private final Names names;
private final Log log;
private final Symtab syms;
private final Infer infer;
@@ -82,7 +82,7 @@
protected Check(Context context) {
context.put(checkKey, this);
- names = Name.Table.instance(context);
+ names = Names.instance(context);
log = Log.instance(context);
syms = Symtab.instance(context);
infer = Infer.instance(context);
@@ -628,7 +628,7 @@
case TYP:
if (sym.isLocal()) {
mask = LocalClassFlags;
- if (sym.name.len == 0) { // Anonymous class
+ if (sym.name.isEmpty()) { // Anonymous class
// Anonymous classes in static methods are themselves static;
// that's why we admit STATIC here.
mask |= STATIC;
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Enter.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Enter.java Tue Sep 16 18:35:18 2008 -0700
@@ -333,7 +333,7 @@
"class.public.should.be.in.file", tree.name);
}
} else {
- if (tree.name.len != 0 &&
+ if (!tree.name.isEmpty() &&
!chk.checkUniqueClassName(tree.pos(), tree.name, enclScope)) {
result = null;
return;
@@ -348,7 +348,7 @@
// We are seeing a local class.
c = reader.defineClass(tree.name, owner);
c.flatname = chk.localClassName(c);
- if (c.name.len != 0)
+ if (!c.name.isEmpty())
chk.checkTransparentClass(tree.pos(), c, env.info.scope);
}
}
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java Tue Sep 16 18:35:18 2008 -0700
@@ -177,7 +177,7 @@
protected static final Context.Key<Flow> flowKey =
new Context.Key<Flow>();
- private final Name.Table names;
+ private final Names names;
private final Log log;
private final Symtab syms;
private final Types types;
@@ -195,7 +195,7 @@
protected Flow(Context context) {
context.put(flowKey, this);
- names = Name.Table.instance(context);
+ names = Names.instance(context);
log = Log.instance(context);
syms = Symtab.instance(context);
types = Types.instance(context);
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java Tue Sep 16 18:35:18 2008 -0700
@@ -64,7 +64,7 @@
return instance;
}
- private Name.Table names;
+ private Names names;
private Log log;
private Symtab syms;
private Resolve rs;
@@ -85,7 +85,7 @@
protected Lower(Context context) {
context.put(lowerKey, this);
- names = Name.Table.instance(context);
+ names = Names.instance(context);
log = Log.instance(context);
syms = Symtab.instance(context);
rs = Resolve.instance(context);
@@ -1830,7 +1830,7 @@
}
VarSymbol var =
new VarSymbol(FINAL|SYNTHETIC,
- Name.fromString(names,
+ names.fromString(
target.syntheticNameChar()
+ "" + rval.hashCode()),
type,
@@ -3338,7 +3338,7 @@
ListBuffer<JCStatement> blockStatements = new ListBuffer<JCStatement>();
JCModifiers mod1 = make.Modifiers(0L);
- Name oName = Name.fromString(names, "o");
+ Name oName = names.fromString("o");
JCVariableDecl par1 = make.Param(oName, cdef.type, compareToSym);
JCIdent paramId1 = make.Ident(names.java_lang_Object);
@@ -3352,7 +3352,7 @@
JCTypeCast cast = make.TypeCast(castTargetIdent, par1UsageId);
cast.setType(castTargetIdent.type);
- Name otherName = Name.fromString(names, "other");
+ Name otherName = names.fromString("other");
VarSymbol otherVarSym = new VarSymbol(mod1.flags,
otherName,
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Tue Sep 16 18:35:18 2008 -0700
@@ -61,7 +61,7 @@
*/
final static boolean checkClash = true;
- private final Name.Table names;
+ private final Names names;
private final Enter enter;
private final Log log;
private final Check chk;
@@ -86,7 +86,7 @@
protected MemberEnter(Context context) {
context.put(memberEnterKey, this);
- names = Name.Table.instance(context);
+ names = Names.instance(context);
enter = Enter.instance(context);
log = Log.instance(context);
chk = Check.instance(context);
@@ -919,7 +919,7 @@
List<Type> thrown = List.nil();
long ctorFlags = 0;
boolean based = false;
- if (c.name.len == 0) {
+ if (c.name.isEmpty()) {
JCNewClass nc = (JCNewClass)env.next.tree;
if (nc.constructor != null) {
Type superConstrType = types.memberType(c.type,
@@ -1068,7 +1068,7 @@
flags = (flags & ~AccessFlags) | PRIVATE | GENERATEDCONSTR;
} else
flags |= (c.flags() & AccessFlags) | GENERATEDCONSTR;
- if (c.name.len == 0) flags |= ANONCONSTR;
+ if (c.name.isEmpty()) flags |= ANONCONSTR;
JCTree result = make.MethodDef(
make.Modifiers(flags),
names.init,
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java Tue Sep 16 18:35:18 2008 -0700
@@ -51,7 +51,7 @@
protected static final Context.Key<Resolve> resolveKey =
new Context.Key<Resolve>();
- Name.Table names;
+ Names names;
Log log;
Symtab syms;
Check chk;
@@ -86,7 +86,7 @@
typeNotFound = new
ResolveError(ABSENT_TYP, syms.errSymbol, "type not found");
- names = Name.Table.instance(context);
+ names = Names.instance(context);
log = Log.instance(context);
chk = Check.instance(context);
infer = Infer.instance(context);
@@ -1538,7 +1538,7 @@
argtypes = List.nil();
if (typeargtypes == null)
typeargtypes = List.nil();
- if (name != name.table.error) {
+ if (name != names.error) {
KindName kindname = absentKind(kind);
Name idname = name;
if (kind >= WRONG_MTHS && kind <= ABSENT_MTH) {
@@ -1547,7 +1547,7 @@
name, argtypes);
return;
}
- if (name == name.table.init) {
+ if (name == names.init) {
kindname = KindName.CONSTRUCTOR;
idname = site.tsym.name;
}
@@ -1563,7 +1563,7 @@
kindName(ws.owner),
ws.owner.type,
explanation);
- } else if (site.tsym.name.len != 0) {
+ } else if (!site.tsym.name.isEmpty()) {
if (site.tsym.kind == PCK && !site.tsym.exists())
log.error(pos, "doesnt.exist", site.tsym);
else {
@@ -1601,9 +1601,9 @@
*/
boolean isOperator(Name name) {
int i = 0;
- while (i < name.len &&
- "+-~!*/%&|^<>=".indexOf(name.byteAt(i)) >= 0) i++;
- return i > 0 && i == name.len;
+ while (i < name.getByteLength() &&
+ "+-~!*/%&|^<>=".indexOf(name.getByteAt(i)) >= 0) i++;
+ return i > 0 && i == name.getByteLength();
}
}
@@ -1639,7 +1639,7 @@
void report(Log log, DiagnosticPosition pos, Type site, Name name,
List<Type> argtypes, List<Type> typeargtypes) {
if (sym.owner.type.tag != ERROR) {
- if (sym.name == sym.name.table.init && sym.owner != site.tsym)
+ if (sym.name == names.init && sym.owner != site.tsym)
new ResolveError(ABSENT_MTH, sym.owner, "absent method " + sym).report(
log, pos, site, name, argtypes, typeargtypes);
if ((sym.flags() & PUBLIC) != 0
@@ -1723,7 +1723,7 @@
else break;
}
Name sname = pair.sym1.name;
- if (sname == sname.table.init) sname = pair.sym1.owner.name;
+ if (sname == names.init) sname = pair.sym1.owner.name;
log.error(pos, "ref.ambiguous", sname,
kindName(pair.sym1),
pair.sym1,
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Tue Sep 16 18:35:18 2008 -0700
@@ -59,7 +59,7 @@
return instance;
}
- private Name.Table names;
+ private Names names;
private Log log;
private Symtab syms;
private TreeMaker make;
@@ -77,7 +77,7 @@
protected TransTypes(Context context) {
context.put(transTypesKey, this);
- names = Name.Table.instance(context);
+ names = Names.instance(context);
log = Log.instance(context);
syms = Symtab.instance(context);
enter = Enter.instance(context);
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassFile.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassFile.java Tue Sep 16 18:35:18 2008 -0700
@@ -108,7 +108,7 @@
* converting '/' to '.'.
*/
public static byte[] internalize(Name name) {
- return internalize(name.table.names, name.index, name.len);
+ return internalize(name.getByteArray(), name.getByteOffset(), name.getByteLength());
}
/** Return external representation of buf[offset..offset+len-1],
@@ -128,7 +128,7 @@
* converting '/' to '.'.
*/
public static byte[] externalize(Name name) {
- return externalize(name.table.names, name.index, name.len);
+ return externalize(name.getByteArray(), name.getByteOffset(), name.getByteLength());
}
/************************************************************************
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Tue Sep 16 18:35:18 2008 -0700
@@ -122,7 +122,7 @@
Types types;
/** The name table. */
- final Name.Table names;
+ final Names names;
/** Force a completion failure on this name
*/
@@ -220,7 +220,7 @@
protected ClassReader(Context context, boolean definitive) {
if (definitive) context.put(classReaderKey, this);
- names = Name.Table.instance(context);
+ names = Names.instance(context);
syms = Symtab.instance(context);
types = Types.instance(context);
fileManager = context.get(JavaFileManager.class);
@@ -516,14 +516,6 @@
int siglimit;
boolean sigEnterPhase = false;
- /** Convert signature to type, where signature is a name.
- */
- Type sigToType(Name sig) {
- return sig == null
- ? null
- : sigToType(sig.table.names, sig.index, sig.len);
- }
-
/** Convert signature to type, where signature is a byte array segment.
*/
Type sigToType(byte[] sig, int offset, int len) {
@@ -741,12 +733,6 @@
return head.tail;
}
- /** Convert signature to type parameters, where signature is a name.
- */
- List<Type> sigToTypeParams(Name name) {
- return sigToTypeParams(name.table.names, name.index, name.len);
- }
-
/** Convert signature to type parameters, where signature is a byte
* array segment.
*/
@@ -952,7 +938,7 @@
self.name = simpleBinaryName(self.flatname, c.flatname) ;
self.owner = m != null ? m : c;
- if (self.name.len == 0)
+ if (self.name.isEmpty())
self.fullname = null;
else
self.fullname = ClassSymbol.formFullName(self.name, self.owner);
@@ -1500,7 +1486,7 @@
// Sometimes anonymous classes don't have an outer
// instance, however, there is no reliable way to tell so
// we never strip this$n
- if (currentOwner.name.len != 0)
+ if (!currentOwner.name.isEmpty())
type = new MethodType(type.getParameterTypes().tail,
type.getReturnType(),
type.getThrownTypes(),
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Tue Sep 16 18:35:18 2008 -0700
@@ -26,7 +26,6 @@
package com.sun.tools.javac.jvm;
import java.io.*;
-import java.util.*;
import java.util.Set;
import java.util.HashSet;
@@ -140,7 +139,7 @@
private final Log log;
/** The name table. */
- private final Name.Table names;
+ private final Names names;
/** Access to files. */
private final JavaFileManager fileManager;
@@ -166,7 +165,7 @@
context.put(classWriterKey, this);
log = Log.instance(context);
- names = Name.Table.instance(context);
+ names = Names.instance(context);
syms = Symtab.instance(context);
options = Options.instance(context);
target = Target.instance(context);
@@ -375,9 +374,7 @@
sigbuf.appendByte('.');
assert c.flatname.startsWith(c.owner.enclClass().flatname);
sigbuf.appendName(rawOuter
- ? c.flatname.subName(c.owner.enclClass()
- .flatname.len+1,
- c.flatname.len)
+ ? c.flatname.subName(c.owner.enclClass().flatname.getByteLength()+1,c.flatname.getByteLength())
: c.name);
} else {
sigbuf.appendBytes(externalize(c.flatname));
@@ -542,7 +539,7 @@
Name fieldName(Symbol sym) {
if (scramble && (sym.flags() & PRIVATE) != 0 ||
scrambleAll && (sym.flags() & (PROTECTED | PUBLIC)) == 0)
- return names.fromString("_$" + sym.name.index);
+ return names.fromString("_$" + sym.name.getIndex());
else
return sym.name;
}
@@ -917,7 +914,7 @@
databuf.appendChar(
inner.owner.kind == TYP ? pool.get(inner.owner) : 0);
databuf.appendChar(
- inner.name.len != 0 ? pool.get(inner.name) : 0);
+ !inner.name.isEmpty() ? pool.get(inner.name) : 0);
databuf.appendChar(flags);
}
endAttr(alenIdx);
@@ -1457,7 +1454,7 @@
try {
writeClassFile(out, c);
if (verbose)
- log.errWriter.println(log.getLocalizedString("verbose.wrote.file", outFile));
+ log.errWriter.println(Log.getLocalizedString("verbose.wrote.file", outFile));
out.close();
out = null;
} finally {
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java Tue Sep 16 18:35:18 2008 -0700
@@ -52,16 +52,16 @@
public enum StackMapFormat {
NONE,
CLDC {
- Name getAttributeName(Name.Table names) {
+ Name getAttributeName(Names names) {
return names.StackMap;
}
},
JSR202 {
- Name getAttributeName(Name.Table names) {
+ Name getAttributeName(Names names) {
return names.StackMapTable;
}
};
- Name getAttributeName(Name.Table names) {
+ Name getAttributeName(Names names) {
return names.empty;
}
}
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java Tue Sep 16 18:35:18 2008 -0700
@@ -61,7 +61,7 @@
private final Check chk;
private final Resolve rs;
private final TreeMaker make;
- private final Name.Table names;
+ private final Names names;
private final Target target;
private final Type stringBufferType;
private final Map<Type,Symbol> stringBufferAppend;
@@ -92,7 +92,7 @@
protected Gen(Context context) {
context.put(genKey, this);
- names = Name.Table.instance(context);
+ names = Names.instance(context);
log = Log.instance(context);
syms = Symtab.instance(context);
chk = Check.instance(context);
@@ -365,7 +365,7 @@
private boolean isOddAccessName(Name name) {
return
name.startsWith(accessDollar) &&
- (name.byteAt(name.len - 1) & 1) == 1;
+ (name.getByteAt(name.getByteLength() - 1) & 1) == 1;
}
/* ************************************************************************
--- a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Tue Sep 16 18:35:18 2008 -0700
@@ -236,7 +236,7 @@
/** The name table.
*/
- protected Name.Table names;
+ protected Names names;
/** The attributor.
*/
@@ -310,7 +310,7 @@
if (context.get(JavaFileManager.class) == null)
JavacFileManager.preRegister(context);
- names = Name.Table.instance(context);
+ names = Names.instance(context);
log = Log.instance(context);
diagFactory = JCDiagnostic.Factory.instance(context);
reader = ClassReader.instance(context);
@@ -1411,7 +1411,7 @@
close(true);
}
- private void close(boolean disposeNames) {
+ public void close(boolean disposeNames) {
rootClasses = null;
reader = null;
make = null;
--- a/langtools/src/share/classes/com/sun/tools/javac/model/AnnotationProxyMaker.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/model/AnnotationProxyMaker.java Tue Sep 16 18:35:18 2008 -0700
@@ -181,7 +181,7 @@
public void visitArray(Attribute.Array a) {
Name elemName = ((ArrayType) a.type).elemtype.tsym.name;
- if (elemName == elemName.table.java_lang_Class) { // Class[]
+ if (elemName == elemName.table.names.java_lang_Class) { // Class[]
// Construct a proxy for a MirroredTypesException
List<TypeMirror> elems = List.nil();
for (Attribute value : a.values) {
--- a/langtools/src/share/classes/com/sun/tools/javac/model/JavacElements.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/model/JavacElements.java Tue Sep 16 18:35:18 2008 -0700
@@ -39,15 +39,14 @@
import com.sun.tools.javac.comp.AttrContext;
import com.sun.tools.javac.comp.Enter;
import com.sun.tools.javac.comp.Env;
-import com.sun.tools.javac.jvm.ClassReader;
import com.sun.tools.javac.main.JavaCompiler;
import com.sun.tools.javac.processing.PrintingProcessor;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.*;
import com.sun.tools.javac.tree.TreeInfo;
import com.sun.tools.javac.tree.TreeScanner;
+import com.sun.tools.javac.util.*;
import com.sun.tools.javac.util.Name;
-import com.sun.tools.javac.util.*;
import static javax.lang.model.util.ElementFilter.methodsIn;
@@ -63,10 +62,9 @@
private JavaCompiler javaCompiler;
private Symtab syms;
- private Name.Table names;
+ private Names names;
private Types types;
private Enter enter;
- private ClassReader reader;
private static final Context.Key<JavacElements> KEY =
new Context.Key<JavacElements>();
@@ -96,10 +94,9 @@
public void setContext(Context context) {
javaCompiler = JavaCompiler.instance(context);
syms = Symtab.instance(context);
- names = Name.Table.instance(context);
+ names = Names.instance(context);
types = Types.instance(context);
enter = Enter.instance(context);
- reader = ClassReader.instance(context);
}
@@ -126,7 +123,7 @@
Class<A> annoType) {
boolean inherited = annoType.isAnnotationPresent(Inherited.class);
A result = null;
- while (annotated.name != annotated.name.table.java_lang_Object) {
+ while (annotated.name != annotated.name.table.names.java_lang_Object) {
result = getAnnotation((Symbol)annotated, annoType);
if (result != null || !inherited)
break;
@@ -568,7 +565,7 @@
}
public Name getName(CharSequence cs) {
- return Name.fromString(names, cs.toString());
+ return names.fromString(cs.toString());
}
/**
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Tue Sep 16 18:35:18 2008 -0700
@@ -73,7 +73,7 @@
private Source source;
/** The name table. */
- private Name.Table names;
+ private Names names;
/** Construct a parser from a given scanner, tree factory and log.
*/
@@ -549,7 +549,7 @@
String strval(Name prefix) {
String s = S.stringVal();
- return (prefix.len == 0) ? s : prefix + s;
+ return prefix.isEmpty() ? s : prefix + s;
}
/** terms can be either expressions or types.
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/Keywords.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/Keywords.java Tue Sep 16 18:35:18 2008 -0700
@@ -28,6 +28,7 @@
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.Log;
import com.sun.tools.javac.util.Name;
+import com.sun.tools.javac.util.Names;
import static com.sun.tools.javac.parser.Token.*;
@@ -51,12 +52,12 @@
}
private final Log log;
- private final Name.Table names;
+ private final Names names;
protected Keywords(Context context) {
context.put(keywordsKey, this);
log = Log.instance(context);
- names = Name.Table.instance(context);
+ names = Names.instance(context);
for (Token t : Token.values()) {
if (t.name != null)
@@ -69,13 +70,13 @@
for (int i = 0; i <= maxKey; i++) key[i] = IDENTIFIER;
for (Token t : Token.values()) {
if (t.name != null)
- key[tokenName[t.ordinal()].index] = t;
+ key[tokenName[t.ordinal()].getIndex()] = t;
}
}
public Token key(Name name) {
- return (name.index > maxKey) ? IDENTIFIER : key[name.index];
+ return (name.getIndex() > maxKey) ? IDENTIFIER : key[name.getIndex()];
}
/**
@@ -94,6 +95,6 @@
private void enterKeyword(String s, Token token) {
Name n = names.fromString(s);
tokenName[token.ordinal()] = n;
- if (n.index > maxKey) maxKey = n.index;
+ if (n.getIndex() > maxKey) maxKey = n.getIndex();
}
}
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/ParserFactory.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/ParserFactory.java Tue Sep 16 18:35:18 2008 -0700
@@ -29,7 +29,7 @@
import com.sun.tools.javac.tree.TreeMaker;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.Log;
-import com.sun.tools.javac.util.Name;
+import com.sun.tools.javac.util.Names;
import com.sun.tools.javac.util.Options;
/**
@@ -52,7 +52,7 @@
final Log log;
final Keywords keywords;
final Source source;
- final Name.Table names;
+ final Names names;
final Options options;
final Scanner.Factory scannerFactory;
@@ -61,7 +61,7 @@
context.put(parserFactoryKey, this);
this.F = TreeMaker.instance(context);
this.log = Log.instance(context);
- this.names = Name.Table.instance(context);
+ this.names = Names.instance(context);
this.keywords = Keywords.instance(context);
this.source = Source.instance(context);
this.options = Options.instance(context);
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/Scanner.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/Scanner.java Tue Sep 16 18:35:18 2008 -0700
@@ -62,7 +62,7 @@
}
final Log log;
- final Name.Table names;
+ final Names names;
final Source source;
final Keywords keywords;
@@ -70,7 +70,7 @@
protected Factory(Context context) {
context.put(scannerFactoryKey, this);
this.log = Log.instance(context);
- this.names = Name.Table.instance(context);
+ this.names = Names.instance(context);
this.source = Source.instance(context);
this.keywords = Keywords.instance(context);
}
@@ -155,7 +155,7 @@
private final Log log;
/** The name table. */
- private final Name.Table names;
+ private final Names names;
/** The keyword table. */
private final Keywords keywords;
--- a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Tue Sep 16 18:35:18 2008 -0700
@@ -70,6 +70,7 @@
import com.sun.tools.javac.util.ListBuffer;
import com.sun.tools.javac.util.Log;
import com.sun.tools.javac.util.Name;
+import com.sun.tools.javac.util.Names;
import com.sun.tools.javac.util.Options;
import static javax.tools.StandardLocation.*;
@@ -831,7 +832,7 @@
topLevelClasses = List.nil();
packageInfoFiles = List.nil();
- compiler.close();
+ compiler.close(false);
currentContext = contextForNextRound(currentContext, true);
JavaFileManager fileManager = currentContext.get(JavaFileManager.class);
@@ -879,7 +880,7 @@
}
runLastRound(xout, roundNumber, errorStatus, taskListener);
- compiler.close();
+ compiler.close(false);
currentContext = contextForNextRound(currentContext, true);
compiler = JavaCompiler.instance(currentContext);
filer.newRound(currentContext, true);
@@ -913,7 +914,7 @@
} else if (procOnly) {
compiler.todo.clear();
} else { // Final compilation
- compiler.close();
+ compiler.close(false);
currentContext = contextForNextRound(currentContext, true);
compiler = JavaCompiler.instance(currentContext);
@@ -987,7 +988,7 @@
private ListBuffer<ClassSymbol> enterNewClassFiles(Context currentContext) {
ClassReader reader = ClassReader.instance(currentContext);
- Name.Table names = Name.Table.instance(currentContext);
+ Names names = Names.instance(currentContext);
ListBuffer<ClassSymbol> list = new ListBuffer<ClassSymbol>();
for (Map.Entry<String,JavaFileObject> entry : filer.getGeneratedClasses().entrySet()) {
@@ -1047,9 +1048,9 @@
next.put(Log.outKey, out);
if (shareNames) {
- Name.Table names = Name.Table.instance(context);
+ Names names = Names.instance(context);
assert names != null;
- next.put(Name.Table.namesKey, names);
+ next.put(Names.namesKey, names);
}
DiagnosticListener dl = context.get(DiagnosticListener.class);
@@ -1067,9 +1068,9 @@
((JavacFileManager)jfm).setContext(next);
}
- Name.Table names = Name.Table.instance(context);
+ Names names = Names.instance(context);
assert names != null;
- next.put(Name.Table.namesKey, names);
+ next.put(Names.namesKey, names);
Keywords keywords = Keywords.instance(context);
assert(keywords != null);
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java Tue Sep 16 18:35:18 2008 -0700
@@ -336,7 +336,7 @@
if (l.head.getTag() == JCTree.IMPORT) {
JCImport imp = (JCImport)l.head;
Name name = TreeInfo.name(imp.qualid);
- if (name == name.table.asterisk ||
+ if (name == name.table.names.asterisk ||
cdef == null ||
isUsed(TreeInfo.symbol(imp.qualid), cdef)) {
if (firstImport) {
@@ -439,14 +439,14 @@
public void visitMethodDef(JCMethodDecl tree) {
try {
// when producing source output, omit anonymous constructors
- if (tree.name == tree.name.table.init &&
+ if (tree.name == tree.name.table.names.init &&
enclClassName == null &&
sourceOutput) return;
println(); align();
printDocComment(tree);
printExpr(tree.mods);
printTypeParameters(tree.typarams);
- if (tree.name == tree.name.table.init) {
+ if (tree.name == tree.name.table.names.init) {
print(enclClassName != null ? enclClassName : tree.name);
} else {
printExpr(tree.restype);
@@ -835,8 +835,8 @@
Name enclClassNamePrev = enclClassName;
enclClassName =
tree.def.name != null ? tree.def.name :
- tree.type != null && tree.type.tsym.name != tree.type.tsym.name.table.empty ? tree.type.tsym.name :
- null;
+ tree.type != null && tree.type.tsym.name != tree.type.tsym.name.table.names.empty
+ ? tree.type.tsym.name : null;
if ((tree.def.mods.flags & Flags.ENUM) != 0) print("/*enum*/");
printBlock(tree.def.defs);
enclClassName = enclClassNamePrev;
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Tue Sep 16 18:35:18 2008 -0700
@@ -61,7 +61,7 @@
private TreeInfo(Context context) {
context.put(treeInfoKey, this);
- Name.Table names = Name.Table.instance(context);
+ Names names = Names.instance(context);
opname[JCTree.POS - JCTree.POS] = names.fromString("+");
opname[JCTree.NEG - JCTree.POS] = names.hyphen;
opname[JCTree.NOT - JCTree.POS] = names.fromString("!");
@@ -104,7 +104,7 @@
public static boolean isConstructor(JCTree tree) {
if (tree.getTag() == JCTree.METHODDEF) {
Name name = ((JCMethodDecl) tree).name;
- return name == name.table.init;
+ return name == name.table.names.init;
} else {
return false;
}
@@ -130,7 +130,7 @@
if (select.sym != null &&
(select.sym.flags() & SYNTHETIC) != 0) {
Name selected = name(select.selected);
- if (selected != null && selected == selected.table._this)
+ if (selected != null && selected == selected.table.names._this)
return true;
}
}
@@ -157,7 +157,7 @@
public static boolean isSelfCall(JCTree tree) {
Name name = calledMethodName(tree);
if (name != null) {
- Name.Table names = name.table;
+ Names names = name.table.names;
return name==names._this || name==names._super;
} else {
return false;
@@ -169,7 +169,7 @@
public static boolean isSuperCall(JCTree tree) {
Name name = calledMethodName(tree);
if (name != null) {
- Name.Table names = name.table;
+ Names names = name.table.names;
return name==names._super;
} else {
return false;
@@ -183,14 +183,14 @@
JCMethodInvocation app = firstConstructorCall(tree);
if (app == null) return false;
Name meth = name(app.meth);
- return meth == null || meth != meth.table._this;
+ return meth == null || meth != meth.table.names._this;
}
/** Return the first call in a constructor definition. */
public static JCMethodInvocation firstConstructorCall(JCTree tree) {
if (tree.getTag() != JCTree.METHODDEF) return null;
JCMethodDecl md = (JCMethodDecl) tree;
- Name.Table names = md.name.table;
+ Names names = md.name.table.names;
if (md.name != names.init) return null;
if (md.body == null) return null;
List<JCStatement> stats = md.body.stats;
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java Tue Sep 16 18:35:18 2008 -0700
@@ -67,7 +67,7 @@
public JCCompilationUnit toplevel;
/** The current name table. */
- Name.Table names;
+ Names names;
Types types;
@@ -80,14 +80,14 @@
context.put(treeMakerKey, this);
this.pos = Position.NOPOS;
this.toplevel = null;
- this.names = Name.Table.instance(context);
+ this.names = Names.instance(context);
this.syms = Symtab.instance(context);
this.types = Types.instance(context);
}
/** Create a tree maker with a given toplevel and FIRSTPOS as initial position.
*/
- TreeMaker(JCCompilationUnit toplevel, Name.Table names, Types types, Symtab syms) {
+ TreeMaker(JCCompilationUnit toplevel, Names names, Types types, Symtab syms) {
this.pos = Position.FIRSTPOS;
this.toplevel = toplevel;
this.names = names;
--- a/langtools/src/share/classes/com/sun/tools/javac/util/ByteBuffer.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/ByteBuffer.java Tue Sep 16 18:35:18 2008 -0700
@@ -150,7 +150,7 @@
/** Append a name.
*/
public void appendName(Name name) {
- appendBytes(name.table.names, name.index, name.len);
+ appendBytes(name.getByteArray(), name.getByteOffset(), name.getByteLength());
}
/** Reset to zero length.
@@ -161,7 +161,7 @@
/** Convert contents to name.
*/
- public Name toName(Name.Table names) {
+ public Name toName(Names names) {
return names.fromUtf(elems, 0, length);
}
}
--- a/langtools/src/share/classes/com/sun/tools/javac/util/Convert.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/Convert.java Tue Sep 16 18:35:18 2008 -0700
@@ -289,7 +289,7 @@
*/
public static Name shortName(Name classname) {
return classname.subName(
- classname.lastIndexOf((byte)'.') + 1, classname.len);
+ classname.lastIndexOf((byte)'.') + 1, classname.getByteLength());
}
public static String shortName(String classname) {
--- a/langtools/src/share/classes/com/sun/tools/javac/util/Name.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/Name.java Tue Sep 16 18:35:18 2008 -0700
@@ -25,246 +25,111 @@
package com.sun.tools.javac.util;
-import java.lang.ref.SoftReference;
-
-
-/** An abstraction for internal compiler strings. For efficiency reasons,
- * GJC uses hashed strings that are stored in a common large buffer.
- *
- * <p>Names represent unique hashable strings. Two names are equal
- * if their indices are equal. Utf8 representation is used
- * for storing names internally.
+/** An abstraction for internal compiler strings. They are stored in
+ * Utf8 format. Names are stored in a Name.Table, and are unique within
+ * that table.
*
* <p><b>This is NOT part of any API supported by Sun Microsystems. If
* you write code that depends on this, you do so at your own risk.
* This code and its internal interfaces are subject to change or
* deletion without notice.</b>
*/
-public class Name implements javax.lang.model.element.Name {
-
- /** The table structure where the name is stored
- */
- public Table table;
-
- /** The index where the bytes of this name are stored in the global name
- * buffer `names'.
- */
- public int index;
-
- /** The number of bytes in this name.
- */
- public int len;
-
- /** The next name occupying the same hash bucket.
- */
- Name next;
-
- /** The hashcode of a name.
- */
- private static int hashValue(byte cs[], int start, int len) {
- int h = 0;
- int off = start;
-
- for (int i = 0; i < len; i++) {
- h = (h << 5) - h + cs[off++];
- }
- return h;
- }
+public abstract class Name implements javax.lang.model.element.Name {
- /** Is (the utf8 representation of) name equal to
- * cs[start..start+len-1]?
- */
- private static boolean equals(byte[] names, int index,
- byte cs[], int start, int len) {
- int i = 0;
- while (i < len && names[index + i] == cs[start + i]) i++;
- return i == len;
- }
+ public final Table table;
- /** Create a name from the bytes in cs[start..start+len-1].
- * Assume that bytes are in utf8 format.
- */
- public static Name fromUtf(Table table, byte cs[], int start, int len) {
- int h = hashValue(cs, start, len) & table.hashMask;
- Name n = table.hashes[h];
- byte[] names = table.names;
- while (n != null &&
- (n.len != len || !equals(names, n.index, cs, start, len)))
- n = n.next;
- if (n == null) {
- int nc = table.nc;
- while (nc + len > names.length) {
-// System.err.println("doubling name buffer of length + " + names.length + " to fit " + len + " bytes");//DEBUG
- byte[] newnames = new byte[names.length * 2];
- System.arraycopy(names, 0, newnames, 0, names.length);
- names = table.names = newnames;
- }
- System.arraycopy(cs, start, names, nc, len);
- n = new Name();
- n.table = table;
- n.index = nc;
- n.len = len;
- n.next = table.hashes[h];
- table.hashes[h] = n;
- table.nc = nc + len;
- if (len == 0) table.nc++;
- }
- return n;
- }
-
- /** Create a name from the bytes in array cs.
- * Assume that bytes are in utf8 format.
- */
- public static Name fromUtf(Table table, byte cs[]) {
- return fromUtf(table, cs, 0, cs.length);
+ protected Name(Table table) {
+ this.table = table;
}
- /** Create a name from the characters in cs[start..start+len-1].
+ /**
+ * @inheritDoc
*/
- public static Name fromChars(Table table, char[] cs, int start, int len) {
- int nc = table.nc;
- byte[] names = table.names;
- while (nc + len * 3 >= names.length) {
-// System.err.println("doubling name buffer of length " + names.length + " to fit " + len + " chars");//DEBUG
- byte[] newnames = new byte[names.length * 2];
- System.arraycopy(names, 0, newnames, 0, names.length);
- names = table.names = newnames;
- }
- int nbytes =
- Convert.chars2utf(cs, start, names, nc, len) - nc;
- int h = hashValue(names, nc, nbytes) & table.hashMask;
- Name n = table.hashes[h];
- while (n != null &&
- (n.len != nbytes ||
- !equals(names, n.index, names, nc, nbytes)))
- n = n.next;
- if (n == null) {
- n = new Name();
- n.table = table;
- n.index = nc;
- n.len = nbytes;
- n.next = table.hashes[h];
- table.hashes[h] = n;
- table.nc = nc + nbytes;
- if (nbytes == 0) table.nc++;
- }
- return n;
- }
-
- /** Create a name from the characters in string s.
- */
- public static Name fromString(Table table, String s) {
- char[] cs = s.toCharArray();
- return fromChars(table, cs, 0, cs.length);
- }
-
- /** Create a name from the characters in char sequence s.
- */
- public static Name fromString(Table table, CharSequence s) {
- return fromString(table, s.toString());
+ public boolean contentEquals(CharSequence cs) {
+ return toString().equals(cs.toString());
}
- /** Return the Utf8 representation of this name.
- */
- public byte[] toUtf() {
- byte[] bs = new byte[len];
- System.arraycopy(table.names, index, bs, 0, len);
- return bs;
- }
-
- /** Return the string representation of this name.
- */
- public String toString() {
- return Convert.utf2string(table.names, index, len);
- }
-
- /** Copy all bytes of this name to buffer cs, starting at start.
- */
- public void getBytes(byte cs[], int start) {
- System.arraycopy(table.names, index, cs, start, len);
- }
-
- /** Return the hash value of this name.
- */
- public int hashCode() {
- return index;
- }
-
- /** Is this name equal to other?
- */
- public boolean equals(Object other) {
- if (other instanceof Name)
- return
- table == ((Name)other).table && index == ((Name)other).index;
- else return false;
- }
-
- /** Compare this name to other name, yielding -1 if smaller, 0 if equal,
- * 1 if greater.
- */
- public boolean less(Name that) {
- int i = 0;
- while (i < this.len && i < that.len) {
- byte thisb = this.table.names[this.index + i];
- byte thatb = that.table.names[that.index + i];
- if (thisb < thatb) return true;
- else if (thisb > thatb) return false;
- else i++;
- }
- return this.len < that.len;
- }
-
- /** Returns the length of this name.
+ /**
+ * @inheritDoc
*/
public int length() {
return toString().length();
}
- /** Returns i'th byte of this name.
+ /**
+ * @inheritDoc
*/
- public byte byteAt(int i) {
- return table.names[index + i];
+ public char charAt(int index) {
+ return toString().charAt(index);
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public CharSequence subSequence(int start, int end) {
+ return toString().subSequence(start, end);
}
- /** Returns first occurrence of byte b in this name, len if not found.
+ /** Return the concatenation of this name and name `n'.
+ */
+ public Name append(Name n) {
+ int len = getByteLength();
+ byte[] bs = new byte[len + n.getByteLength()];
+ getBytes(bs, 0);
+ n.getBytes(bs, len);
+ return table.fromUtf(bs, 0, bs.length);
+ }
+
+ /** Return the concatenation of this name, the given ASCII
+ * character, and name `n'.
*/
- public int indexOf(byte b) {
- byte[] names = table.names;
- int i = 0;
- while (i < len && names[index + i] != b) i++;
- return i;
+ public Name append(char c, Name n) {
+ int len = getByteLength();
+ byte[] bs = new byte[len + 1 + n.getByteLength()];
+ getBytes(bs, 0);
+ bs[len] = (byte) c;
+ n.getBytes(bs, len+1);
+ return table.fromUtf(bs, 0, bs.length);
+ }
+
+ /** An arbitrary but consistent complete order among all Names.
+ */
+ public int compareTo(Name other) {
+ return other.getIndex() - this.getIndex();
+ }
+
+ /** Return true if this is the empty name.
+ */
+ public boolean isEmpty() {
+ return getByteLength() == 0;
}
/** Returns last occurrence of byte b in this name, -1 if not found.
*/
public int lastIndexOf(byte b) {
- byte[] names = table.names;
- int i = len - 1;
- while (i >= 0 && names[index + i] != b) i--;
+ byte[] bytes = getByteArray();
+ int offset = getByteOffset();
+ int i = getByteLength() - 1;
+ while (i >= 0 && bytes[offset + i] != b) i--;
return i;
}
/** Does this name start with prefix?
*/
public boolean startsWith(Name prefix) {
- int i = 0;
- while (i < prefix.len &&
- i < len &&
- table.names[index + i] == prefix.table.names[prefix.index + i])
- i++;
- return i == prefix.len;
- }
+ byte[] thisBytes = this.getByteArray();
+ int thisOffset = this.getByteOffset();
+ int thisLength = this.getByteLength();
+ byte[] prefixBytes = prefix.getByteArray();
+ int prefixOffset = prefix.getByteOffset();
+ int prefixLength = prefix.getByteLength();
- /** Does this name end with suffix?
- */
- public boolean endsWith(Name suffix) {
- int i = len - 1;
- int j = suffix.len - 1;
- while (j >= 0 && i >= 0 &&
- table.names[index + i] == suffix.table.names[suffix.index + j]) {
- i--; j--;
- }
- return j < 0;
+ int i = 0;
+ while (i < prefixLength &&
+ i < thisLength &&
+ thisBytes[thisOffset + i] == prefixBytes[prefixOffset + i])
+ i++;
+ return i == prefixLength;
}
/** Returns the sub-name starting at position start, up to and
@@ -272,382 +137,110 @@
*/
public Name subName(int start, int end) {
if (end < start) end = start;
- return fromUtf(table, table.names, index + start, end - start);
+ return table.fromUtf(getByteArray(), getByteOffset() + start, end - start);
}
- /** Replace all `from' bytes in this name with `to' bytes.
+ /** Return the string representation of this name.
*/
- public Name replace(byte from, byte to) {
- byte[] names = table.names;
- int i = 0;
- while (i < len) {
- if (names[index + i] == from) {
- byte[] bs = new byte[len];
- System.arraycopy(names, index, bs, 0, i);
- bs[i] = to;
- i++;
- while (i < len) {
- byte b = names[index + i];
- bs[i] = b == from ? to : b;
- i++;
- }
- return fromUtf(table, bs, 0, len);
- }
- i++;
- }
- return this;
+ public String toString() {
+ return Convert.utf2string(getByteArray(), getByteOffset(), getByteLength());
}
- /** Return the concatenation of this name and name `n'.
- */
- public Name append(Name n) {
- byte[] bs = new byte[len + n.len];
- getBytes(bs, 0);
- n.getBytes(bs, len);
- return fromUtf(table, bs, 0, bs.length);
- }
-
- /** Return the concatenation of this name, the given ASCII
- * character, and name `n'.
+ /** Return the Utf8 representation of this name.
*/
- public Name append(char c, Name n) {
- byte[] bs = new byte[len + n.len + 1];
+ public byte[] toUtf() {
+ byte[] bs = new byte[getByteLength()];
getBytes(bs, 0);
- bs[len] = (byte)c;
- n.getBytes(bs, len+1);
- return fromUtf(table, bs, 0, bs.length);
- }
-
- /** An arbitrary but consistent complete order among all Names.
- */
- public int compareTo(Name other) {
- return other.index - this.index;
+ return bs;
}
- /** Return the concatenation of all names in the array `ns'.
+ /* Get a "reasonably small" value that uniquely identifies this name
+ * within its name table.
+ */
+ public abstract int getIndex();
+
+ /** Get the length (in bytes) of this name.
*/
- public static Name concat(Table table, Name ns[]) {
- int len = 0;
- for (int i = 0; i < ns.length; i++)
- len = len + ns[i].len;
- byte[] bs = new byte[len];
- len = 0;
- for (int i = 0; i < ns.length; i++) {
- ns[i].getBytes(bs, len);
- len = len + ns[i].len;
- }
- return fromUtf(table, bs, 0, len);
- }
+ public abstract int getByteLength();
- public char charAt(int index) {
- return toString().charAt(index);
- }
+ /** Returns i'th byte of this name.
+ */
+ public abstract byte getByteAt(int i);
- public CharSequence subSequence(int start, int end) {
- return toString().subSequence(start, end);
- }
-
- public boolean contentEquals(CharSequence cs) {
- return this.toString().equals(cs.toString());
+ /** Copy all bytes of this name to buffer cs, starting at start.
+ */
+ public void getBytes(byte cs[], int start) {
+ System.arraycopy(getByteArray(), getByteOffset(), cs, start, getByteLength());
}
- public static class Table {
- // maintain a freelist of recently used name tables for reuse.
- private static List<SoftReference<Table>> freelist = List.nil();
+ /** Get the underlying byte array for this name. The contents of the
+ * array must not be modified.
+ */
+ public abstract byte[] getByteArray();
- static private synchronized Table make() {
- while (freelist.nonEmpty()) {
- Table t = freelist.head.get();
- freelist = freelist.tail;
- if (t != null) return t;
- }
- return new Table();
- }
+ /** Get the start offset of this name within its byte array.
+ */
+ public abstract int getByteOffset();
- static private synchronized void dispose(Table t) {
- freelist = freelist.prepend(new SoftReference<Table>(t));
- }
-
- public void dispose() {
- dispose(this);
- }
+ /** An abstraction for the hash table used to create unique Name instances.
+ */
+ public static abstract class Table {
+ /** Standard name table.
+ */
+ public final Names names;
- public static final Context.Key<Table> namesKey =
- new Context.Key<Table>();
-
- public static Table instance(Context context) {
- Table instance = context.get(namesKey);
- if (instance == null) {
- instance = make();
- context.put(namesKey, instance);
- }
- return instance;
+ Table(Names names) {
+ this.names = names;
}
- /** The hash table for names.
- */
- private Name[] hashes;
-
- /** The array holding all encountered names.
- */
- public byte[] names;
-
- /** The mask to be used for hashing
- */
- private int hashMask;
-
- /** The number of filled bytes in `names'.
- */
- private int nc = 0;
-
- /** Allocator
- * @param hashSize the (constant) size to be used for the hash table
- * needs to be a power of two.
- * @param nameSize the initial size of the name table.
+ /** Get the name from the characters in cs[start..start+len-1].
*/
- public Table(int hashSize, int nameSize) {
- hashMask = hashSize - 1;
- hashes = new Name[hashSize];
- names = new byte[nameSize];
-
- slash = fromString("/");
- hyphen = fromString("-");
- T = fromString("T");
- slashequals = fromString("/=");
- deprecated = fromString("deprecated");
-
- init = fromString("<init>");
- clinit = fromString("<clinit>");
- error = fromString("<error>");
- any = fromString("<any>");
- empty = fromString("");
- one = fromString("1");
- period = fromString(".");
- comma = fromString(",");
- semicolon = fromString(";");
- asterisk = fromString("*");
- _this = fromString("this");
- _super = fromString("super");
- _default = fromString("default");
+ public abstract Name fromChars(char[] cs, int start, int len);
- _class = fromString("class");
- java_lang = fromString("java.lang");
- java_lang_Object = fromString("java.lang.Object");
- java_lang_Class = fromString("java.lang.Class");
- java_lang_Cloneable = fromString("java.lang.Cloneable");
- java_io_Serializable = fromString("java.io.Serializable");
- java_lang_Enum = fromString("java.lang.Enum");
- package_info = fromString("package-info");
- serialVersionUID = fromString("serialVersionUID");
- ConstantValue = fromString("ConstantValue");
- LineNumberTable = fromString("LineNumberTable");
- LocalVariableTable = fromString("LocalVariableTable");
- LocalVariableTypeTable = fromString("LocalVariableTypeTable");
- CharacterRangeTable = fromString("CharacterRangeTable");
- StackMap = fromString("StackMap");
- StackMapTable = fromString("StackMapTable");
- SourceID = fromString("SourceID");
- CompilationID = fromString("CompilationID");
- Code = fromString("Code");
- Exceptions = fromString("Exceptions");
- SourceFile = fromString("SourceFile");
- InnerClasses = fromString("InnerClasses");
- Synthetic = fromString("Synthetic");
- Bridge= fromString("Bridge");
- Deprecated = fromString("Deprecated");
- Enum = fromString("Enum");
- _name = fromString("name");
- Signature = fromString("Signature");
- Varargs = fromString("Varargs");
- Annotation = fromString("Annotation");
- RuntimeVisibleAnnotations = fromString("RuntimeVisibleAnnotations");
- RuntimeInvisibleAnnotations = fromString("RuntimeInvisibleAnnotations");
- RuntimeVisibleParameterAnnotations = fromString("RuntimeVisibleParameterAnnotations");
- RuntimeInvisibleParameterAnnotations = fromString("RuntimeInvisibleParameterAnnotations");
- Value = fromString("Value");
- EnclosingMethod = fromString("EnclosingMethod");
-
- desiredAssertionStatus = fromString("desiredAssertionStatus");
-
- append = fromString("append");
- family = fromString("family");
- forName = fromString("forName");
- toString = fromString("toString");
- length = fromString("length");
- valueOf = fromString("valueOf");
- value = fromString("value");
- getMessage = fromString("getMessage");
- getClass = fromString("getClass");
-
- TYPE = fromString("TYPE");
- FIELD = fromString("FIELD");
- METHOD = fromString("METHOD");
- PARAMETER = fromString("PARAMETER");
- CONSTRUCTOR = fromString("CONSTRUCTOR");
- LOCAL_VARIABLE = fromString("LOCAL_VARIABLE");
- ANNOTATION_TYPE = fromString("ANNOTATION_TYPE");
- PACKAGE = fromString("PACKAGE");
-
- SOURCE = fromString("SOURCE");
- CLASS = fromString("CLASS");
- RUNTIME = fromString("RUNTIME");
-
- Array = fromString("Array");
- Method = fromString("Method");
- Bound = fromString("Bound");
- clone = fromString("clone");
- getComponentType = fromString("getComponentType");
- getClassLoader = fromString("getClassLoader");
- initCause = fromString("initCause");
- values = fromString("values");
- iterator = fromString("iterator");
- hasNext = fromString("hasNext");
- next = fromString("next");
- AnnotationDefault = fromString("AnnotationDefault");
- ordinal = fromString("ordinal");
- equals = fromString("equals");
- hashCode = fromString("hashCode");
- compareTo = fromString("compareTo");
- getDeclaringClass = fromString("getDeclaringClass");
- ex = fromString("ex");
- finalize = fromString("finalize");
+ /** Get the name for the characters in string s.
+ */
+ public Name fromString(String s) {
+ char[] cs = s.toCharArray();
+ return fromChars(cs, 0, cs.length);
}
- public Table() {
- this(0x8000, 0x20000);
+ /** Get the name for the bytes in array cs.
+ * Assume that bytes are in utf8 format.
+ */
+ public Name fromUtf(byte[] cs) {
+ return fromUtf(cs, 0, cs.length);
}
- /** Create a name from the bytes in cs[start..start+len-1].
- * Assume that bytes are in utf8 format.
- */
- public Name fromUtf(byte cs[], int start, int len) {
- return Name.fromUtf(this, cs, start, len);
- }
-
- /** Create a name from the bytes in array cs.
+ /** get the name for the bytes in cs[start..start+len-1].
* Assume that bytes are in utf8 format.
*/
- public Name fromUtf(byte cs[]) {
- return Name.fromUtf(this, cs, 0, cs.length);
- }
+ public abstract Name fromUtf(byte[] cs, int start, int len);
- /** Create a name from the characters in cs[start..start+len-1].
+ /** Release any resources used by this table.
+ */
+ public abstract void dispose();
+
+ /** The hashcode of a name.
*/
- public Name fromChars(char[] cs, int start, int len) {
- return Name.fromChars(this, cs, start, len);
- }
+ protected static int hashValue(byte bytes[], int offset, int length) {
+ int h = 0;
+ int off = offset;
- /** Create a name from the characters in string s.
- */
- public Name fromString(CharSequence s) {
- return Name.fromString(this, s);
+ for (int i = 0; i < length; i++) {
+ h = (h << 5) - h + bytes[off++];
+ }
+ return h;
}
- public final Name slash;
- public final Name hyphen;
- public final Name T;
- public final Name slashequals;
- public final Name deprecated;
-
- public final Name init;
- public final Name clinit;
- public final Name error;
- public final Name any;
- public final Name empty;
- public final Name one;
- public final Name period;
- public final Name comma;
- public final Name semicolon;
- public final Name asterisk;
- public final Name _this;
- public final Name _super;
- public final Name _default;
-
- public final Name _class;
- public final Name java_lang;
- public final Name java_lang_Object;
- public final Name java_lang_Class;
- public final Name java_lang_Cloneable;
- public final Name java_io_Serializable;
- public final Name serialVersionUID;
- public final Name java_lang_Enum;
- public final Name package_info;
- public final Name ConstantValue;
- public final Name LineNumberTable;
- public final Name LocalVariableTable;
- public final Name LocalVariableTypeTable;
- public final Name CharacterRangeTable;
- public final Name StackMap;
- public final Name StackMapTable;
- public final Name SourceID;
- public final Name CompilationID;
- public final Name Code;
- public final Name Exceptions;
- public final Name SourceFile;
- public final Name InnerClasses;
- public final Name Synthetic;
- public final Name Bridge;
- public final Name Deprecated;
- public final Name Enum;
- public final Name _name;
- public final Name Signature;
- public final Name Varargs;
- public final Name Annotation;
- public final Name RuntimeVisibleAnnotations;
- public final Name RuntimeInvisibleAnnotations;
- public final Name RuntimeVisibleParameterAnnotations;
- public final Name RuntimeInvisibleParameterAnnotations;
-
- public final Name Value;
- public final Name EnclosingMethod;
-
- public final Name desiredAssertionStatus;
-
- public final Name append;
- public final Name family;
- public final Name forName;
- public final Name toString;
- public final Name length;
- public final Name valueOf;
- public final Name value;
- public final Name getMessage;
- public final Name getClass;
-
- public final Name TYPE;
- public final Name FIELD;
- public final Name METHOD;
- public final Name PARAMETER;
- public final Name CONSTRUCTOR;
- public final Name LOCAL_VARIABLE;
- public final Name ANNOTATION_TYPE;
- public final Name PACKAGE;
-
- public final Name SOURCE;
- public final Name CLASS;
- public final Name RUNTIME;
-
- public final Name Array;
- public final Name Method;
- public final Name Bound;
- public final Name clone;
- public final Name getComponentType;
- public final Name getClassLoader;
- public final Name initCause;
- public final Name values;
- public final Name iterator;
- public final Name hasNext;
- public final Name next;
- public final Name AnnotationDefault;
- public final Name ordinal;
- public final Name equals;
- public final Name hashCode;
- public final Name compareTo;
- public final Name getDeclaringClass;
- public final Name ex;
- public final Name finalize;
- }
-
- public boolean isEmpty() {
- return len == 0;
+ /** Compare two subarrays
+ */
+ protected static boolean equals(byte[] bytes1, int offset1,
+ byte[] bytes2, int offset2, int length) {
+ int i = 0;
+ while (i < length && bytes1[offset1 + i] == bytes2[offset2 + i]) {
+ i++;
+ }
+ return i == length;
+ }
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/Names.java Tue Sep 16 18:35:18 2008 -0700
@@ -0,0 +1,281 @@
+/*
+ * Copyright 1999-2006 Sun Microsystems, Inc. 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package com.sun.tools.javac.util;
+
+/**
+ * Access to the compiler's name table. STandard names are defined,
+ * as well as methods to create new names.
+ *
+ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
+ * you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.</b>
+ */
+public class Names {
+
+ public static final Context.Key<Names> namesKey = new Context.Key<Names>();
+
+ public static Names instance(Context context) {
+ Names instance = context.get(namesKey);
+ if (instance == null) {
+ instance = new Names(context);
+ context.put(namesKey, instance);
+ }
+ return instance;
+ }
+
+ public final Name slash;
+ public final Name hyphen;
+ public final Name T;
+ public final Name slashequals;
+ public final Name deprecated;
+ public final Name init;
+ public final Name clinit;
+ public final Name error;
+ public final Name any;
+ public final Name empty;
+ public final Name one;
+ public final Name period;
+ public final Name comma;
+ public final Name semicolon;
+ public final Name asterisk;
+ public final Name _this;
+ public final Name _super;
+ public final Name _default;
+ public final Name _class;
+ public final Name java_lang;
+ public final Name java_lang_Object;
+ public final Name java_lang_Class;
+ public final Name java_lang_Cloneable;
+ public final Name java_io_Serializable;
+ public final Name serialVersionUID;
+ public final Name java_lang_Enum;
+ public final Name package_info;
+ public final Name ConstantValue;
+ public final Name LineNumberTable;
+ public final Name LocalVariableTable;
+ public final Name LocalVariableTypeTable;
+ public final Name CharacterRangeTable;
+ public final Name StackMap;
+ public final Name StackMapTable;
+ public final Name SourceID;
+ public final Name CompilationID;
+ public final Name Code;
+ public final Name Exceptions;
+ public final Name SourceFile;
+ public final Name InnerClasses;
+ public final Name Synthetic;
+ public final Name Bridge;
+ public final Name Deprecated;
+ public final Name Enum;
+ public final Name _name;
+ public final Name Signature;
+ public final Name Varargs;
+ public final Name Annotation;
+ public final Name RuntimeVisibleAnnotations;
+ public final Name RuntimeInvisibleAnnotations;
+ public final Name RuntimeVisibleParameterAnnotations;
+ public final Name RuntimeInvisibleParameterAnnotations;
+ public final Name Value;
+ public final Name EnclosingMethod;
+ public final Name desiredAssertionStatus;
+ public final Name append;
+ public final Name family;
+ public final Name forName;
+ public final Name toString;
+ public final Name length;
+ public final Name valueOf;
+ public final Name value;
+ public final Name getMessage;
+ public final Name getClass;
+ public final Name TYPE;
+ public final Name FIELD;
+ public final Name METHOD;
+ public final Name PARAMETER;
+ public final Name CONSTRUCTOR;
+ public final Name LOCAL_VARIABLE;
+ public final Name ANNOTATION_TYPE;
+ public final Name PACKAGE;
+ public final Name SOURCE;
+ public final Name CLASS;
+ public final Name RUNTIME;
+ public final Name Array;
+ public final Name Method;
+ public final Name Bound;
+ public final Name clone;
+ public final Name getComponentType;
+ public final Name getClassLoader;
+ public final Name initCause;
+ public final Name values;
+ public final Name iterator;
+ public final Name hasNext;
+ public final Name next;
+ public final Name AnnotationDefault;
+ public final Name ordinal;
+ public final Name equals;
+ public final Name hashCode;
+ public final Name compareTo;
+ public final Name getDeclaringClass;
+ public final Name ex;
+ public final Name finalize;
+
+ public final Name.Table table;
+
+ public Names(Context context) {
+ Options options = Options.instance(context);
+ table = createTable(options);
+
+ slash = fromString("/");
+ hyphen = fromString("-");
+ T = fromString("T");
+ slashequals = fromString("/=");
+ deprecated = fromString("deprecated");
+
+ init = fromString("<init>");
+ clinit = fromString("<clinit>");
+ error = fromString("<error>");
+ any = fromString("<any>");
+ empty = fromString("");
+ one = fromString("1");
+ period = fromString(".");
+ comma = fromString(",");
+ semicolon = fromString(";");
+ asterisk = fromString("*");
+ _this = fromString("this");
+ _super = fromString("super");
+ _default = fromString("default");
+
+ _class = fromString("class");
+ java_lang = fromString("java.lang");
+ java_lang_Object = fromString("java.lang.Object");
+ java_lang_Class = fromString("java.lang.Class");
+ java_lang_Cloneable = fromString("java.lang.Cloneable");
+ java_io_Serializable = fromString("java.io.Serializable");
+ java_lang_Enum = fromString("java.lang.Enum");
+ package_info = fromString("package-info");
+ serialVersionUID = fromString("serialVersionUID");
+ ConstantValue = fromString("ConstantValue");
+ LineNumberTable = fromString("LineNumberTable");
+ LocalVariableTable = fromString("LocalVariableTable");
+ LocalVariableTypeTable = fromString("LocalVariableTypeTable");
+ CharacterRangeTable = fromString("CharacterRangeTable");
+ StackMap = fromString("StackMap");
+ StackMapTable = fromString("StackMapTable");
+ SourceID = fromString("SourceID");
+ CompilationID = fromString("CompilationID");
+ Code = fromString("Code");
+ Exceptions = fromString("Exceptions");
+ SourceFile = fromString("SourceFile");
+ InnerClasses = fromString("InnerClasses");
+ Synthetic = fromString("Synthetic");
+ Bridge = fromString("Bridge");
+ Deprecated = fromString("Deprecated");
+ Enum = fromString("Enum");
+ _name = fromString("name");
+ Signature = fromString("Signature");
+ Varargs = fromString("Varargs");
+ Annotation = fromString("Annotation");
+ RuntimeVisibleAnnotations = fromString("RuntimeVisibleAnnotations");
+ RuntimeInvisibleAnnotations = fromString("RuntimeInvisibleAnnotations");
+ RuntimeVisibleParameterAnnotations = fromString("RuntimeVisibleParameterAnnotations");
+ RuntimeInvisibleParameterAnnotations = fromString("RuntimeInvisibleParameterAnnotations");
+ Value = fromString("Value");
+ EnclosingMethod = fromString("EnclosingMethod");
+
+ desiredAssertionStatus = fromString("desiredAssertionStatus");
+
+ append = fromString("append");
+ family = fromString("family");
+ forName = fromString("forName");
+ toString = fromString("toString");
+ length = fromString("length");
+ valueOf = fromString("valueOf");
+ value = fromString("value");
+ getMessage = fromString("getMessage");
+ getClass = fromString("getClass");
+
+ TYPE = fromString("TYPE");
+ FIELD = fromString("FIELD");
+ METHOD = fromString("METHOD");
+ PARAMETER = fromString("PARAMETER");
+ CONSTRUCTOR = fromString("CONSTRUCTOR");
+ LOCAL_VARIABLE = fromString("LOCAL_VARIABLE");
+ ANNOTATION_TYPE = fromString("ANNOTATION_TYPE");
+ PACKAGE = fromString("PACKAGE");
+
+ SOURCE = fromString("SOURCE");
+ CLASS = fromString("CLASS");
+ RUNTIME = fromString("RUNTIME");
+
+ Array = fromString("Array");
+ Method = fromString("Method");
+ Bound = fromString("Bound");
+ clone = fromString("clone");
+ getComponentType = fromString("getComponentType");
+ getClassLoader = fromString("getClassLoader");
+ initCause = fromString("initCause");
+ values = fromString("values");
+ iterator = fromString("iterator");
+ hasNext = fromString("hasNext");
+ next = fromString("next");
+ AnnotationDefault = fromString("AnnotationDefault");
+ ordinal = fromString("ordinal");
+ equals = fromString("equals");
+ hashCode = fromString("hashCode");
+ compareTo = fromString("compareTo");
+ getDeclaringClass = fromString("getDeclaringClass");
+ ex = fromString("ex");
+ finalize = fromString("finalize");
+ }
+
+ protected Name.Table createTable(Options options) {
+ boolean useUnsharedTable = options.get("useUnsharedTable") != null;
+ if (useUnsharedTable)
+ return new UnsharedNameTable(this);
+ else
+ return new SharedNameTable(this);
+ }
+
+ public void dispose() {
+ table.dispose();
+ }
+
+ public Name fromChars(char[] cs, int start, int len) {
+ return table.fromChars(cs, start, len);
+ }
+
+ public Name fromString(String s) {
+ return table.fromString(s);
+ }
+
+ public Name fromUtf(byte[] cs) {
+ return table.fromUtf(cs);
+ }
+
+ public Name fromUtf(byte[] cs, int start, int len) {
+ return table.fromUtf(cs, start, len);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/SharedNameTable.java Tue Sep 16 18:35:18 2008 -0700
@@ -0,0 +1,221 @@
+/*
+ * Copyright 1999-2006 Sun Microsystems, Inc. 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package com.sun.tools.javac.util;
+
+import java.lang.ref.SoftReference;
+
+/**
+ * Implementation of Name.Table that stores all names in a single shared
+ * byte array, expanding it as needed. This avoids the overhead incurred
+ * by using an array of bytes for each name.
+ *
+ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
+ * you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.</b>
+ */
+public class SharedNameTable extends Name.Table {
+ // maintain a freelist of recently used name tables for reuse.
+ private static List<SoftReference<SharedNameTable>> freelist = List.nil();
+
+ static public synchronized SharedNameTable create(Names names) {
+ while (freelist.nonEmpty()) {
+ SharedNameTable t = freelist.head.get();
+ freelist = freelist.tail;
+ if (t != null) {
+ return t;
+ }
+ }
+ return new SharedNameTable(names);
+ }
+
+ static private synchronized void dispose(SharedNameTable t) {
+ freelist = freelist.prepend(new SoftReference<SharedNameTable>(t));
+ }
+
+ /** The hash table for names.
+ */
+ private NameImpl[] hashes;
+
+ /** The shared byte array holding all encountered names.
+ */
+ public byte[] bytes;
+
+ /** The mask to be used for hashing
+ */
+ private int hashMask;
+
+ /** The number of filled bytes in `names'.
+ */
+ private int nc = 0;
+
+ /** Allocator
+ * @param names The main name table
+ * @param hashSize the (constant) size to be used for the hash table
+ * needs to be a power of two.
+ * @param nameSize the initial size of the name table.
+ */
+ public SharedNameTable(Names names, int hashSize, int nameSize) {
+ super(names);
+ hashMask = hashSize - 1;
+ hashes = new NameImpl[hashSize];
+ bytes = new byte[nameSize];
+
+ }
+
+ public SharedNameTable(Names names) {
+ this(names, 0x8000, 0x20000);
+ }
+
+ @Override
+ public Name fromChars(char[] cs, int start, int len) {
+ int nc = this.nc;
+ byte[] bytes = this.bytes;
+ while (nc + len * 3 >= bytes.length) {
+ // System.err.println("doubling name buffer of length " + names.length + " to fit " + len + " chars");//DEBUG
+ byte[] newnames = new byte[bytes.length * 2];
+ System.arraycopy(bytes, 0, newnames, 0, bytes.length);
+ bytes = this.bytes = newnames;
+ }
+ int nbytes = Convert.chars2utf(cs, start, bytes, nc, len) - nc;
+ int h = hashValue(bytes, nc, nbytes) & hashMask;
+ NameImpl n = hashes[h];
+ while (n != null &&
+ (n.getByteLength() != nbytes ||
+ !equals(bytes, n.index, bytes, nc, nbytes))) {
+ n = n.next;
+ }
+ if (n == null) {
+ n = new NameImpl(this);
+ n.index = nc;
+ n.length = nbytes;
+ n.next = hashes[h];
+ hashes[h] = n;
+ this.nc = nc + nbytes;
+ if (nbytes == 0) {
+ this.nc++;
+ }
+ }
+ return n;
+ }
+
+ @Override
+ public Name fromUtf(byte[] cs, int start, int len) {
+ int h = hashValue(cs, start, len) & hashMask;
+ NameImpl n = hashes[h];
+ byte[] names = this.bytes;
+ while (n != null &&
+ (n.getByteLength() != len || !equals(names, n.index, cs, start, len))) {
+ n = n.next;
+ }
+ if (n == null) {
+ int nc = this.nc;
+ while (nc + len > names.length) {
+ // System.err.println("doubling name buffer of length + " + names.length + " to fit " + len + " bytes");//DEBUG
+ byte[] newnames = new byte[names.length * 2];
+ System.arraycopy(names, 0, newnames, 0, names.length);
+ names = this.bytes = newnames;
+ }
+ System.arraycopy(cs, start, names, nc, len);
+ n = new NameImpl(this);
+ n.index = nc;
+ n.length = len;
+ n.next = hashes[h];
+ hashes[h] = n;
+ this.nc = nc + len;
+ if (len == 0) {
+ this.nc++;
+ }
+ }
+ return n;
+ }
+
+ @Override
+ public void dispose() {
+ dispose(this);
+ }
+
+ static class NameImpl extends Name {
+ /** The next name occupying the same hash bucket.
+ */
+ NameImpl next;
+
+ /** The index where the bytes of this name are stored in the global name
+ * buffer `byte'.
+ */
+ int index;
+
+ /** The number of bytes in this name.
+ */
+ int length;
+
+ NameImpl(SharedNameTable table) {
+ super(table);
+ }
+
+ @Override
+ public int getIndex() {
+ return index;
+ }
+
+ @Override
+ public int getByteLength() {
+ return length;
+ }
+
+ @Override
+ public byte getByteAt(int i) {
+ return getByteArray()[index + i];
+ }
+
+ @Override
+ public byte[] getByteArray() {
+ return ((SharedNameTable) table).bytes;
+ }
+
+ @Override
+ public int getByteOffset() {
+ return index;
+ }
+
+ /** Return the hash value of this name.
+ */
+ public int hashCode() {
+ return index;
+ }
+
+ /** Is this name equal to other?
+ */
+ public boolean equals(Object other) {
+ if (other instanceof Name)
+ return
+ table == ((Name)other).table && index == ((Name) other).getIndex();
+ else return false;
+ }
+
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/UnsharedNameTable.java Tue Sep 16 18:35:18 2008 -0700
@@ -0,0 +1,185 @@
+/*
+ * Copyright 1999-2006 Sun Microsystems, Inc. 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package com.sun.tools.javac.util;
+
+import java.lang.ref.WeakReference;
+
+/**
+ * Implementation of Name.Table that stores names in individual arrays
+ * using weak references. It is recommended for use when a single shared
+ * byte array is unsuitable.
+ *
+ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
+ * you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.</b>
+ */
+public class UnsharedNameTable extends Name.Table {
+ static public Name.Table create(Names names) {
+ return new UnsharedNameTable(names);
+ }
+
+ static class HashEntry extends WeakReference<NameImpl> {
+ HashEntry next;
+ HashEntry(NameImpl referent) {
+ super(referent);
+ }
+ }
+
+ /** The hash table for names.
+ */
+ private HashEntry[] hashes = null;
+
+ /** The mask to be used for hashing
+ */
+ private int hashMask;
+
+ /** Index counter for names in this table.
+ */
+ public int index;
+
+ /** Allocator
+ * @param names The main name table
+ * @param hashSize the (constant) size to be used for the hash table
+ * needs to be a power of two.
+ */
+ public UnsharedNameTable(Names names, int hashSize) {
+ super(names);
+ hashMask = hashSize - 1;
+ hashes = new HashEntry[hashSize];
+ }
+
+ public UnsharedNameTable(Names names) {
+ this(names, 0x8000);
+ }
+
+
+ @Override
+ public Name fromChars(char[] cs, int start, int len) {
+ byte[] name = new byte[len * 3];
+ int nbytes = Convert.chars2utf(cs, start, name, 0, len);
+ return fromUtf(name, 0, nbytes);
+ }
+
+ @Override
+ public Name fromUtf(byte[] cs, int start, int len) {
+ int h = hashValue(cs, start, len) & hashMask;
+
+ HashEntry element = hashes[h];
+
+ NameImpl n = null;
+
+ HashEntry previousNonNullTableEntry = null;
+ HashEntry firstTableEntry = element;
+
+ while (element != null) {
+ if (element == null) {
+ break;
+ }
+
+ n = element.get();
+
+ if (n == null) {
+ if (firstTableEntry == element) {
+ hashes[h] = firstTableEntry = element.next;
+ }
+ else {
+ assert previousNonNullTableEntry != null : "previousNonNullTableEntry cannot be null here.";
+ previousNonNullTableEntry.next = element.next;
+ }
+ }
+ else {
+ if (n.getByteLength() == len && equals(n.bytes, 0, cs, start, len)) {
+ return n;
+ }
+ previousNonNullTableEntry = element;
+ }
+
+ element = element.next;
+ }
+
+ byte[] bytes = new byte[len];
+ System.arraycopy(cs, start, bytes, 0, len);
+ n = new NameImpl(this, bytes, index++);
+
+ System.arraycopy(cs, start, n.bytes, 0, len);
+
+ HashEntry newEntry = new HashEntry(n);
+
+ if (previousNonNullTableEntry == null) { // We are not the first name with that hashCode.
+ hashes[h] = newEntry;
+ }
+ else {
+ assert previousNonNullTableEntry.next == null : "previousNonNullTableEntry.next must be null.";
+ previousNonNullTableEntry.next = newEntry;
+ }
+
+ return n;
+ }
+
+ @Override
+ public void dispose() {
+ hashes = null;
+ }
+
+ static class NameImpl extends Name {
+ NameImpl(UnsharedNameTable table, byte[] bytes, int index) {
+ super(table);
+ this.bytes = bytes;
+ this.index = index;
+ }
+
+ final byte[] bytes;
+ final int index;
+
+ @Override
+ public int getIndex() {
+ return index;
+ }
+
+ @Override
+ public int getByteLength() {
+ return bytes.length;
+ }
+
+ @Override
+ public byte getByteAt(int i) {
+ return bytes[i];
+ }
+
+ @Override
+ public byte[] getByteArray() {
+ return bytes;
+ }
+
+ @Override
+ public int getByteOffset() {
+ return 0;
+ }
+
+ }
+
+}
--- a/langtools/src/share/classes/com/sun/tools/javadoc/AnnotationTypeDocImpl.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/AnnotationTypeDocImpl.java Tue Sep 16 18:35:18 2008 -0700
@@ -27,17 +27,13 @@
import com.sun.javadoc.*;
-import static com.sun.javadoc.LanguageVersion.*;
-import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.code.Kinds;
import com.sun.tools.javac.code.Scope;
-import com.sun.tools.javac.code.Symbol;
import com.sun.tools.javac.code.Symbol.*;
import com.sun.tools.javac.tree.JCTree.*;
import com.sun.tools.javac.util.List;
-import com.sun.tools.javac.util.ListBuffer;
-import com.sun.tools.javac.util.Name;
+import com.sun.tools.javac.util.Names;
import com.sun.tools.javac.util.Position;
/**
@@ -93,7 +89,7 @@
* Elements are always public, so no need to filter them.
*/
public AnnotationTypeElementDoc[] elements() {
- Name.Table names = tsym.name.table;
+ Names names = tsym.name.table.names;
List<AnnotationTypeElementDoc> elements = List.nil();
for (Scope.Entry e = tsym.members().elems; e != null; e = e.sibling) {
if (e.sym != null && e.sym.kind == Kinds.MTH) {
--- a/langtools/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java Tue Sep 16 18:35:18 2008 -0700
@@ -25,8 +25,6 @@
package com.sun.tools.javadoc;
-import java.util.*;
-
import com.sun.javadoc.*;
import static com.sun.javadoc.LanguageVersion.*;
@@ -40,7 +38,6 @@
import com.sun.tools.javac.code.Kinds;
import com.sun.tools.javac.code.TypeTags;
import com.sun.tools.javac.code.Type;
-import com.sun.tools.javac.code.Types;
import com.sun.tools.javac.code.Type.ClassType;
import com.sun.tools.javac.code.Scope;
import com.sun.tools.javac.code.Symbol;
@@ -55,9 +52,9 @@
import com.sun.tools.javac.tree.JCTree.JCClassDecl;
import com.sun.tools.javac.tree.TreeInfo;
+import com.sun.tools.javac.util.Names;
import static com.sun.tools.javac.code.Flags.*;
import static com.sun.tools.javac.code.Kinds.*;
-import static com.sun.tools.javac.code.TypeTags.*;
import java.io.File;
import java.util.Set;
@@ -549,7 +546,7 @@
* methods in this class. Does not include constructors.
*/
public MethodDoc[] methods(boolean filter) {
- Name.Table names = tsym.name.table;
+ Names names = tsym.name.table.names;
List<MethodDocImpl> methods = List.nil();
for (Scope.Entry e = tsym.members().elems; e != null; e = e.sibling) {
if (e.sym != null &&
@@ -582,7 +579,7 @@
* constructors in this class.
*/
public ConstructorDoc[] constructors(boolean filter) {
- Name.Table names = tsym.name.table;
+ Names names = tsym.name.table.names;
List<ConstructorDocImpl> constructors = List.nil();
for (Scope.Entry e = tsym.members().elems; e != null; e = e.sibling) {
if (e.sym != null &&
@@ -696,7 +693,7 @@
}
private ClassDoc searchClass(String className) {
- Name.Table names = tsym.name.table;
+ Names names = tsym.name.table.names;
// search by qualified name first
ClassDoc cd = env.lookupClass(className);
@@ -848,7 +845,7 @@
*---------------------------------*/
// search current class
- Name.Table names = tsym.name.table;
+ Names names = tsym.name.table.names;
Scope.Entry e = tsym.members().lookup(names.fromString(methodName));
//### Using modifier filter here isn't really correct,
@@ -936,7 +933,7 @@
*/
public ConstructorDoc findConstructor(String constrName,
String[] paramTypes) {
- Name.Table names = tsym.name.table;
+ Names names = tsym.name.table.names;
for (Scope.Entry e = tsym.members().lookup(names.fromString("<init>")); e.scope != null; e = e.next()) {
if (e.sym.kind == Kinds.MTH) {
if (hasParameterTypes((MethodSymbol)e.sym, paramTypes)) {
@@ -973,7 +970,7 @@
}
private FieldDocImpl searchField(String fieldName, Set<ClassDocImpl> searched) {
- Name.Table names = tsym.name.table;
+ Names names = tsym.name.table.names;
if (searched.contains(this)) {
return null;
}
@@ -1040,7 +1037,7 @@
Env<AttrContext> compenv = env.enter.getEnv(tsym);
if (compenv == null) return new ClassDocImpl[0];
- Name asterisk = tsym.name.table.asterisk;
+ Name asterisk = tsym.name.table.names.asterisk;
for (JCTree t : compenv.toplevel.defs) {
if (t.getTag() == JCTree.IMPORT) {
JCTree imp = ((JCImport) t).qualid;
@@ -1076,7 +1073,7 @@
ListBuffer<PackageDocImpl> importedPackages = new ListBuffer<PackageDocImpl>();
//### Add the implicit "import java.lang.*" to the result
- Name.Table names = tsym.name.table;
+ Names names = tsym.name.table.names;
importedPackages.append(env.getPackageDoc(env.reader.enterPackage(names.java_lang)));
Env<AttrContext> compenv = env.enter.getEnv(tsym);
--- a/langtools/src/share/classes/com/sun/tools/javadoc/DocEnv.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/DocEnv.java Tue Sep 16 18:35:18 2008 -0700
@@ -33,13 +33,11 @@
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.code.Symbol.*;
import com.sun.tools.javac.code.Type.ClassType;
-import com.sun.tools.javac.code.Type.TypeVar;
import com.sun.tools.javac.comp.Attr;
import com.sun.tools.javac.comp.Check;
import com.sun.tools.javac.tree.JCTree.*;
import com.sun.tools.javac.util.Context;
-import com.sun.tools.javac.util.List;
-import com.sun.tools.javac.util.Name;
+import com.sun.tools.javac.util.Names;
import com.sun.tools.javac.util.Position;
@@ -83,7 +81,7 @@
JavadocEnter enter;
/** The name table. */
- Name.Table names;
+ Names names;
/** The encoding name. */
private String encoding;
@@ -131,7 +129,7 @@
reader = JavadocClassReader.instance0(context);
enter = JavadocEnter.instance0(context);
attr = Attr.instance(context);
- names = Name.Table.instance(context);
+ names = Names.instance(context);
externalizableSym = reader.enterClass(names.fromString("java.io.Externalizable"));
chk = Check.instance(context);
types = Types.instance(context);
--- a/langtools/src/share/classes/com/sun/tools/javadoc/SerializedForm.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/SerializedForm.java Tue Sep 16 18:35:18 2008 -0700
@@ -35,6 +35,7 @@
import com.sun.tools.javac.code.Symbol.MethodSymbol;
import com.sun.tools.javac.util.Name;
import com.sun.tools.javac.util.ListBuffer;
+import com.sun.tools.javac.util.Names;
/**
* The serialized form is the specification of a class' serialization
@@ -149,7 +150,7 @@
* name SERIALIZABLE_FIELDS.
*/
private VarSymbol getDefinedSerializableFields(ClassSymbol def) {
- Name.Table names = def.name.table;
+ Names names = def.name.table.names;
/* SERIALIZABLE_FIELDS can be private,
* so must lookup by ClassSymbol, not by ClassDocImpl.
@@ -202,7 +203,7 @@
* @param visibility the visibility flag for the given method.
*/
private void addMethodIfExist(DocEnv env, ClassSymbol def, String methodName) {
- Name.Table names = def.name.table;
+ Names names = def.name.table.names;
for (Scope.Entry e = def.members().lookup(names.fromString(methodName)); e.scope != null; e = e.next()) {
if (e.sym.kind == Kinds.MTH) {
@@ -228,7 +229,7 @@
private void mapSerialFieldTagImplsToFieldDocImpls(FieldDocImpl spfDoc,
DocEnv env,
ClassSymbol def) {
- Name.Table names = def.name.table;
+ Names names = def.name.table.names;
SerialFieldTag[] sfTag = spfDoc.serialFieldTags();
for (int i = 0; i < sfTag.length; i++) {
--- a/langtools/src/share/classes/com/sun/tools/javadoc/TypeVariableImpl.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/TypeVariableImpl.java Tue Sep 16 18:35:18 2008 -0700
@@ -36,6 +36,7 @@
import com.sun.tools.javac.code.Type.TypeVar;
import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.Name;
+import com.sun.tools.javac.util.Names;
/**
* Implementation of <code>TypeVariable</code>, which
@@ -66,7 +67,7 @@
if ((osym.kind & Kinds.TYP) != 0) {
return env.getClassDoc((ClassSymbol)osym);
}
- Name.Table names = osym.name.table;
+ Names names = osym.name.table.names;
if (osym.name == names.init) {
return env.getConstructorDoc((MethodSymbol)osym);
} else {
@@ -113,7 +114,7 @@
*/
private static List<Type> getBounds(TypeVar v, DocEnv env) {
Name boundname = v.getUpperBound().tsym.getQualifiedName();
- if (boundname == boundname.table.java_lang_Object) {
+ if (boundname == boundname.table.names.java_lang_Object) {
return List.nil();
} else {
return env.types.getBounds(v);
--- a/langtools/test/tools/javac/unit/util/convert/EnclosingCandidates.java Fri Sep 12 23:32:51 2008 -0700
+++ b/langtools/test/tools/javac/unit/util/convert/EnclosingCandidates.java Tue Sep 16 18:35:18 2008 -0700
@@ -36,7 +36,7 @@
public class EnclosingCandidates {
- Name.Table names = Name.Table.instance(new Context());
+ Names names = Names.instance(new Context());
void test(String name, String... expected) {
List<Name> result = enclosingCandidates(names.fromString(name));