# HG changeset patch
# User lana
# Date 1298599510 28800
# Node ID 83cbfe0a919f859da86517f5a3c8cf577094a5db
# Parent e68c5280c717e926c1b83fab6d13e490323c92ac# Parent 07679d7a46ff9e35a54464e0c42eae586fe9b376
Merge
diff -r e68c5280c717 -r 83cbfe0a919f langtools/make/build.xml
--- a/langtools/make/build.xml Thu Feb 24 15:16:13 2011 -0800
+++ b/langtools/make/build.xml Thu Feb 24 18:05:10 2011 -0800
@@ -868,8 +868,10 @@
executable="${boot.java.home}/bin/javac"
srcdir="${make.tools.dir}/GenStubs"
destdir="${build.toolclasses.dir}/"
- classpath="${build.bootstrap.dir}/classes:${ant.core.lib}"
- includeantruntime="false"/>
+ classpath="${ant.core.lib}"
+ includeantruntime="false">
+
+
diff -r e68c5280c717 -r 83cbfe0a919f langtools/src/share/bin/launcher.sh-template
--- a/langtools/src/share/bin/launcher.sh-template Thu Feb 24 15:16:13 2011 -0800
+++ b/langtools/src/share/bin/launcher.sh-template Thu Feb 24 18:05:10 2011 -0800
@@ -31,8 +31,7 @@
mydir=`cygpath -m $mydir`
;;
esac
-
-mylib="`dirname $mydir`"/lib
+mylib="$mydir/../lib"
# By default, put the jar file and its dependencies on the bootclasspath.
# This is always required on a Mac, because the system langtools classes
@@ -73,4 +72,4 @@
unset DUALCASE
IFS=$nl
-"#TARGET_JAVA#" "${bcp:+-Xbootclasspath/p:"$bcp"}" ${ea} ${javaOpts} -jar "${mydir}"/../lib/#PROGRAM#.jar ${toolOpts}
+"#TARGET_JAVA#" "${bcp:+-Xbootclasspath/p:"$bcp"}" ${ea} ${javaOpts} -jar "${mylib}/#PROGRAM#.jar" ${toolOpts}
diff -r e68c5280c717 -r 83cbfe0a919f langtools/src/share/classes/com/sun/tools/javac/code/Scope.java
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java Thu Feb 24 15:16:13 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java Thu Feb 24 18:05:10 2011 -0800
@@ -74,7 +74,7 @@
/** A list of scopes to be notified if items are to be removed from this scope.
*/
- List listeners = List.nil();
+ List listeners = List.nil();
/** Use as a "not-found" result for lookup.
* Also used to mark deleted entries in the table.
@@ -219,12 +219,27 @@
Entry e = makeEntry(sym, old, elems, s, origin);
table[hash] = e;
elems = e;
+
+ //notify listeners
+ for (List l = listeners; l.nonEmpty(); l = l.tail) {
+ l.head.symbolAdded(sym, this);
+ }
}
Entry makeEntry(Symbol sym, Entry shadowed, Entry sibling, Scope scope, Scope origin) {
return new Entry(sym, shadowed, sibling, scope);
}
+
+ public interface ScopeListener {
+ public void symbolAdded(Symbol sym, Scope s);
+ public void symbolRemoved(Symbol sym, Scope s);
+ }
+
+ public void addScopeListener(ScopeListener sl) {
+ listeners = listeners.prepend(sl);
+ }
+
/** Remove symbol from this scope. Used when an inner class
* attribute tells us that the class isn't a package member.
*/
@@ -258,9 +273,9 @@
te = te.sibling;
}
- // remove items from scopes that have done importAll
- for (List l = listeners; l.nonEmpty(); l = l.tail) {
- l.head.remove(sym);
+ //notify listeners
+ for (List l = listeners; l.nonEmpty(); l = l.tail) {
+ l.head.symbolRemoved(sym, this);
}
}
@@ -393,7 +408,32 @@
};
}
};
+ }
+ public Iterable getElementsByName(Name name) {
+ return getElementsByName(name, noFilter);
+ }
+
+ public Iterable getElementsByName(final Name name, final Filter sf) {
+ return new Iterable() {
+ public Iterator iterator() {
+ return new Iterator() {
+ Scope.Entry currentEntry = lookup(name, sf);
+
+ public boolean hasNext() {
+ return currentEntry.scope != null;
+ }
+ public Symbol next() {
+ Scope.Entry prevEntry = currentEntry;
+ currentEntry = currentEntry.next(sf);
+ return prevEntry.sym;
+ }
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+ };
}
public String toString() {
@@ -488,7 +528,7 @@
}
}
- public static class StarImportScope extends ImportScope {
+ public static class StarImportScope extends ImportScope implements ScopeListener {
public StarImportScope(Symbol owner) {
super(owner);
@@ -500,8 +540,13 @@
enter(e.sym, fromScope);
}
// Register to be notified when imported items are removed
- fromScope.listeners = fromScope.listeners.prepend(this);
+ fromScope.addScopeListener(this);
}
+
+ public void symbolRemoved(Symbol sym, Scope s) {
+ remove(sym);
+ }
+ public void symbolAdded(Symbol sym, Scope s) { }
}
/** An empty scope, into which you can't place anything. Used for
@@ -538,6 +583,151 @@
}
}
+ /** A class scope adds capabilities to keep track of changes in related
+ * class scopes - this allows client to realize whether a class scope
+ * has changed, either directly (because a new member has been added/removed
+ * to this scope) or indirectly (i.e. because a new member has been
+ * added/removed into a supertype scope)
+ */
+ public static class CompoundScope extends Scope implements ScopeListener {
+
+ public static final Entry[] emptyTable = new Entry[0];
+
+ private List subScopes = List.nil();
+ private int mark = 0;
+
+ public CompoundScope(Symbol owner) {
+ super(null, owner, emptyTable);
+ }
+
+ public void addSubScope(Scope that) {
+ if (that != null) {
+ subScopes = subScopes.prepend(that);
+ that.addScopeListener(this);
+ mark++;
+ for (ScopeListener sl : listeners) {
+ sl.symbolAdded(null, this); //propagate upwards in case of nested CompoundScopes
+ }
+ }
+ }
+
+ public void symbolAdded(Symbol sym, Scope s) {
+ mark++;
+ for (ScopeListener sl : listeners) {
+ sl.symbolAdded(sym, s);
+ }
+ }
+
+ public void symbolRemoved(Symbol sym, Scope s) {
+ mark++;
+ for (ScopeListener sl : listeners) {
+ sl.symbolRemoved(sym, s);
+ }
+ }
+
+ public int getMark() {
+ return mark;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder buf = new StringBuilder();
+ buf.append("CompoundScope{");
+ String sep = "";
+ for (Scope s : subScopes) {
+ buf.append(sep);
+ buf.append(s);
+ sep = ",";
+ }
+ buf.append("}");
+ return buf.toString();
+ }
+
+ @Override
+ public Iterable getElements(final Filter sf) {
+ return new Iterable() {
+ public Iterator iterator() {
+ return new CompoundScopeIterator(subScopes) {
+ Iterator nextIterator(Scope s) {
+ return s.getElements().iterator();
+ }
+ };
+ }
+ };
+ }
+
+ @Override
+ public Iterable getElementsByName(final Name name, final Filter sf) {
+ return new Iterable() {
+ public Iterator iterator() {
+ return new CompoundScopeIterator(subScopes) {
+ Iterator nextIterator(Scope s) {
+ return s.getElementsByName(name, sf).iterator();
+ }
+ };
+ }
+ };
+ }
+
+ abstract class CompoundScopeIterator implements Iterator {
+
+ private Iterator currentIterator;
+ private List scopesToScan;
+
+ public CompoundScopeIterator(List scopesToScan) {
+ this.scopesToScan = scopesToScan;
+ update();
+ }
+
+ abstract Iterator nextIterator(Scope s);
+
+ public boolean hasNext() {
+ return currentIterator != null;
+ }
+
+ public Symbol next() {
+ Symbol sym = currentIterator.next();
+ if (!currentIterator.hasNext()) {
+ update();
+ }
+ return sym;
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+ private void update() {
+ while (scopesToScan.nonEmpty()) {
+ currentIterator = nextIterator(scopesToScan.head);
+ scopesToScan = scopesToScan.tail;
+ if (currentIterator.hasNext()) return;
+ }
+ currentIterator = null;
+ }
+ }
+
+ @Override
+ public Entry lookup(Name name, Filter sf) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Scope dup(Symbol newOwner) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void enter(Symbol sym, Scope s, Scope origin) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void remove(Symbol sym) {
+ throw new UnsupportedOperationException();
+ }
+ }
+
/** An error scope, for which the owner should be an error symbol. */
public static class ErrorScope extends Scope {
ErrorScope(Scope next, Symbol errSymbol, Entry[] table) {
diff -r e68c5280c717 -r 83cbfe0a919f langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java Thu Feb 24 15:16:13 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java Thu Feb 24 18:05:10 2011 -0800
@@ -731,7 +731,7 @@
/** members closure cache (set by Types.membersClosure)
*/
- Scope membersClosure;
+ Scope.CompoundScope membersClosure;
public ClassSymbol(long flags, Name name, Type type, Symbol owner) {
super(flags, name, type, owner);
diff -r e68c5280c717 -r 83cbfe0a919f langtools/src/share/classes/com/sun/tools/javac/code/Type.java
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Type.java Thu Feb 24 15:16:13 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Type.java Thu Feb 24 18:05:10 2011 -0800
@@ -270,10 +270,6 @@
public Type getUpperBound() { return null; }
public Type getLowerBound() { return null; }
- public void setThrown(List ts) {
- throw new AssertionError();
- }
-
/** Navigation methods, these will work for classes, type variables,
* foralls, but will return null for arrays and methods.
*/
@@ -388,14 +384,6 @@
*/
public void complete() {}
- public Object clone() {
- try {
- return super.clone();
- } catch (CloneNotSupportedException e) {
- throw new AssertionError(e);
- }
- }
-
public TypeSymbol asElement() {
return tsym;
}
@@ -817,8 +805,7 @@
}
}
- public static class MethodType extends Type
- implements Cloneable, ExecutableType {
+ public static class MethodType extends Type implements ExecutableType {
public List argtypes;
public Type restype;
@@ -880,10 +867,6 @@
public Type getReturnType() { return restype; }
public List getThrownTypes() { return thrown; }
- public void setThrown(List t) {
- thrown = t;
- }
-
public boolean isErroneous() {
return
isErroneous(argtypes) ||
@@ -1068,12 +1051,10 @@
public List getThrownTypes() { return qtype.getThrownTypes(); }
public List allparams() { return qtype.allparams(); }
public Type getUpperBound() { return qtype.getUpperBound(); }
- public Object clone() { DelegatedType t = (DelegatedType)super.clone(); t.qtype = (Type)qtype.clone(); return t; }
public boolean isErroneous() { return qtype.isErroneous(); }
}
- public static class ForAll extends DelegatedType
- implements Cloneable, ExecutableType {
+ public static class ForAll extends DelegatedType implements ExecutableType {
public List tvars;
public ForAll(List tvars, Type qtype) {
@@ -1092,16 +1073,6 @@
public List getTypeArguments() { return tvars; }
- public void setThrown(List t) {
- qtype.setThrown(t);
- }
-
- public Object clone() {
- ForAll result = (ForAll)super.clone();
- result.qtype = (Type)result.qtype.clone();
- return result;
- }
-
public boolean isErroneous() {
return qtype.isErroneous();
}
diff -r e68c5280c717 -r 83cbfe0a919f langtools/src/share/classes/com/sun/tools/javac/code/Types.java
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java Thu Feb 24 15:16:13 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java Thu Feb 24 18:05:10 2011 -0800
@@ -2023,18 +2023,22 @@
final MethodSymbol cachedImpl;
final Filter implFilter;
final boolean checkResult;
+ final int prevMark;
public Entry(MethodSymbol cachedImpl,
Filter scopeFilter,
- boolean checkResult) {
+ boolean checkResult,
+ int prevMark) {
this.cachedImpl = cachedImpl;
this.implFilter = scopeFilter;
this.checkResult = checkResult;
+ this.prevMark = prevMark;
}
- boolean matches(Filter scopeFilter, boolean checkResult) {
+ boolean matches(Filter scopeFilter, boolean checkResult, int mark) {
return this.implFilter == scopeFilter &&
- this.checkResult == checkResult;
+ this.checkResult == checkResult &&
+ this.prevMark == mark;
}
}
@@ -2046,10 +2050,11 @@
_map.put(ms, new SoftReference