diff --git a/src/java.management/share/classes/com/sun/jmx/defaults/JmxProperties.java b/src/java.management/share/classes/com/sun/jmx/defaults/JmxProperties.java
index 566d0f9d5cd..a70080161af 100644
--- a/src/java.management/share/classes/com/sun/jmx/defaults/JmxProperties.java
+++ b/src/java.management/share/classes/com/sun/jmx/defaults/JmxProperties.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2017, 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
@@ -44,24 +44,14 @@ public class JmxProperties {
//------------------------
/**
- * References the property that specifies the directory where
- * the native libraries will be stored before the MLet Service
- * loads them into memory.
+ * References the property that optionally specifies the class name
+ * of an alternative MBeanServerBuilder.
*
- * Property Name: jmx.mlet.library.dir
+ * Property Name: javax.management.builder.initial
*/
public static final String JMX_INITIAL_BUILDER =
"javax.management.builder.initial";
- /**
- * References the property that specifies the directory where
- * the native libraries will be stored before the MLet Service
- * loads them into memory.
- *
- * Property Name: jmx.mlet.library.dir
- */
- public static final String MLET_LIB_DIR = "jmx.mlet.library.dir";
-
/**
* References the property that specifies the full name of the JMX
* specification implemented by this product.
@@ -122,18 +112,6 @@ public class JmxProperties {
public static final Logger MBEANSERVER_LOGGER =
System.getLogger(MBEANSERVER_LOGGER_NAME);
- /**
- * Logger name for MLet service information.
- */
- public static final String MLET_LOGGER_NAME =
- "javax.management.mlet";
-
- /**
- * Logger for MLet service information.
- */
- public static final Logger MLET_LOGGER =
- System.getLogger(MLET_LOGGER_NAME);
-
/**
* Logger name for Monitor information.
*/
diff --git a/src/java.management/share/classes/com/sun/jmx/defaults/ServiceName.java b/src/java.management/share/classes/com/sun/jmx/defaults/ServiceName.java
index 8f742dff0f8..b1948178483 100644
--- a/src/java.management/share/classes/com/sun/jmx/defaults/ServiceName.java
+++ b/src/java.management/share/classes/com/sun/jmx/defaults/ServiceName.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2008, 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
@@ -44,14 +44,6 @@ public class ServiceName {
public static final String DELEGATE =
"JMImplementation:type=MBeanServerDelegate" ;
- /**
- * The default key properties for registering the class loader of the
- * MLet service.
- *
- * The value is type=MLet.
- */
- public static final String MLET = "type=MLet";
-
/**
* The default domain.
*
diff --git a/src/java.management/share/classes/com/sun/jmx/mbeanserver/ClassLoaderRepositorySupport.java b/src/java.management/share/classes/com/sun/jmx/mbeanserver/ClassLoaderRepositorySupport.java
index 38050ca0d7a..a73e46e6020 100644
--- a/src/java.management/share/classes/com/sun/jmx/mbeanserver/ClassLoaderRepositorySupport.java
+++ b/src/java.management/share/classes/com/sun/jmx/mbeanserver/ClassLoaderRepositorySupport.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -206,18 +206,6 @@ final class ClassLoaderRepositorySupport
if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
MBEANSERVER_LOGGER.log(Level.TRACE, "Trying loader = " + cl);
}
- /* We used to have a special case for "instanceof
- MLet" here, where we invoked the method
- loadClass(className, null) to prevent infinite
- recursion. But the rule whereby the MLet only
- consults loaders that precede it in the CLR (via
- loadClassBefore) means that the recursion can't
- happen, and the test here caused some legitimate
- classloading to fail. For example, if you have
- dependencies C->D->E with loaders {E D C} in the
- CLR in that order, you would expect to be able to
- load C. The problem is that while resolving D, CLR
- delegation is disabled, so it can't find E. */
return Class.forName(className, false, cl);
} catch (ClassNotFoundException e) {
// OK: continue with next class
diff --git a/src/java.management/share/classes/com/sun/jmx/remote/security/MBeanServerAccessController.java b/src/java.management/share/classes/com/sun/jmx/remote/security/MBeanServerAccessController.java
index ac9c8cfada9..c94750e99ff 100644
--- a/src/java.management/share/classes/com/sun/jmx/remote/security/MBeanServerAccessController.java
+++ b/src/java.management/share/classes/com/sun/jmx/remote/security/MBeanServerAccessController.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -75,12 +75,11 @@ import javax.management.remote.MBeanServerForwarder;
* inappropriate.
*
*
If there is no SecurityManager, then the access controller will refuse
- * to create an MBean that is a ClassLoader, which includes MLets, or to
- * execute the method addURL on an MBean that is an MLet. This prevents
+ * to create an MBean that is a ClassLoader. This prevents
* people from opening security holes unintentionally. Otherwise, it
* would not be obvious that granting write access grants the ability to
* download and execute arbitrary code in the target MBean server. Advanced
- * users who do want the ability to use MLets are presumably advanced enough
+ * users who do want an MBean which is a ClassLoader are presumably advanced enough
* to handle policy files and security managers.
*/
public abstract class MBeanServerAccessController
@@ -468,7 +467,6 @@ public abstract class MBeanServerAccessController
MBeanException,
ReflectionException {
checkWrite();
- checkMLetMethods(name, operationName);
return getMBeanServer().invoke(name, operationName, params, signature);
}
@@ -620,49 +618,6 @@ public abstract class MBeanServerAccessController
"manager is installed.");
}
- private void checkMLetMethods(ObjectName name, String operation)
- throws InstanceNotFoundException {
- // Check if security manager installed
- @SuppressWarnings("removal")
- SecurityManager sm = System.getSecurityManager();
- if (sm != null) {
- return;
- }
- // Check for addURL and getMBeansFromURL methods
- if (!operation.equals("addURL") &&
- !operation.equals("getMBeansFromURL")) {
- return;
- }
- // Check if MBean is instance of MLet
- if (!getMBeanServer().isInstanceOf(name,
- "javax.management.loading.MLet")) {
- return;
- }
- // Throw security exception
- if (operation.equals("addURL")) { // addURL
- throw new SecurityException("Access denied! MLet method addURL " +
- "cannot be invoked unless a security manager is installed.");
- } else { // getMBeansFromURL
- // Whether or not calling getMBeansFromURL is allowed is controlled
- // by the value of the "jmx.remote.x.mlet.allow.getMBeansFromURL"
- // system property. If the value of this property is true, calling
- // the MLet's getMBeansFromURL method is allowed. The default value
- // for this property is false.
- final String propName = "jmx.remote.x.mlet.allow.getMBeansFromURL";
- GetPropertyAction propAction = new GetPropertyAction(propName);
- @SuppressWarnings("removal")
- String propValue = AccessController.doPrivileged(propAction);
- boolean allowGetMBeansFromURL = "true".equalsIgnoreCase(propValue);
- if (!allowGetMBeansFromURL) {
- throw new SecurityException("Access denied! MLet method " +
- "getMBeansFromURL cannot be invoked unless a " +
- "security manager is installed or the system property " +
- "-Djmx.remote.x.mlet.allow.getMBeansFromURL=true " +
- "is specified.");
- }
- }
- }
-
//------------------
// PRIVATE VARIABLES
//------------------
diff --git a/src/java.management/share/classes/javax/management/loading/MLet.java b/src/java.management/share/classes/javax/management/loading/MLet.java
deleted file mode 100644
index aacf73e4821..00000000000
--- a/src/java.management/share/classes/javax/management/loading/MLet.java
+++ /dev/null
@@ -1,1294 +0,0 @@
-/*
- * Copyright (c) 1999, 2022, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package javax.management.loading;
-
-import com.sun.jmx.defaults.ServiceName;
-
-import com.sun.jmx.remote.util.EnvHelp;
-
-import java.io.Externalizable;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInput;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutput;
-import java.lang.reflect.Constructor;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLStreamHandlerFactory;
-import java.nio.file.Files;
-import java.nio.file.StandardCopyOption;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.lang.System.Logger.Level;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanException;
-import javax.management.MBeanRegistration;
-import javax.management.MBeanRegistrationException;
-import javax.management.MBeanServer;
-import javax.management.NotCompliantMBeanException;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.ReflectionException;
-
-import static com.sun.jmx.defaults.JmxProperties.MLET_LIB_DIR;
-import static com.sun.jmx.defaults.JmxProperties.MLET_LOGGER;
-import javax.management.ServiceNotFoundException;
-
-/**
- * Allows you to instantiate and register one or several MBeans in the MBean server
- * coming from a remote URL. M-let is a shortcut for management applet. The m-let service does this
- * by loading an m-let text file, which specifies information on the MBeans to be obtained.
- * The information on each MBean is specified in a single instance of a tag, called the MLET tag.
- * The location of the m-let text file is specified by a URL.
- *
- * This attribute specifies the full Java class name, including package name, of the MBean to be obtained.
- * The compiled .class file of the MBean must be contained in one of the .jar files specified by the ARCHIVE
- * attribute. Either CODE or OBJECT must be present.
- *
- *
OBJECT = serfile
- *
- * This attribute specifies the .ser file that contains a serialized representation of the MBean to be obtained.
- * This file must be contained in one of the .jar files specified by the ARCHIVE attribute. If the .jar file contains a directory hierarchy, specify the path of the file within this hierarchy. Otherwise a match will not be found. Either CODE or OBJECT must be present.
- *
- *
ARCHIVE = "archiveList"
- *
- * This mandatory attribute specifies one or more .jar files
- * containing MBeans or other resources used by
- * the MBean to be obtained. One of the .jar files must contain the file specified by the CODE or OBJECT attribute.
- * If archivelist contains more than one file:
- *
- *
Each file must be separated from the one that follows it by a comma (,).
- *
archivelist must be enclosed in double quote marks.
- *
- * All .jar files in archivelist must be stored in the directory specified by the code base URL.
- *
- *
CODEBASE = codebaseURL
- *
- * This optional attribute specifies the code base URL of the MBean to be obtained. It identifies the directory that contains
- * the .jar files specified by the ARCHIVE attribute. Specify this attribute only if the .jar files are not in the same
- * directory as the m-let text file. If this attribute is not specified, the base URL of the m-let text file is used.
- *
- *
NAME = mbeanname
- *
- * This optional attribute specifies the object name to be assigned to the
- * MBean instance when the m-let service registers it. If
- * mbeanname starts with the colon character (:), the domain
- * part of the object name is the default domain of the MBean server,
- * as returned by {@link javax.management.MBeanServer#getDefaultDomain()}.
- *
- *
VERSION = version
- *
- * This optional attribute specifies the version number of the MBean and
- * associated .jar files to be obtained. This version number can
- * be used to specify that the .jar files are loaded from the
- * server to update those stored locally in the cache the next time the m-let
- * text file is loaded. version must be a series of non-negative
- * decimal integers each separated by a period from the one that precedes it.
- *
- *
arglist
- *
- * This optional attribute specifies a list of one or more parameters for the
- * MBean to be instantiated. This list describes the parameters to be passed the MBean's constructor.
- * Use the following syntax to specify each item in
- * arglist:
- *
- *
<ARG TYPE=argumentTypeVALUE=value>
- *
where:
- *
- *
argumentType is the type of the argument that will be passed as parameter to the MBean's constructor.
- *
- *
- *
The arguments' type in the argument list should be a Java primitive type or a Java basic type
- * (java.lang.Boolean, java.lang.Byte, java.lang.Short, java.lang.Long, java.lang.Integer, java.lang.Float, java.lang.Double, java.lang.String).
- *
- *
- *
- * When an m-let text file is loaded, an
- * instance of each MBean specified in the file is created and registered.
- *
- * The m-let service extends the java.net.URLClassLoader and can be used to load remote classes
- * and jar files in the VM of the agent.
- *
Note - The MLet class loader uses the {@link javax.management.MBeanServerFactory#getClassLoaderRepository(javax.management.MBeanServer)}
- * to load classes that could not be found in the loaded jar files.
- *
- * @deprecated This API is part of Management Applets (m-lets), which is a legacy feature that allows loading
- * of remote MBeans. This feature is not usable without a Security Manager, which is deprecated and subject to
- * removal in a future release. Consequently, this API is also deprecated and subject to removal. There is no replacement.
- *
- * @since 1.5
- */
-@Deprecated(since="20", forRemoval=true)
-@SuppressWarnings("removal")
-public class MLet extends java.net.URLClassLoader
- implements MLetMBean, MBeanRegistration, Externalizable {
-
- private static final long serialVersionUID = 3636148327800330130L;
-
- /*
- * ------------------------------------------
- * PRIVATE VARIABLES
- * ------------------------------------------
- */
-
- /**
- * The reference to the MBean server.
- * @serial
- */
- @SuppressWarnings("serial") // Type of field is not Serializable
- private MBeanServer server = null;
-
-
- /**
- * The list of instances of the MLetContent
- * class found at the specified URL.
- * @serial
- */
- @SuppressWarnings("serial") // Type of field is not Serializable
- private List mletList = new ArrayList<>();
-
-
- /**
- * The directory used for storing libraries locally before they are loaded.
- */
- private String libraryDirectory;
-
-
- /**
- * The object name of the MLet Service.
- * @serial
- */
- private ObjectName mletObjectName = null;
-
- /**
- * The URLs of the MLet Service.
- * @serial
- */
- private URL[] myUrls = null;
-
- /**
- * What ClassLoaderRepository, if any, to use if this MLet
- * doesn't find an asked-for class.
- */
- private transient ClassLoaderRepository currentClr;
-
- /**
- * True if we should consult the {@link ClassLoaderRepository}
- * when we do not find a class ourselves.
- */
- private transient boolean delegateToCLR;
-
- /**
- * objects maps from primitive classes to primitive object classes.
- */
- @SuppressWarnings("serial") // Type of field is not Serializable
- private Map> primitiveClasses = new HashMap<>(8) ;
- {
- primitiveClasses.put(Boolean.TYPE.toString(), Boolean.class);
- primitiveClasses.put(Character.TYPE.toString(), Character.class);
- primitiveClasses.put(Byte.TYPE.toString(), Byte.class);
- primitiveClasses.put(Short.TYPE.toString(), Short.class);
- primitiveClasses.put(Integer.TYPE.toString(), Integer.class);
- primitiveClasses.put(Long.TYPE.toString(), Long.class);
- primitiveClasses.put(Float.TYPE.toString(), Float.class);
- primitiveClasses.put(Double.TYPE.toString(), Double.class);
-
- }
-
-
- /*
- * ------------------------------------------
- * CONSTRUCTORS
- * ------------------------------------------
- */
-
- /*
- * The constructor stuff would be considerably simplified if our
- * parent, URLClassLoader, specified that its one- and
- * two-argument constructors were equivalent to its
- * three-argument constructor with trailing null arguments. But
- * it doesn't, which prevents us from having all the constructors
- * but one call this(...args...).
- */
-
- /**
- * Constructs a new MLet using the default delegation parent ClassLoader.
- */
- public MLet() {
- this(new URL[0]);
- }
-
- /**
- * Constructs a new MLet for the specified URLs using the default
- * delegation parent ClassLoader. The URLs will be searched in
- * the order specified for classes and resources after first
- * searching in the parent class loader.
- *
- * @param urls The URLs from which to load classes and resources.
- *
- */
- public MLet(URL[] urls) {
- this(urls, true);
- }
-
- /**
- * Constructs a new MLet for the given URLs. The URLs will be
- * searched in the order specified for classes and resources
- * after first searching in the specified parent class loader.
- * The parent argument will be used as the parent class loader
- * for delegation.
- *
- * @param urls The URLs from which to load classes and resources.
- * @param parent The parent class loader for delegation.
- *
- */
- public MLet(URL[] urls, ClassLoader parent) {
- this(urls, parent, true);
- }
-
- /**
- * Constructs a new MLet for the specified URLs, parent class
- * loader, and URLStreamHandlerFactory. The parent argument will
- * be used as the parent class loader for delegation. The factory
- * argument will be used as the stream handler factory to obtain
- * protocol handlers when creating new URLs.
- *
- * @param urls The URLs from which to load classes and resources.
- * @param parent The parent class loader for delegation.
- * @param factory The URLStreamHandlerFactory to use when creating URLs.
- *
- */
- public MLet(URL[] urls,
- ClassLoader parent,
- URLStreamHandlerFactory factory) {
- this(urls, parent, factory, true);
- }
-
- /**
- * Constructs a new MLet for the specified URLs using the default
- * delegation parent ClassLoader. The URLs will be searched in
- * the order specified for classes and resources after first
- * searching in the parent class loader.
- *
- * @param urls The URLs from which to load classes and resources.
- * @param delegateToCLR True if, when a class is not found in
- * either the parent ClassLoader or the URLs, the MLet should delegate
- * to its containing MBeanServer's {@link ClassLoaderRepository}.
- *
- */
- public MLet(URL[] urls, boolean delegateToCLR) {
- super(urls);
- init(delegateToCLR);
- }
-
- /**
- * Constructs a new MLet for the given URLs. The URLs will be
- * searched in the order specified for classes and resources
- * after first searching in the specified parent class loader.
- * The parent argument will be used as the parent class loader
- * for delegation.
- *
- * @param urls The URLs from which to load classes and resources.
- * @param parent The parent class loader for delegation.
- * @param delegateToCLR True if, when a class is not found in
- * either the parent ClassLoader or the URLs, the MLet should delegate
- * to its containing MBeanServer's {@link ClassLoaderRepository}.
- *
- */
- public MLet(URL[] urls, ClassLoader parent, boolean delegateToCLR) {
- super(urls, parent);
- init(delegateToCLR);
- }
-
- /**
- * Constructs a new MLet for the specified URLs, parent class
- * loader, and URLStreamHandlerFactory. The parent argument will
- * be used as the parent class loader for delegation. The factory
- * argument will be used as the stream handler factory to obtain
- * protocol handlers when creating new URLs.
- *
- * @param urls The URLs from which to load classes and resources.
- * @param parent The parent class loader for delegation.
- * @param factory The URLStreamHandlerFactory to use when creating URLs.
- * @param delegateToCLR True if, when a class is not found in
- * either the parent ClassLoader or the URLs, the MLet should delegate
- * to its containing MBeanServer's {@link ClassLoaderRepository}.
- *
- */
- public MLet(URL[] urls,
- ClassLoader parent,
- URLStreamHandlerFactory factory,
- boolean delegateToCLR) {
- super(urls, parent, factory);
- init(delegateToCLR);
- }
-
- private void init(boolean delegateToCLR) {
- this.delegateToCLR = delegateToCLR;
-
- try {
- libraryDirectory = System.getProperty(MLET_LIB_DIR);
- if (libraryDirectory == null)
- libraryDirectory = getTmpDir();
- } catch (SecurityException e) {
- // OK : We don't do AccessController.doPrivileged, but we don't
- // stop the user from creating an MLet just because they
- // can't read the MLET_LIB_DIR or java.io.tmpdir properties
- // either.
- }
- }
-
-
- /*
- * ------------------------------------------
- * PUBLIC METHODS
- * ------------------------------------------
- */
-
-
- /**
- * Appends the specified URL to the list of URLs to search for classes and
- * resources.
- */
- public void addURL(URL url) {
- if (!Arrays.asList(getURLs()).contains(url))
- super.addURL(url);
- }
-
- /**
- * Appends the specified URL to the list of URLs to search for classes and
- * resources.
- * @exception ServiceNotFoundException The specified URL is malformed.
- */
- public void addURL(String url) throws ServiceNotFoundException {
- try {
- @SuppressWarnings("deprecation")
- URL ur = new URL(url);
- if (!Arrays.asList(getURLs()).contains(ur))
- super.addURL(ur);
- } catch (MalformedURLException e) {
- if (MLET_LOGGER.isLoggable(Level.DEBUG)) {
- MLET_LOGGER.log(Level.DEBUG, "Malformed URL: " + url, e);
- }
- throw new
- ServiceNotFoundException("The specified URL is malformed");
- }
- }
-
- /** Returns the search path of URLs for loading classes and resources.
- * This includes the original list of URLs specified to the constructor,
- * along with any URLs subsequently appended by the addURL() method.
- */
- public URL[] getURLs() {
- return super.getURLs();
- }
-
- /**
- * Loads a text file containing MLET tags that define the MBeans to
- * be added to the MBean server. The location of the text file is specified by
- * a URL. The MBeans specified in the MLET file will be instantiated and
- * registered in the MBean server.
- *
- * @param url The URL of the text file to be loaded as URL object.
- *
- * @return A set containing one entry per MLET tag in the m-let text file loaded.
- * Each entry specifies either the ObjectInstance for the created MBean, or a throwable object
- * (that is, an error or an exception) if the MBean could not be created.
- *
- * @exception ServiceNotFoundException One of the following errors has occurred: The m-let text file does
- * not contain an MLET tag, the m-let text file is not found, a mandatory
- * attribute of the MLET tag is not specified, the value of url is
- * null.
- * @exception IllegalStateException MLet MBean is not registered with an MBeanServer.
- */
- public Set