On Tue, 12 Apr 2022 13:02:44 GMT, Alan Bateman <al...@openjdk.org> wrote:
>> src/java.base/share/classes/java/io/BufferedReader.java line 101: >> >>> 99: */ >>> 100: public BufferedReader(Reader in, int sz) { >>> 101: Objects.requireNonNull(in); >> >> Not sure if that even matters - but there will be a slight change of >> behaviour here if `InternalLock.CAN_USE_INTERNAL_LOCK` is ever `false`. >> Instead of synchronizing on `in`, the `BufferedReader` will synchronize on >> `this`. >> Now that I think of it - it probably does matter since even if >> CAN_USE_INTERNAL_LOCK is true, untrusted subclasses of BufferedReader >> calling this constructor might expect the locking to be performed on `in`? > >> Not sure if that even matters - but there will be a slight change of >> behaviour here if `InternalLock.CAN_USE_INTERNAL_LOCK` is ever `false`. >> Instead of synchronizing on `in`, the `BufferedReader` will synchronize on >> `this`. > > Good! We can change this so that depends on whether BufferedReader is > extended and whether the given Reader is trusted. It's not clear if anyone > could reliably depend on undocumented behavior like this but we have to be > cautious at the same time. Thanks - the same issue appears with `BufferedWriter`/`Writer`. ------------- PR: https://git.openjdk.java.net/jdk/pull/8166