Created
May 15, 2012 14:25
-
-
Save siosio/2702154 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; | |
import java.lang.reflect.Constructor; | |
import java.lang.reflect.InvocationTargetException; | |
public class NewInstanceInConstructor { | |
public NewInstanceInConstructor() throws Throwable { | |
// チェック例外を送出する。 | |
throw new IOException(); | |
} | |
public static void main(String[] args) throws NoSuchMethodException { | |
invoke(); | |
} | |
private static void invoke() throws NoSuchMethodException { | |
Constructor<NewInstanceInConstructor> constructor = | |
NewInstanceInConstructor.class.getConstructor(); | |
try { | |
constructor.newInstance(); | |
} catch (InstantiationException e) { | |
e.printStackTrace(); | |
} catch (IllegalAccessException e) { | |
e.printStackTrace(); | |
} catch (InvocationTargetException e) { | |
// 例外が発生するので、ここで補足される。 | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment