test/tools/javac/failover/CheckAttributedTree.java

changeset 1521
71f35e4b93a5
parent 1520
5c956be64b9e
child 2525
2eb010b6cb22
equal deleted inserted replaced
1520:5c956be64b9e 1521:71f35e4b93a5
360 excludeTags.contains(treeUtil.nameFromTag(tree.getTag()))) { 360 excludeTags.contains(treeUtil.nameFromTag(tree.getTag()))) {
361 return; 361 return;
362 } 362 }
363 363
364 Info self = new Info(tree, endPosTable); 364 Info self = new Info(tree, endPosTable);
365 check(!mandatoryType(tree) || 365 if (mandatoryType(tree)) {
366 (tree.type != null && 366 check(tree.type != null,
367 checkFields(tree)), 367 "'null' field 'type' found in tree ", self);
368 "'null' found in tree ", 368 if (tree.type==null)
369 self); 369 new Throwable().printStackTrace();
370 }
371
372 Field errField = checkFields(tree);
373 if (errField!=null) {
374 check(false,
375 "'null' field '" + errField.getName() + "' found in tree ", self);
376 }
370 377
371 Info prevEncl = encl; 378 Info prevEncl = encl;
372 encl = self; 379 encl = self;
373 tree.accept(this); 380 tree.accept(this);
374 encl = prevEncl; 381 encl = prevEncl;
393 error(label + self.toString() + " encl: " + encl.toString() + 400 error(label + self.toString() + " encl: " + encl.toString() +
394 " in file: " + sourcefile + " " + self.tree); 401 " in file: " + sourcefile + " " + self.tree);
395 } 402 }
396 } 403 }
397 404
398 boolean checkFields(JCTree t) { 405 Field checkFields(JCTree t) {
399 List<Field> fieldsToCheck = treeUtil.getFieldsOfType(t, 406 List<Field> fieldsToCheck = treeUtil.getFieldsOfType(t,
400 excludedFields, 407 excludedFields,
401 Symbol.class, 408 Symbol.class,
402 Type.class); 409 Type.class);
403 for (Field f : fieldsToCheck) { 410 for (Field f : fieldsToCheck) {
404 try { 411 try {
405 if (f.get(t) == null) { 412 if (f.get(t) == null) {
406 return false; 413 return f;
407 } 414 }
408 } 415 }
409 catch (IllegalAccessException e) { 416 catch (IllegalAccessException e) {
410 System.err.println("Cannot read field: " + f); 417 System.err.println("Cannot read field: " + f);
411 //swallow it 418 //swallow it
412 } 419 }
413 } 420 }
414 return true; 421 return null;
415 } 422 }
416 423
417 @Override 424 @Override
418 public void visitImport(JCImport tree) { } 425 public void visitImport(JCImport tree) { }
419 426

mercurial