Code Monkey home page Code Monkey logo

java-runtime-compiler's Introduction

Chronicle Overview

Chronicle Software provides libraries to help with fast data. The majority of our customers are in financial services. Our products include:

Chronicle FIX/ITCH Engine - Low latency FIX/ITCH engine in Java for all versions of FIX. Can parse and generate messages within 1 microsecond.

Chronicle Microservices Framework - Microservices built with Chronicle Services are efficient, easy to build, test, and maintain. Equally importantly they provide exceptional high-throughput, low latency, and transparent HA/DR.

Chronicle Matching Engine - forms the backbone for a resilient and scalable exchange solution. It provides order matching, validation, and risk checks with high capacity and low latency. It has a modular and flexible design which enables it to be used stand-alone, or seamlessly integrated with Chronicle FIX and Chronicle Services.

Chronicle EFX - built on Chronicle Microservices, EFX contains components for Aggregation, Pricing, Hedging, Position Keeping, P&L, Market Gateway and Algo containers. EFX allows the customer to use off the shelf functionality built and maintained by Chronicle, or to extend and customise with their own algos and IP - the best compromise of "buy vs build".

Chronicle Queue and also Chronicle Queue Enterprise - using Chronicle Queue for low latency message passing provides an effectively unlimited buffer between producers and consumers and a complete audit trail of every message sent. Queue Enterprise provides even lower latencies and additional delivery semantics - for example - only process a message once it is guaranteed replicated to another host(s).

Chronicle Map is a key-value store sharing persisted memory between processes, either on the same server or across networks. CM is designed to store the data off-heap, which means it minimizes the heap usage and garbage collection allowing the data to be stored with sub-microsecond latency. CM is structured key-value store able to support exceptionally high updates and high throughput data e.g. OPRA Market Data with minimum configuration. Replication is provided by Chronicle Map Enterprise

Contributor agreement

For us to accept contributions to open source libraries we require contributors to sign the below

Documentation in this repo

This repo contains the following docs

  • Java Version Support documents which versions of Java/JVM are supported by Chronicle libraries

  • Platform Support documents which Operating Systems are supported by Chronicle libraries

  • Version Support explains Chronicle’s version numbers and release timetable

  • Anatomy shows a graphical representation of the OpenHFT projects and their dependencies

  • Reducing Garbage contains tips and tricks to reduce garbage

java-runtime-compiler's People

Contributors

alexdik avatar danielshaya avatar dekmm avatar dependabot[bot] avatar dpisklov avatar epickrram avatar glukos avatar hft-team-city avatar jansturenielsen avatar jerryshea avatar lburgazzoli avatar leventov avatar marcono1234 avatar minborg avatar mlesniak avatar nicktindall avatar nvdpsingh avatar peter-lawrey avatar robaustin avatar sullis avatar surajpattanaik avatar tomshercliff avatar yevgenp avatar yukoba avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

java-runtime-compiler's Issues

Java 14 : CachedCompiler.loadFromJava() throws java.lang.NoSuchFieldException: override

Code Works Well On JDK 11 but crashes on JDK 11
Im using LibericaJDK

Exception in thread "main" java.lang.AssertionError: java.lang.NoSuchFieldException: override
at net.openhft.compiler.CompilerUtils.(CompilerUtils.java:64)
at net.openhft.compiler.CachedCompiler.loadFromJava(CachedCompiler.java:140)
at net.openhft.compiler.CachedCompiler.loadFromJava(CachedCompiler.java:76)
at Test.DynamicJavaClassLoading.getStrategy(DynamicJavaClassLoading.java:51)
at Test.DynamicJavaClassLoading.main(DynamicJavaClassLoading.java:34)
Caused by: java.lang.NoSuchFieldException: override
at java.base/java.lang.Class.getDeclaredField(Class.java:2489)
at net.openhft.compiler.CompilerUtils.(CompilerUtils.java:60)
... 4 more

`package Test;

import net.openhft.compiler.CachedCompiler;

import java.lang.reflect.InvocationTargetException;

/**

  • Loads the addingStrategy and then after 3s replaces it with the

  • subtractingStrategy.
    */
    public class DynamicJavaClassLoading {

    private final static String className = "Test.MyClass";
    private final static String addingStrategy = "package Test;\n" +
    "import Test.DynamicJavaClassLoading.Strategy;\n" +
    "public class MyClass implements Strategy {\n" +
    " public int compute(int a, int b) {\n" +
    " return a+b;\n" +
    " }\n" +
    "}\n";

    private final static String subtractingStrategy = "package Test;\n" +
    "import Test.DynamicJavaClassLoading.Strategy;\n" +
    "public class MyClass implements Strategy {\n" +
    " public int compute(int a, int b) {\n" +
    " return a-b;\n" +
    " }\n" +
    "}\n";

    public static void main(String[] args) throws Exception {

     Strategy strategy;
    
     strategy = getStrategy(Type.Adding);
     System.out.println(strategy.compute(10,20));
    
     strategy = getStrategy(Type.Substracting);
     System.out.println(strategy.compute(10,20));
    

    }

    public interface Strategy{
    int compute(int a, int b);
    }

    public static Strategy getStrategy(Type type) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
    {
    ClassLoader cl = new ClassLoader() {};
    CachedCompiler cc = new CachedCompiler(null, null);
    String strategyType = (type == Type.Adding) ? addingStrategy : subtractingStrategy;
    Class aClass = cc.loadFromJava(cl, className, strategyType);
    return (Strategy) aClass.getDeclaredConstructor().newInstance();
    }
    }

    public static class StrategyProxy implements Strategy{
    private volatile Strategy underlying;

     public void setStratgey(Strategy underlying){
         this.underlying = underlying;
     }
    
     public int compute(int a, int b){
         Strategy underlying = this.underlying;
         return underlying == null ? Integer.MIN_VALUE : underlying.compute(a, b);
     }
    

    }
    }`

Illegal reflective access operation (java 11)

This is the same as #33 and #34. Adding a bit more information.

I'm using OpenJDK version 11.0.1 on a Mac. Using version 2.3.1 of the compiler library.

The error is:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by net.openhft.compiler.CompilerUtils (file:/Users/ccleve/.m2/repository/net/openhft/compiler/2.3.1/compiler-2.3.1.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int)
WARNING: Please consider reporting this to the maintainers of net.openhft.compiler.CompilerUtils
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

This warning is getting dumped to the console. I'm guessing that it's going to System.err.

The code I'm using is almost identical to the sample code in the Readme.

My best guess is that the problem is in CompilerUtils, these lines:

DEFINE_CLASS_METHOD = ClassLoader.class.getDeclaredMethod("defineClass", String.class, byte[].class, int.class, int.class);
DEFINE_CLASS_METHOD.setAccessible(true);

Here's a discussion of the issue: https://stackoverflow.com/questions/50251798/what-is-an-illegal-reflective-access

Can you subclass the classloader and get a reference to that defineClass() method, without having to do reflection?

Add JSR-223 script engine

Would it be possible to implement and export via META-INF/services a JSR-223 script engine for Java?

Just compiling and running the code is not enough for that, as you'd have to keep track of declared variables (that must be added to the engine bindings).

Feature request: Add the Eclipse compiler as an option

The Eclipse compiler has some advantages over the built-in javac compiler. You can test it by doing this:

s_compiler = new EclipseCompiler(); // ToolProvider.getSystemJavaCompiler();
Get it with this:

<dependency>
	<groupId>org.eclipse.jdt</groupId>
	<artifactId>ecj</artifactId>
	<version>3.16.0</version>
</dependency>

Obviously you don't want to force a dependency on it, so you could add a static method somewhere to set s_compiler externally. Don't call .getSystemJavaCompiler() if it gets set that way.

NullPointerException suspect at s_standardJavaFileManager

Creating compiler:

public static CachedCompiler compiler = null;
	
static {
		
	File srcDir = new File("compiler/src");
	srcDir.mkdirs();
		
	File binDir = new File("compiler/bin");
	binDir.mkdirs();
		
	compiler = new CachedCompiler(srcDir, binDir);
}

Stack trace part:
Exception in thread "main" java.lang.NullPointerException
at net.openhft.compiler.CachedCompiler.compileFromJava(CachedCompiler.java:94)
at net.openhft.compiler.CachedCompiler.loadFromJava(CachedCompiler.java:143)
at net.openhft.compiler.CachedCompiler.loadFromJava(CachedCompiler.java:70)

Java 12/13/...

Hello,

Is there any plan to support Java 12 ?
If not, do you know any viable replacement to migrate to ?

Any way to clear the loadedClassesMap in CachedCompiler class

I would like to dynamically change code during runtime but keep the same class name.

Currently the way it seems to work is that this line of code:
aClass = CompilerUtils.CACHED_COMPILER.loadFromJava(className1, javaCode);
will compile the code when it runs the first time.
The 2nd time it won't compile, it will returned the compiled class from cash instead (even if the input String javaCode is different.

Can I somehow force that every time I call that line of code it will re-compile?

Thanks a bunch
-H

Unable to Load jar file during plugin startup JDK 12

I am trying to load a jar file during plugin startup. But unable to load it with JDK 12 or later version.
below is the code snippet :
-------------------------------------CODE---------------------------------------------------
URLClassLoader urlSysLoader = new URLClassLoader(new URL[] {url}, sysLoader);
Method method = sysClass.getDeclaredMethod("addURL", parameters);
/**

The addURL() appends the specified URL to the list of URLs to search for
classes and resources. and since this Method is Protected and we are not inheriting
i'm forced to make it visible.
*/
method.setAccessible(true);
// Invoke addURL method with jar URL to add the classes to URL ClassLoader
method.invoke(urlSysLoader, new Object[] { url });
Field scl = ClassLoader.class.getDeclaredField("scl");
scl.setAccessible(true);
// Replace the static scl (System Class Loader for running instance) with
// newly created URL ClassLoader (system class loader + jar files loaded)
scl.set(null, urlSysLoader);
-----------------------------------------CODE----------------------------------------------
Getting below error :
----------------------------------------ERROR---------------------------------------------------------------------------------
java.lang.NoSuchFieldException: scl
at java.base/java.lang.Class.getDeclaredField(Class.java:2569)
at com.unisys.tde.core.characterset.OS2200CharSetPlugin.loadCharSetLib(OS2200CharSetPlugin.java:160)
at com.unisys.tde.core.characterset.OS2200CharSetPlugin$1.run(OS2200CharSetPlugin.java:66)
----------------------------------------ERROR---------------------------------------------------------------------------------

The above code was working till JDK 11 version.

Please let me know any suggestion or any other alternative approach to achieve the same.

Thanks and Regards,
Raghu

Sporadic ConcurrentModificationException when compiling lots of method readers under Java 17

	at net.openhft.chronicle.wire.GenerateMethodReader.createClass(GenerateMethodReader.java:115)
	at net.openhft.chronicle.wire.VanillaMethodReaderBuilder.lambda$createGeneratedInstance$1(VanillaMethodReaderBuilder.java:132)
	at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1740)
	at net.openhft.chronicle.wire.VanillaMethodReaderBuilder.createGeneratedInstance(VanillaMethodReaderBuilder.java:132)
	at net.openhft.chronicle.wire.VanillaMethodReaderBuilder.build(VanillaMethodReaderBuilder.java:172)
	at net.openhft.chronicle.wire.MethodReaderInterceptorReturnsTest.doTestInterceptorSupportedInGeneratedCode(MethodReaderInterceptorReturnsTest.java:112)
	at net.openhft.chronicle.wire.MethodReaderInterceptorReturnsTest.lambda$testInterceptingReaderConcurrentCreation$0(MethodReaderInterceptorReturnsTest.java:63)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.RuntimeException: java.util.ConcurrentModificationException
	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.invocationHelper(JavacTaskImpl.java:168)
	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100)
	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94)
	at net.openhft.compiler.CachedCompiler.compileFromJava(CachedCompiler.java:112)
	at net.openhft.compiler.CachedCompiler.loadFromJava(CachedCompiler.java:151)
	at net.openhft.compiler.CachedCompiler.loadFromJava(CachedCompiler.java:77)
	at net.openhft.chronicle.wire.GenerateMethodReader.createClass(GenerateMethodReader.java:104)
	... 12 more
Caused by: java.util.ConcurrentModificationException
	at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1221)
	at jdk.compiler/com.sun.tools.javac.file.JavacFileManager.pathsAndContainers(JavacFileManager.java:1018)
	at jdk.compiler/com.sun.tools.javac.file.JavacFileManager.list(JavacFileManager.java:774)
	at net.openhft.compiler.MyJavaFileManager.list(MyJavaFileManager.java:91)
	at jdk.compiler/com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager.list(ClientCodeWrapper.java:223)
	at jdk.compiler/com.sun.tools.javac.code.ClassFinder.list(ClassFinder.java:737)
	at jdk.compiler/com.sun.tools.javac.code.ClassFinder.scanModulePaths(ClassFinder.java:609)
	at jdk.compiler/com.sun.tools.javac.code.ClassFinder.fillIn(ClassFinder.java:557)
	at jdk.compiler/com.sun.tools.javac.code.ClassFinder.complete(ClassFinder.java:299)
	at jdk.compiler/com.sun.tools.javac.code.Symbol.complete(Symbol.java:682)
	at jdk.compiler/com.sun.tools.javac.code.Symbol$PackageSymbol.members(Symbol.java:1176)
	at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.resolveImports(TypeEnter.java:359)
	at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.runPhase(TypeEnter.java:327)
	at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$Phase.doCompleteEnvs(TypeEnter.java:288)
	at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$Phase.completeEnvs(TypeEnter.java:257)
	at jdk.compiler/com.sun.tools.javac.comp.TypeEnter.complete(TypeEnter.java:204)
	at jdk.compiler/com.sun.tools.javac.code.Symbol.complete(Symbol.java:682)
	at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1410)
	at jdk.compiler/com.sun.tools.javac.comp.Enter.complete(Enter.java:610)
	at jdk.compiler/com.sun.tools.javac.comp.Enter.main(Enter.java:587)
	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:1042)
	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:917)
	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:104)
	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.invocationHelper(JavacTaskImpl.java:152)
	... 18 more

Inconsistent license information

Hi,

The LICENSE file was switched to LGPL-3 but the headers in the .java files still refer to the Apache-2.0 license. The headers should be updated, or the LICENSE file switched back to Apache-2.0 (which may be a good idea considering that Apache projects are not allowed to use LGPL libraries).

Support JDKs with strong encapsulation

Recent JDK versions, such as JDK 17, strongly encapsulate their internals, see JEP 403.
Therefore using your library fails for these versions by default because the internal JDK fields are not accessible:

java.lang.RuntimeException: java.lang.reflect.InaccessibleObjectException: Unable to make public java.lang.Iterable com.sun.tools.javac.file.JavacFileManager.listLocationsForModules(javax.tools.JavaFileManager$Location) throws java.io.IOException accessible: module jdk.compiler does not "exports com.sun.tools.javac.file" to unnamed module @c86b9e3
	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.invocationHelper(JavacTaskImpl.java:168)
	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100)
	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94)
	at net.openhft.compiler.CachedCompiler.compileFromJava(CachedCompiler.java:112)
	at net.openhft.compiler.CachedCompiler.loadFromJava(CachedCompiler.java:151)
	<omitted>
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make public java.lang.Iterable com.sun.tools.javac.file.JavacFileManager.listLocationsForModules(javax.tools.JavaFileManager$Location) throws java.io.IOException accessible: module jdk.compiler does not "exports com.sun.tools.javac.file" to unnamed module @c86b9e3
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
	at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
	at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
	at net.openhft.compiler.MyJavaFileManager.invokeNamedMethodIfAvailable(MyJavaFileManager.java:214)
	at net.openhft.compiler.MyJavaFileManager.listLocationsForModules(MyJavaFileManager.java:77)
	at jdk.compiler/com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager.listLocationsForModules(ClientCodeWrapper.java:388)
	at jdk.compiler/com.sun.tools.javac.code.ModuleFinder$ModuleLocationIterator.hasNext(ModuleFinder.java:138)
	at jdk.compiler/com.sun.tools.javac.code.ModuleFinder.scanModulePath(ModuleFinder.java:294)
	at jdk.compiler/com.sun.tools.javac.code.ModuleFinder.findAllModules(ModuleFinder.java:187)
	at jdk.compiler/com.sun.tools.javac.comp.Modules.getUnnamedModuleCompleter(Modules.java:1434)
	at jdk.compiler/com.sun.tools.javac.comp.Modules.setCompilationUnitModules(Modules.java:471)
	at jdk.compiler/com.sun.tools.javac.comp.Modules.enter(Modules.java:265)
	at jdk.compiler/com.sun.tools.javac.comp.Modules.initModules(Modules.java:231)
	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.initModules(JavaCompiler.java:1021)
	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:919)
	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:104)
	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.invocationHelper(JavacTaskImpl.java:152)
	... 133 more

This can be worked around by using --add-opens jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED, but that is rather cumbersome and brittle.
Would it be possible for this library to not rely on JDK internals (possibly at the cost that the user has to provide additional arguments)?

package does not exist

I'm trying to run the compiler inside a REST server, with Maven, but the compiler is not finding my .jar libraries.

mysource.java:3: error: package com.gargoylesoftware.htmlunit does not exist
import com.gargoylesoftware.htmlunit.BrowserVersion;
^
mysource.java:4: error: package com.gargoylesoftware.htmlunit does not exist
import com.gargoylesoftware.htmlunit.WebClient;
^
mysource.java:5: error: package com.gargoylesoftware.htmlunit.html does not exist
import com.gargoylesoftware.htmlunit.html.DomElement;

Is it possible to handle this situation?

Thx

Get the stack trace

Hi,
I'd like to capture the stack trace when the compilation fails right now i got the following console output when compilation fails :

/org/javascool/JvsToJavaTranslated2.java:5: error: invalid method declaration; return type required
int toot(){
    ^

Is it possible to capture this output in a String ?
Thank you.

reCompile question

when I compile a java file,the second time cannot work,it is still the first one.(I will change the code,but will not change the classname)How can make it diffierent when I compile it.
give me help ,3Q.

Cannot compile class after compile error

After trying to load class that has compile error, CachedCompiler cannot compile anything successfully any more:

String className = "MyClass";
String javaCode = "public class MyClass {}";

try {
  CompilerUtils.CACHED_COMPILER.loadFromJava("z" + className, " some compile error " + javaCode);
} catch (Exception ex) {
  ex.printStackTrace();
}

// This should work, but throws an exception:
CompilerUtils.CACHED_COMPILER.loadFromJava(className, javaCode);

ClassLoader provided to loadFromJava() is not used to when actually compiling a class

Classes loaded by the classLoader provided to the CachedCompiler are not visible to the class being compiled.

For example, in OSGi, if you have a class A in a bundle, then call CachedCompiler.loadFromJava() using that bundle's class loader to compile a class which refers to A, an error occurs as A is not found.

It seems the problem is that the JavaFileManager does not use the classLoader provided to loadFromJava().

I will try to fix this and make a pull request in the next couple of days or hours.

Feature request: Support collecting non-error diagnostics

Currently this library only considers error diagnostics (relevant source) and ignores all other diagnostic kinds.

Would it be possible to support collecting other diagnostic types as well (if explicitly configured)?

For example, for my use case I would like to know whether some generated code produces any compiler warnings (or other relevant diagnostics). However, it is not that important, so I can understand if you don't think it is worth it to support this feature.

Classes fail to import

This works locally, and in the individual teamcity build on chronicle1, however in the build-all it started failing on the same machine this morning.

Illegal reflective access operation (java 10)

Issue 33 didn't fix the problem for me:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by net.openhft.compiler.CompilerUtils (file:/home/p/.gradle/caches/modules-2/files-2.1/net.openhft/compiler/2.3.1/1
c598d9164a3bc8f163c19ca750c3a09a69c52af/compiler-2.3.1.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int)
WARNING: Please consider reporting this to the maintainers of net.openhft.compiler.CompilerUtils
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

Example working on Eclipse, but causing ClassNotFoundException on EC2 Centos

I am trying your sample code and it works fine when running it on my mac in eclipse using spring boot. However, when I deploy the jar file to AWS EC2 it can't find the compiler.

here is the exception I get:

nested exception is java.lang.AssertionError: java.lang.ClassNotFoundException: com.sun.tools.javac.api.JavacTool] with root cause
java.lang.ClassNotFoundException: com.sun.tools.javac.api.JavacTool
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:92)
at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at net.openhft.compiler.CompilerUtils.reset(CompilerUtils.java:81)
at net.openhft.compiler.CompilerUtils.(CompilerUtils.java:69)
at com.tictoc.util.Brain.analyzeRules(Brain.java:235)
at com.tictoc.util.Brain$$FastClassBySpringCGLIB$$953bc331.invoke()
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:749)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:136)
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:124)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)
at com.tictoc.util.Brain$$EnhancerBySpringCGLIB$$1dea4dd.analyzeRules()
at com.tictoc.controller.TradeController.analyzerules(TradeController.java:168)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:892)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1039)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:908)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:103)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:119)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at com.tictoc.jwt.JwtTokenAuthorizationOncePerRequestFilter.doFilterInternal(JwtTokenAuthorizationOncePerRequestFilter.java:80)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:74)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:114)
at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:104)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:853)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1587)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)

I am running OpenJDK Runtime Environment (build 1.8.0_242-b08) on my EC2 instance.

Any thoughts of what I am doing wrong?

Thanks!
H

I got ClassNotFoundException in Linux

It runs well in Eclipse IDE in WINDOWS. But I got ClassNotFoundException when running it in Linux. This project is building by SpringBoot and packing by Maven with JDK1.8.0_112.

Exception detail:
Caused by: java.lang.ClassNotFoundException: com.szx.core.logexp.dc.Lecilfaafaafroolfaafaafr
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at net.openhft.compiler.CachedCompiler.loadFromJava(CachedCompiler.java:163)
at net.openhft.compiler.CachedCompiler.loadFromJava(CachedCompiler.java:70)

My code:
CompilerUtils.CACHED_COMPILER.loadFromJava(className, javaCode).newInstance();

So what problem did I got?

java.lang.ClassNotFoundException: com.sun.tools.javac.api.JavacTool

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" java.lang.AssertionError: java.lang.ClassNotFoundException: com.sun.tools.javac.api.JavacTool
at net.openhft.compiler.CompilerUtils.reset(CompilerUtils.java:85)
at net.openhft.compiler.CompilerUtils.(CompilerUtils.java:69)
at tests.javacompile.Main.main(Main.java:22)
Caused by: java.lang.ClassNotFoundException: com.sun.tools.javac.api.JavacTool
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at net.openhft.compiler.CompilerUtils.reset(CompilerUtils.java:81)
... 2 more

GitHub releases are outdated

The GitHub releases tab (https://github.com/OpenHFT/Java-Runtime-Compiler/releases) is outdated. It still lists compiler-2.21ea80 from 2021 as latest release.

Could you please create new GitHub release entries for the versions you have released in between?
Or, in case you are not planning to update the GitHub releases anymore, you could hide them by clicking the gear icon next to the "About" section on the right side of your repository view; this would then reduce confusion about what the latest release is.

How to handle stale cache issues

This is more a question than an issue. If I understand the code correctly, the purpose of caching is
to avoid compiling the same class twice. But if the source code changes, recompiling should probably take place. So the question is: shouldn't there be some mechanism to auto-recompile in case of source code changes ( perhaps with some hash like md5 or with timestamps ) or at least a method to clear the entire cache ? Or do I miss something ?

RuntimeCompileTest not configured for Java 11+

on Azul Zing and Java 17 builds e.g.

java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.UnsupportedOperationException: Unable to invoke method listLocationsForModules
  at mytest.RuntimeCompileTest.testMultiThread(RuntimeCompileTest.java:85)
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.UnsupportedOperationException: Unable to invoke method listLocationsForModules
  at mytest.RuntimeCompileTest.lambda$testMultiThread$0(RuntimeCompileTest.java:79)
Caused by: java.lang.RuntimeException: java.lang.UnsupportedOperationException: Unable to invoke method listLocationsForModules
  at mytest.RuntimeCompileTest.lambda$testMultiThread$0(RuntimeCompileTest.java:75)
Caused by: java.lang.UnsupportedOperationException: Unable to invoke method listLocationsForModules
  at mytest.RuntimeCompileTest.lambda$testMultiThread$0(RuntimeCompileTest.java:75)
Caused by: java.lang.reflect.InvocationTargetException
  at mytest.RuntimeCompileTest.lambda$testMultiThread$0(RuntimeCompileTest.java:75)
Caused by: java.util.ConcurrentModificationException
  at mytest.RuntimeCompileTest.lambda$testMultiThread$0(RuntimeCompileTest.java:75)
------- Stderr: -------
Fatal Error: Unable to find package java.lang in classpath or bootclasspath

"java.lang.NoSuchFieldException: override" using loadFromJava (JDK 12, Mac)

Hello.
I'm using compiler v 2.3.4.
Here is my code:

    public ILogicalExpression generateFunction(String funcName, String function, String arguments) throws Exception {
        String prepared = prepareExpression(function, arguments);

        String className = funcName + "Expression";

        String source = "import static java.lang.Math.*;\n" +
                "public final class " + className + " implements " + BASE_CLASS_NAME + " {\n"
                + "public boolean compute(double[] args) {\n"
                + "\treturn " + prepared + ";}\n}\n";

        Class aClass = CompilerUtils.CACHED_COMPILER.loadFromJava(className, source);
        ILogicalExpression expr = (ILogicalExpression) aClass.getConstructor().newInstance();

        return expr;
    }
Exception in thread "main" java.lang.AssertionError: java.lang.NoSuchFieldException: override
	at net.openhft.compiler.CompilerUtils.<clinit>(CompilerUtils.java:64)
	at com.synstorm.common.Utils.ConfigInterfaces.CodeGeneration.LogicalFunctionFactory.generateFunction(LogicalFunctionFactory.java:35)
Caused by: java.lang.NoSuchFieldException: override
	at java.base/java.lang.Class.getDeclaredField(Class.java:2417)
	at net.openhft.compiler.CompilerUtils.<clinit>(CompilerUtils.java:60)
	... 14 more

java.lang.NoSuchFieldException: override occured when calling CompilerUtils.CACHED_COMPILER.loadFromJava.

Is it issue with my code or with compiler on Java 12?

Source files without license headers - invalid license file

Hi
The following source files are without license headers.

./compiler/src/test/java/eg/FooBarTee.java

Please, confirm the licensing of code and/or content/s, and add license headers.

https://fedoraproject.org/wiki/Packaging:LicensingGuidelines?rd=Packaging/LicensingGuidelines#License_Clarification

LICENSE.adoc file, usually it is considered as the "NOTICE" file used in projects of this type of license. You could use this instead http://www.apache.org/licenses/LICENSE-2.0.txt ?

Thanks in advance
Regards

java.lang.ClassNotFoundException: com.sun.tools.javac.api.JavacTool while executing jar in command line

I have an app that taking name(excel sheet) from user and I use those name as method and compile at runtime it's working in eclipse when running the project (not from command line ) but getting java.lang.ClassNotFoundException: com.sun.tools.javac.api.JavacTool exception when running batch file containing command for executing jar file(which has logic for runtime compilation ) I have try with the added dependency in maven com.sun artifact mentioned in the issue but did not work any suggestions

Java Runtime Compiler with Wilfly Swarm

Hi,

I'm using java runtime compiler in a wildfly swarm project.

When I'm on my IDE, everything works fine, but after building my jar and deploying my app,
I'm have compilation errors that says that some class does not exists ( knowing that this classes ar in the jar app )

Anyone to tells me what's wrong ?

Thank's

R

java.lang.UnsupportedOperationException generated when run with Java 9 (but not Java 8)

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by net.openhft.compiler.CompilerUtils (file:/home/ubuntu/master/tool_files/floodgage/floodgage-1.0.0.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int)
WARNING: Please consider reporting this to the maintainers of net.openhft.compiler.CompilerUtils
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Exception in thread "main" java.lang.RuntimeException: java.lang.UnsupportedOperationException
	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:158)
	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:96)
	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:90)
	at net.openhft.compiler.CachedCompiler.compileFromJava(CachedCompiler.java:101)
	at net.openhft.compiler.CachedCompiler.loadFromJava(CachedCompiler.java:143)
	at net.openhft.compiler.CachedCompiler.loadFromJava(CachedCompiler.java:70)
	at edu.rice.cs.caper.floodgage.application.floodgage.TrailsRunner.runTrails(TrailsRunner.java:73)
	at edu.rice.cs.caper.floodgage.application.floodgage.FloodGage.run(FloodGage.java:63)
	at edu.rice.cs.caper.floodgage.application.floodgage.FloodGageMain.main(FloodGageMain.java:39)
Caused by: java.lang.UnsupportedOperationException
	at [email protected]/javax.tools.JavaFileManager.listLocationsForModules(JavaFileManager.java:566)
	at jdk.compiler/com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager.listLocationsForModules(ClientCodeWrapper.java:397)
	at jdk.compiler/com.sun.tools.javac.code.ModuleFinder$ModuleLocationIterator.hasNext(ModuleFinder.java:135)
	at jdk.compiler/com.sun.tools.javac.code.ModuleFinder.scanModulePath(ModuleFinder.java:288)
	at jdk.compiler/com.sun.tools.javac.code.ModuleFinder.findAllModules(ModuleFinder.java:184)
	at jdk.compiler/com.sun.tools.javac.comp.Modules.getUnnamedModuleCompleter(Modules.java:1396)
	at jdk.compiler/com.sun.tools.javac.comp.Modules.setCompilationUnitModules(Modules.java:466)
	at jdk.compiler/com.sun.tools.javac.comp.Modules.enter(Modules.java:270)
	at jdk.compiler/com.sun.tools.javac.comp.Modules.initModules(Modules.java:236)
	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.initModules(JavaCompiler.java:1031)
	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:925)
	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:100)
	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:142)
$ java -version
java version "9.0.1"
Java(TM) SE Runtime Environment (build 9.0.1+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)

Warnings regarding illegal reflective access operations

Hi all, I'm getting an issue when trying to create a Chronicle Map or Queue of this sort.

"WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access using Lookup on net.openhft.chronicle.core.Jvm (file:/C:/Users/bryan/.m2/repository/net/openhft/chronicle-core/2.21ea61/chronicle-core-2.21ea61.jar) to class java.lang.reflect.AccessibleObject
WARNING: Please consider reporting this to the maintainers of net.openhft.chronicle.core.Jvm
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release"

I believe i'm on JDK 12 and I have this included in my pom.xml:
"

net.openhft
chronicle-map
3.21ea62
bundle

"

I know many other developers are having this issue as shown here: OpenHFT/Chronicle-Map#271

Any help would be greatly appreciated.

Re-implement rt.java classes

Will Java-Runtime-Compiler be able to re-implement classes in rt.jar?

As a quick test, I tried to re-implement java.lang.NullPointerException, but I get "Caused by: java.lang.SecurityException: Prohibited package name: java.lang"

Getting the " package does not exist" exception while loading with custom class loader

I have a URLClassLoader which i added my jar file dependency to it . The below example throw package com.mypackage does not exist exception

 String className = "mypackage.MyClass";
        String javaCode = "package mypackage;\n" +
                "public class MyClass implements Runnable {\n" +
                "private com.mypackage.MyClass clazz;\n" +
                "    public void run() {\n" +
                "        System.out.println(\"Hello World\");\n" +
                "    }\n" +
                "}\n";
        println project.buildDir
        Class aClass =  CompilerUtils.CACHED_COMPILER.loadFromJava(classLoader, className, javaCode);
        Runnable runner = (Runnable) aClass.newInstance();
        runner.run();

But Class.forName("com.mypackage.MyClass",true,classLoader) returns the class object of MyClass.

Where is .class generated by using CompilerUtils.CACHED_COMPILER.loadFromJava

I am using CompilerUtils.CACHED_COMPILER.loadFromJava Api to generate Class and is being generated successfully (based on example) but I am not able to figure out where is the .class being generated ? Or what property need to be set to generated .class ?

My apology if this is not right place to ask question.

Simple documentation bug

On the home page, the "Simple example" says to call "aClass.nextInstance()" which I assume should be newInstance().

Thanks for the library.

Illegal reflective access operation (java 10)

I get the following error:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by net.openhft.compiler.CompilerUtils (file:/home/p/.gradle/caches/modules-2/files-2.1/net.openhft/compiler/2.3.0/8
72e7f90c0223c27fa63c25f22b3a6610fa1ae4f/compiler-2.3.0.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int)
WARNING: Please consider reporting this to the maintainers of net.openhft.compiler.CompilerUtils
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

Here is the stack:

java.lang.RuntimeException: java.lang.UnsupportedOperationException
	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:158)
	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:96)
	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:90)
	at net.openhft.compiler.CachedCompiler.compileFromJava(CachedCompiler.java:101)
	at net.openhft.compiler.CachedCompiler.loadFromJava(CachedCompiler.java:143)
	at net.openhft.compiler.CachedCompiler.loadFromJava(CachedCompiler.java:76)
	at robobrix.compile.lib.impl.F_.compile(F_.java:84)
	at robobrix.compile.lib.impl.F_.compile(F_.java:77)
	at robobrix.compile.lib.TestCompile.simple(TestCompile.java:23)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
Caused by: java.lang.UnsupportedOperationException
	at [email protected]/javax.tools.JavaFileManager.listLocationsForModules(JavaFileManager.java:566)
	at jdk.compiler/com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager.listLocationsForModules(ClientCodeWrapper.java:397)
	at jdk.compiler/com.sun.tools.javac.code.ModuleFinder$ModuleLocationIterator.hasNext(ModuleFinder.java:135)
	at jdk.compiler/com.sun.tools.javac.code.ModuleFinder.scanModulePath(ModuleFinder.java:288)
	at jdk.compiler/com.sun.tools.javac.code.ModuleFinder.findAllModules(ModuleFinder.java:184)
	at jdk.compiler/com.sun.tools.javac.comp.Modules.getUnnamedModuleCompleter(Modules.java:1408)
	at jdk.compiler/com.sun.tools.javac.comp.Modules.setCompilationUnitModules(Modules.java:459)
	at jdk.compiler/com.sun.tools.javac.comp.Modules.enter(Modules.java:264)
	at jdk.compiler/com.sun.tools.javac.comp.Modules.initModules(Modules.java:230)
	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.initModules(JavaCompiler.java:1037)
	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:931)
	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:100)
	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:142)
	... 31 more

❯ sdk current java

Using java version 10.0.1-oracle

How i can add imports?

i get error:

/TestRunnable.java:2: error: package PACKAGE_NAME_HERE does not exist
import PACKAGE_NAME_HERE.*;
^

Unclear README

The README for this project does not explain how to properly take advantage of this project. It looks great, but I'm not sure where to start. It looks like there is a working example included, but I don't see how to use it.

Do you have any example code you could put on the README to show users how to utilize the CachedCompiler class?

Packages fail to import

Okay, so.
i've tried to load code, which contains imports from packages, which aren't contained in java by default.
So API imports.

I get this error:
[15:37:25 WARN]: SLF4J: No SLF4J providers were found.
[15:37:25 WARN]: SLF4J: Defaulting to no-operation (NOP) logger implementation
[15:37:25 WARN]: SLF4J: See http://www.slf4j.org/codes.html#noProviders for further details.
[15:37:26 WARN]: /de/mcsilentde/game/oneinthechamber/utils/PlayerFetcher.java:15: error: package org.json does not exist
public static org.json.JSONObject getPlayerJson(UUID uuid, String name) {
^
/de/mcsilentde/game/oneinthechamber/utils/PlayerFetcher.java:14: error: package lombok does not exist
@lombok.SneakyThrows
^

even though all of these packages mentioned are existing.
Please help

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.