org.codehaus.janino.util.ClassFile Java Examples
The following examples show how to use
org.codehaus.janino.util.ClassFile.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JaninoClassCompiler.java From dremio-oss with Apache License 2.0 | 6 votes |
@Override protected ClassBytes[] getByteCode(final ClassNames className, final String sourcecode, boolean debug) throws CompileException, IOException, ClassNotFoundException, ClassTransformationException { StringReader reader = new StringReader(sourcecode); Scanner scanner = new Scanner((String) null, reader); Java.CompilationUnit compilationUnit = new Parser(scanner).parseCompilationUnit(); ClassFile[] classFiles = new UnitCompiler(compilationUnit, compilationClassLoader) .compileUnit(debug, debug, debug); ClassBytes[] byteCodes = new ClassBytes[classFiles.length]; for(int i = 0; i < classFiles.length; i++){ ClassFile file = classFiles[i]; byteCodes[i] = new ClassBytes(file.getThisClassName(), file.toByteArray()); } return byteCodes; }
Example #2
Source File: JaninoClassCompiler.java From Bats with Apache License 2.0 | 5 votes |
@Override protected byte[][] getByteCode(final ClassNames className, final String sourceCode) throws CompileException, IOException, ClassNotFoundException, ClassTransformationException { ClassFile[] classFiles = doCompile(sourceCode); byte[][] byteCodes = new byte[classFiles.length][]; for(int i = 0; i < classFiles.length; i++){ byteCodes[i] = classFiles[i].toByteArray(); } return byteCodes; }
Example #3
Source File: JaninoClassCompiler.java From Bats with Apache License 2.0 | 5 votes |
@Override public Map<String,byte[]> compile(final ClassNames className, final String sourceCode) throws CompileException, IOException, ClassNotFoundException { ClassFile[] classFiles = doCompile(sourceCode); Map<String,byte[]> results = new HashMap<>(); for(int i = 0; i < classFiles.length; i++) { ClassFile classFile = classFiles[i]; results.put(classFile.getThisClassName(), classFile.toByteArray()); } return results; }
Example #4
Source File: JaninoClassCompiler.java From Bats with Apache License 2.0 | 5 votes |
private ClassFile[] doCompile(final String sourceCode) throws CompileException, IOException, ClassNotFoundException { StringReader reader = new StringReader(sourceCode); Scanner scanner = new Scanner((String) null, reader); Java.CompilationUnit compilationUnit = new Parser(scanner).parseCompilationUnit(); return new UnitCompiler(compilationUnit, compilationClassLoader) .compileUnit(this.debug, this.debug, this.debug); }