瀏覽代碼

Jdk classes no longer 'created', stopped 2nd registration of empty classes

- Apparently, ZC tried to create (empty) java.lang and java.util classes
- Script blocks and Module Highleveldefinitions create the same class and they aren't merged but the scripts blocks (which run later) try to replace the definitions. Workaround by preventing 2nd registrations and printing to System.err
kindlich 5 年之前
父節點
當前提交
341f8c23f5
沒有發現已知的金鑰在資料庫的簽署中

+ 6
- 2
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/JavaBytecodeModule.java 查看文件

29
 	public void addClass(String name, byte[] bytecode) {
29
 	public void addClass(String name, byte[] bytecode) {
30
 		if (bytecode == null)
30
 		if (bytecode == null)
31
 			return;
31
 			return;
32
-		
33
-		classes.put(name, bytecode);
32
+
33
+		if(name.startsWith("java")) {
34
+			System.err.println("Invalid name " + name);
35
+		} else {
36
+			classes.put(name, bytecode);
37
+		}
34
 	}
38
 	}
35
 	
39
 	
36
 	public void addScript(JavaScriptMethod method) {
40
 	public void addScript(JavaScriptMethod method) {

+ 7
- 1
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/JavaCompiler.java 查看文件

103
 				target.addScript(method);
103
 				target.addScript(method);
104
 
104
 
105
 			entry.getValue().classWriter.visitEnd();
105
 			entry.getValue().classWriter.visitEnd();
106
-			target.addClass(entry.getKey(), entry.getValue().classWriter.toByteArray());
106
+
107
+			if (target.getClasses().containsKey(entry.getKey())) {
108
+				//TODO Scripts and definitions seem to create the same class. Bad!
109
+				System.err.println("Trying to register " + entry.getKey() + " a 2nd time");
110
+			}else{
111
+				target.addClass(entry.getKey(), entry.getValue().classWriter.toByteArray());
112
+			}
107
 		}
113
 		}
108
 
114
 
109
 		return target;
115
 		return target;

Loading…
取消
儲存