org.jetbrains. jps.builders.impl.java.JavaoCmpilerTool available
Answered
I want to dynamically compile a piece of Java code, but ToolProvider. getSystemJavaCompiler() returns null,
Perhaps the idea is a JRE environment, but I found the class org.jetbrains. jps.builders.impl.java.JavaoCmpilerTool , which allows me to create a java.tools.JavaCompiler using 'create.Compiler ';
Why can Class. forName ("com. sun. tools. javac. api. JavacTool") be loaded
Is this class safe for users?
Please sign in to leave a comment.
Hi,
I'm sorry, but I don't understand your question. Please rephrase it or provide more information.
Is it safe to use
org. jetbrains. jps. builders. impl. java. JavaoCmpilerTool? Is it possible for it to return null?According to https://plugins.jetbrains.com/docs/intellij/explore-api.html#26-refrain-from-using-internal-classes, you should refrain from using classes from an
implpackage.If you use it, please keep in mind it can be changed in the future in a backward incompatible way. The method is annotated with
@NotNull, which indicates that it can't return null.I don't understand. IDEA should be running in a JRE environment, so why does executing
Class.forName("com.sun.tools.javac.api.JavacTool")not throw an exception?I'm sorry, but I'm confused by your questions.
You asked whether it is safe to use
org.jetbrains.jps.builders.impl.java.JavacCompilerTooland I answered it is not. What is unclear here?I don't understand what problem you have with
com.sun.tools.javac.api.JavacTool. You write that it can be loaded:and doesn't throw an exception:
Why does this cause a problem?