Questions tagged [ecj]

Eclipse has implemented its own compiler called as Eclipse Compiler for Java (ECJ). This tag is for questions relating to the behaviour of that compiler.

ECJ is different from javac, the compiler that is shipped with Sun JDK. One notable difference is that the Eclipse compiler lets you run code that didn't actually properly compile. If the block of code with the error is never ran, your program will run fine. Otherwise, it will throw an exception indicating that you tried to run code that doesn't compile.

Another difference is that the Eclipse compiler allows for incremental builds from within the Eclipse IDE, that is, all code is compiled as soon as you finish typing.

The fact that Eclipse comes with its own compiler is also apparent because you can write, compile, and run Java code in Eclipse without even installing the Java SDK.

Further reading: What is the difference between javac and the Eclipse compiler? (from which the above text was taken).

67 questions
6
votes
2 answers

Mockito: Verifying overloaded methods with type-compatible arguments

Consider you want to mock an interface using Mockito containing the following method signatures: public void doThis(Object o); public void doThis(Object... o) I need to verify that doThis(Object o) (and not the other method) has been invoked…
MRalwasser
  • 15,605
  • 15
  • 101
  • 147
6
votes
1 answer

Class org.eclipse.jdt.core.JDTCompilerAdapter could not be loaded because of an invalid dependency

I am creating a java agent that will be used to to do some bytecode modification to some classes org.eclipse.jdt.core.JDTCompilerAdapter is one of them. I am using javassit to modify some the execute() method of…
Master Mind
  • 3,014
  • 4
  • 32
  • 63
5
votes
2 answers

JDK 17: Switch statement causes java.lang.VerifyError: Bad type on operand stack

Just tried JDK17 on Eclipse 2021-09 to have it fail with a java.lang.VerifyError, which wasn't very helpful itself. I tracked it down to a switch statement, that gets fed a value pulled out of a Map or another generic type. If I use a local variable…
Zhedar
  • 3,480
  • 1
  • 21
  • 44
5
votes
0 answers

Instance method reference of a null object

What is the right behavior according to JLS when methodReferenceOfNullObject() is invoked? throw a NullPointerException (Oracle Java Compiler) or assign supplier to result though o is null (Eclipse Java Compiler) public void…
bjmi
  • 497
  • 3
  • 12
5
votes
4 answers

Why does Eclipse let me compile some Java 7 language features into Java 6 class files?

I have found that in Eclipse (using the Eclipse compiler) I can use some Java 7 language features but still create Java 6 class files. In the below image, you can see two Java 7 language features that are successfully compiled as a Java 6 class…
martinez314
  • 12,162
  • 5
  • 36
  • 63
5
votes
1 answer

Java 8: generic type inference fails on method reference?

Can anyone tell me why the following code fails to compile but the lambda version does: Are there rules about the generic type inference? Anything I should avoid? Failed: EntityLayerManager.refreshLayerRenderables( wwd,…
jiping-s
  • 483
  • 1
  • 5
  • 13
4
votes
0 answers

Sealing interface with generics in eclipse

The following is legal (i.e. I can compile it) and works in Java 15 with preview features enabled (in eclipse 2020-09) public sealed interface Quantity permits QuantityImpl { } public record QuantityImpl(T value) implements…
John
  • 251
  • 3
  • 5
4
votes
0 answers

Eclipse JDT ASTParser - resolving in lambdas

I'm using the Eclipse JDT AST to parse Java source code, with the aim of identifying all uses of a given method. I am using eclipse.jdt.core 3.21.0. While the tool resolves method bindings correctly most of the time, I'm running into a problem…
4
votes
3 answers

Ambiguity error while trying to print result of JAVA8 Collector

I am getting Ambiguity error while trying to print result of JAVA8 collectors. I am trying to print result of summation of IDs in Product object, but getting the following error : "The method println(double) is ambiguous for the type…
Gunjan Shah
  • 5,088
  • 16
  • 53
  • 72
4
votes
0 answers

How to compile this code with Java 10, Ant and the Eclipse compiler?

I am trying to compile this simple code using Java 10, Ant and the Eclipse compiler: import java.util.ArrayList; import javax.xml.bind.JAXBException; class Test { void foo() throws JAXBException { throw new JAXBException("hi there"); …
ph8c4
  • 96
  • 1
  • 7
4
votes
3 answers

Determine return type of a Java expression in a String at runtime

At runtime, in my Java program, given a String, I 'd like to know the return type. For example: 1 + 1 returns int 1L + 1L returns long 1L + 1 returns long 1 + 1.5 returns double 1 + 2 - 3 * 4 / 5 returns int 1 / 0 returns int 1 + Math.nextInt()…
Geoffrey De Smet
  • 26,223
  • 11
  • 73
  • 120
4
votes
0 answers

Play framework does not automatically reload on changes when running on virtual machine

The problem I am using the Play Framework, and I am doing so on a virtual machine. However Play does not recompile on changes in dev mode. I have tried using run and ~run in the activator console. When I do ~run it correctly recompiles the changed…
ogroendal
  • 343
  • 3
  • 6
3
votes
2 answers

Optaplanner - drools file cannot be compiled when project is deployed

We developped a SpringBoot project with Java 11 using optaplanner-core and defining rules in a Drools file. We have no issue for running the app in intelliJ with JDK. We then deployed the app onto Azure app service where a JRE is installed. We get…
axellerdp
  • 31
  • 1
3
votes
2 answers

Is the standalone ecj (Eclipse Java Compiler) package no longer maintained?

We are using ecj from org.eclipse.jdt.core.compiler in our project, however it looks like the package is not updated since 07-Oct-2016. Is it no longer maintained? Or should I switch to the ecj from org.eclipse.jdt? Looks like the version number…
Gelin Luo
  • 14,035
  • 27
  • 86
  • 139
3
votes
1 answer

Does the Java compiler has bug with "assignment has no effect" warning/error

It seems that the java compiler (Jdk8) missing the warning for assignments like 'j = j++;' that have no effect but instead it generates warnings for assignments like 'j = ++j;' that actually have effect. I have attached a script for demonstration.…
mike
  • 33
  • 5