Skip to content

Commit

Permalink
8345987: java.management has two Util.newObjectName methods (remove one)
Browse files Browse the repository at this point in the history
Reviewed-by: cjplummer, amenkov, lmesnik
  • Loading branch information
kevinjwalls committed Dec 13, 2024
1 parent f647d4d commit e7fc0eb
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import com.sun.jmx.mbeanserver.NamedObject;
import com.sun.jmx.mbeanserver.Repository;
import com.sun.jmx.mbeanserver.Repository.RegistrationContext;
import com.sun.jmx.mbeanserver.Util;
import com.sun.jmx.remote.util.EnvHelp;

import java.lang.ref.WeakReference;
Expand Down Expand Up @@ -81,6 +80,8 @@
import javax.management.RuntimeOperationsException;
import javax.management.loading.ClassLoaderRepository;

import sun.management.Util;

/**
* This is the default class for MBean manipulation on the agent side. It
* contains the methods necessary for the creation, registration, and
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -281,7 +281,7 @@ public void addMBean(final DynamicMBean object, ObjectName name,

// Set domain to default if domain is empty and not already set
if (dom.length() == 0)
name = Util.newObjectName(domain + name.toString());
name = sun.management.Util.newObjectName(domain + name.toString());

// Do we have default domain ?
if (dom == domain) { // ES: OK (dom & domain are interned)
Expand Down Expand Up @@ -438,10 +438,9 @@ public Set<NamedObject> query(ObjectName pattern, QueryExp query) {
if (allNames)
result.addAll(moiTb.values());
else
addAllMatching(moiTb, result, Util.newObjectName(domain + name.getCanonicalName()));
addAllMatching(moiTb, result, sun.management.Util.newObjectName(domain + name.getCanonicalName()));
return result;
}

if (!name.isDomainPattern()) {
final Map<String,NamedObject> moiTb = domainTb.get(dom2Match);
if (moiTb == null) return Collections.emptySet();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -43,13 +43,6 @@
import javax.management.ObjectName;

public class Util {
public static ObjectName newObjectName(String string) {
try {
return new ObjectName(string);
} catch (MalformedObjectNameException e) {
throw new IllegalArgumentException(e);
}
}

static <K, V> Map<K, V> newMap() {
return new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import java.lang.System.Logger.Level;
import com.sun.jmx.defaults.JmxProperties;
import com.sun.jmx.defaults.ServiceName;
import com.sun.jmx.mbeanserver.Util;
import sun.management.Util;

/**
* Represents the MBean server from the management point of view.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,7 @@ public static ObjectName getInstance(String domain,
public static ObjectName getInstance(ObjectName name) {
if (name.getClass().equals(ObjectName.class))
return name;
return Util.newObjectName(name.getSerializedNameString());
return sun.management.Util.newObjectName(name.getSerializedNameString());
}

/**
Expand Down Expand Up @@ -1813,7 +1813,7 @@ public static String unquote(String q) {
*
* @since 1.6
*/
public static final ObjectName WILDCARD = Util.newObjectName("*:*");
public static final ObjectName WILDCARD = sun.management.Util.newObjectName("*:*");

// Category : Utilities <===================================

Expand Down

1 comment on commit e7fc0eb

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.