As java programmers we have inherited a legacy app which is now being upgraded to java8. The App runs on an embedded jre which is shipped along with our App.
We also ship tools.jar with the App, which is used to: 1) Compile .java files at run time; e.g. com.sun.tools.javac.Main.compile("SomeCustomClass.java"...). 2) Process annotations using the apt tool( package com.sun.mirror.apt); e.g. 'int aptReturnCode = com.sun.tools.apt.Main.process(myAnnotationProcessorFactory...);
Problem is that the apt tool has been removed from tools.jar in java8 -> http://docs.oracle.com/javase/7/docs/technotes/guides/apt/GettingStarted.html#deprecated
and we cannot use some thing like 'JavaCompilerTool compiler = ToolProvider.getSystemJavaCompilerTool()' because we only have access to our embedded jre and no jdk on client systems.
As a workaround we are compiling the SomeCustomClass.java into a jar file externally and then adding it to our app's classpath but its not viable long term as these class's come from the client and can change all the time.
I can think of the following ways around this problem: 1) Ship 2 tools.jar an old one for annotation processing and one java8 for compiling code at run time, but no idea how to avoid any naming conflicts etc. 2) Rework the myAnnotationProcessorFactory code that is using annotation processing to use javax.annotation.* instead of com.sun.tools.apt.* . As this is legacy code it will be quite error prone.
Can you guys think of any other ways around it ?
Many Thanks