Skip to content

Commit 81fe1e0

Browse files
committed
fix access to constructor
1 parent ac1d23c commit 81fe1e0

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

jme3-core/src/main/java/com/jme3/util/struct/fields/SubStructArrayField.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.jme3.util.struct.fields;
22

33
import java.lang.reflect.Array;
4+
import java.lang.reflect.Constructor;
45

56
import com.jme3.util.struct.Struct;
67
import com.jme3.util.struct.StructField;
@@ -20,7 +21,9 @@ public SubStructArrayField(int position, String name, int length, Class<? extend
2021
private void initializeToZero(Class<? extends T> structClass) {
2122
for (int i = 0; i < value.length; i++) {
2223
if (value[i] == null) try {
23-
value[i] = structClass.getDeclaredConstructor().newInstance();
24+
Constructor<? extends T> constructor = structClass.getDeclaredConstructor();
25+
constructor.setAccessible(true);
26+
value[i] = constructor.newInstance();
2427
} catch (Exception e) {
2528
throw new RuntimeException("Can't create new instance of " + structClass + " default constructor is missing? ",e);
2629
}

0 commit comments

Comments
 (0)