getSerialVersionUID ( )源码实例Demo

java.io.ObjectStreamClass#getSerialVersionUID ( )源码实例Demo

下面列出了java.io.ObjectStreamClass#getSerialVersionUID ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: dragonwell8_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();
}
 
源代码2 项目: TencentKona-8   文件: 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();
}
 
源代码3 项目: openjdk-jdk8u   文件: 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();
}
 
/**
 * Updates the options that the current classifier is using.
 */
@Override
protected void updateOptions() {

  if (m_Template instanceof OptionHandler) {
    m_ClassifierOptions = Utils.joinOptions(((OptionHandler) m_Template)
        .getOptions());
  } else {
    m_ClassifierOptions = "";
  }
  if (m_Template instanceof Serializable) {
    ObjectStreamClass obs = ObjectStreamClass.lookup(m_Template.getClass());
    m_ClassifierVersion = "" + obs.getSerialVersionUID();
  } else {
    m_ClassifierVersion = "";
  }
}
 
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();
}
 
源代码6 项目: hottub   文件: 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();
}
 
源代码7 项目: Flink-CEPplus   文件: InstantiationUtil.java
@Override
protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException {
	ObjectStreamClass streamClassDescriptor = super.readClassDescriptor();

	try {
		Class.forName(streamClassDescriptor.getName(), false, classLoader);
	} catch (ClassNotFoundException e) {

		final ObjectStreamClass equivalentSerializer =
				MigrationUtil.getEquivalentSerializer(streamClassDescriptor.getName());

		if (equivalentSerializer != null) {
			return equivalentSerializer;
		}
	}

	final Class localClass = resolveClass(streamClassDescriptor);
	final String name = localClass.getName();
	if (scalaSerializerClassnames.contains(name) || scalaTypes.contains(name) || isAnonymousClass(localClass)
		|| isOldAvroSerializer(name, streamClassDescriptor.getSerialVersionUID())) {
		final ObjectStreamClass localClassDescriptor = ObjectStreamClass.lookup(localClass);
		if (localClassDescriptor != null
			&& localClassDescriptor.getSerialVersionUID() != streamClassDescriptor.getSerialVersionUID()) {
			LOG.warn("Ignoring serialVersionUID mismatch for class {}; was {}, now {}.",
				streamClassDescriptor.getName(), streamClassDescriptor.getSerialVersionUID(), localClassDescriptor.getSerialVersionUID());

			streamClassDescriptor = localClassDescriptor;
		}
	}

	return streamClassDescriptor;
}
 
源代码8 项目: j2objc   文件: ObjectStreamFieldTest.java
public ObjectStreamClass readClassDescriptor() throws IOException,
        ClassNotFoundException {
    ObjectStreamClass osc = super.readClassDescriptor();
    // To get the ObjectStreamClass of SerializableObject
    if (osc.getSerialVersionUID() == -2953957835918368056L) {
        temp = osc;
    }
    return osc;
}
 
源代码9 项目: offheap-store   文件: SerializablePortability.java
public SerializableDataKey(ObjectStreamClass desc, boolean store) throws IOException {
  Class<?> forClass = desc.forClass();
  if (forClass != null) {
    if (store) {
      throw new AssertionError("Must not store ObjectStreamClass instances with strong references to classes");
    } else if (ObjectStreamClass.lookup(forClass) == desc) {
      this.klazz = new WeakReference<>(forClass);
    }
  }
  this.hashCode = (3 * desc.getName().hashCode()) ^ (7 * (int) (desc.getSerialVersionUID() >>> 32))
      ^ (11 * (int) desc.getSerialVersionUID());
  this.osc = desc;
}
 
源代码10 项目: jdk8u_jdk   文件: SerialVer.java
static String resolveClass(String classname) throws ClassNotFoundException {
    Class<?> cl = Class.forName(classname, false, loader);
    ObjectStreamClass desc = ObjectStreamClass.lookup(cl);
    if (desc != null) {
        return "    private static final long serialVersionUID = " +
            desc.getSerialVersionUID() + "L;";
    } else {
        return null;
    }
}
 
private void readObject(
        ObjectInputStream stream)
        throws IOException, ClassNotFoundException {
    stream.defaultReadObject();
    ObjectStreamClass myObject = ObjectStreamClass.lookup(
            Class.forName(Kosler_Agilent7700_RawDataTemplate.class.getCanonicalName()));
    long theSUID = myObject.getSerialVersionUID();
    System.out.println("Customized De-serialization of Kosler_Agilent7700_RawDataTemplate " + theSUID);
}
 
源代码12 项目: jdk8u60   文件: SerialVer.java
static String resolveClass(String classname) throws ClassNotFoundException {
    Class<?> cl = Class.forName(classname, false, loader);
    ObjectStreamClass desc = ObjectStreamClass.lookup(cl);
    if (desc != null) {
        return "    private static final long serialVersionUID = " +
            desc.getSerialVersionUID() + "L;";
    } else {
        return null;
    }
}
 
源代码13 项目: openjdk-jdk8u   文件: SerialVer.java
static String resolveClass(String classname) throws ClassNotFoundException {
    Class<?> cl = Class.forName(classname, false, loader);
    ObjectStreamClass desc = ObjectStreamClass.lookup(cl);
    if (desc != null) {
        return "    private static final long serialVersionUID = " +
            desc.getSerialVersionUID() + "L;";
    } else {
        return null;
    }
}
 
源代码14 项目: flink   文件: InstantiationUtil.java
@Override
protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException {
	ObjectStreamClass streamClassDescriptor = super.readClassDescriptor();

	try {
		Class.forName(streamClassDescriptor.getName(), false, classLoader);
	} catch (ClassNotFoundException e) {

		final ObjectStreamClass equivalentSerializer =
				MigrationUtil.getEquivalentSerializer(streamClassDescriptor.getName());

		if (equivalentSerializer != null) {
			return equivalentSerializer;
		}
	}

	final Class localClass = resolveClass(streamClassDescriptor);
	final String name = localClass.getName();
	if (scalaSerializerClassnames.contains(name) || scalaTypes.contains(name) || isAnonymousClass(localClass)
		|| isOldAvroSerializer(name, streamClassDescriptor.getSerialVersionUID())) {
		final ObjectStreamClass localClassDescriptor = ObjectStreamClass.lookup(localClass);
		if (localClassDescriptor != null
			&& localClassDescriptor.getSerialVersionUID() != streamClassDescriptor.getSerialVersionUID()) {
			LOG.warn("Ignoring serialVersionUID mismatch for class {}; was {}, now {}.",
				streamClassDescriptor.getName(), streamClassDescriptor.getSerialVersionUID(), localClassDescriptor.getSerialVersionUID());

			streamClassDescriptor = localClassDescriptor;
		}
	}

	return streamClassDescriptor;
}
 
private void readObject(
        ObjectInputStream stream)
        throws IOException, ClassNotFoundException {
    stream.defaultReadObject();
    ObjectStreamClass myObject = ObjectStreamClass.lookup(
            Class.forName(LevenbergMarquardGeneralSolverWithVecV.class.getCanonicalName()));
    long theSUID = myObject.getSerialVersionUID();
    System.out.println("Customized De-serialization of LevenbergMarquardGeneralSolverWithVecV " + theSUID);
}
 
源代码16 项目: ET_Redux   文件: RittnerAgilent7700FileHandler.java
private void readObject(
        ObjectInputStream stream)
        throws IOException, ClassNotFoundException {
    stream.defaultReadObject();
    ObjectStreamClass myObject = ObjectStreamClass.lookup(
            Class.forName(RittnerAgilent7700FileHandler.class.getCanonicalName()));
    long theSUID = myObject.getSerialVersionUID();
    System.out.println("Customized De-serialization of RittnerAgilent7700FileHandler " + theSUID);
}
 
源代码17 项目: jdk8u-jdk   文件: SerialVer.java
static String resolveClass(String classname) throws ClassNotFoundException {
    Class<?> cl = Class.forName(classname, false, loader);
    ObjectStreamClass desc = ObjectStreamClass.lookup(cl);
    if (desc != null) {
        return "    private static final long serialVersionUID = " +
            desc.getSerialVersionUID() + "L;";
    } else {
        return null;
    }
}
 
private void readObject(
        ObjectInputStream stream)
        throws IOException, ClassNotFoundException {
    stream.defaultReadObject();
    ObjectStreamClass myObject = ObjectStreamClass.lookup(
            Class.forName(Rittner_Agilent7700_RawDataTemplate.class.getCanonicalName()));
    long theSUID = myObject.getSerialVersionUID();
    System.out.println("Customized De-serialization of Rittner_Agilent7700_RawDataTemplate " + theSUID);
}
 
源代码19 项目: openjdk-8-source   文件: SerialVer.java
static String resolveClass(String classname) throws ClassNotFoundException {
    Class<?> cl = Class.forName(classname, false, loader);
    ObjectStreamClass desc = ObjectStreamClass.lookup(cl);
    if (desc != null) {
        return "    private static final long serialVersionUID = " +
            desc.getSerialVersionUID() + "L;";
    } else {
        return null;
    }
}
 
源代码20 项目: openjdk-8   文件: SerialVer.java
static String resolveClass(String classname) throws ClassNotFoundException {
    Class<?> cl = Class.forName(classname, false, loader);
    ObjectStreamClass desc = ObjectStreamClass.lookup(cl);
    if (desc != null) {
        return "    private static final long serialVersionUID = " +
            desc.getSerialVersionUID() + "L;";
    } else {
        return null;
    }
}