Skip to content

Commit 4b3dc39

Browse files
committed
Remove the final modifiers from the "interpreter" and the "module" fields in the "LangNativeModule" class and change the "LangModuleManager" class to be compatible with Java 12+
1 parent 858d6ad commit 4b3dc39

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

src/me/jddev0/module/lang/LangModuleManager.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import java.lang.reflect.Constructor;
1010
import java.lang.reflect.Field;
1111
import java.lang.reflect.InvocationTargetException;
12-
import java.lang.reflect.Modifier;
1312
import java.util.HashMap;
1413
import java.util.List;
1514
import java.util.Map;
@@ -399,17 +398,12 @@ protected Class<?> findClass(String name) throws ClassNotFoundException {
399398

400399
LangNativeModule langNativeModule = lnmArray[0] = (LangNativeModule)entryPointConstructor.newInstance();
401400

402-
Field modifiersField = Field.class.getDeclaredField("modifiers");
403-
modifiersField.setAccessible(true);
404-
405401
Field interpreterField = LangNativeModule.class.getDeclaredField("interpreter");
406402
interpreterField.setAccessible(true);
407-
modifiersField.setInt(interpreterField, interpreterField.getModifiers() & ~Modifier.FINAL);
408403
interpreterField.set(langNativeModule, interpreter);
409404

410405
Field moduleField = LangNativeModule.class.getDeclaredField("module");
411406
moduleField.setAccessible(true);
412-
modifiersField.setInt(moduleField, moduleField.getModifiers() & ~Modifier.FINAL);
413407
moduleField.set(langNativeModule, module);
414408
}catch(ClassNotFoundException|NoSuchMethodException|SecurityException|InstantiationException|
415409
IllegalAccessException|IllegalArgumentException|InvocationTargetException|NoSuchFieldException e) {

src/me/jddev0/module/lang/LangNativeModule.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ public abstract class LangNativeModule {
1414
/**
1515
* The value for this field will be injected after the instantiation with the default constructor
1616
*/
17-
protected final LangInterpreter interpreter = null;
17+
protected LangInterpreter interpreter;
1818
/**
1919
* The value for this field will be injected after the instantiation with the default constructor
2020
*/
21-
protected final LangModule module = null;
21+
protected LangModule module;
2222

2323
protected final void exportFunction(String functionName, LangPredefinedFunctionObject func) {
2424
if(!module.isLoad())

0 commit comments

Comments
 (0)