Questions tagged [javacompiler]

javax.tools.JavaCompiler is an interface used to invoke Java programming language compilers from programs. Not to be confused with Javac, which is the Java compiler included in the Java Development Kit (JDK).

Not to be confused with , the Java compiler included in the Java Development Kit (JDK) from Sun Microsystems.

javax.tools.JavaCompiler is an interface used to invoke programming language compilers from programs.

140 questions
4
votes
7 answers

Remove @Override annotation error in Java8

I created the following interface with a single method: public interface Greeting { public void perform(); } I was trying to pass an instance of the interface to the greet() method. public class Greeter { public void greet(Greeting…
4
votes
2 answers

Compile Circular Dependency classes using javax.tools.JavaCompiler

I have been trying to compile some Java Classes in a String using java. I have used javax.tools.JavaCompiler to compile the Classes in the Strings. I have made instances of SimpleJavaFileObject by a Subclass that I have made of…
Bhanuka Yd
  • 646
  • 8
  • 25
4
votes
1 answer

Java for-loop optimization

I made some runtime tests with java for loops and recognized a strange behaviour. For my code I need wrapper objects for primitive types like int, double and so on, to simulate io and output parameters, but thats not the point. Just watch my code.…
user3490546
  • 292
  • 6
  • 16
4
votes
1 answer

How to get compile error messages with JavaCompiler

This is the code I am using to compile a java class: public void javaCompile(String fileName) throws IOException { JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); DiagnosticCollector diagnostics = new…
Dragos
  • 776
  • 8
  • 32
4
votes
1 answer

(JavaCompiler) Compiling multiple files at the same time

So I'm working on building a program that uses the built in JavaCompiler API to compile a directory of .java files. I got it parse through a directory to compile the files, and even compiles them, just not in the order I need. I get back the classic…
3
votes
1 answer

How to validate Java code programatically?

Given the source code and the Java version, I need to be able to validate whether or not the code will compile. If the code does not compile, I need to be able to return the errors within the source code. The following solution works, but only for…
Lindstorm
  • 890
  • 2
  • 7
  • 22
3
votes
1 answer

ToolProvider.getSystemJavaCompiler() returning null in JDK 9

My project in Eclipse is running WITH SYSTEM JRE 9. When I try to set Java home to JDK 9 to get the system compiler I got null. System.setProperty("java.home", "C:\\Program…
vda8888
  • 689
  • 1
  • 8
  • 19
3
votes
1 answer

javac generates a bridge method containing an invokespecial instruction pointing to an abstract method

Suppose the following real-life code structure: interface I { I m(); } abstract class A implements I { @Override public abstract A m(); abstract class B extends A { } } The bytecode generated for B is abstract class A$B extends A { …
3
votes
1 answer

How to run AnnotationProcessor in IntelliJ IDEA?

I created simple Annotation processor in IntelliJ IDEA, added annotation profile, but I'm not understand how to run it. I know that annotation processor works in compile time, but I didn't see any messages from Annotation processor messenger in…
Pein
  • 1,059
  • 3
  • 10
  • 31
3
votes
1 answer

Different checksum results for jar files compiled on subsequent build?

I am working verifying the jar files present on remote unix boxes with that of built on local machine(Windows & Cygwin) with same JVM. As a POC I am trying to verify if same checksum is produced with jar files generated on my machine with…
Xinus
  • 29,617
  • 32
  • 119
  • 165
2
votes
1 answer

System Java Compiler behaves different depending on dependencies defined in maven

Recently I've observed a (at least for me) strange behavior of the Java Compiler "ToolProvider.getSystemJavaCompiler()". If I try to compile a not-compilable java file in a "bare" maven project, I can obtain the errors as expected. If I add…
dfuchss
  • 43
  • 6
2
votes
0 answers

How to use javax.tools.JavaCompiler to create a function that calls a list of methods of child class filtered by custom annotation?

I have this unusual (I think?) situation public abstract class Base { public Base() { // code } public final void executeAll() { final Foo foo = new Foo(); final Bar bar = new Bar(); // now execute all method of…
Vento
  • 63
  • 7
2
votes
1 answer

com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:

I cannot compile my project, scenario i converted one of my activity to kotlin using Android Studio's "Convert Java File to Kotlin File" and fixed all errors for code that was not properly converted. Java complier log: Caused by:…
Jayson Garcia
  • 180
  • 1
  • 5
  • 16
2
votes
1 answer

Compile Java class in runtime with dependencies to nested jar

In a Spring Boot app I'm doing the following at runtime: Generating a Java class Compiling it Accessing some static fields of the compiled class using reflection. I've based my code on this post and got a problem compiling my generated class in…
forhas
  • 11,551
  • 21
  • 77
  • 111
2
votes
0 answers

Creating a Java code playground in Android application by Janino

I'm trying to create a Java learning Android application. It should have a code playground for users; which can run simple Java code. I save users code in a java code and I'm trying to run it. I'm using JANINO, but the problem is that I can not load…
1
2
3
9 10