Просмотр исходного кода

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 6 лет назад
Родитель
Сommit
341f8c23f5
Не найден GPG ключ соответствующий данной подписи

+ 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;

Загрузка…
Отмена
Сохранить