java compiler regression in nested varags

XMLWordPrintable

    • Type: Bug
    • Resolution: Duplicate
    • Priority: P2
    • None
    • Affects Version/s: 9
    • Component/s: tools
    • generic
    • generic

      Please refer to the following sample code.
      This file can be compiled before jdk 9 b94 (JDK 8 can compile too). It looks a regression in javac (type inference?). I can reproduce on both Linux/mac, so looks to be OS independent.

      I saw a bunch of changes on javac were integrated in jdk 9 b94. The following items may be related:
      JDK-8067767
      JDK-8046685
      JDK-8142931

      import java.util.stream.Stream;

      public class TypeInfer {
          public static <E extends Exception> void perform(Func<? extends E>... args) throws E {
              perform(Stream.of(args));
          }

          public static <E extends Exception> void perform(Func<? extends E> args) throws E {
              perform(Stream.of(args));
          }

          public static <E extends Exception> void perform(Stream<Func<? extends E>> list) throws E {
          }

          public interface Func<E extends Exception> {
              void func();// throws E;
          }
      }


      Javac output with jdk 9 after b94:
      TypeInfer.java:4: error: unreported exception Exception; must be caught or declared to be thrown
                      perform(Stream.of(args));
                             ^
      Note: TypeInfer.java uses unchecked or unsafe operations.
      Note: Recompile with -Xlint:unchecked for details.
      1 error
      2 warnings

            Assignee:
            Dan Smith
            Reporter:
            Xiaofeng Yang
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: