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

Creation of generic exceptions

XMLWordPrintable

    • generic
    • generic

      javac fails to reject this program. There may also be a specification bug.

      class Hole<T> {
          class X extends RuntimeException {
              T t;
              X(T t) { this.t = t; }
          }
          T foo() {
              try {
                  bar();
                  return null;
              } catch (X x) {
                  return x.t;
              }
          }
          void bar() {
              throw new Hole<Integer>().new X(3);
          }
          public static void main(String[] args) {
              System.out.println (new Hole<String>().foo());
          }
      }

            Unassigned Unassigned
            ahe Peter Ahe
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: