|
Java example source code file (Neg07.java)
The Neg07.java Java example source code/* * @test /nodynamiccopyright/ * @bug 7039822 * @summary Verify typing of lub of exception parameter w.r.t getClass * @author Joseph D. Darcy * @compile/fail/ref=Neg07.out -XDrawDiagnostics Neg07.java */ public class Neg07 { private static void test(int i) { try { thrower(i); } catch (SonException | DaughterException e) { Class<? extends HasFoo> clazz2 = e.getClass(); // Rejected! HasFoo m = e; e.foo(); } } private static interface HasFoo { void foo(); } static void thrower(int i) throws SonException, DaughterException { if (i == 0) throw new SonException(); else throw new DaughterException(); } private static class ParentException extends RuntimeException {} private static class SonException extends ParentException implements HasFoo { public void foo() { System.out.println("SonException.foo"); } } private static class DaughterException extends ParentException implements HasFoo { public void foo() { System.out.println("DaughterException.foo"); } } } Other Java examples (source code examples)Here is a short list of links related to this Java Neg07.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.