Java 类java.io.ObjectStreamClass 实例源码

项目:AgentWorkbench    文件:ObjectInputStreamForClassLoadService.java   
@Override
protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {

    if (this.utilityClass!=null) {
        try {
            Method method = this.utilityClass.getMethod("forName", String.class);
            Object returnObject = method.invoke(null, desc.getName());
            Class<?> returnClass = (Class<?>) returnObject;
            return returnClass;

        } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
            //ex.printStackTrace();
        }
    }
    return BaseClassLoadServiceUtility.forName(desc.getName());
}
项目:EatDubbo    文件:CompactedObjectInputStream.java   
@Override
protected ObjectStreamClass readClassDescriptor() throws IOException,ClassNotFoundException
{
    int type = read();
    if( type < 0 )
        throw new EOFException();
    switch( type )
    {
        case 0:
            return super.readClassDescriptor();
        case 1:
            Class<?> clazz = loadClass(readUTF());
            return ObjectStreamClass.lookup(clazz);
        default:
            throw new StreamCorruptedException("Unexpected class descriptor type: " + type);
    }
}
项目:ooso    文件:DecompressibleInputStream.java   
protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException {
    ObjectStreamClass resultClassDescriptor = super.readClassDescriptor();
    Class localClass;
    try {
        localClass = Class.forName(resultClassDescriptor.getName());
    } catch (ClassNotFoundException e) {
        return resultClassDescriptor;
    }
    ObjectStreamClass localClassDescriptor = ObjectStreamClass.lookup(localClass);
    if (localClassDescriptor != null) {
        final long localSUID = localClassDescriptor.getSerialVersionUID();
        final long streamSUID = resultClassDescriptor.getSerialVersionUID();
        if (streamSUID != localSUID) {
            resultClassDescriptor = localClassDescriptor;
        }
    }
    return resultClassDescriptor;
}
项目:dubbo2    文件:CompactedObjectInputStream.java   
@Override
protected ObjectStreamClass readClassDescriptor() throws IOException,ClassNotFoundException
{
    int type = read();
    if( type < 0 )
        throw new EOFException();
    switch( type )
    {
        case 0:
            return super.readClassDescriptor();
        case 1:
            Class<?> clazz = loadClass(readUTF());
            return ObjectStreamClass.lookup(clazz);
        default:
            throw new StreamCorruptedException("Unexpected class descriptor type: " + type);
    }
}
项目:myfaces-trinidad    文件:ObjectInputStreamResolveClass.java   
protected Class<?> resolveClass(ObjectStreamClass desc)
                         throws IOException,
                                ClassNotFoundException
{
  Class<?> cls = null;
  String className = desc.getName();

  // if it is primitive class, for example, long.class
  // we resolve them by getting them from the hashMaps
  cls = _PRIMITIVE_CLASSES.get(className);

  if (null == cls)
  {
    // TRINIDAD-1062 It has been noticed that in OC4J and Weblogic that the
    // classes being resolved are having problems by not finding
    // them using the context class loader. Therefore, we are adding
    // this work-around until the problem with these application
    // servers can be better understood
    cls = ClassLoaderUtils.loadClass(desc.getName());
  }
  return cls;
}
项目:letv    文件:UnsafeAllocator.java   
public static UnsafeAllocator create() {
    try {
        Class cls = Class.forName("sun.misc.Unsafe");
        Field declaredField = cls.getDeclaredField("theUnsafe");
        declaredField.setAccessible(true);
        return new aj(cls.getMethod("allocateInstance", new Class[]{Class.class}), declaredField.get(null));
    } catch (Exception e) {
        try {
            Method declaredMethod = ObjectStreamClass.class.getDeclaredMethod("getConstructorId", new Class[]{Class.class});
            declaredMethod.setAccessible(true);
            int intValue = ((Integer) declaredMethod.invoke(null, new Object[]{Object.class})).intValue();
            Method declaredMethod2 = ObjectStreamClass.class.getDeclaredMethod("newInstance", new Class[]{Class.class, Integer.TYPE});
            declaredMethod2.setAccessible(true);
            return new ak(declaredMethod2, intValue);
        } catch (Exception e2) {
            try {
                Method declaredMethod3 = ObjectInputStream.class.getDeclaredMethod("newInstance", new Class[]{Class.class, Class.class});
                declaredMethod3.setAccessible(true);
                return new al(declaredMethod3);
            } catch (Exception e3) {
                return new am();
            }
        }
    }
}
项目:OpenJSharp    文件:ValueType.java   
/**
 * Get the names and types of all the persistent fields of a Class.
 */
private Hashtable getPersistentFields (Class clz) {
    Hashtable result = new Hashtable();
    ObjectStreamClass osc = ObjectStreamClass.lookup(clz);
    if (osc != null) {
        ObjectStreamField[] fields = osc.getFields();
        for (int i = 0; i < fields.length; i++) {
            String typeSig;
            String typePrefix = String.valueOf(fields[i].getTypeCode());
            if (fields[i].isPrimitive()) {
                typeSig = typePrefix;
            } else {
                if (fields[i].getTypeCode() == '[') {
                    typePrefix = "";
                }
                typeSig = typePrefix + fields[i].getType().getName().replace('.','/');
                if (typeSig.endsWith(";")) {
                    typeSig = typeSig.substring(0,typeSig.length()-1);
                }
            }
            result.put(fields[i].getName(),typeSig);
        }
    }
    return result;
}
项目:openjdk-jdk10    文件:TestObjectStreamClass.java   
public static void main(String[] args) throws Exception {
    ByteArrayOutputStream byteOutput = new ByteArrayOutputStream();
    ObjectOutputStream output = new ObjectOutputStream(byteOutput);
    output.writeObject(new TestClass());

    ByteArrayInputStream bais = new ByteArrayInputStream(byteOutput.toByteArray());
    TestObjectInputStream input = new TestObjectInputStream(bais);
    input.readObject();

    ObjectStreamClass osc = input.getDescriptor();

    // All OSC public API methods should complete without throwing.
    osc.getName();
    osc.forClass();
    osc.getField("str");
    osc.getFields();
    osc.getSerialVersionUID();
    osc.toString();
}
项目:dubbox-hystrix    文件:CompactedObjectInputStream.java   
@Override
protected ObjectStreamClass readClassDescriptor() throws IOException,ClassNotFoundException
{
    int type = read();
    if( type < 0 )
        throw new EOFException();
    switch( type )
    {
        case 0:
            return super.readClassDescriptor();
        case 1:
            Class<?> clazz = loadClass(readUTF());
            return ObjectStreamClass.lookup(clazz);
        default:
            throw new StreamCorruptedException("Unexpected class descriptor type: " + type);
    }
}
项目:jdk8u-jdk    文件:ClassDesc.java   
/**
 * Write and read class descriptors to/from a stream.
 * Arguments: <# cycles>
 */
public long run(String[] args) throws Exception {
    int ncycles = Integer.parseInt(args[0]);
    StreamBuffer sbuf = new StreamBuffer();
    ObjectOutputStream oout =
        new ObjectOutputStream(sbuf.getOutputStream());
    ObjectInputStream oin =
        new ObjectInputStream(sbuf.getInputStream());
    ObjectStreamClass desc = ObjectStreamClass.lookup(Dummy50.class);

    doReps(oout, oin, sbuf, desc, 1);       // warmup

    long start = System.currentTimeMillis();
    doReps(oout, oin, sbuf, desc, ncycles);
    return System.currentTimeMillis() - start;
}
项目:jdk8u-jdk    文件:ProxyClassDesc.java   
/**
 * Write and read proxy class descriptors to/from a stream.
 * Arguments: <# cycles>
 */
public long run(String[] args) throws Exception {
    int ncycles = Integer.parseInt(args[0]);
    StreamBuffer sbuf = new StreamBuffer();
    ObjectOutputStream oout =
        new ObjectOutputStream(sbuf.getOutputStream());
    ObjectInputStream oin =
        new ObjectInputStream(sbuf.getInputStream());
    ObjectStreamClass[] descs = genDescs();

    doReps(oout, oin, sbuf, descs, 1);      // warmup

    long start = System.currentTimeMillis();
    doReps(oout, oin, sbuf, descs, ncycles);
    return System.currentTimeMillis() - start;
}
项目:jdk8u-jdk    文件:ProxyClassDesc.java   
/**
 * Generate proxy class descriptors.
 */
ObjectStreamClass[] genDescs() {
    ClassLoader ldr = ProxyClassDesc.class.getClassLoader();
    Class[] ifaces = new Class[3];
    Class[] a =
        new Class[] { A1.class, A2.class, A3.class, A4.class, A5.class };
    Class[] b =
        new Class[] { B1.class, B2.class, B3.class, B4.class, B5.class };
    Class[] c =
        new Class[] { C1.class, C2.class, C3.class, C4.class, C5.class };
    ObjectStreamClass[] descs =
        new ObjectStreamClass[a.length * b.length * c.length];
    int n = 0;
    for (int i = 0; i < a.length; i++) {
        ifaces[0] = a[i];
        for (int j = 0; j < b.length; j++) {
            ifaces[1] = b[j];
            for (int k = 0; k < c.length; k++) {
                ifaces[2] = c[k];
                Class proxyClass = Proxy.getProxyClass(ldr, ifaces);
                descs[n++] = ObjectStreamClass.lookup(proxyClass);
            }
        }
    }
    return descs;
}
项目:jdk8u-jdk    文件:ProxyClassDesc.java   
/**
 * Run benchmark for given number of cycles.
 */
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
            StreamBuffer sbuf, ObjectStreamClass[] descs, int ncycles)
    throws Exception
{
    int ndescs = descs.length;
    for (int i = 0; i < ncycles; i++) {
        sbuf.reset();
        oout.reset();
        for (int j = 0; j < ndescs; j++) {
            oout.writeObject(descs[j]);
        }
        oout.flush();
        for (int j = 0; j < ndescs; j++) {
            oin.readObject();
        }
    }
}
项目:jdk8u-jdk    文件:TestObjectStreamClass.java   
public static void main(String[] args) throws Exception {
    ByteArrayOutputStream byteOutput = new ByteArrayOutputStream();
    ObjectOutputStream output = new ObjectOutputStream(byteOutput);
    output.writeObject(new TestClass());

    ByteArrayInputStream bais = new ByteArrayInputStream(byteOutput.toByteArray());
    TestObjectInputStream input = new TestObjectInputStream(bais);
    input.readObject();

    ObjectStreamClass osc = input.getDescriptor();

    // All OSC public API methods should complete without throwing.
    osc.getName();
    osc.forClass();
    osc.getField("str");
    osc.getFields();
    osc.getSerialVersionUID();
    osc.toString();
}
项目:openjdk-jdk10    文件:ValueType.java   
/**
 * Get the names and types of all the persistent fields of a Class.
 */
private Hashtable getPersistentFields (Class clz) {
    Hashtable result = new Hashtable();
    ObjectStreamClass osc = ObjectStreamClass.lookup(clz);
    if (osc != null) {
        ObjectStreamField[] fields = osc.getFields();
        for (int i = 0; i < fields.length; i++) {
            String typeSig;
            String typePrefix = String.valueOf(fields[i].getTypeCode());
            if (fields[i].isPrimitive()) {
                typeSig = typePrefix;
            } else {
                if (fields[i].getTypeCode() == '[') {
                    typePrefix = "";
                }
                typeSig = typePrefix + fields[i].getType().getName().replace('.','/');
                if (typeSig.endsWith(";")) {
                    typeSig = typeSig.substring(0,typeSig.length()-1);
                }
            }
            result.put(fields[i].getName(),typeSig);
        }
    }
    return result;
}
项目:dubbocloud    文件:CompactedObjectInputStream.java   
@Override
protected ObjectStreamClass readClassDescriptor() throws IOException,ClassNotFoundException
{
    int type = read();
    if( type < 0 )
        throw new EOFException();
    switch( type )
    {
        case 0:
            return super.readClassDescriptor();
        case 1:
            Class<?> clazz = loadClass(readUTF());
            return ObjectStreamClass.lookup(clazz);
        default:
            throw new StreamCorruptedException("Unexpected class descriptor type: " + type);
    }
}
项目:openjdk-jdk10    文件:ClassDesc.java   
/**
 * Write and read class descriptors to/from a stream.
 * Arguments: <# cycles>
 */
public long run(String[] args) throws Exception {
    int ncycles = Integer.parseInt(args[0]);
    StreamBuffer sbuf = new StreamBuffer();
    ObjectOutputStream oout =
        new ObjectOutputStream(sbuf.getOutputStream());
    ObjectInputStream oin =
        new ObjectInputStream(sbuf.getInputStream());
    ObjectStreamClass desc = ObjectStreamClass.lookup(Dummy50.class);

    doReps(oout, oin, sbuf, desc, 1);       // warmup

    long start = System.currentTimeMillis();
    doReps(oout, oin, sbuf, desc, ncycles);
    return System.currentTimeMillis() - start;
}
项目:openjdk-jdk10    文件:ProxyClassDesc.java   
/**
 * Write and read proxy class descriptors to/from a stream.
 * Arguments: <# cycles>
 */
public long run(String[] args) throws Exception {
    int ncycles = Integer.parseInt(args[0]);
    StreamBuffer sbuf = new StreamBuffer();
    ObjectOutputStream oout =
        new ObjectOutputStream(sbuf.getOutputStream());
    ObjectInputStream oin =
        new ObjectInputStream(sbuf.getInputStream());
    ObjectStreamClass[] descs = genDescs();

    doReps(oout, oin, sbuf, descs, 1);      // warmup

    long start = System.currentTimeMillis();
    doReps(oout, oin, sbuf, descs, ncycles);
    return System.currentTimeMillis() - start;
}
项目:openjdk-jdk10    文件:ProxyClassDesc.java   
/**
 * Generate proxy class descriptors.
 */
ObjectStreamClass[] genDescs() {
    ClassLoader ldr = ProxyClassDesc.class.getClassLoader();
    Class[] ifaces = new Class[3];
    Class[] a =
        new Class[] { A1.class, A2.class, A3.class, A4.class, A5.class };
    Class[] b =
        new Class[] { B1.class, B2.class, B3.class, B4.class, B5.class };
    Class[] c =
        new Class[] { C1.class, C2.class, C3.class, C4.class, C5.class };
    ObjectStreamClass[] descs =
        new ObjectStreamClass[a.length * b.length * c.length];
    int n = 0;
    for (int i = 0; i < a.length; i++) {
        ifaces[0] = a[i];
        for (int j = 0; j < b.length; j++) {
            ifaces[1] = b[j];
            for (int k = 0; k < c.length; k++) {
                ifaces[2] = c[k];
                Class proxyClass = Proxy.getProxyClass(ldr, ifaces);
                descs[n++] = ObjectStreamClass.lookup(proxyClass);
            }
        }
    }
    return descs;
}
项目:openjdk-jdk10    文件:ProxyClassDesc.java   
/**
 * Run benchmark for given number of cycles.
 */
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
            StreamBuffer sbuf, ObjectStreamClass[] descs, int ncycles)
    throws Exception
{
    int ndescs = descs.length;
    for (int i = 0; i < ncycles; i++) {
        sbuf.reset();
        oout.reset();
        for (int j = 0; j < ndescs; j++) {
            oout.writeObject(descs[j]);
        }
        oout.flush();
        for (int j = 0; j < ndescs; j++) {
            oin.readObject();
        }
    }
}
项目:openjdk-jdk10    文件:SuperclassDataLossTest.java   
protected Class resolveClass(ObjectStreamClass desc)
    throws IOException, ClassNotFoundException
{
    // resolve A's classdesc to class != B's superclass
    String name = desc.getName();
    if (ldr12A) {
        if (name.equals("A")) {
            return Class.forName(name, true, ldr1);
        } else if (name.equals("B")) {
            return Class.forName(name, true, ldr2);
        }
    } else {
        if (name.equals("B")) {
            return Class.forName(name, true, ldr1);
        } else if (name.equals("A")) {
            return Class.forName(name, true, ldr2);
        }
    }
    return super.resolveClass(desc);
}
项目:Reer    文件:ClassLoaderObjectInputStream.java   
@Override
protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
    try {
        return Class.forName(desc.getName(), false, loader);
    } catch (ClassNotFoundException e) {
        return super.resolveClass(desc);
    }
}
项目:Reer    文件:PayloadSerializerObjectInputStream.java   
@Override
protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException {
    Class<?> aClass = readClass();
    ObjectStreamClass descriptor = ObjectStreamClass.lookupAny(aClass);
    if (descriptor == null) {
        throw new ClassNotFoundException(aClass.getName());
    }
    return descriptor;
}
项目:openrasp    文件:DeserializationHook.java   
/**
 * 反序列化监检测点
 *
 * @param objectStreamClass 反序列化的类的流对象
 */
public static void checkDeserializationClass(ObjectStreamClass objectStreamClass) {
    if (objectStreamClass != null) {
        String clazz = objectStreamClass.getName();
        if (clazz != null) {
            JSContext cx = JSContextFactory.enterAndInitContext();
            Scriptable params = cx.newObject(cx.getScope());
            params.put("clazz", params, clazz);
            HookHandler.doCheck(CheckParameter.Type.DESERIALIZATION, params);
        }
    }

}
项目:Squid    文件:Average.java   
private void readObject(
        ObjectInputStream stream)
        throws IOException, ClassNotFoundException {
    stream.defaultReadObject();
    ObjectStreamClass myObject = ObjectStreamClass.lookup(Class.forName(Average.class.getCanonicalName()));
    long theSUID = myObject.getSerialVersionUID();
    System.out.println("Customized De-serialization of Average " + theSUID);
}
项目:Squid    文件:Exp.java   
private void readObject(
        ObjectInputStream stream)
        throws IOException, ClassNotFoundException {
    stream.defaultReadObject();
    ObjectStreamClass myObject = ObjectStreamClass.lookup(Class.forName(Exp.class.getCanonicalName()));
    long theSUID = myObject.getSerialVersionUID();
    System.out.println("Customized De-serialization of Exp " + theSUID);
}
项目:Squid    文件:Count.java   
private void readObject(
        ObjectInputStream stream)
        throws IOException, ClassNotFoundException {
    stream.defaultReadObject();
    ObjectStreamClass myObject = ObjectStreamClass.lookup(Class.forName(Count.class.getCanonicalName()));
    long theSUID = myObject.getSerialVersionUID();
    System.out.println("Customized De-serialization of Count " + theSUID);
}
项目:Squid    文件:Max.java   
private void readObject(
        ObjectInputStream stream)
        throws IOException, ClassNotFoundException {
    stream.defaultReadObject();
    ObjectStreamClass myObject = ObjectStreamClass.lookup(Class.forName(Max.class.getCanonicalName()));
    long theSUID = myObject.getSerialVersionUID();
    System.out.println("Customized De-serialization of Max " + theSUID);
}
项目:incubator-netbeans    文件:NbObjectInputStream.java   
protected Class resolveClass(ObjectStreamClass v) throws IOException, ClassNotFoundException {
    ClassLoader cl = getNBClassLoader();

    try {
        return Class.forName(v.getName(), false, cl);
    } catch (ClassNotFoundException cnfe) {
        String msg = "Offending classloader: " + cl; // NOI18N
        Exceptions.attachMessage(cnfe, msg);
        throw cnfe;
    }
}
项目:Robin_Java    文件:SecurityObjectInputStream.java   
@Override
protected Class<?> resolveClass( ObjectStreamClass desc )
        throws IOException, ClassNotFoundException
{

    //System.out.println(desc.getName());
    if(!securityList.contains( desc.getName() )){
        throw new ClassNotFoundException( desc.getName() + " not found" );
    };
    return super.resolveClass( desc );
}
项目:AgentWorkbench    文件:SerialClone.java   
@Override
protected Class<?> resolveClass(ObjectStreamClass osc) throws IOException, ClassNotFoundException {
    Class<?> c = output.classQueue.poll();
    String expected = osc.getName();
    String found = (c == null) ? null : c.getName();
    if (!expected.equals(found)) {
        throw new InvalidClassException("Classes desynchronized: found " + found + " when expecting " + expected);
    }
    return c;
}
项目:JRediClients    文件:CustomObjectInputStream.java   
@Override
protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
    try {
        String name = desc.getName();
        return Class.forName(name, false, classLoader);
    } catch (ClassNotFoundException e) {
        return super.resolveClass(desc);
    }
}
项目:EatDubbo    文件:CompactedObjectOutputStream.java   
@Override
protected void writeClassDescriptor(ObjectStreamClass desc) throws IOException
{
    Class<?> clazz = desc.forClass();
    if( clazz.isPrimitive() || clazz.isArray() )
    {
        write(0);
        super.writeClassDescriptor(desc);
    }
    else
    {
        write(1);
        writeUTF(desc.getName());
    }
}
项目:Moenagade    文件:ClassLoaderObjectInputStream.java   
/**
 * Resolve a class specified by the descriptor using the
 * specified ClassLoader or the super ClassLoader.
 *
 * @param objectStreamClass  descriptor of the class
 * @return the Class object described by the ObjectStreamClass
 * @throws IOException in case of an I/O error
 * @throws ClassNotFoundException if the Class cannot be found
 */
@Override
protected Class<?> resolveClass(ObjectStreamClass objectStreamClass)
        throws IOException, ClassNotFoundException {

    Class<?> clazz = Class.forName(objectStreamClass.getName(), false, classLoader);

    if (clazz != null) {
        // the classloader knows of the class
        return clazz;
    } else {
        // classloader knows not of class, let the super classloader do it
        return super.resolveClass(objectStreamClass);
    }
}
项目:neoscada    文件:AbstractIoBuffer.java   
/**
 * {@inheritDoc}
 */
@Override
public IoBuffer putObject(Object o) {
    int oldPos = position();
    skip(4); // Make a room for the length field.
    try {
        ObjectOutputStream out = new ObjectOutputStream(asOutputStream()) {
            @Override
            protected void writeClassDescriptor(ObjectStreamClass desc) throws IOException {
                try {
                    Class<?> clz = Class.forName(desc.getName());
                    if (!Serializable.class.isAssignableFrom(clz)) { // NON-Serializable class
                        write(0);
                        super.writeClassDescriptor(desc);
                    } else { // Serializable class
                        write(1);
                        writeUTF(desc.getName());
                    }
                } catch (ClassNotFoundException ex) { // Primitive types
                    write(0);
                    super.writeClassDescriptor(desc);
                }
            }
        };
        out.writeObject(o);
        out.flush();
    } catch (IOException e) {
        throw new BufferDataException(e);
    }

    // Fill the length field
    int newPos = position();
    position(oldPos);
    putInt(newPos - oldPos - 4);
    position(newPos);
    return this;
}
项目:tomcat7    文件:CustomObjectInputStream.java   
/**
 * Load the local class equivalent of the specified stream class
 * description, by using the class loader assigned to this Context.
 *
 * @param classDesc Class description from the input stream
 *
 * @exception ClassNotFoundException if this class cannot be found
 * @exception IOException if an input/output error occurs
 */
@Override
public Class<?> resolveClass(ObjectStreamClass classDesc)
    throws ClassNotFoundException, IOException {

    String name = classDesc.getName();
    if (allowedClassNamePattern != null) {
        boolean allowed = allowedClassNamePattern.matcher(name).matches();
        if (!allowed) {
            boolean doLog = warnOnFailure && reportedClasses.add(name);
            String msg = sm.getString("customObjectInputStream.nomatch", name, allowedClassNameFilter);
            if (doLog) {
                log.warn(msg);
            } else if (log.isDebugEnabled()) {
                log.debug(msg);
            }
            throw new InvalidClassException(msg);
        }
    }

    try {
        return Class.forName(name, false, classLoader);
    } catch (ClassNotFoundException e) {
        try {
            // Try also the superclass because of primitive types
            return super.resolveClass(classDesc);
        } catch (ClassNotFoundException e2) {
            // Rethrow original exception, as it can have more information
            // about why the class was not found. BZ 48007
            throw e;
        }
    }
}
项目:dubbo2    文件:CompactedObjectOutputStream.java   
@Override
protected void writeClassDescriptor(ObjectStreamClass desc) throws IOException
{
    Class<?> clazz = desc.forClass();
    if( clazz.isPrimitive() || clazz.isArray() )
    {
        write(0);
        super.writeClassDescriptor(desc);
    }
    else
    {
        write(1);
        writeUTF(desc.getName());
    }
}
项目:myfaces-trinidad    文件:MyFacesObjectInputStream.java   
protected Class resolveClass(ObjectStreamClass desc)
    throws ClassNotFoundException, IOException
{
    try
    {
        return ClassUtils.classForName(desc.getName());
    }
    catch (ClassNotFoundException e)
    {
        return super.resolveClass(desc);
    }
}
项目:Equella    文件:PluginAwareObjectInputStream.java   
@Override
protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException
{
    if (banned.contains(desc.getName()))
    {
        throw new RuntimeException("Class is banned: "+desc.getName());
    }
    int loaderNum = readByte();
    ClassLoader loader;
    if( loaderNum == 0 )
    {
        loader = Thread.currentThread().getContextClassLoader();
    }
    else if( loaderNum > loaders.size() )
    {
        String pluginId = readUTF();
        PluginClassResolver pluginService = PluginClassResolver.resolver();
        loader = pluginService.getLoaderForPluginId(pluginId);
        loaders.add(loader);
    }
    else
    {
        loader = loaders.get(loaderNum - 1);
    }
    try
    {
        return Class.forName(desc.getName(), false, loader);
    }
    catch( ClassNotFoundException cnfe )
    {
        return super.resolveClass(desc);
    }
}
项目:lams    文件:ClassLoaderObjectInputStream.java   
/**
 * Resolve a class specified by the descriptor using the
 * specified ClassLoader or the super ClassLoader.
 *
 * @param objectStreamClass  descriptor of the class
 * @return the Class object described by the ObjectStreamClass
 * @throws IOException in case of an I/O error
 * @throws ClassNotFoundException if the Class cannot be found
 */
@Override
protected Class<?> resolveClass(ObjectStreamClass objectStreamClass)
        throws IOException, ClassNotFoundException {

    Class<?> clazz = Class.forName(objectStreamClass.getName(), false, classLoader);

    if (clazz != null) {
        // the classloader knows of the class
        return clazz;
    } else {
        // classloader knows not of class, let the super classloader do it
        return super.resolveClass(objectStreamClass);
    }
}