當前位置: 首頁>>代碼示例>>Java>>正文


Java ObjectStreamClass類代碼示例

本文整理匯總了Java中java.io.ObjectStreamClass的典型用法代碼示例。如果您正苦於以下問題:Java ObjectStreamClass類的具體用法?Java ObjectStreamClass怎麽用?Java ObjectStreamClass使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ObjectStreamClass類屬於java.io包,在下文中一共展示了ObjectStreamClass類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: resolveClass

import java.io.ObjectStreamClass; //導入依賴的package包/類
@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());
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:17,代碼來源:ObjectInputStreamForClassLoadService.java

示例2: readClassDescriptor

import java.io.ObjectStreamClass; //導入依賴的package包/類
@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);
	}
}
 
開發者ID:dachengxi,項目名稱:EatDubbo,代碼行數:18,代碼來源:CompactedObjectInputStream.java

示例3: readClassDescriptor

import java.io.ObjectStreamClass; //導入依賴的package包/類
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;
}
 
開發者ID:d2si-oss,項目名稱:ooso,代碼行數:19,代碼來源:DecompressibleInputStream.java

示例4: resolveClass

import java.io.ObjectStreamClass; //導入依賴的package包/類
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;
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:23,代碼來源:ObjectInputStreamResolveClass.java

示例5: create

import java.io.ObjectStreamClass; //導入依賴的package包/類
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();
            }
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:26,代碼來源:UnsafeAllocator.java

示例6: getPersistentFields

import java.io.ObjectStreamClass; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:28,代碼來源:ValueType.java

示例7: main

import java.io.ObjectStreamClass; //導入依賴的package包/類
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();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:TestObjectStreamClass.java

示例8: run

import java.io.ObjectStreamClass; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:20,代碼來源:ClassDesc.java

示例9: run

import java.io.ObjectStreamClass; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:20,代碼來源:ProxyClassDesc.java

示例10: genDescs

import java.io.ObjectStreamClass; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:29,代碼來源:ProxyClassDesc.java

示例11: doReps

import java.io.ObjectStreamClass; //導入依賴的package包/類
/**
 * 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();
        }
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:21,代碼來源:ProxyClassDesc.java

示例12: resolveClass

import java.io.ObjectStreamClass; //導入依賴的package包/類
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);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:21,代碼來源:SuperclassDataLossTest.java

示例13: resolveClass

import java.io.ObjectStreamClass; //導入依賴的package包/類
@Override
protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
    try {
        return Class.forName(desc.getName(), false, loader);
    } catch (ClassNotFoundException e) {
        return super.resolveClass(desc);
    }
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:9,代碼來源:ClassLoaderObjectInputStream.java

示例14: readClassDescriptor

import java.io.ObjectStreamClass; //導入依賴的package包/類
@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;
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:10,代碼來源:PayloadSerializerObjectInputStream.java

示例15: checkDeserializationClass

import java.io.ObjectStreamClass; //導入依賴的package包/類
/**
 * 反序列化監檢測點
 *
 * @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);
        }
    }

}
 
開發者ID:baidu,項目名稱:openrasp,代碼行數:18,代碼來源:DeserializationHook.java


注:本文中的java.io.ObjectStreamClass類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。