File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
jvm/src/main/scala/org/portablescala/reflect Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 11package org .portablescala .reflect
22
3+ import java .lang .reflect .InvocationTargetException
4+
35/** A wrapper for a class that can be instantiated.
46 *
57 * @param runtimeClass
@@ -18,9 +20,13 @@ final class InstantiatableClass private[reflect] (val runtimeClass: Class[_]) {
1820 */
1921 def newInstance (): Any = {
2022 try {
21- runtimeClass.newInstance()
23+ runtimeClass.getDeclaredConstructor(). newInstance()
2224 } catch {
23- case e : IllegalAccessException =>
25+ case e : InvocationTargetException if e.getCause != null =>
26+ throw e.getCause
27+ case e : NoSuchMethodException =>
28+ throw new InstantiationException (runtimeClass.getName).initCause(e)
29+ case _ : IllegalAccessException =>
2430 /* The constructor exists but is private; make it look like it does not
2531 * exist at all.
2632 */
You can’t perform that action at this time.
0 commit comments