1 | // compile JavaX source and load main class |
2 | static Class<?> compileAndLoadMainClass(String src) ctex { |
3 | O javax = getJavaX(); |
4 | File srcDir = cast call(javax, "TempDirMaker_make"); |
5 | File classesDir = cast call(javax, "TempDirMaker_make"); |
6 | saveTextFile(new File(srcDir, "main.java"), src); |
7 | new List<File> libraries; |
8 | set(javax, "safeTranslate", true); |
9 | File transpiledDir = cast call(javax, "topLevelTranslate", srcDir, libraries); |
10 | String javacOutput = cast call(javax, "compileJava", transpiledDir, libraries, classesDir); |
11 | System.out.println(javacOutput); |
12 | URL[] urls = {classesDir.toURI().toURL()}; |
13 | |
14 | // make class loader |
15 | URLClassLoader classLoader = new URLClassLoader(urls); |
16 | |
17 | // load main class |
18 | Class<?> mainClass = classLoader.loadClass("main"); |
19 | return mainClass; |
20 | } |
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
No comments. add comment
Snippet ID: | #1000595 |
Snippet name: | compileAndLoadMainClass |
Eternal ID of this version: | #1000595/1 |
Text MD5: | c448ae451102854af320b5fc84fdc816 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-04-20 18:51:39 |
Source code size: | 812 bytes / 20 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 681 / 929 |
Referenced in: | [show references] |