JDK-8185952 : package-info.java file affects annotation-processing
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8u141
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • CPU: x86
  • Submitted: 2017-08-07
  • Updated: 2019-08-02
  • Resolved: 2017-08-08
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_141"
Java(TM) SE Runtime Environment (build 1.8.0_141-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.141-b15, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 10.0.14393]

A DESCRIPTION OF THE PROBLEM :
When a simple package-info.java file (only a package declaration - no annotations, etc.) is included in build, it causes the annotation processor to create additional files, which it should NOT create (and does NOT create when the package-info.java file is not on the source path.

AFAIK, adding a package-info.java file should not affect the files, that an annotation processor creates.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
I've managed to create a minimal project to reproduce the issue with javac only. 
The project has too much code to post here, so I've published the project on GitLab.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Adding a package-info.java file should not affect the files, that an annotation processor creates - in the example project, the files "ColorEnum_MapperFull*" should NOT be created.
ACTUAL -
In the example project, the files "ColorEnum_MapperFull*" are created when the package-info.java file is on the source-path of javac.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
javac does not crash - but after the compilation we have 2 versions of the same files (in the same package) which causes problems in all following build steps: e.g. in Android development you will get a DEX error which is hard to track down: see https://stackoverflow.com/questions/45393034/immutables-library-generates-the-same-immutable-class-twice

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
I've managed to create a minimal project to reproduce the issue with javac only. 
The project has too much code to post here, so I've published the project on GitLab.
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
there is no real workaround, but in some cases we may be able to:
* delete package-info.java
* comment out it's contents
* don't include package-info.java in the build


Comments
Provided report contains dependency with below softwares == Android Studio 3.0 Canary 5 Gradle 4.1-milestone-1 Android gradle plugin: 3.0.0-alpha5 == Requested submitter to reduce to smaller test and share with us
08-08-2017