Package com.sun.tools.javac.main.Main

Examples of com.sun.tools.javac.main.Main.Result


   * NullPointerExceptions in the matchers.
   */
  @Test
  public void fileWithMultipleTopLevelClassesExtendsWithError()
      throws Exception {
    Result exitCode = compiler.compile(
        compiler.fileManager().sources(getClass(), "MultipleTopLevelClassesWithErrors.java",
            "ExtendedMultipleTopLevelClassesWithErrors.java"));
    outputStream.flush();
    assertThat(outputStream.toString(), exitCode, is(Result.ERROR));

View Full Code Here


        throw new IllegalStateException("test123");
      }
    }
    compilerBuilder.report(new ErrorProneScanner(new Throwing()));
    compiler = compilerBuilder.build();
    Result exitCode = compiler.compile(
        compiler.fileManager().sources(getClass(), "MultipleTopLevelClassesWithErrors.java",
            "ExtendedMultipleTopLevelClassesWithErrors.java"));
    outputStream.flush();
    assertThat(outputStream.toString(), exitCode, is(Result.ERROR));
    @SuppressWarnings("unchecked"// hamcrest should use @SafeVarargs
View Full Code Here

  /**
   * Regression test for Issue 188, error-prone doesn't work with annotation processors.
   */
  @Test
  public void annotationProcessingWorks() throws Exception {
    Result exitCode = compiler.compile(
        compiler.fileManager().sources(getClass(), "UsesAnnotationProcessor.java"),
        List.of(new NullAnnotationProcessor()));
    outputStream.flush();
    assertThat(outputStream.toString(), exitCode, is(Result.OK));
  }
View Full Code Here

  /**
   * Test that if javac does dataflow on a class twice error-prone only analyses it once.
   */
  @Test
  public void reportReadyForAnalysisOnce() throws Exception {
    Result exitCode = compiler.compile(
        compiler.fileManager().sources(getClass(),
            "FlowConstants.java",
            "FlowSub.java",
            // This order is important: the superclass needs to occur after the subclass in the
            // sources so it goes through flow twice (once so it can be used when the subclass
View Full Code Here

  @Test
  public void propagatesScannerThroughAnnotationProcessingRounds() throws Exception {
    ErrorProneScanner scanner = new ErrorProneScanner();
    compilerBuilder.report(scanner);
    compiler = compilerBuilder.build();
    Result exitCode = compiler.compile(
        compiler.fileManager().sources(getClass(), "UsesAnnotationProcessor.java"),
        Arrays.asList(new ScannerCheckingProcessor(scanner)));
    outputStream.flush();
    assertThat(outputStream.toString(), exitCode, is(Result.OK));
  }
View Full Code Here

  @Test
  public void ignoreGeneratedConstructors() throws Exception {
    compilerBuilder.report(new ErrorProneScanner(new ConstructorMatcher()));
    compiler = compilerBuilder.build();
    Result exitCode = compiler.compile(
        Arrays.asList(compiler.fileManager().forSourceLines("Test.java", "public class Test {}")));
    outputStream.flush();

    Matcher<Iterable<Diagnostic<JavaFileObject>>> matcher = not(hasItem(
        diagnosticMessage(containsString("[ConstructorMatcher]"))));
View Full Code Here

  @Ignore
  @Test
  public void ignoreGeneratedSuperInvocations() throws Exception {
    compilerBuilder.report(new ErrorProneScanner(new SuperCallMatcher()));
    compiler = compilerBuilder.build();
    Result exitCode = compiler.compile(Arrays.asList(
        compiler.fileManager().forSourceLines("Test.java",
            "public class Test {",
            "  public Test() {}",
            "}")));
    outputStream.flush();
View Full Code Here

   * @param sources The list of files to compile
   * @param args Extra command-line arguments to pass to the compiler
   */
  public void assertCompileSucceeds(List<JavaFileObject> sources, List<String> args) {
    List<String> allArgs = buildArguments(args);
    Result exitCode = compile(asJavacList(sources), allArgs.toArray(new String[0]));
    List<Diagnostic<? extends JavaFileObject>> diagnostics = diagnosticHelper.getDiagnostics();
    assertThat("Compilation failed: " + diagnostics.toString(), exitCode, is(Result.OK));
    assertThat("Compilation succeeded but gave warnings: " + diagnostics.toString(),
        diagnostics.size(), is(0));
  }
View Full Code Here

  /**
   * Asserts that the compilation succeeds regardless of whether any diagnostics were produced.
   */
  private void assertCompileSucceedsIgnoringWarnings(List<JavaFileObject> sources) {
    List<String> allArgs = buildArguments(Collections.<String>emptyList());
    Result exitCode = compile(asJavacList(sources), allArgs.toArray(new String[0]));
    assertThat(diagnosticHelper.getDiagnostics().toString(), exitCode, is(Result.OK));
  }
View Full Code Here

   * @param args The list of args to pass to the compilation
   */
  public void assertCompileFailsWithMessages(List<JavaFileObject> sources, List<String> args)
      throws IOException {
    List<String> allArgs = buildArguments(args);
    Result exitCode = compile(asJavacList(sources), allArgs.toArray(new String[0]));
    assertThat("Compiler returned an unexpected error code", exitCode, is(Result.ERROR));
    for (JavaFileObject source : sources) {
      diagnosticHelper.assertHasDiagnosticOnAllMatchingLines(source);
    }
  }
View Full Code Here

TOP

Related Classes of com.sun.tools.javac.main.Main.Result

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.