9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 6970584 8006694 8062373 8129962
27 * @summary assorted position errors in compiler syntax trees
28 * temporarily workaround combo tests are causing time out in several platforms
29 * @library ../lib
30 * @modules java.desktop
31 * jdk.compiler/com.sun.tools.javac.api
32 * jdk.compiler/com.sun.tools.javac.code
33 * jdk.compiler/com.sun.tools.javac.file
34 * jdk.compiler/com.sun.tools.javac.tree
35 * jdk.compiler/com.sun.tools.javac.util
36 * @build combo.ComboTestHelper
37 * @run main CheckAttributedTree -q -r -et ERRONEOUS .
38 */
39
40 import java.awt.BorderLayout;
41 import java.awt.Color;
42 import java.awt.Dimension;
43 import java.awt.EventQueue;
44 import java.awt.Font;
45 import java.awt.GridBagConstraints;
46 import java.awt.GridBagLayout;
47 import java.awt.Rectangle;
48 import java.awt.event.ActionEvent;
389
390 Field errField = checkFields(tree);
391 if (errField!=null) {
392 check(false,
393 "'null' field '" + errField.getName() + "' found in tree ", self);
394 }
395
396 Info prevEncl = encl;
397 encl = self;
398 tree.accept(this);
399 encl = prevEncl;
400 }
401
402 private boolean mandatoryType(JCTree that) {
403 return that instanceof JCTree.JCExpression ||
404 that.hasTag(VARDEF) ||
405 that.hasTag(METHODDEF) ||
406 that.hasTag(CLASSDEF);
407 }
408
409 private final List<String> excludedFields = Arrays.asList("varargsElement", "targetType");
410
411 void check(boolean ok, String label, Info self) {
412 if (!ok) {
413 if (gui) {
414 if (viewer == null)
415 viewer = new Viewer();
416 viewer.addEntry(sourcefile, label, encl, self);
417 }
418 error(label + self.toString() + " encl: " + encl.toString() +
419 " in file: " + sourcefile + " " + self.tree);
420 }
421 }
422
423 Field checkFields(JCTree t) {
424 List<Field> fieldsToCheck = treeUtil.getFieldsOfType(t,
425 excludedFields,
426 Symbol.class,
427 Type.class);
428 for (Field f : fieldsToCheck) {
429 try {
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 6970584 8006694 8062373 8129962
27 * @summary assorted position errors in compiler syntax trees
28 * temporarily workaround combo tests are causing time out in several platforms
29 * @enablePreview
30 * @library ../lib
31 * @modules java.desktop
32 * jdk.compiler/com.sun.tools.javac.api
33 * jdk.compiler/com.sun.tools.javac.code
34 * jdk.compiler/com.sun.tools.javac.file
35 * jdk.compiler/com.sun.tools.javac.tree
36 * jdk.compiler/com.sun.tools.javac.util
37 * @build combo.ComboTestHelper
38 * @run main CheckAttributedTree -q -r -et ERRONEOUS .
39 */
40
41 import java.awt.BorderLayout;
42 import java.awt.Color;
43 import java.awt.Dimension;
44 import java.awt.EventQueue;
45 import java.awt.Font;
46 import java.awt.GridBagConstraints;
47 import java.awt.GridBagLayout;
48 import java.awt.Rectangle;
49 import java.awt.event.ActionEvent;
390
391 Field errField = checkFields(tree);
392 if (errField!=null) {
393 check(false,
394 "'null' field '" + errField.getName() + "' found in tree ", self);
395 }
396
397 Info prevEncl = encl;
398 encl = self;
399 tree.accept(this);
400 encl = prevEncl;
401 }
402
403 private boolean mandatoryType(JCTree that) {
404 return that instanceof JCTree.JCExpression ||
405 that.hasTag(VARDEF) ||
406 that.hasTag(METHODDEF) ||
407 that.hasTag(CLASSDEF);
408 }
409
410 private final List<String> excludedFields = Arrays.asList("varargsElement", "targetType", "factoryProduct");
411
412 void check(boolean ok, String label, Info self) {
413 if (!ok) {
414 if (gui) {
415 if (viewer == null)
416 viewer = new Viewer();
417 viewer.addEntry(sourcefile, label, encl, self);
418 }
419 error(label + self.toString() + " encl: " + encl.toString() +
420 " in file: " + sourcefile + " " + self.tree);
421 }
422 }
423
424 Field checkFields(JCTree t) {
425 List<Field> fieldsToCheck = treeUtil.getFieldsOfType(t,
426 excludedFields,
427 Symbol.class,
428 Type.class);
429 for (Field f : fieldsToCheck) {
430 try {
|