RFR: 8255729: com.sun.tools.javac.processing.JavacFiler.FilerOutputStream is inefficient
github.com+13688759+lgxbslgx at openjdk.java.net
Mon Dec 21 09:57:54 UTC 2020
On Mon, 21 Dec 2020 09:29:46 GMT, Joel Borggrén-Franck <jfranck at openjdk.org> wrote:
>> Hi all,
>> `FilerOutputStream` extends `FilterOutputStream` without overwriting the method `write(byte b, int off, int len)` which would suffer from the performance problem.
>> This patch fixes it and adds some `@Override` to polish the code. But I can't find a good way to write a corresponding test case. Maybe it doesn't need a test case. And all existing tests in `test/langtools/tools/javac` passed locally.
>> Thank you for taking the time to review.
>> Best Regards.
> src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacFiler.java line 282:
>> 280: if ((off | len | (b.length - (len + off)) | (off + len)) < 0)
>> 281: throw new IndexOutOfBoundsException();
>> 282: out.write(b, off, len);
> If I understand this `out` is the underlying `OutputStream` and calling `write(byte, int, int)` performs the same one-byte-at-a-time write as without the override.
In my opinion, the `out` depends on the `FileObject.openOutputStream` which differ depending on the implementation of `FileObject` and can be set by users in the implementation of `FileObject`.
More information about the compiler-dev