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.

113 questions
11
votes
3 answers

Java Annotation processor for remote JAR

General question I have two projects A and B; B has a dependency on A. I want to generate some code in B with an Annotation Processor, based on annotations on objects in A. When I run the compilation with the correct Processor implementation, only…
blagae
  • 2,200
  • 1
  • 21
  • 40
10
votes
5 answers

solve error: cannot access Publisher in Android Studio?

I am getting this error while compilation of my code: Can anyone help me how to solve this error or what might be causing this error? Edit1: Gradle file of the project . And also the error log is attached with the question above.please check…
Sushrita
  • 715
  • 10
  • 27
10
votes
3 answers

How to avoid IntelliJ to reset language level?

I am having troubles with this which have been answered dusin of times on this site. My take on the problem is a bit different. I have a project which builds fine using maven 3.5.x and java release 10 (configured in the maven-compiler-plugin) When…
jactor-rises
  • 961
  • 9
  • 28
9
votes
1 answer

JavaCompiler API - slow compilation when running in tomcat

My application generates java code during runtime and compiles it using the JavaCompiler API. Some of the generated files can be rather large - up to a few hundred thousand lines. I find that when I run the javac command on the generated code in the…
Jewels
  • 706
  • 7
  • 24
8
votes
2 answers

Internal Architecture of Java Compiler

I have been working on Java from more than 8 years. Last week, in a small meeting in my company, one of my colleague has asked me how exactly does Java Compiler work? I was with no answer. I tried explaining, like Java Compiler takes statements one…
Jagadeesh
  • 772
  • 5
  • 22
6
votes
1 answer

Javac missing optimization for effective final

Fact: javac is programmed to detect if a variable is final or if it can be treated as effectively final. Proof: This code illustrates this. public static void finalCheck() { String str1 = "hello"; Runnable r = () -> { …
jmj
  • 225,392
  • 41
  • 383
  • 426
6
votes
2 answers

Gradle incremental java compilation leads to full recompile

I change only one source file and relaunch the build: $ gradle jar Incremental java compilation is an incubating feature. :compileJava Full recompilation is required because 'XXX.java' was changed. Analysis took 0.241 secs. My gradle configuration…
benji
  • 2,026
  • 5
  • 25
  • 51
6
votes
1 answer

Could not find method sourceCompatibility() for arguments on root project

I would like to define source and target compatibility for a Java library which is built with Gradle. Therefore, I add the following block as documented for the Java plugin. apply plugin: 'java' // ... compileJava { sourceCompatibility…
JJD
  • 44,755
  • 49
  • 183
  • 309
5
votes
2 answers

Strange behaviour of Kotlin compiler or Java decompiler

This question is driven by my curiosity alone, so I would like to receive a full answer, rather than simple "yes" or "no". Let's consider this piece of code: // Is stored in util files and used to omit annoying (this as? Smth)?.doSmth() inline fun…
GV_FiQst
  • 1,191
  • 9
  • 27
5
votes
2 answers

Error: when I replace compile with implementation in gradle(dependency)

I update my Android Studio from 3.0.1 to 3.1.0 But after the update when I build my project it shows 2 warning: 1. Replace compile with implementation (and compile support will be ended at end of 2018) 2. Replace testCompile with testImplementaion…
Aashish
  • 2,355
  • 2
  • 22
  • 35
4
votes
1 answer

'overridden method does not throw Exception' when use lambda with override exception thrown

To prevent to be closed as duplicate, this question is totally different with this one. Consider I have the following interface @FunctionalInterface interface FuncE0 { R call() throws E; } It works fine with…
Dean Xu
  • 3,133
  • 1
  • 12
  • 36
4
votes
5 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…
sbk
  • 414
  • 1
  • 5
  • 17
4
votes
1 answer

Is there anyway to tell compiler to keep variable names around via annotations?

It is very annoying to have the whole app add an @Param() annotation with the variable name for each variable name. It is also frustrating when you change the variable name and have to change the name inside @Param Is there any good way to annotate…
Dean Hiller
  • 17,183
  • 19
  • 103
  • 176
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
  • 637
  • 7
  • 23
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
  • 262
  • 6
  • 14
1
2 3 4 5 6 7 8