test/tools/javac/multicatch/Neg07.java

Thu, 21 Feb 2013 15:26:46 +0000

author
mcimadamore
date
Thu, 21 Feb 2013 15:26:46 +0000
changeset 1599
9f0ec00514b6
parent 0
959103a6100f
permissions
-rw-r--r--

8007461: Regression: bad overload resolution when inner class and outer class have method with same name
Summary: Fix regression in varargs method resolution introduced by bad refactoring
Reviewed-by: jjg

     1 /*
     2  * @test  /nodynamiccopyright/
     3  * @bug 7039822
     4  * @summary Verify typing of lub of exception parameter w.r.t getClass
     5  * @author Joseph D. Darcy
     6  * @compile/fail/ref=Neg07.out -XDrawDiagnostics Neg07.java
     7  */
     9 public class Neg07 {
    10     private static void test(int i) {
    11         try {
    12             thrower(i);
    13         } catch (SonException | DaughterException e) {
    14             Class<? extends HasFoo> clazz2 = e.getClass(); // Rejected!
    15             HasFoo m = e;
    16             e.foo();
    17         }
    18     }
    20     private static interface HasFoo {
    21         void foo();
    22     }
    24     static void thrower(int i) throws SonException, DaughterException {
    25         if (i == 0)
    26             throw new SonException();
    27         else
    28             throw new DaughterException();
    29     }
    31     private static class ParentException extends RuntimeException {}
    33     private static class SonException
    34         extends ParentException
    35         implements HasFoo {
    37         public void foo() {
    38             System.out.println("SonException.foo");
    39         }
    40     }
    42     private static class DaughterException
    43         extends ParentException
    44         implements HasFoo {
    46         public void foo() {
    47             System.out.println("DaughterException.foo");
    48         }
    49     }
    50 }

mercurial