/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 7021183
* @summary 269: assertion failure getting enclosing element of an undefined name
*/
/**
* Scan javac Symtab looking for TypeMirrors and Elements, and ensure that
* no exceptions are thrown when used with javax.lang.model visitors.
*
*/
public class TestSymtabItems {
new TestSymtabItems().run();
}
// print("noSymbol", syms.noSymbol);
// print("errSymbol", syms.errSymbol);
// print("unknownSymbol", syms.unknownSymbol);
// print("botType", syms.botType);
// print("errType", syms.errType);
// print("unknownType", syms.unknownType);
// System.err.println(f.getType() + " " + f.getName());
// Temporarily ignore methodHandle and transientMethodHandle
// during API evolution
continue;
}
if (errors > 0)
}
}
}
errors++;
}
int errors;
show("package", e);
indent(+1);
super.visitPackage(e, p);
indent(-1);
return null;
}
show("type", e);
indent(+1);
super.visitType(e, p);
indent(-1);
return null;
}
show("variable", e);
indent(+1);
super.visitVariable(e, p);
indent(-1);
return null;
}
show("executable", e);
indent(+1);
super.visitExecutable(e, p);
indent(-1);
return null;
}
show("type parameter", e);
indent(+1);
super.visitTypeParameter(e, p);
indent(-1);
return null;
}
show("unknown", e);
indent(+1);
try {
super.visitUnknown(e, p);
} catch (UnknownElementException ex) {
}
indent(-1);
return null;
}
void indent(int i) {
indent += i;
}
for (int i = 0; i < w; i++)
}
+ ": mods:" + e.getModifiers()
+ " " + e.getSimpleName()
+ ", kind: " + e.getKind()
+ ", type: " + e.asType()
+ ", encl: " + e.getEnclosingElement());
// The following checks help establish why NPE might occur when trying to scan children
if (e instanceof ClassSymbol) {
error("members_field is null");
}
}
int indent;
};
return null;
}
try {
return super.visitUnknown(t, types);
} catch (UnknownTypeException ex) {
return null;
}
}
};
}