On Fri, 8 May 2026 13:26:21 GMT, Alan Bateman <[email protected]> wrote:

>> src/jdk.attach/share/classes/com/sun/tools/attach/spi/AttachProvider.java 
>> line 175:
>> 
>>> 173:      * @since 27
>>> 174:      */
>>> 175:     public VirtualMachine attachVirtualMachine(String id, Map<String, 
>>> ?> env)
>> 
>> This will meed an `@implSpec` to say that the default implementation throws 
>> UOE.
>
> Do you agree that `provider.attachVirtualMachine(id, Map.of())` and 
> `provider.attachVirtualMachine(id)` should be equivalent? 
> 
> (This goes to the question as to whether an empty map should invoke the 1-arg 
> method rather than throw UOE)

Currently core file attach needs the method that takes the Map env.

An empty Map is fine, the settings in there are optional, not always required 
(i.e. library/JVM location can be located at path in core file, cache can be 
written).

It might be a tiny bit simpler to understand if they are equivalent, but it may 
leave a trap:  I like having the two methods NOT equivalent, as this makes the 
tool author know that for core files, the env is required sometimes, and if you 
don't facilitate passing it then there will be problems for some tool users.

JCmd.java is the only tool in question right now and with this change that uses 
attach(String id, Map<String, ?> env).

Happy to hear any thoughts either way 8-)

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

PR Review Comment: https://git.openjdk.org/jdk/pull/31011#discussion_r3209860546

Reply via email to