--- a/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java Thu Oct 10 13:55:41 2013 -0400
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java Thu Oct 10 20:12:08 2013 -0400
@@ -71,6 +71,7 @@
import com.sun.tools.javac.util.ListBuffer;
import com.sun.tools.javac.util.Log;
import com.sun.tools.javac.util.Names;
+import com.sun.tools.javac.util.Options;
/**
* Contains operations specific to processing type annotations.
@@ -94,6 +95,7 @@
final Names names;
final Symtab syms;
final Annotate annotate;
+ private final boolean typeAnnoAsserts;
protected TypeAnnotations(Context context) {
context.put(typeAnnosKey, this);
@@ -101,6 +103,8 @@
log = Log.instance(context);
syms = Symtab.instance(context);
annotate = Annotate.instance(context);
+ Options options = Options.instance(context);
+ typeAnnoAsserts = options.isSet("TypeAnnotationAsserts");
}
/**
@@ -265,10 +269,6 @@
*/
private void separateAnnotationsKinds(JCTree typetree, Type type, Symbol sym,
TypeAnnotationPosition pos) {
- /*
- System.out.printf("separateAnnotationsKinds(typetree: %s, type: %s, symbol: %s, pos: %s%n",
- typetree, type, sym, pos);
- */
List<Attribute.Compound> annotations = sym.getRawAttributes();
ListBuffer<Attribute.Compound> declAnnos = new ListBuffer<Attribute.Compound>();
ListBuffer<Attribute.TypeCompound> typeAnnos = new ListBuffer<Attribute.TypeCompound>();
@@ -1023,10 +1023,12 @@
@Override
public void visitMethodDef(final JCMethodDecl tree) {
if (tree.sym == null) {
- // Something most be wrong, e.g. a class not found.
- // Quietly ignore. (See test FailOver15.java)
+ if (typeAnnoAsserts) {
+ Assert.error("Visiting tree node before memberEnter");
+ } else {
return;
}
+ }
if (sigOnly) {
if (!tree.mods.annotations.isEmpty()) {
// Nothing to do for separateAnnotationsKinds if
@@ -1129,6 +1131,9 @@
// Nothing to do for separateAnnotationsKinds if
// there are no annotations of either kind.
} else if (tree.sym == null) {
+ if (typeAnnoAsserts) {
+ Assert.error("Visiting tree node before memberEnter");
+ }
// Something is wrong already. Quietly ignore.
} else if (tree.sym.getKind() == ElementKind.PARAMETER) {
// Parameters are handled in visitMethodDef or visitLambda.
@@ -1282,9 +1287,9 @@
private void findPosition(JCTree tree, JCTree frame, List<JCAnnotation> annotations) {
if (!annotations.isEmpty()) {
/*
- System.out.println("Finding pos for: " + annotations);
- System.out.println(" tree: " + tree + " kind: " + tree.getKind());
- System.out.println(" frame: " + frame + " kind: " + frame.getKind());
+ System.err.println("Finding pos for: " + annotations);
+ System.err.println(" tree: " + tree + " kind: " + tree.getKind());
+ System.err.println(" frame: " + frame + " kind: " + frame.getKind());
*/
TypeAnnotationPosition p = new TypeAnnotationPosition();
p.onLambda = currentLambda;