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

java compiler regression in nested varags

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2
    • Resolution: Duplicate
    • Affects Version/s: 9
    • Fix Version/s: None
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      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

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: