Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8328045

javac prints out all recoverable errors when one unrecoverable issue is present

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 8, 11, 17, 21, 22
    • tools
    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM :
      When using an annotation processor library which generates new classes which are referenced by the files in the initial round of compilation, and one of the original files also contain an error, javac will report all errors including those related to missing classes which would have been generated in the next round of processing. When the number of missing classes is quite important, this makes diagnosing the actual issue very hard to find amongst tens of hundreds of error messages.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1/ Get immutables library from Maven Central
      https://repo1.maven.org/maven2/org/immutables/value/2.10.1/value-2.10.1.jar

      2/ try to compile both source files (Bad.java and ValueObject.java)

      3/ Check javac output

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Javac should only report the problem in Bad.java

      ```
      example/Bad.java:10: error: method bad() is already defined in class Bad
          public void bad() {
                      ^
      1 error
      ```
      ACTUAL -
      Javac also reports about missing classes

      ```
      example/ValueObject.java:9: error: cannot find symbol
      public interface ValueObject extends WithValueObject {
                                           ^
        symbol: class WithValueObject
      example/ValueObject.java:15: error: package ImmutableValueObject does not exist
        class Builder extends ImmutableValueObject.Builder {}
                                                  ^
      example/Bad.java:10: error: method bad() is already defined in class Bad
          public void bad() {
                      ^
      3 errors
      ```

      ---------- BEGIN SOURCE ----------
      // example/Bad.java
      package example;

      /**
       * A class with a duplicate method
       */
      class Bad {
          public void bad() {
          }

          public void bad() {
          }
      }

      // example/ValueObject.java
      package example;

      import java.util.List;
      import java.util.Optional;
      import org.immutables.value.Value;

      // Define abstract value type using interface, abstract class or annotation
      @Value.Immutable
      public interface ValueObject extends WithValueObject {
        // WithValueObject is not yet generated, We extend With* to inherit `with*` method signatures
        String name();
        List<Integer> counts();
        Optional<String> description();

        class Builder extends ImmutableValueObject.Builder {}
        // ImmutableValueObject.Builder will be generated and
        // our builder will inherit and reexport methods as its own.
        // Static nested Builder will inherit all the public method
        // signatures of ImmutableValueObject.Builder
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


        1. Bad.java
          0.1 kB
        2. value-2.10.1.jar
          3.12 MB
        3. ValueObject.java
          0.7 kB

            jlahoda Jan Lahoda
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: