/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* 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.
*/
/*
* @test
* @bug 4924683
* @author Eamonn McManus
* @run clean DeserializeEncodedURLTest SingleClassLoader
* @run build DeserializeEncodedURLTest SingleClassLoader
* @run main DeserializeEncodedURLTest
*/
import javax.management.*;
/*
Test that the RMI connector client can handle a URL of the form
where the serialized RMIServer stub is encoded directly in the URL,
when the class of that stub is known to the supplied
DEFAULT_CLASS_LOADER but not to the calling code's class loader.
This is an unusual usage, and is not explicitly specified in the JMX
Remote API, but it is potentially useful where client and server
agree to a code base for mutant stubs (that e.g. use a different
protocol or include debugging or optimization).
We make an RMI connector server by giving it an instance of an
RMIJRMPServerImpl subclass that manufactures mutant stubs. These
stubs are known to a special loader (mutantLoader) but not to this
test's loader. We set up the client's default loader to
mutantLoader, and check that it can deserialize the stub containing
the mutant stub.
This test incidentally creates the connector server as an MBean
rather than using the JMXConnectorServerFactory, just because I'm
not sure we have coverage of that elsewhere.
*/
public class DeserializeEncodedURLTest {
new SingleClassLoader("SubMutantRMIServerStub",
MutantRMIServerStub.class,
MutantRMIServerStub.class.getClassLoader());
static {
try {
} catch (ClassNotFoundException e) {
throw new Error(e);
}
}
"from an RMI connector URL even when the stub's " +
"class is known to the user's default loader " +
"but not the caller's loader");
RMIServerImpl.class.getName(),
MBeanServer.class.getName()});
try {
"have");
} catch (MutantException e) {
} catch (Exception e) {
}
}
public static class MutantRMIServerStub
implements RMIServer, Serializable {
public MutantRMIServerStub() {}
return "1.0 BOGUS";
}
throw new MutantException();
}
}
}
try {
} catch (Exception e) {
new IOException("Couldn't make submutant stub");
throw ioe;
}
}
}
}