Pārlūkot izejas kodu

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 gadus atpakaļ
vecāks
revīzija
341f8c23f5
Šim parakstam datu bāzē netika atrasta zināma atslēga

+ 6
- 2
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/JavaBytecodeModule.java Parādīt failu

@@ -29,8 +29,12 @@ public class JavaBytecodeModule extends JavaCompiledModule {
29 29
 	public void addClass(String name, byte[] bytecode) {
30 30
 		if (bytecode == null)
31 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 40
 	public void addScript(JavaScriptMethod method) {

+ 7
- 1
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/JavaCompiler.java Parādīt failu

@@ -103,7 +103,13 @@ public class JavaCompiler {
103 103
 				target.addScript(method);
104 104
 
105 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 115
 		return target;

Notiek ielāde…
Atcelt
Saglabāt