On Sat, 27 Jun 2026 01:35:34 GMT, Chen Liang <[email protected]> wrote:

>> (work in progress, not ready for ready)
>> 
>> - Improve preview-comment in class description that defines value class and 
>> value object
>> - Update spec for the finalize method to make it clear when finalize method 
>> of a value class is never invoked by the garbage collector
>> - Update the implSpec for the clone to specify behavior of Object.clone for 
>> value objects. Also add paragraph to method description for value objects, 
>> and add API note to advise using copy constructors or static factory methods 
>> instead
>> - Improve preview-comment in wait/notify methods and drop confusing addition 
>> to IMSE exception
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> src/java.base/share/classes/java/lang/Object.java line 216:
> 
>> 214:      * <p>
>> 215:      * By convention, the returned object should be obtained by calling
>> 216:      * {@code super.clone}.  If a class and all of its superclasses 
>> (except
> 
> Note this convention is unrealistic for value objects - I recall we discussed 
> about this with Dan Smith participating, forgot if we reached any conclusion 
> about actions to take.

Object.clone is a flawed mechanism and its API docs has many issues. This 
convention is just re-framed in the context of identity objects. Kinda like 
constructor chaining, this convention is important for non-final classes to 
allow some subclass to override clone. It's not the main focus on the update 
though. The important bit is updating the implSpec so the method of the Object 
class is specified for value objects.

> test/jdk/java/lang/Object/ValueObjects.java line 127:
> 
>> 125:             System.gc();
>> 126:             // latch should not count down
>> 127:             assertFalse(latch.await(1, TimeUnit.SECONDS));
> 
> 1 second is too long for a tier 1 test I think; we should also use 
> Utils.adjustTimeout to respect jtreg timeouts.

1s isn't too bad for a tier1 test, it could be small. Using Utils.adjustTimeout 
here is a bit overkill but okay.

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

PR Review Comment: 
https://git.openjdk.org/valhalla/pull/2588#discussion_r3494022750
PR Review Comment: 
https://git.openjdk.org/valhalla/pull/2588#discussion_r3493970889

Reply via email to