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
12
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
  • 2,395
  • 2
  • 22
  • 44
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,342
  • 1
  • 27
  • 48
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
  • 725
  • 10
  • 29
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
  • 966
  • 11
  • 28
9
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
  • 862
  • 7
  • 23
7
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
  • 237,923
  • 42
  • 401
  • 438
6
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,487
  • 14
  • 30
6
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 Kumar
  • 2,771
  • 3
  • 28
  • 43
6
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
  • 19,235
  • 25
  • 129
  • 212
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,331
  • 6
  • 33
  • 62
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
  • 50,076
  • 60
  • 203
  • 339
5
votes
1 answer

Does a Java compiler optimize ad hoc instances of `Set.of`, `List.of`, and `Map.of` in loops as constants

Given the following code snippet in which an ad hoc instance of a Set is created, will todays Java compiler see that they do not need to create the instance for each loop pass and optimize set as a kind of final constant such that the instance is…
twwwt
  • 438
  • 1
  • 4
  • 16
4
votes
0 answers

Java 11 JavaCompiler throws java.lang.StackOverflowError on linux only

Java version: 11.0.13 I have a function that compiles java files into classes at runtime, on Java 8 everything worked ok, also with java 11.0.13 on windows everything works ok but on linux(Red Hat Enterprise Linux Server release 6.10) it failes with…
Roie Beck
  • 1,113
  • 3
  • 15
  • 30
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
  • 4,438
  • 1
  • 17
  • 44
4
votes
1 answer

diamond operator is not supported in -source 1.5 even when compiler version is 1.8

When packaging my project using maven in intellij idea, it gives below error, also my java compiler version is set on 1.8: diamond operator is not supported in -source 1.5 [ERROR] (use -source 7 or higher to enable diamond operator) I'm really…
ShakibaZar
  • 727
  • 3
  • 9
  • 27
1
2 3
9 10