diff options
author | Jeff Hao <jeffhao@google.com> | 2014-04-23 14:55:10 -0700 |
---|---|---|
committer | Jeff Hao <jeffhao@google.com> | 2014-04-23 17:52:03 -0700 |
commit | 793b9ef91876cb7bea31ddf74f110ac45302f1dd (patch) | |
tree | afc54f40f9c741e2e22b856767b8f65080d26a95 | |
parent | 2e667679740a2a204b7f0566d2ba334b3fb2acc1 (diff) | |
download | libcore-793b9ef91876cb7bea31ddf74f110ac45302f1dd.zip libcore-793b9ef91876cb7bea31ddf74f110ac45302f1dd.tar.gz libcore-793b9ef91876cb7bea31ddf74f110ac45302f1dd.tar.bz2 |
Fix Class.newInstance to not wrap its exceptions.
Unlike Constructor.newInstance, Class.newInstance should not wrap
exceptions it throws.
Bug: https://code.google.com/p/android/issues/detail?id=68620
Change-Id: I3b89e8417d770b1908fea585062e62d5de292331
-rw-r--r-- | libart/src/main/java/java/lang/Class.java | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/libart/src/main/java/java/lang/Class.java b/libart/src/main/java/java/lang/Class.java index ea41d6e..c66b01a 100644 --- a/libart/src/main/java/java/lang/Class.java +++ b/libart/src/main/java/java/lang/Class.java @@ -62,6 +62,7 @@ import libcore.reflect.Types; import libcore.util.BasicLruCache; import libcore.util.CollectionUtils; import libcore.util.EmptyArray; +import libcore.util.SneakyThrow; /** * The in-memory representation of a Java class. This representation serves as @@ -1568,11 +1569,10 @@ public final class Class<T> implements Serializable, AnnotatedElement, GenericDe throw new IllegalAccessException(init + " is not accessible from " + caller); } try { - return init.newInstance(null, init.isAccessible()); + return init.newInstance(null, init.isAccessible()); } catch (InvocationTargetException e) { - InstantiationException t = new InstantiationException(this); - t.initCause(e); - throw t; + SneakyThrow.sneakyThrow(e.getCause()); + return null; // Unreachable. } } |