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?

0
5 comments

Hi,

I'm sorry, but I don't understand your question. Please rephrase it or provide more information.

0

Is it safe to use org. jetbrains. jps. builders. impl. java. JavaoCmpilerTool? Is it possible for it to return null?

0

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 impl package.

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.

0

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?

0

I'm sorry, but I'm confused by your questions.

You asked whether it is safe to use org.jetbrains.jps.builders.impl.java.JavacCompilerTool and 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:

Why can Class. forName ("com. sun. tools. javac. api. JavacTool") be loaded

 and doesn't throw an exception:

why does executing Class.forName("com.sun.tools.javac.api.JavacTool") not throw an exception?

Why does this cause a problem?

0

Please sign in to leave a comment.