Browse Source

Made the bytecode run unit throw errors instead of eating them

Jared 5 years ago
parent
commit
82257b2a71
No account linked to committer's email address

+ 8
- 11
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/JavaBytecodeRunUnit.java View File

22
 import java.io.FileOutputStream;
22
 import java.io.FileOutputStream;
23
 import java.io.IOException;
23
 import java.io.IOException;
24
 import java.lang.reflect.InvocationTargetException;
24
 import java.lang.reflect.InvocationTargetException;
25
-import java.lang.reflect.Method;
26
-import java.util.*;
27
-import java.util.logging.Level;
28
-import java.util.logging.Logger;
25
+import java.util.ArrayList;
26
+import java.util.Collections;
27
+import java.util.HashMap;
28
+import java.util.List;
29
+import java.util.Map;
29
 
30
 
30
 /**
31
 /**
31
  * @author Hoofdgebruiker
32
  * @author Hoofdgebruiker
57
 		}
58
 		}
58
 	}
59
 	}
59
 
60
 
60
-	public void run() {
61
+	public void run() throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
61
 		run(Collections.emptyMap(), this.getClass().getClassLoader());
62
 		run(Collections.emptyMap(), this.getClass().getClassLoader());
62
 	}
63
 	}
63
 
64
 
64
-	public void run(Map<FunctionParameter, Object> arguments) {
65
+	public void run(Map<FunctionParameter, Object> arguments) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
65
 		run(arguments, this.getClass().getClassLoader());
66
 		run(arguments, this.getClass().getClassLoader());
66
 	}
67
 	}
67
 
68
 
68
-	public void run(Map<FunctionParameter, Object> arguments, ClassLoader parentClassLoader) {
69
+	public void run(Map<FunctionParameter, Object> arguments, ClassLoader parentClassLoader) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
69
 		writeScripts();
70
 		writeScripts();
70
 
71
 
71
 		ScriptClassLoader classLoader = new ScriptClassLoader(parentClassLoader);
72
 		ScriptClassLoader classLoader = new ScriptClassLoader(parentClassLoader);
78
 
79
 
79
 			argumentsArray[i] = arguments.get(parameter);
80
 			argumentsArray[i] = arguments.get(parameter);
80
 		}
81
 		}
81
-		try {
82
 			Class[] classes = new Class[scriptParameters.size()];
82
 			Class[] classes = new Class[scriptParameters.size()];
83
 			for (int i = 0; i < classes.length; i++)
83
 			for (int i = 0; i < classes.length; i++)
84
 				classes[i] = loadClass(classLoader, scriptParameterInfo.get(i).typeDescriptor);
84
 				classes[i] = loadClass(classLoader, scriptParameterInfo.get(i).typeDescriptor);
85
 			classLoader.loadClass("Scripts").getMethod("run", classes).invoke(null, argumentsArray);
85
 			classLoader.loadClass("Scripts").getMethod("run", classes).invoke(null, argumentsArray);
86
-		} catch (ClassNotFoundException | InvocationTargetException | NoSuchMethodException | IllegalAccessException | SecurityException | IllegalArgumentException ex) {
87
-			Logger.getLogger(JavaBytecodeRunUnit.class.getName()).log(Level.SEVERE, null, ex);
88
-		}
89
 	}
86
 	}
90
 
87
 
91
 	public void dump(File directory) {
88
 	public void dump(File directory) {

Loading…
Cancel
Save