Bug 547010 - FilerException: Source file already exists using ecj with AutoValue from maven or IntelliJ
Summary: FilerException: Source file already exists using ecj with AutoValue from mave...
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: APT (show other bugs)
Version: 4.11   Edit
Hardware: PC Linux
: P3 normal with 5 votes (vote)
Target Milestone: ---   Edit
Assignee: Generic inbox for the JDT-APT component CLA
QA Contact: Jay Arthanareeswaran CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-05-06 10:39 EDT by Sebastien Arod CLA
Modified: 2022-06-03 09:49 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastien Arod CLA 2019-05-06 10:39:07 EDT
ecj compiler raises a warning when trying to generate java file from annotation processor and fails to generate any class file.


This looks similar to 542090 but the warning message is different.



How to reproduce
==================

Clone the following github project: https://github.com/sarod/bugs-repro/tree/master/ecj-bugs/ecj-filer-exception

Using Maven
-----------
Run the following commands

Compile the project
```sh
mvn clean compile
```

Modify MyDataClass.java 
```sh
touch src/main/java/bugs/repro/MyDataClass.java
```

Compile the project again WITHOUT clean
```sh
mvn -X compile
```

The compilation ends with "BUILD SUCCESS" but it's wrong.

However it did not generate the class files and it issued the warning
```
1. WARNING in /home/sarod/dev/git/bugs-repro/ecj-bugs/ecj-filer-exception/src/main/java/bugs/repro/MyDataClass.java (at line 6)
	public abstract class MyDataClass {
	                      ^^^^^^^^^^^
Could not write generated class bugs.repro.AutoValue_MyDataClass: javax.annotation.processing.FilerException: Source file already exists : bugs.repro.AutoValue_MyDataClass
```

Using intellij
-----------
1. Open the project using intellij community edition.
2. Build the whole project using "Build">"Rebuild Project".
3. Open the file src/main/java/bugs/repro/MyDataClass.java
4. Re-compile this file only using "Build">"Recompile '...MyDataClass.java'".

The "Messages" view displays the same warning.
Comment 1 Rémi AUBEL CLA 2020-09-11 10:32:20 EDT
I have the same issue with ECJ-4.13 (the version embedded with IntelliJ 2020.2) and with the last ECJ version (ECJ-4.16).
Any hope to get a fix or a workaround for this issue?
Comment 2 Jay Arthanareeswaran CLA 2020-09-21 02:58:57 EDT
I don't have access to IntelliJ. Is there a way to reproduce this with just Eclipse/ECJ?
Comment 3 Jack Beaudet CLA 2021-09-28 14:39:37 EDT
There are steps using maven, aren't those enough to reproduce?
Comment 4 Marko Bauhardt CLA 2022-01-10 14:55:09 EST
I'm able to reproduce this issue as well. 
See github project https://github.com/mbauhardt/ecj-filer-exception
which is similar to https://github.com/sarod/bugs-repro/tree/master/ecj-bugs/ecj-filer-exception

It looks like, compiling via commandline is working fine. See readme / compile.sh
of the project from above. But with IntelliJ the compilation fails.
Is it an pure IntelliJ issue??
Comment 5 Marko Bauhardt CLA 2022-01-10 15:38:38 EST
(In reply to Marko Bauhardt from comment #4)
> I'm able to reproduce this issue as well. 
> See github project https://github.com/mbauhardt/ecj-filer-exception
> which is similar to
> https://github.com/sarod/bugs-repro/tree/master/ecj-bugs/ecj-filer-exception
> 
> It looks like, compiling via commandline is working fine. See readme /
> compile.sh
> of the project from above. But with IntelliJ the compilation fails.
> Is it an pure IntelliJ issue??

I commented on https://youtrack.jetbrains.com/issue/IDEA-211545#focus=Comments-27-5694078.0-0 as well.
Comment 6 Marko Bauhardt CLA 2022-02-15 01:57:46 EST
This issue seems to be fixed with IntelliJ 2021.3.2.
see https://intellij-support.jetbrains.com/hc/en-us/community/posts/4417393355666-Eclipse-Compiler-including-annotation-processing
Comment 7 Jay Arthanareeswaran CLA 2022-02-16 02:54:02 EST
(In reply to Marko Bauhardt from comment #6)
> This issue seems to be fixed with IntelliJ 2021.3.2.
> see
> https://intellij-support.jetbrains.com/hc/en-us/community/posts/4417393355666-Eclipse-Compiler-including-annotation-processing
> 

Thanks for following up and update. Does this mean this bug can be closed?
Comment 8 Marko Bauhardt CLA 2022-02-17 02:28:41 EST
(In reply to Jay Arthanareeswaran from comment #7)
 
> Thanks for following up and update. Does this mean this bug can be closed?

From my perspective yes. I don't get the error with IntelliJ 2021.3.2
Maybe @Sebastien Arod can confirm...
Comment 9 Marko Bauhardt CLA 2022-06-03 09:49:25 EDT
(In reply to Marko Bauhardt from comment #8)
> (In reply to Jay Arthanareeswaran from comment #7)
>  
> > Thanks for following up and update. Does this mean this bug can be closed?
> 
> From my perspective yes. I don't get the error with IntelliJ 2021.3.2
> Maybe @Sebastien Arod can confirm...

New update from my side. when a class contains an inner class the generation doesn't work anymore again. 
so this issue is not 100% resolved.

see https://github.com/mbauhardt/ecj-filer-exception to reproduce.