fix: set constructor accessible before invocation
This commit is contained in:
parent
1d000d813c
commit
0f712a14c1
|
@ -3,6 +3,7 @@ import org.gradle.api.JavaVersion.VERSION_1_8
|
|||
val specTitle = "JAlec"
|
||||
val artifact = specTitle.lowercase()
|
||||
group = "net.anvilcraft"
|
||||
version = "0.1.1"
|
||||
|
||||
plugins {
|
||||
id("java")
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package net.anvilcraft.alec.jalec.strategies.implementations;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
import net.anvilcraft.alec.jalec.IAlecException;
|
||||
import net.anvilcraft.alec.jalec.factories.AlecCriticalRuntimeErrorExceptionFactory;
|
||||
import net.anvilcraft.alec.jalec.strategies.interfaces.IAlecExceptionContructionStrategy;
|
||||
|
@ -9,8 +11,12 @@ public class StandardConstructorAlecExceptionConstructionStrategy<E extends IAle
|
|||
@Override
|
||||
public E constructAlecException(String message, Throwable cause, Class<E> alecExceptionClass) {
|
||||
try {
|
||||
return alecExceptionClass.getConstructor(String.class, Throwable.class)
|
||||
.newInstance(message, cause);
|
||||
Constructor<E> constructor
|
||||
= alecExceptionClass.getConstructor(String.class, Throwable.class);
|
||||
|
||||
constructor.setAccessible(true);
|
||||
|
||||
return constructor.newInstance(message, cause);
|
||||
} catch (Exception e) {
|
||||
throw AlecCriticalRuntimeErrorExceptionFactory.PLAIN.createAlecExceptionWithCause(
|
||||
e, "Error while constructing ALEC exception"
|
||||
|
|
Loading…
Reference in a new issue