JDK-8255729 : com.sun.tools.javac.processing.JavacFiler.FilerOutputStream is inefficient
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 15.0.1
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2020-10-28
  • Updated: 2025-01-13
  • Resolved: 2021-01-03
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 17
11.0.17Fixed 17 b04Fixed
Description
ADDITIONAL SYSTEM INFORMATION :
Java 8 all the way up to 15

A DESCRIPTION OF THE PROBLEM :
FilerOutputStream, which can be used by annotation processors to write source files, extends from FilterOutputStream without overwriting the write(byte[], offset, length) method. This means that content written to this stream is written to disk one byte at a time, greatly slowing down builds.


CUSTOMER SUBMITTED WORKAROUND :
Use JavaFileObject.openWriter instead, which does not suffer from this performance problem.

FREQUENCY : always



Comments
A pull request was submitted for review. URL: https://git.openjdk.org/jdk11u-dev/pull/1218 Date: 2022-07-12 08:07:26 +0000
12-07-2022

Fix Request(11u) Request to backport this patch to jdk11u. The code doesn't apply cleanly. Low risk: it is a cleanup and performance issue. And the code has run for a long time in the jdk mainline. Thanks.
12-07-2022

There has been no response from the submitter after 14 days. Closing the bug.
25-05-2021

Requested the submitter to see if the bug is fixed in the latest build at https://jdk.java.net/17/ b21 and provide the feedback.
11-05-2021

See comments in the review related to the performance analysis.
04-01-2021

Changeset: 526c0005 Author: Guoxiong Li <lgxbslgx@gmail.com> Committer: Jonathan Gibbons <jjg@openjdk.org> Date: 2021-01-03 17:32:46 +0000 URL: https://git.openjdk.java.net/jdk/commit/526c0005
03-01-2021

There seems to be performance degradation because underlying write method writes single byte to disk at time in com.sun.tools.javac.processing.JavacFiler.FilerOutputStream
02-11-2020