JDK-8193462 : Fix Filer handling of package-info initial elements
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2017-12-13
  • Updated: 2022-10-25
  • Resolved: 2018-07-20
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 12
11.0.17Fixed 12 b04Fixed
Related Reports
Relates :  
Relates :  
Description
The annotation processing Filer is obliged to maintain various invariants:

"During each run of an annotation processing tool, a file with a given pathname may be created only once. If that file already exists before the first attempt to create it, the old contents will be deleted. Any subsequent attempt to create the same file during a run will throw a FilerException, as will attempting to create both a class file and source file for the same type name or same package name. The initial inputs to the tool are considered to be created by the zeroth round; therefore, attempting to create a source or class file corresponding to one of those inputs will result in a FilerException."

The handling of package-info files and the handling of files for types are subject to the same constraints.

However, the javac Filer implementation does not correctly catch attempting to open a package-info file through the Filer when the same file has been passed as an initial argument.
Comments
A pull request was submitted for review. URL: https://git.openjdk.org/jdk11u-dev/pull/1208 Date: 2022-07-10 13:47:23 +0000
10-07-2022

Fix request(11u) Request to backport this patch to jdk11. I want to backport JDK-8255729 to jdk11, firstly I need to backport this patch so that the JDK-8255729 can be backported cleanly. But I don't know the risk of this patch now. Thanks.
10-07-2022

URL: http://hg.openjdk.java.net/jdk/jdk/rev/ae39ec0b0502 User: darcy Date: 2018-07-20 16:55:49 +0000
20-07-2018

Review thread: http://mail.openjdk.java.net/pipermail/compiler-dev/2018-July/012209.html
20-07-2018

See background discussion in http://mail.openjdk.java.net/pipermail/compiler-dev/2017-December/011434.html The version of the fix in http://cr.openjdk.java.net/~darcy/8193462.0/ does not work since the sourcefile field of the PackageSymbol/PackageElement returned by elementUtils.getPackageElement is not getting set, unlike for the elementUtils.getTypeElement lookup.
13-12-2017