RFR: 8303078: Reduce allocations when pretty printing JCTree during compilation [v3]

Jonathan Gibbons jonathan.gibbons at oracle.com
Wed Feb 22 21:25:07 UTC 2023


Regarding paranoia: I'll address that in the PR, I'd like to record the 
suggestion there, but probably agree with your suggestion to leave it as is.

Regarding the scary comment: the comment goes back to pre-module days, 
when more people were helping themselves to using notionally internal 
JDK API.  Now that the internals are encapsulated, the scary comment 
seems less important, and might even go away, or be replaced by a single 
notice higher up. (It's helpful to have a place we can point to that 
says, "you were warned...").  We have already removed the scary warning 
from the `jdk.javadoc` module, but that code has the added advantage of 
having `.internal.` in the name of the relevant packages.

-- Jon


On 2/22/23 11:02 AM, Christoph Dreis wrote:
> On Wed, 22 Feb 2023 18:57:47 GMT, Jonathan Gibbons <jjg at openjdk.org> wrote:
>
>>> Done - but had to change the one with the `sep` argument to take a char instead of String. Seems not used elsewhere, but wasn't sure because of the `protected`
>> While `DocPretty` is public, the package is not publicly exported from the `jdk.compiler` module, and there are no subtypes within the JDK code base, so I think we can ignore the `protected` for now.
>>
>> If we wanted to be paranoid, it would be reasonable to change `print(char)` to something along the lines of
>>
>> if (Character.isASCII(ch)) out.write(ch); else print((Character) ch);
> Should we (I in that case) be paranoid, though? I would leave it as-is. There is a big class comment above that anyone depending on the internal api uses this at his own risk.
>
> -------------
>
> PR: https://git.openjdk.org/jdk/pull/12667


More information about the compiler-dev mailing list