Java Code Examples for java.io.ObjectStreamClass.getSerialVersionUID()

The following are Jave code examples for showing how to use getSerialVersionUID() of the java.io.ObjectStreamClass class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: ooso   File: DecompressibleInputStream.java   View Source Code Vote up 6 votes
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;
}
 
Example 2
Project: jdk8u-jdk   File: TestObjectStreamClass.java   View Source Code Vote up 6 votes
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();
}
 
Example 3
Project: openjdk-jdk10   File: TestObjectStreamClass.java   View Source Code Vote up 6 votes
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();
}
 
Example 4
Project: Squid   File: Average.java   View Source Code Vote up 5 votes
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);
}
 
Example 5
Project: Squid   File: Exp.java   View Source Code Vote up 5 votes
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);
}
 
Example 6
Project: Squid   File: Count.java   View Source Code Vote up 5 votes
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);
}
 
Example 7
Project: Squid   File: Max.java   View Source Code Vote up 5 votes
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);
}
 
Example 8
Project: OpenJSharp   File: SerialVer.java   View Source Code Vote up 5 votes
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;
    }
}
 
Example 9
Project: jdk8u-jdk   File: SerialVer.java   View Source Code Vote up 5 votes
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;
    }
}
 
Example 10
Project: openjdk-jdk10   File: SerialVer.java   View Source Code Vote up 5 votes
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;
    }
}
 
Example 11
Project: BetterRandom   File: BaseRandomStaticTest.java   View Source Code Vote up 4 votes
@Override protected Class<?> resolveClass(final ObjectStreamClass desc)
    throws IOException, ClassNotFoundException {
  return (Switcheroo.serialVersionUID == desc.getSerialVersionUID()) ? AesCounterRandom.class
      : super.resolveClass(desc);
}