picadoh / imc Goto Github PK
View Code? Open in Web Editor NEWIn-Memory Java Compiler
License: MIT License
In-Memory Java Compiler
License: MIT License
Based on the following two observations:
The method public CompilationPackage compile(Map<String, String> classesToCompile) throws CompilerException
of the class InMemoryCompiler
declares that throws that Exception, therefore enforces to be handled explictly. Of course same applies to singleCompile
In the tl;dr use case this exception is not handled, probably delegated to the main(String[] args)
method or a unit test
Three proposals for a more flexible (end user point of view) approach, the three of them imply removing the explicit throws
of the methods:
Provide a null-like CompilationPackage
so that BaseCompilationPackage
is an interface that is implemented by NullCompilationPackage
and CompilationPackage
(say).
Provide a way to access the compilationReport
in the CompilationPackage
so that the user of the compiler can decide what to do with the CompilationPackage result.
A combination of both 1 and 2.
A use case is an interface declaring a single method such as:
public interface CompilationPackageGenerator<T> {
CompilationPackage compile (T t);
}
whose implementation may be
@Override
public CompilationPackage compile(Foo foo)
{
HashMap<String, String> classes = irrelevantSourceCodeSupplier(foo);
try
{
return inMemoryCompiler.compile(classes);
}
catch (InMemoryCompiler.CompilerException e)
{
e.printStackTrace();
}
return null;
}
The return null
is the part that lead me to open this ticket. I don't want to add throws CompileException
to the interface.
Hi @picadoh
I run the application, I get the error NullPointerException.
JavaCompiler getSystemJavaCompiler () {
return ToolProvider.getSystemJavaCompiler();
}
ToolProvider.getSystemJavaCompiler() returns null.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.