test/tools/javac/api/EndPositions.java

changeset 1521
71f35e4b93a5
parent 1323
1a7c11b22192
child 2525
2eb010b6cb22
     1.1 --- a/test/tools/javac/api/EndPositions.java	Wed Jan 23 20:57:40 2013 +0000
     1.2 +++ b/test/tools/javac/api/EndPositions.java	Wed Jan 23 13:27:24 2013 -0800
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -28,11 +28,7 @@
    1.11   * an annotation processor is present
    1.12   */
    1.13  
    1.14 -import com.sun.source.tree.ClassTree;
    1.15 -import com.sun.source.tree.CompilationUnitTree;
    1.16 -import com.sun.source.tree.Tree;
    1.17  import com.sun.source.util.JavacTask;
    1.18 -import com.sun.source.util.Trees;
    1.19  import java.io.IOException;
    1.20  import java.net.URI;
    1.21  import java.util.Arrays;
    1.22 @@ -72,16 +68,17 @@
    1.23          JavacTask task = (JavacTask)javac.getTask(null, null, diagnostics, options, null, compilationUnits);
    1.24          boolean valid = task.call();
    1.25          if (valid)
    1.26 -            throw new AssertionError("Compilation succeeded unexpectedly");
    1.27 +            throw new AssertionError("Expected one error, but found none.");
    1.28  
    1.29          List<Diagnostic<? extends JavaFileObject>> errors = diagnostics.getDiagnostics();
    1.30          if (errors.size() != 1)
    1.31 -            throw new AssertionError("Expected one error only, but found " + errors.size() + " errors");
    1.32 +            throw new AssertionError("Expected one error only, but found " + errors.size() + "; errors: " + errors);
    1.33  
    1.34          Diagnostic<?> error = errors.get(0);
    1.35          if (error.getStartPosition() >= error.getEndPosition())
    1.36              throw new AssertionError("Expected start to be less than end position: start [" +
    1.37 -                    error.getStartPosition() + "], end [" + error.getEndPosition() +"]");
    1.38 +                    error.getStartPosition() + "], end [" + error.getEndPosition() +"]" +
    1.39 +                    "; diagnostics code: " + error.getCode());
    1.40  
    1.41          System.out.println("All is good!");
    1.42      }

mercurial