Created
May 15, 2012 14:19
-
-
Save siosio/2702119 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
import java.io.IOException; | |
public class NewInstanceInClass { | |
public NewInstanceInClass() throws Throwable { | |
// チェック例外を送出する。 | |
throw new IOException(); | |
} | |
public static void main(String[] args) { | |
invoke(); | |
} | |
// チェック例外が補足されずに上位にthrowされる。 | |
private static void invoke() { | |
Class<NewInstanceInClass> clazz = NewInstanceInClass.class; | |
try { | |
clazz.newInstance(); | |
} catch (InstantiationException e) { | |
System.out.println("InstantiationException"); | |
e.printStackTrace(); | |
} catch (IllegalAccessException e) { | |
System.out.println("IllegalAccessException"); | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment