mx4j/src/core/mx4j/remote/rmi RMIMarshaller.java,1.9,1.10
Simone Bordet <[email protected]>
| Newsgroups | gmane.comp.java.mx4j.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/mx4j/mx4j/src/core/mx4j/remote/rmi
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17585/src/core/mx4j/remote/rmi
Modified Files:
RMIMarshaller.java
Log Message:
Fixed once again the classloading: now we just load the Marshaller class with the MarshallerLoader, delegating everything else to the parent. This solves bug #919599.
Index: RMIMarshaller.java
===================================================================
RCS file: /cvsroot/mx4j/mx4j/src/core/mx4j/remote/rmi/RMIMarshaller.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** RMIMarshaller.java 11 Mar 2004 10:54:05 -0000 1.9
--- RMIMarshaller.java 19 Mar 2004 17:21:11 -0000 1.10
***************
*** 198,201 ****
--- 198,210 ----
private byte[] bytes;
+ /**
+ * Parent classloader is null, thus we can load JDK classes, but for example not the JMX classes.
+ * This will force usage of the context classloader for unmarshalling, and the context classloader
+ * must be able to find the JMX classes. For example, when invoking setAttribute(), the marshalled
+ * parameter is a javax.management.Attribute that may contain an object of a custom class.
+ * To unmarshal the custom class (seen only by the context classloader), we must be able to unmarshal
+ * first the Attribute class that so it must either be loadable by the context classloader or by
+ * one of its ancestor classloaders.
+ */
private MarshallerClassLoader(byte[] classBytes)
{
***************
*** 205,210 ****
/**
! * This method is overridden to load only classes from the java.* packages and the
! * {@link Marshaller} class ONLY.
* Classes from java.* packages (like java.lang.Object and java.rmi.MarshalledObject) are
* referenced by {@link Marshaller} itself.
--- 214,219 ----
/**
! * This method is overridden to define the {@link Marshaller} class and to delegate to the parent
! * further loading.
* Classes from java.* packages (like java.lang.Object and java.rmi.MarshalledObject) are
* referenced by {@link Marshaller} itself.
***************
*** 214,227 ****
public Class loadClass(final String name) throws ClassNotFoundException
{
! if (name.startsWith("java.")) return super.loadClass(name);
! if (!name.startsWith(Marshaller.class.getName())) throw new ClassNotFoundException(name);
!
! try
{
! return defineClass(name, bytes, 0, bytes.length, MarshallerClassLoader.this.getClass().getProtectionDomain());
}
! catch (ClassFormatError x)
{
! throw new ClassNotFoundException("Class Format Error", x);
}
}
--- 223,240 ----
public Class loadClass(final String name) throws ClassNotFoundException
{
! if (name.startsWith(Marshaller.class.getName()))
{
! try
! {
! return defineClass(name, bytes, 0, bytes.length, MarshallerClassLoader.this.getClass().getProtectionDomain());
! }
! catch (ClassFormatError x)
! {
! throw new ClassNotFoundException("Class Format Error", x);
! }
}
! else
{
! return super.loadClass(name);
}
}
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click