jjg@489: /* ohair@554: * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. jjg@489: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jjg@489: * jjg@489: * This code is free software; you can redistribute it and/or modify it jjg@489: * under the terms of the GNU General Public License version 2 only, as jjg@489: * published by the Free Software Foundation. jjg@489: * jjg@489: * This code is distributed in the hope that it will be useful, but WITHOUT jjg@489: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jjg@489: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jjg@489: * version 2 for more details (a copy is included in the LICENSE file that jjg@489: * accompanied this code). jjg@489: * jjg@489: * You should have received a copy of the GNU General Public License version jjg@489: * 2 along with this work; if not, write to the Free Software Foundation, jjg@489: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jjg@489: * ohair@554: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@554: * or visit www.oracle.com if you need additional information or have any ohair@554: * questions. jjg@489: */ jjg@489: jjg@489: jjg@489: /** jjg@489: * Utility and test program to check javac's internal TreeScanner class. jjg@489: * The program can be run standalone, or as a jtreg test. For info on jjg@489: * command line args, run program with no args. jjg@489: * jjg@489: *
jjg@489: * jtreg: Note that by using the -r switch in the test description below, this test
jjg@489: * will process all java files in the langtools/test directory, thus implicitly
jjg@489: * covering any new language features that may be tested in this test suite.
jjg@489: */
jjg@489:
jjg@489: /*
jjg@489: * @test
jjg@489: * @bug 6923080
jjg@489: * @summary TreeScanner.visitNewClass should scan tree.typeargs
jjg@679: * @build AbstractTreeScannerTest JavacTreeScannerTest
jjg@679: * @run main JavacTreeScannerTest -q -r .
jjg@489: */
jjg@489:
jjg@489: import java.io.*;
jjg@489: import java.lang.reflect.*;
jjg@489: import java.util.*;
jjg@489: import javax.tools.*;
jjg@489:
jjg@679: import com.sun.tools.javac.tree.JCTree;
jjg@679: import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
jjg@679: import com.sun.tools.javac.tree.TreeScanner;
jjg@489: import com.sun.tools.javac.util.List;
jjg@489:
jjg@679: public class JavacTreeScannerTest extends AbstractTreeScannerTest {
jjg@489: /**
jjg@489: * Main entry point.
jjg@489: * If test.src is set, program runs in jtreg mode, and will throw an Error
jjg@489: * if any errors arise, otherwise System.exit will be used. In jtreg mode,
jjg@489: * the default base directory for file args is the value of ${test.src}.
jjg@489: * In jtreg mode, the -r option can be given to change the default base
jjg@489: * directory to the root test directory.
jjg@489: */
jjg@489: public static void main(String... args) {
jjg@489: String testSrc = System.getProperty("test.src");
jjg@489: File baseDir = (testSrc == null) ? null : new File(testSrc);
jjg@679: boolean ok = new JavacTreeScannerTest().run(baseDir, args);
jjg@489: if (!ok) {
jjg@489: if (testSrc != null) // jtreg mode
jjg@489: throw new Error("failed");
jjg@489: else
jjg@489: System.exit(1);
jjg@489: }
jjg@489: }
jjg@489:
jjg@679: int test(JCCompilationUnit tree) {
jjg@679: return new ScanTester().test(tree);
jjg@489: }
jjg@489:
jjg@489: /**
jjg@489: * Main class for testing operation of tree scanner.
jjg@489: * The set of nodes found by the scanner are compared
jjg@489: * against the set of nodes found by reflection.
jjg@489: */
jjg@489: private class ScanTester extends TreeScanner {
jjg@489: /** Main entry method for the class. */
jjg@679: int test(JCCompilationUnit tree) {
jjg@489: sourcefile = tree.sourcefile;
jjg@489: found = new HashSet