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

Generic throws, overriding and method reference

XMLWordPrintable

    • b100
    • 8
    • b106
    • Verified

      Compiler fails to compile the following code:

      import java.io.PrintStream;

      interface A {
          public <E extends Throwable> void foo() throws E ;
      }

      interface B extends A{
           public void foo() throws Throwable ;
      }

      public class lmbd09501m0111{
          public static void main(String argv[]) {
              System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
          }

          public void boo() throws Throwable {}

          public static int run(String argv[], PrintStream out) {
              try {
                  B b = new lmbd09501m0111()::boo;
                  b.foo();
              } catch(Throwable ex) {
                  return 2/*STATUS_FAILED*/;
              }
              return 0/*STATUS_PASSED*/;
          }
      }
         
      Compiler output:
      error: incompatible thrown types Throwable in method reference
                  B b = new lmbd09501m0111()::boo;

      The following JCK tests fail:

      lang/LMBD/lmbd095/lmbd09501m2111/lmbd09501m2111.html
      lang/LMBD/lmbd095/lmbd09501m0111/lmbd09501m0111.html
      lang/LMBD/lmbd095/lmbd09501m1111/lmbd09501m1111.html
      lang/LMBD/lmbd095/lmbd09501m4111/lmbd09501m4111.html
      lang/LMBD/lmbd095/lmbd09501m2111/lmbd09501m2111_rt.html
      lang/LMBD/lmbd095/lmbd09501m0111/lmbd09501m0111_rt.html
      lang/LMBD/lmbd095/lmbd09501m1111/lmbd09501m1111_rt.html
      lang/LMBD/lmbd095/lmbd09501m4111/lmbd09501m4111_rt.html


            vromero Vicente Arturo Romero Zaldivar
            vrudomet Victor Rudometov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: