On Fri, 13 Dec 2024 19:57:14 GMT, Leonid Mesnik <lmes...@openjdk.org> wrote:

> Thanks for describing.

Thanks for confirming. The fewer of these methods the better!

> src/java.management/share/classes/javax/management/ObjectName.java line 1225:
> 
>> 1223:         if (name.getClass().equals(ObjectName.class))
>> 1224:             return name;
>> 1225:         return 
>> sun.management.Util.newObjectName(name.getSerializedNameString());
> 
> The newObjectName methods are different in 2 Utils.
> The share/classes/sun/management/Util.java is
> 
>   45   │     public static ObjectName newObjectName(String name) {
>   46   │         try {
>   47   │             return ObjectName.getInstance(name);
>   48   │         } catch (MalformedObjectNameException e) {
>   49   │             throw new IllegalArgumentException(e);
>   50   │         }
>   51   │     }
> 
> Isn't it infinite recursion?

Right, they are different, but one uses "new", and one calls a newInstance 
method which uses "new", so they are really the same.  Daniel's note in the JBS 
bug hints that there may have been an idea to do some caching in getInstance, 
which has not as yet been implemented.

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

PR Comment: https://git.openjdk.org/jdk/pull/22681#issuecomment-2542205911
PR Review Comment: https://git.openjdk.org/jdk/pull/22681#discussion_r1884463700

Reply via email to