< prev index next >
src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java
Print this page
rev 48841 : imported patch 8187950
*** 45,59 ****
import javax.lang.model.element.TypeParameterElement;
import javax.lang.model.element.VariableElement;
import javax.tools.JavaFileManager;
import javax.tools.JavaFileObject;
- import com.sun.tools.javac.code.ClassFinder.BadEnclosingMethodAttr;
- import com.sun.tools.javac.code.Directive.RequiresFlag;
import com.sun.tools.javac.code.Kinds.Kind;
import com.sun.tools.javac.comp.Annotate.AnnotationTypeMetadata;
- import com.sun.tools.javac.code.Scope.WriteableScope;
import com.sun.tools.javac.code.Type.*;
import com.sun.tools.javac.comp.Attr;
import com.sun.tools.javac.comp.AttrContext;
import com.sun.tools.javac.comp.Env;
import com.sun.tools.javac.jvm.*;
--- 45,56 ----
*** 66,75 ****
--- 63,73 ----
import static com.sun.tools.javac.code.Flags.*;
import static com.sun.tools.javac.code.Kinds.*;
import static com.sun.tools.javac.code.Kinds.Kind.*;
import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE;
+ import com.sun.tools.javac.code.Scope.WriteableScope;
import static com.sun.tools.javac.code.Symbol.OperatorSymbol.AccessCode.FIRSTASGOP;
import static com.sun.tools.javac.code.TypeTag.CLASS;
import static com.sun.tools.javac.code.TypeTag.FORALL;
import static com.sun.tools.javac.code.TypeTag.TYPEVAR;
import static com.sun.tools.javac.jvm.ByteCodes.iadd;
*** 632,641 ****
--- 630,647 ----
completer = Completer.NULL_COMPLETER;
c.complete(this);
}
}
+ public void apiComplete() throws CompletionFailure {
+ try {
+ complete();
+ } catch (CompletionFailure cf) {
+ cf.dcfh.handleAPICompletionFailure(cf);
+ }
+ }
+
/** True if the symbol represents an entity that exists.
*/
public boolean exists() {
return true;
}
*** 655,664 ****
--- 661,671 ----
return ElementKind.OTHER; // most unkind
}
@DefinedBy(Api.LANGUAGE_MODEL)
public Set<Modifier> getModifiers() {
+ apiComplete();
return Flags.asModifierSet(flags());
}
@DefinedBy(Api.LANGUAGE_MODEL)
public Name getSimpleName() {
*** 669,678 ****
--- 676,686 ----
* This is the implementation for {@code
* javax.lang.model.element.Element.getAnnotationMirrors()}.
*/
@Override @DefinedBy(Api.LANGUAGE_MODEL)
public List<Attribute.Compound> getAnnotationMirrors() {
+ apiComplete();
return getRawAttributes();
}
// TODO: getEnclosedElements should return a javac List, fix in FilteredMemberList
*** 793,810 ****
public java.util.List<Symbol> getEnclosedElements() {
List<Symbol> list = List.nil();
if (kind == TYP && type.hasTag(TYPEVAR)) {
return list;
}
for (Symbol sym : members().getSymbols(NON_RECURSIVE)) {
! try {
! if (sym != null && (sym.flags() & SYNTHETIC) == 0 && sym.owner == this) {
list = list.prepend(sym);
}
- } catch (BadEnclosingMethodAttr badEnclosingMethod) {
- // ignore the exception
- }
}
return list;
}
public AnnotationTypeMetadata getAnnotationTypeMetadata() {
--- 801,816 ----
public java.util.List<Symbol> getEnclosedElements() {
List<Symbol> list = List.nil();
if (kind == TYP && type.hasTag(TYPEVAR)) {
return list;
}
+ apiComplete();
for (Symbol sym : members().getSymbols(NON_RECURSIVE)) {
! sym.apiComplete();
! if ((sym.flags() & SYNTHETIC) == 0 && sym.owner == this && sym.kind != ERR) {
list = list.prepend(sym);
}
}
return list;
}
public AnnotationTypeMetadata getAnnotationTypeMetadata() {
*** 978,988 ****
return ElementKind.MODULE;
}
@Override @DefinedBy(Api.LANGUAGE_MODEL)
public java.util.List<Directive> getDirectives() {
! complete();
completeUsesProvides();
return Collections.unmodifiableList(directives);
}
public void completeUsesProvides() {
--- 984,994 ----
return ElementKind.MODULE;
}
@Override @DefinedBy(Api.LANGUAGE_MODEL)
public java.util.List<Directive> getDirectives() {
! apiComplete();
completeUsesProvides();
return Collections.unmodifiableList(directives);
}
public void completeUsesProvides() {
*** 1302,1324 ****
}
/** Complete the elaboration of this symbol's definition.
*/
public void complete() throws CompletionFailure {
try {
super.complete();
} catch (CompletionFailure ex) {
// quiet error recovery
flags_field |= (PUBLIC|STATIC);
this.type = new ErrorType(this, Type.noType);
throw ex;
}
}
@DefinedBy(Api.LANGUAGE_MODEL)
public List<Type> getInterfaces() {
! complete();
if (type instanceof ClassType) {
ClassType t = (ClassType)type;
if (t.interfaces_field == null) // FIXME: shouldn't be null
t.interfaces_field = List.nil();
if (t.all_interfaces_field != null)
--- 1308,1332 ----
}
/** Complete the elaboration of this symbol's definition.
*/
public void complete() throws CompletionFailure {
+ Completer origCompleter = completer;
try {
super.complete();
} catch (CompletionFailure ex) {
+ ex.dcfh.classSymbolCompleteFailed(this, origCompleter);
// quiet error recovery
flags_field |= (PUBLIC|STATIC);
this.type = new ErrorType(this, Type.noType);
throw ex;
}
}
@DefinedBy(Api.LANGUAGE_MODEL)
public List<Type> getInterfaces() {
! apiComplete();
if (type instanceof ClassType) {
ClassType t = (ClassType)type;
if (t.interfaces_field == null) // FIXME: shouldn't be null
t.interfaces_field = List.nil();
if (t.all_interfaces_field != null)
*** 1329,1339 ****
}
}
@DefinedBy(Api.LANGUAGE_MODEL)
public Type getSuperclass() {
! complete();
if (type instanceof ClassType) {
ClassType t = (ClassType)type;
if (t.supertype_field == null) // FIXME: shouldn't be null
t.supertype_field = Type.noType;
// An interface has no superclass; its supertype is Object.
--- 1337,1347 ----
}
}
@DefinedBy(Api.LANGUAGE_MODEL)
public Type getSuperclass() {
! apiComplete();
if (type instanceof ClassType) {
ClassType t = (ClassType)type;
if (t.supertype_field == null) // FIXME: shouldn't be null
t.supertype_field = Type.noType;
// An interface has no superclass; its supertype is Object.
*** 1370,1379 ****
--- 1378,1388 ----
}
@DefinedBy(Api.LANGUAGE_MODEL)
public ElementKind getKind() {
+ apiComplete();
long flags = flags();
if ((flags & ANNOTATION) != 0)
return ElementKind.ANNOTATION_TYPE;
else if ((flags & INTERFACE) != 0)
return ElementKind.INTERFACE;
*** 1383,1399 ****
return ElementKind.CLASS;
}
@Override @DefinedBy(Api.LANGUAGE_MODEL)
public Set<Modifier> getModifiers() {
long flags = flags();
return Flags.asModifierSet(flags & ~DEFAULT);
}
@DefinedBy(Api.LANGUAGE_MODEL)
public NestingKind getNestingKind() {
! complete();
if (owner.kind == PCK)
return NestingKind.TOP_LEVEL;
else if (name.isEmpty())
return NestingKind.ANONYMOUS;
else if (owner.kind == MTH)
--- 1392,1409 ----
return ElementKind.CLASS;
}
@Override @DefinedBy(Api.LANGUAGE_MODEL)
public Set<Modifier> getModifiers() {
+ apiComplete();
long flags = flags();
return Flags.asModifierSet(flags & ~DEFAULT);
}
@DefinedBy(Api.LANGUAGE_MODEL)
public NestingKind getNestingKind() {
! apiComplete();
if (owner.kind == PCK)
return NestingKind.TOP_LEVEL;
else if (name.isEmpty())
return NestingKind.ANONYMOUS;
else if (owner.kind == MTH)
*** 2103,2119 ****
}
}
public static class CompletionFailure extends RuntimeException {
private static final long serialVersionUID = 0;
public Symbol sym;
/** A diagnostic object describing the failure
*/
public JCDiagnostic diag;
! public CompletionFailure(Symbol sym, JCDiagnostic diag) {
this.sym = sym;
this.diag = diag;
// this.printStackTrace();//DEBUG
}
--- 2113,2131 ----
}
}
public static class CompletionFailure extends RuntimeException {
private static final long serialVersionUID = 0;
+ public final DeferredCompletionFailureHandler dcfh;
public Symbol sym;
/** A diagnostic object describing the failure
*/
public JCDiagnostic diag;
! public CompletionFailure(Symbol sym, JCDiagnostic diag, DeferredCompletionFailureHandler dcfh) {
! this.dcfh = dcfh;
this.sym = sym;
this.diag = diag;
// this.printStackTrace();//DEBUG
}
< prev index next >