-
-
Save DasBrain/61d2859a66183d29cb2eb9bf4cc1c81b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package pkg; | |
public class Exceptions { | |
private static class EBase extends Exception { | |
public void m() {} | |
} | |
public static class E1 extends EBase {} | |
public static class E2 extends EBase {} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pkg.Exceptions; | |
public class ExceptionsTest { | |
public static void main(String[] args) { | |
try { | |
m1(); | |
} catch (Exceptions.E1 | Exceptions.E2 e) { | |
e.m(); | |
} | |
} | |
private static void m1() throws Exceptions.E1, Exceptions.E2 { | |
throw new Exceptions.E1(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> java ExceptionsTest | |
Exception in thread "main" java.lang.IllegalAccessError: failed to access class pkg.Exceptions$EBase from class ExceptionsTest (pkg.Exceptions$EBase and ExceptionsTest are in unnamed module of loader 'app') | |
at ExceptionsTest.main(ExceptionsTest.java:8) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment