RFD: Replace class java.lang.Shutdown.Lock with Object?
Glavo
zjx001202 at gmail.com
Tue Jan 27 12:05:48 UTC 2026
> Was there ever any thoughts to add an API point for defining new montor
objects, such as Object.newLock() or perhaps even something like
Object.newLock(Class context, String tag)?
Does it have any advantages over ReentrantLock?
Glavo
On Tue, Jan 27, 2026 at 2:28 PM Eirik Bjørsnøs <eirbjo at gmail.com> wrote:
> On Tue, Jan 27, 2026 at 12:05 AM Roger Riggs <roger.riggs at oracle.com>
> wrote:
>
>> Hi,
>>
>> String is also an Identity class and its value could distinguish between
>> the cases. (Both strings can be very short).
>>
>> About java.lang.Object as a lock, the pervasiveness of `new Object()` for
>> locks resulted in giving it special dispensation in as a supertype of value
>> objects. Trying to change its existing uses was determined to be infeasible.
>>
>
> Great minds are pulling this thread in interesting directions, which is
> fine! I may go ahead file a PR to focus on the specific small changes
> initially suggested. Then any broader discussions can continue here.
>
> Was there ever any thoughts to add an API point for defining new montor
> objects, such as Object.newLock() or perhaps even something like
> Object.newLock(Class context, String tag)?
>
> Perhaps this could:
>
> a) Make the semantics/purpose of creating a new object more clear
> b) Allow the JVM to return any object it wants
> c) Allow monitor objects to be more informative
>
> Cheers,
> Eirik.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20260127/01dc4f12/attachment.htm>
More information about the core-libs-dev
mailing list