1 7 8 package com.sun.jmx.mbeanserver; 9 10 import java.io.ObjectInputStream ; 12 import java.io.InputStream ; 13 import java.io.IOException ; 14 import java.io.StreamCorruptedException ; 15 import java.io.ObjectStreamClass ; 16 17 import javax.management.* ; 18 19 20 21 22 27 class ObjectInputStreamWithLoader extends ObjectInputStream { 28 29 30 private ClassLoader loader; 31 32 33 38 public ObjectInputStreamWithLoader(InputStream in, ClassLoader theLoader) 39 throws IOException { 40 super(in); 41 this.loader = theLoader; 42 } 43 44 protected Class resolveClass(ObjectStreamClass aClass) 45 throws IOException , ClassNotFoundException { 46 if (loader == null) { 47 return super.resolveClass(aClass); 48 } else { 49 String name = aClass.getName(); 50 return Class.forName(name, false, loader); 52 } 53 } 54 } 55 | Popular Tags |