Uses 1806K of libraries. Click here for Pure Java version (712L/6K/20K).
!7 lib 1001164 // ecj import org.eclipse.jdt.internal.compiler.ClassFile; import org.eclipse.jdt.internal.compiler.CompilationResult; import org.eclipse.jdt.internal.compiler.Compiler; import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies; import org.eclipse.jdt.internal.compiler.ICompilerRequestor; import org.eclipse.jdt.internal.compiler.batch.CompilationUnit; import org.eclipse.jdt.internal.compiler.batch.FileSystem; import org.eclipse.jdt.internal.compiler.batch.FileSystem.Classpath; import org.eclipse.jdt.internal.compiler.env.ICompilationUnit; import org.eclipse.jdt.internal.compiler.env.INameEnvironment; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; import org.eclipse.jdt.internal.compiler.util.Util; p { compile("package test; class main {} class bla {}", "main.java"); } static void compile(String code, String filename) { L<FileSystem.Classpath> cp = new L; Util.collectRunningVMBootclasspath(cp); INameEnvironment env = new FileSystem(cp.toArray(new FileSystem.Classpath[cp.size()]), null) {}; ICompilerRequestor requestor = new ICompilerRequestor() { @Override public void acceptResult(CompilationResult result) { ClassFile[] cf = result.getClassFiles(); print("Got " + n(cf, "class file")); for (ClassFile c : cf) print("File: " + str(c.fileName()) + ", bytes: " + l(c.getBytes())); } }; Compiler compiler = new Compiler(env, DefaultErrorHandlingPolicies.exitAfterAllProblems(), new CompilerOptions(), requestor, new DefaultProblemFactory()); ICompilationUnit[] units = new ICompilationUnit[] { new CompilationUnit(code.toCharArray(), filename, null) }; compiler.compile(units); }
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1006406 |
Snippet name: | Test straight-to-memory compilation using Eclipse compiler |
Eternal ID of this version: | #1006406/1 |
Text MD5: | 18e59089be5af3c2bd01a358b0736308 |
Transpilation MD5: | 0ebf607ccdaad6c5691d283057c863da |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-01-01 15:14:53 |
Source code size: | 1832 bytes / 41 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 563 / 716 |
Referenced in: | -