RFR: 8255729: com.sun.tools.javac.processing.JavacFiler.FilerOutputStream is inefficient

Jonathan Gibbons jjg at openjdk.java.net
Sun Dec 20 20:04:54 UTC 2020


On Sun, 20 Dec 2020 17:29:59 GMT, Guoxiong Li <github.com+13688759+lgxbslgx 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.

Normally, I would leave this to @jddarcy, who wrote this code, but he is currently on vacation.

I'll approve it with the understanding that I'll help make changes if Joe thinks that any are necessary.

src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacFiler.java line 281:

> 279:         public void write(byte b[], int off, int len) throws IOException {
> 280:             if ((off | len | (b.length - (len + off)) | (off + len)) < 0)
> 281:                 throw new IndexOutOfBoundsException();

This code is pretty ugly, treating integers as bit-wise values. However, I see it is the same as in FilterOutputStream itself.

-------------

Marked as reviewed by jjg (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/1854


More information about the compiler-dev mailing list