Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

45
LINES

< > BotCompany Repo | #1002246 // hotwire_overBot (uses compiler bot, experimental)

JavaX fragment (include)

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  
}

Author comment

Began life as a copy of #1000963

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

Comments [hide]

ID Author/Program Comment Date
1204 stefan TODO: Load source code for registerSourceCode 2016-01-22 01:50:23

add comment

Snippet ID: #1002246
Snippet name: hotwire_overBot (uses compiler bot, experimental)
Eternal ID of this version: #1002246/1
Text MD5: 424a67ec0a6ba64da2ace23a48c1a811
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-05-01 18:12:36
Source code size: 1388 bytes / 45 lines
Pitched / IR pitched: No / No
Views / Downloads: 919 / 2134
Referenced in: [show references]