1 | static Class<?> hotwire_overBot(String progID) ctex {
|
2 | S compilerBot = "Compiler Bot with caching!";
|
3 | startBot(compilerBot, "#1002203");
|
4 |
|
5 | S ss = "please compile this javax snippet: *";
|
6 | print("Sending to compiler bot: " + ss);
|
7 | S s = sendToLocalBot_cached(compilerBot, ss, progID);
|
8 | new Matches m;
|
9 | print(s);
|
10 | assertTrue("Compiler Bot response: " + s, match("ok, *", s, m));
|
11 | S jarPath = m.unq(0);
|
12 | File jar = new File(jarPath);
|
13 | assertTrue(jar.getAbsolutePath(), jar.isFile());
|
14 |
|
15 | // collect urls (program + libraries)
|
16 |
|
17 | L<URL> urls = litlist(jar.toURI().toURL());
|
18 | S dehlibs = unnull(loadTextFileFromZip(jar, "libraries"));
|
19 |
|
20 | Matcher matcher = Pattern.compile("\\d+").matcher(dehlibs);
|
21 | while (matcher.find()) {
|
22 | S libID = matcher.group();
|
23 | urls.add(loadLibrary(libID).toURI().toURL());
|
24 | }
|
25 |
|
26 | // make class loader
|
27 | URLClassLoader classLoader = new URLClassLoader(urls.toArray(new URL[l(urls)]));
|
28 |
|
29 | // load & return main class
|
30 | Class<?> theClass = classLoader.loadClass("main");
|
31 |
|
32 | Class j = getJavaX();
|
33 |
|
34 | S src = loadTextFileFromZip(jar, "main.java");
|
35 | call(j, "registerSourceCode", theClass, src);
|
36 |
|
37 | synchronized(j) { // hopefully this goes well...
|
38 | call(j, "setVars", theClass, progID);
|
39 | callOpt(j, "addInstance", progID, theClass);
|
40 | }
|
41 |
|
42 | hotwire_copyOver(theClass);
|
43 |
|
44 | return theClass;
|
45 | } |