Giter Site home page Giter Site logo

jimcy's Introduction

JIMCy

Info

JIMCy(Java In Memory Compiler) is a lightweight library wrapped around javax.tools.JavaCompiler. It allows you to compile String-based sources without use of filesystem.

Build Status

Example

Following examples are minimal. API tries to be as customizable as the javax.tools.JavaCompiler.

Scala

import com.github.krever.jimcy.JIMCompiler

val simpleClassSource = """
                        |public class HelloWorld {
                        |  public static void main(String args[]) {
                        |    System.out.println("This is in another java file");
                        |  }
                        |}
                        """.stripMargin

val jimCompiler = JIMCompiler.newCompiler()

val result = jimCompiler.compile(List(simpleClassSource))
val clazz = result.classLoader.loadClass(simpleClassName)

Java

import com.github.krever.jimcy.j_api.JIMCompiler

JIMCompiler compiler = JIMCompilerFactory.newCompiler();
CompilationTask<DiagnosticCollector<JavaFileObject>> compilationTask = compiler.compilation(Arrays.asList("sourceCode")));
CompilationResult<DiagnosticCollector<JavaFileObject>> compilationResult = compilationTask.run();

Install

libraryDependencies += "com.github.krever" %% "jimcy-core" % "0.2.0"
libraryDependencies += "com.github.krever" %% "jimcy-java-api" % "0.2.0"

Thanks

http://www.javablogging.com/dynamic-in-memory-compilation/

jimcy's People

Contributors

krever avatar

Watchers

 avatar  avatar  avatar

jimcy's Issues

Broken Intellij build.

Intellij is not able to build project, because of lombok integration in java-api. In sbt compileOrder is a solution.

Error:(34, 65) value getClassName is not a member of pl.krever.jimcy.j_api.CompilationUnit
      compilationEntries = compilationUnits.toList.map( u => (u.getClassName, u.getSourceCode)),
                                                                ^
Error:(34, 81) value getSourceCode is not a member of pl.krever.jimcy.j_api.CompilationUnit
      compilationEntries = compilationUnits.toList.map( u => (u.getClassName, u.getSourceCode)),
                                                                                ^
Error:(43, 7) too many arguments for constructor CompilationResult: ()pl.krever.jimcy.j_api.CompilationResult[DiagnosticListenerType]
      new CompilationResult[DiagnosticListenerType](scalaResult.status, scalaResult.diagnostics, javaInMemoryClassLoader)
      ^

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.