File tree 1 file changed +8
-2
lines changed
jvm/src/main/scala/org/portablescala/reflect 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 1
1
package org .portablescala .reflect
2
2
3
+ import java .lang .reflect .InvocationTargetException
4
+
3
5
/** A wrapper for a class that can be instantiated.
4
6
*
5
7
* @param runtimeClass
@@ -18,9 +20,13 @@ final class InstantiatableClass private[reflect] (val runtimeClass: Class[_]) {
18
20
*/
19
21
def newInstance (): Any = {
20
22
try {
21
- runtimeClass.newInstance()
23
+ runtimeClass.getDeclaredConstructor(). newInstance()
22
24
} 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 =>
24
30
/* The constructor exists but is private; make it look like it does not
25
31
* exist at all.
26
32
*/
You can’t perform that action at this time.
0 commit comments