RFR: JDK-8304945: StringBuilder and StringBuffer should implement Appendable explicitly
Alan Bateman
alanb at openjdk.org
Mon Apr 3 10:25:31 UTC 2023
On Mon, 3 Apr 2023 07:57:56 GMT, Per Minborg <pminborg at openjdk.org> wrote:
> Are there more places where we "accidentally" expose interfaces via non-public (or even public) super classes?
Appendable was added as part of the scanning/formatting update in Java 5. It's intentional that SB implements Appendable but the intermediate/non-public superclass does complicate things. It makes it harder to reason about access control of public methods defined in the superclass, and problematic for javadoc. The funny thing is that the change that Joe has proposed here is what was discussed as a workaround in JDK-4983949 when it initially didn't show up in the javadoc. More discussion JDK-8224052 and JDK-8304060 for some of the challenges for javadoc.
Other examples are come up mind are
- j.u.concurrent.{Long,Double}{Adder,Accumulator} extend non-public Stripe64, Stripe64 extends Number
- j.t.chrono.XXXDate extends ChronoLocalDateImpl, ChronoLocalDateImpl implements several interfaces
It's good question though, as it would be easy to "leak" an interface into the API.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/13278#issuecomment-1494065784
More information about the core-libs-dev
mailing list