/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Serialization's descriptor for classes. It contains the name and
* serialVersionUID of the class. The ObjectStreamClass for a specific class
*
* <p>The algorithm to compute the SerialVersionUID is described in
* <a href="../../../platform/serialization/spec/class.html#4100">Object
* Serialization Specification, Section 4.6, Stream Unique Identifiers</a>.
*
* @author Mike Warres
* @author Roger Riggs
* @see ObjectStreamField
* @see <a href="../../../platform/serialization/spec/class.html">Object Serialization Specification, Section 4, Class Descriptors</a>
* @since JDK1.1
*/
/** serialPersistentFields value indicating no serializable fields */
new ObjectStreamField[0];
/** reflection factory for obtaining serialization constructors */
private static class Caches {
/** cache mapping local classes -> descriptors */
new ConcurrentHashMap<>();
new ConcurrentHashMap<>();
/** queue for WeakReferences to local classes */
new ReferenceQueue<>();
/** queue for WeakReferences to field reflectors keys */
new ReferenceQueue<>();
}
/** class associated with this descriptor (if any) */
/** name of class represented by this descriptor */
/** serialVersionUID of represented class (null if not computed yet) */
/** true if represents dynamic proxy class */
private boolean isProxy;
/** true if represents enum type */
private boolean isEnum;
/** true if represented class implements Serializable */
private boolean serializable;
/** true if represented class implements Externalizable */
private boolean externalizable;
/** true if desc has data written by class-defined writeObject method */
private boolean hasWriteObjectData;
/**
* true if desc has externalizable data written in block data format; this
* must be true by default to accommodate ObjectInputStream subclasses which
* override readClassDescriptor() to return class descriptors obtained from
* ObjectStreamClass.lookup() (see 4461737)
*/
private boolean hasBlockExternalData = true;
/**
* Contains information about InvalidClassException instances to be thrown
* when attempting operations on an invalid class. Note that instances of
* this class are immutable and are potentially shared among
* ObjectStreamClass instances.
*/
private static class ExceptionInfo {
}
/**
* Returns (does not throw) an InvalidClassException instance created
* from the information in this object, suitable for being thrown by
* the caller.
*/
}
}
/** exception (if any) thrown while attempting to resolve class */
/** exception (if any) to throw if non-enum deserialization attempted */
/** exception (if any) to throw if non-enum serialization attempted */
/** exception (if any) to throw if default serialization attempted */
/** serializable fields */
/** aggregate marshalled size of primitive fields */
private int primDataSize;
/** number of non-primitive fields */
private int numObjFields;
/** data layout of serialized objects described by this class desc */
/** serialization-appropriate constructor, or null if none */
/** class-defined writeObject method, or null if none */
/** class-defined readObject method, or null if none */
/** class-defined readObjectNoData method, or null if none */
/** class-defined writeReplace method, or null if none */
/** class-defined readResolve method, or null if none */
/** local class descriptor for represented class (may point to self) */
/** superclass descriptor appearing in stream */
/**
* Initializes native code.
*/
private static native void initNative();
static {
initNative();
}
/**
* Find the descriptor for a class that can be serialized. Creates an
* ObjectStreamClass instance if one does not exist yet for class. Null is
* returned if the specified class does not implement java.io.Serializable
* or java.io.Externalizable.
*
* @param cl class for which to get the descriptor
* @return the class descriptor for the specified class
*/
}
/**
* Returns the descriptor for any class, regardless of whether it
* implements {@link Serializable}.
*
* @param cl class for which to get the descriptor
* @return the class descriptor for the specified class
* @since 1.6
*/
}
/**
* Returns the name of the class described by this descriptor.
* This method returns the name of the class in the format that
* is used by the {@link Class#getName} method.
*
* @return a string representing the name of the class
*/
return name;
}
/**
* Return the serialVersionUID for this class. The serialVersionUID
* defines a set of classes all with the same name that have evolved from a
* common root class and agree to be serialized and deserialized using a
* common format. NonSerializable classes have a serialVersionUID of 0L.
*
* @return the SUID of the class described by this descriptor
*/
public long getSerialVersionUID() {
// REMIND: synchronize instead of relying on volatile?
new PrivilegedAction<Long>() {
return computeDefaultSUID(cl);
}
}
);
}
}
/**
* Return the class in the local VM that this version is mapped to. Null
* is returned if there is no corresponding local class.
*
* @return the <code>Class</code> instance that this descriptor represents
*/
return null;
}
}
}
return cl;
}
/**
* Return an array of the fields of this serializable class.
*
* @return an array containing an element for each persistent field of
* this class. Returns an array of length zero if there are no
* fields.
* @since 1.2
*/
return getFields(true);
}
/**
* Get the field of this class by name.
*
* @param name the name of the data field to look for
* @return The ObjectStreamField object of the named field or null if
* there is no such named field.
*/
}
/**
* Return a string describing this ObjectStreamClass.
*/
return name + ": static final long serialVersionUID = " +
getSerialVersionUID() + "L;";
}
/**
* Looks up and returns class descriptor for given class, or null if class
* is non-serializable and "all" is set to false.
*
* @param cl class to look up
* @param all if true, return descriptors for all classes; if false, only
* return descriptors for serializable classes
*/
return null;
}
}
do {
}
}
}
}
return (ObjectStreamClass) entry;
}
if (entry instanceof EntryFuture) {
/*
* Handle nested call situation described by 4803747: waiting
* for future value to be set by a lookup() call further up the
* stack will result in deadlock, so calculate and set the
* future value here instead.
*/
} else {
}
}
try {
}
} else {
// nested lookup call already set future
}
}
if (entry instanceof ObjectStreamClass) {
return (ObjectStreamClass) entry;
} else if (entry instanceof RuntimeException) {
throw (RuntimeException) entry;
} else {
}
}
/**
* Placeholder used in class descriptor and field reflector lookup tables
* for an entry in the process of being initialized. (Internal) callers
* which receive an EntryFuture belonging to another thread as the result
* of a lookup should call the get() method of the EntryFuture; this will
* return the actual entry once it is ready for use and has been set(). To
* conserve objects, EntryFutures synchronize on themselves.
*/
private static class EntryFuture {
/**
* Attempts to set the value contained by this EntryFuture. If the
* EntryFuture's value has not been set already, then the value is
* saved, any callers blocked in the get() method are notified, and
* true is returned. If the value has already been set, then no saving
* or notification occurs, and false is returned.
*/
return false;
}
notifyAll();
return true;
}
/**
* Returns the value contained by this EntryFuture, blocking if
* necessary until a value is set.
*/
boolean interrupted = false;
try {
wait();
} catch (InterruptedException ex) {
interrupted = true;
}
}
if (interrupted) {
new PrivilegedAction<Void>() {
return null;
}
}
);
}
return entry;
}
/**
* Returns the thread that created this EntryFuture.
*/
return owner;
}
}
/**
* Creates local class descriptor representing given class.
*/
localDesc = this;
if (serializable) {
if (isEnum) {
return null;
}
return null;
}
try {
} catch (InvalidClassException e) {
}
if (externalizable) {
} else {
new Class<?>[] { ObjectOutputStream.class },
new Class<?>[] { ObjectInputStream.class },
}
return null;
}
});
} else {
}
try {
} catch (InvalidClassException ex) {
// field mismatches impossible when matching local fields vs. self
throw new InternalError();
}
if (deserializeEx == null) {
if (isEnum) {
}
}
defaultSerializeEx = new ExceptionInfo(
name, "unmatched serializable field(s) declared");
}
}
}
/**
* Creates blank class descriptor which should be initialized via a
* subsequent call to initProxy(), initNonProxy() or readNonProxy().
*/
}
/**
* Initializes class descriptor representing a proxy class.
*/
throws InvalidClassException
{
isProxy = true;
serializable = true;
throw new InvalidClassException(
"cannot bind proxy descriptor to a non-proxy class");
}
}
}
/**
* Initializes class descriptor representing a non-proxy class.
*/
throws InvalidClassException
{
isProxy = false;
throw new InvalidClassException(
"cannot bind non-proxy descriptor to a proxy class");
}
throw new InvalidClassException(isEnum ?
"cannot bind enum descriptor to a non-enum class" :
"cannot bind non-enum descriptor to an enum class");
}
{
"local class incompatible: " +
"stream classdesc serialVersionUID = " + suid +
", local class serialVersionUID = " +
}
"local class name incompatible with stream class " +
}
if (!isEnum) {
{
"Serializable incompatible with Externalizable");
}
!(serializable || externalizable))
{
deserializeEx = new ExceptionInfo(
}
}
if (deserializeEx == null) {
}
}
// reassign to matched fields so as to reflect local unshared settings
}
/**
* Reads non-proxy class descriptor information from given input stream.
* The resulting class descriptor is not fully functional; it can only be
* used as input to the ObjectInputStream.resolveClass() and
* ObjectStreamClass.initNonProxy() methods.
*/
throws IOException, ClassNotFoundException
{
isProxy = false;
boolean sflag =
if (externalizable && sflag) {
throw new InvalidClassException(
name, "serializable and externalizable flags conflict");
}
throw new InvalidClassException(name,
"enum descriptor has non-zero serialVersionUID: " + suid);
}
throw new InvalidClassException(name,
"enum descriptor has non-zero field count: " + numFields);
}
for (int i = 0; i < numFields; i++) {
try {
} catch (RuntimeException e) {
}
}
}
/**
* Writes non-proxy class descriptor information to given output stream.
*/
byte flags = 0;
if (externalizable) {
}
} else if (serializable) {
}
if (hasWriteObjectData) {
}
if (isEnum) {
}
ObjectStreamField f = fields[i];
if (!f.isPrimitive()) {
}
}
}
/**
* Returns ClassNotFoundException (if any) thrown while attempting to
* resolve local class corresponding to this class descriptor.
*/
return resolveEx;
}
/**
* Throws an InvalidClassException if object instances referencing this
* class descriptor should not be allowed to deserialize. This method does
* not apply to deserialization of enum constants.
*/
if (deserializeEx != null) {
throw deserializeEx.newInvalidClassException();
}
}
/**
* Throws an InvalidClassException if objects whose class is represented by
* this descriptor should not be allowed to serialize. This method does
* not apply to serialization of enum constants.
*/
if (serializeEx != null) {
throw serializeEx.newInvalidClassException();
}
}
/**
* Throws an InvalidClassException if objects whose class is represented by
* this descriptor should not be permitted to use default serialization
* (e.g., if the class declares serializable fields that do not correspond
* to actual fields, and hence must use the GetField API). This method
* does not apply to deserialization of enum constants.
*/
if (defaultSerializeEx != null) {
}
}
/**
* Returns superclass descriptor. Note that on the receiving side, the
* superclass descriptor may be bound to a class that is not a superclass
* of the subclass descriptor's bound class.
*/
return superDesc;
}
/**
* Returns the "local" class descriptor for the class associated with this
* class descriptor (i.e., the result of
* ObjectStreamClass.lookup(this.forClass())) or null if there is no class
* associated with this descriptor.
*/
return localDesc;
}
/**
* Returns arrays of ObjectStreamFields representing the serializable
* fields of the represented class. If copy is true, a clone of this class
* descriptor's field array is returned, otherwise the array itself is
* returned.
*/
}
/**
* Looks up a serializable field of the represented class by name and type.
* A specified type of null matches all types, Object.class matches all
* non-primitive types, and any other non-null type matches assignable
* types only. Returns matching field, or null if no match found.
*/
ObjectStreamField f = fields[i];
{
return f;
}
return f;
}
}
}
return null;
}
/**
* Returns true if class descriptor represents a dynamic proxy class, false
* otherwise.
*/
boolean isProxy() {
return isProxy;
}
/**
* Returns true if class descriptor represents an enum type, false
* otherwise.
*/
boolean isEnum() {
return isEnum;
}
/**
* Returns true if represented class implements Externalizable, false
* otherwise.
*/
boolean isExternalizable() {
return externalizable;
}
/**
* Returns true if represented class implements Serializable, false
* otherwise.
*/
boolean isSerializable() {
return serializable;
}
/**
* Returns true if class descriptor represents externalizable class that
* has written its data in 1.2 (block data) format, false otherwise.
*/
boolean hasBlockExternalData() {
return hasBlockExternalData;
}
/**
* Returns true if class descriptor represents serializable (but not
* externalizable) class which has written its data via a custom
* writeObject() method, false otherwise.
*/
boolean hasWriteObjectData() {
return hasWriteObjectData;
}
/**
* Returns true if represented class is serializable/externalizable and can
* be instantiated by the serialization runtime--i.e., if it is
* externalizable and defines a public no-arg constructor, or if it is
* non-externalizable and its first non-serializable superclass defines an
* accessible no-arg constructor. Otherwise, returns false.
*/
boolean isInstantiable() {
}
/**
* Returns true if represented class is serializable (but not
* externalizable) and defines a conformant writeObject method. Otherwise,
* returns false.
*/
boolean hasWriteObjectMethod() {
return (writeObjectMethod != null);
}
/**
* Returns true if represented class is serializable (but not
* externalizable) and defines a conformant readObject method. Otherwise,
* returns false.
*/
boolean hasReadObjectMethod() {
return (readObjectMethod != null);
}
/**
* Returns true if represented class is serializable (but not
* externalizable) and defines a conformant readObjectNoData method.
* Otherwise, returns false.
*/
boolean hasReadObjectNoDataMethod() {
return (readObjectNoDataMethod != null);
}
/**
* Returns true if represented class is serializable or externalizable and
* defines a conformant writeReplace method. Otherwise, returns false.
*/
boolean hasWriteReplaceMethod() {
return (writeReplaceMethod != null);
}
/**
* Returns true if represented class is serializable or externalizable and
* defines a conformant readResolve method. Otherwise, returns false.
*/
boolean hasReadResolveMethod() {
return (readResolveMethod != null);
}
/**
* Creates a new instance of the represented class. If the class is
* externalizable, invokes its public no-arg constructor; otherwise, if the
* class is serializable, invokes the no-arg constructor of the first
* non-serializable superclass. Throws UnsupportedOperationException if
* this class descriptor is not associated with a class, if the associated
* class is non-serializable or if the appropriate no-arg constructor is
*/
{
try {
return cons.newInstance();
} catch (IllegalAccessException ex) {
// should not occur, as access checks have been suppressed
throw new InternalError();
}
} else {
throw new UnsupportedOperationException();
}
}
/**
* Invokes the writeObject method of the represented serializable class.
* Throws UnsupportedOperationException if this class descriptor is not
* associated with a class, or if the class is externalizable,
* non-serializable or does not define writeObject.
*/
{
if (writeObjectMethod != null) {
try {
} catch (InvocationTargetException ex) {
if (th instanceof IOException) {
throw (IOException) th;
} else {
}
} catch (IllegalAccessException ex) {
// should not occur, as access checks have been suppressed
throw new InternalError();
}
} else {
throw new UnsupportedOperationException();
}
}
/**
* Invokes the readObject method of the represented serializable class.
* Throws UnsupportedOperationException if this class descriptor is not
* associated with a class, or if the class is externalizable,
* non-serializable or does not define readObject.
*/
throws ClassNotFoundException, IOException,
{
if (readObjectMethod != null) {
try {
} catch (InvocationTargetException ex) {
if (th instanceof ClassNotFoundException) {
throw (ClassNotFoundException) th;
} else if (th instanceof IOException) {
throw (IOException) th;
} else {
}
} catch (IllegalAccessException ex) {
// should not occur, as access checks have been suppressed
throw new InternalError();
}
} else {
throw new UnsupportedOperationException();
}
}
/**
* Invokes the readObjectNoData method of the represented serializable
* class. Throws UnsupportedOperationException if this class descriptor is
* not associated with a class, or if the class is externalizable,
* non-serializable or does not define readObjectNoData.
*/
{
if (readObjectNoDataMethod != null) {
try {
} catch (InvocationTargetException ex) {
if (th instanceof ObjectStreamException) {
throw (ObjectStreamException) th;
} else {
}
} catch (IllegalAccessException ex) {
// should not occur, as access checks have been suppressed
throw new InternalError();
}
} else {
throw new UnsupportedOperationException();
}
}
/**
* Invokes the writeReplace method of the represented serializable class and
* returns the result. Throws UnsupportedOperationException if this class
* descriptor is not associated with a class, or if the class is
* non-serializable or does not define writeReplace.
*/
{
if (writeReplaceMethod != null) {
try {
} catch (InvocationTargetException ex) {
if (th instanceof ObjectStreamException) {
throw (ObjectStreamException) th;
} else {
throw new InternalError(); // never reached
}
} catch (IllegalAccessException ex) {
// should not occur, as access checks have been suppressed
throw new InternalError();
}
} else {
throw new UnsupportedOperationException();
}
}
/**
* Invokes the readResolve method of the represented serializable class and
* returns the result. Throws UnsupportedOperationException if this class
* descriptor is not associated with a class, or if the class is
* non-serializable or does not define readResolve.
*/
{
if (readResolveMethod != null) {
try {
} catch (InvocationTargetException ex) {
if (th instanceof ObjectStreamException) {
throw (ObjectStreamException) th;
} else {
throw new InternalError(); // never reached
}
} catch (IllegalAccessException ex) {
// should not occur, as access checks have been suppressed
throw new InternalError();
}
} else {
throw new UnsupportedOperationException();
}
}
/**
* Class representing the portion of an object's serialized form allotted
* to data described by a given class descriptor. If "hasData" is false,
* the object's serialized form does not contain data associated with the
* class descriptor.
*/
static class ClassDataSlot {
/** class descriptor "occupying" this slot */
/** true if serialized form includes data for this slot's descriptor */
final boolean hasData;
}
}
/**
* Returns array of ClassDataSlot instances representing the data layout
* (including superclass data) for serialized objects described by this
* class descriptor. ClassDataSlots are ordered by inheritance with those
* containing "higher" superclasses appearing first. The final
* ClassDataSlot contains a reference to this descriptor.
*/
// REMIND: synchronize instead of relying on volatile?
if (dataLayout == null) {
}
return dataLayout;
}
throws InvalidClassException
{
// locate closest non-serializable superclass
}
throw new InvalidClassException("Circular reference.");
} else {
}
// search up inheritance hierarchy for class with matching name
match = c;
break;
}
}
// add "no data" slot for each unmatched class below match
ObjectStreamClass.lookup(c, true), false));
}
}
// record descriptor/class pairing
}
// add "no data" slot for any leftover unmatched classes
ObjectStreamClass.lookup(c, true), false));
}
// order slots from superclass -> subclass
}
/**
* Returns aggregate size (in bytes) of marshalled primitive field values
* for represented class.
*/
int getPrimDataSize() {
return primDataSize;
}
/**
* Returns number of non-primitive serializable fields of represented
* class.
*/
int getNumObjFields() {
return numObjFields;
}
/**
* Fetches the serializable primitive field values of object obj and
* marshals them into byte array buf starting at offset 0. It is the
* responsibility of the caller to ensure that obj is of the proper type if
* non-null.
*/
}
/**
* Sets the serializable primitive fields of object obj using values
* unmarshalled from byte array buf starting at offset 0. It is the
* responsibility of the caller to ensure that obj is of the proper type if
* non-null.
*/
}
/**
* Fetches the serializable object field values of object obj and stores
* them in array vals starting at offset 0. It is the responsibility of
* the caller to ensure that obj is of the proper type if non-null.
*/
}
/**
* Sets the serializable object fields of object obj using values from
* array vals starting at offset 0. It is the responsibility of the caller
* to ensure that obj is of the proper type if non-null.
*/
}
/**
* Calculates and sets serializable field offsets, as well as primitive
* data size and object field count totals. Throws InvalidClassException
* if fields are illegally ordered.
*/
primDataSize = 0;
numObjFields = 0;
int firstObjIndex = -1;
ObjectStreamField f = fields[i];
switch (f.getTypeCode()) {
case 'Z':
case 'B':
f.setOffset(primDataSize++);
break;
case 'C':
case 'S':
primDataSize += 2;
break;
case 'I':
case 'F':
primDataSize += 4;
break;
case 'J':
case 'D':
primDataSize += 8;
break;
case '[':
case 'L':
f.setOffset(numObjFields++);
if (firstObjIndex == -1) {
firstObjIndex = i;
}
break;
default:
throw new InternalError();
}
}
if (firstObjIndex != -1 &&
{
}
}
/**
* If given class is the same as the class associated with this class
* descriptor, returns reference to this class descriptor. Otherwise,
* returns variant of this class descriptor bound to given class.
*/
throws InvalidClassException
{
return this;
}
if (isProxy) {
} else {
}
return desc;
}
/**
* Returns public no-arg constructor of given class, or null if none found.
* Access checks are disabled on the returned constructor (if any), since
* the defining class may still be non-public.
*/
try {
cons.setAccessible(true);
} catch (NoSuchMethodException ex) {
return null;
}
}
/**
* Returns subclass-accessible no-arg constructor of first non-serializable
* superclass, or null if none found. Access checks are disabled on the
* returned constructor (if any).
*/
return null;
}
}
try {
{
return null;
}
cons.setAccessible(true);
return cons;
} catch (NoSuchMethodException ex) {
return null;
}
}
/**
* Returns non-static, non-abstract method with given signature provided it
* is defined by or accessible (via inheritance) by the given class, or
* null if no match found. Access checks are disabled on the returned
* method (if any).
*/
Class<?> returnType)
{
try {
break;
} catch (NoSuchMethodException ex) {
}
}
return null;
}
meth.setAccessible(true);
return null;
return meth;
} else {
}
}
/**
* Returns non-static private method with given signature defined by given
* class, or null if none found. Access checks are disabled on the
* returned method (if any).
*/
Class<?> returnType)
{
try {
meth.setAccessible(true);
} catch (NoSuchMethodException ex) {
return null;
}
}
/**
* Returns true if classes are defined in the same runtime package, false
* otherwise.
*/
}
/**
* Returns package name of given class.
*/
int i = s.lastIndexOf('[');
if (i >= 0) {
s = s.substring(i + 2);
}
i = s.lastIndexOf('.');
}
/**
* Compares class names for equality, ignoring package names. Returns true
* if class names equal, false otherwise.
*/
}
/**
* Returns JVM type signature for given class.
*/
}
if (cl.isPrimitive()) {
} else {
throw new InternalError();
}
} else {
}
}
/**
* Returns JVM type signature for given list of parameters and return type.
*/
{
}
}
/**
* Convenience method for throwing an exception that is either a
* RuntimeException, Error, or of some unexpected type (in which case it is
* wrapped inside an IOException).
*/
if (th instanceof RuntimeException) {
throw (RuntimeException) th;
} else {
throw ex;
}
}
/**
* Returns ObjectStreamField array describing the serializable fields of
* the given class. Serializable fields backed by an actual field of the
* class are represented by ObjectStreamFields with corresponding non-null
* Field objects. Throws InvalidClassException if the (explicitly
* declared) serializable fields are invalid.
*/
throws InvalidClassException
{
!cl.isInterface())
{
}
} else {
}
return fields;
}
/**
* Returns serializable fields of given class as defined explicitly by a
* "serialPersistentFields" field, or null if no appropriate
* "serialPersistentFields" field is defined. Serializable fields backed
* by an actual field of the class are represented by ObjectStreamFields
* with corresponding non-null Field objects. For compatibility with past
* releases, a "serialPersistentFields" field with a null value is
* considered equivalent to not declaring "serialPersistentFields". Throws
* InvalidClassException if the declared serializable fields are
* invalid--e.g., if multiple fields share the same name.
*/
throws InvalidClassException
{
try {
f.setAccessible(true);
}
}
if (serialPersistentFields == null) {
return null;
return NO_FIELDS;
}
throw new InvalidClassException(
"multiple serializable fields named " + fname);
}
try {
{
boundFields[i] =
}
} catch (NoSuchFieldException ex) {
}
if (boundFields[i] == null) {
boundFields[i] = new ObjectStreamField(
}
}
return boundFields;
}
/**
* Returns array of ObjectStreamFields corresponding to all non-static
* non-transient fields declared by given class. Each ObjectStreamField
* contains a Field object for the field it represents. If no default
* serializable fields exist, NO_FIELDS is returned.
*/
}
}
}
/**
* Returns explicit serial version UID value declared by given class, or
* null if none.
*/
try {
f.setAccessible(true);
}
}
return null;
}
/**
* Computes the default serial version UID value for the given class.
*/
{
return 0L;
}
try {
/*
* compensate for javac bug in which ABSTRACT bit was set for an
* interface only if the interface declared methods
*/
}
/*
* compensate for change in 1.2FCS in which
* Class.getInterfaces() was modified to return Cloneable and
* Serializable for array classes.
*/
}
}
}
}
}
});
{
}
}
if (hasStaticInitializer(cl)) {
}
}
}
});
}
}
}
if (comp == 0) {
}
return comp;
}
});
}
}
long hash = 0;
}
return hash;
} catch (IOException ex) {
throw new InternalError();
} catch (NoSuchAlgorithmException ex) {
}
}
/**
* Returns true if the given class defines a static initializer method,
* false otherwise.
*/
/**
* Class for computing and caching field/constructor/method signatures
* during serialVersionUID calculation.
*/
private static class MemberSignature {
}
}
}
}
/**
* Class for setting and retrieving serializable field values in batch.
*/
// REMIND: dynamically generate these?
private static class FieldReflector {
/** handle for performing unsafe operations */
/** fields to operate on */
/** number of primitive fields */
private final int numPrimFields;
/** unsafe field keys for reading fields - may contain dupes */
private final long[] readKeys;
/** unsafe fields keys for writing fields - no dupes */
private final long[] writeKeys;
/** field data offsets */
private final int[] offsets;
/** field type codes */
private final char[] typeCodes;
/** field types */
/**
* subset of fields whose ObjectStreamFields contain non-null
* reflective Field objects. ObjectStreamFields with null Fields are
* treated as filler, for which get operations return default values
* and set operations discard given values.
*/
for (int i = 0; i < nfields; i++) {
ObjectStreamField f = fields[i];
typeCodes[i] = f.getTypeCode();
if (!f.isPrimitive()) {
}
}
}
/**
* Returns list of ObjectStreamFields representing fields operated on
* contained by ObjectStreamFields in the list reflect their bindings
* to locally defined serializable fields.
*/
return fields;
}
/**
* Fetches the serializable primitive field values of object obj and
* marshals them into byte array buf starting at offset 0. The caller
* is responsible for ensuring that obj is of the proper type.
*/
throw new NullPointerException();
}
/* assuming checkDefaultSerialize() has been called on the class
* descriptor this FieldReflector was obtained from, no field keys
* in array should be equal to Unsafe.INVALID_FIELD_OFFSET.
*/
for (int i = 0; i < numPrimFields; i++) {
switch (typeCodes[i]) {
case 'Z':
break;
case 'B':
break;
case 'C':
break;
case 'S':
break;
case 'I':
break;
case 'F':
break;
case 'J':
break;
case 'D':
break;
default:
throw new InternalError();
}
}
}
/**
* Sets the serializable primitive fields of object obj using values
* unmarshalled from byte array buf starting at offset 0. The caller
* is responsible for ensuring that obj is of the proper type.
*/
throw new NullPointerException();
}
for (int i = 0; i < numPrimFields; i++) {
continue; // discard value
}
switch (typeCodes[i]) {
case 'Z':
break;
case 'B':
break;
case 'C':
break;
case 'S':
break;
case 'I':
break;
case 'F':
break;
case 'J':
break;
case 'D':
break;
default:
throw new InternalError();
}
}
}
/**
* Fetches the serializable object field values of object obj and
* stores them in array vals starting at offset 0. The caller is
* responsible for ensuring that obj is of the proper type.
*/
throw new NullPointerException();
}
/* assuming checkDefaultSerialize() has been called on the class
* descriptor this FieldReflector was obtained from, no field keys
* in array should be equal to Unsafe.INVALID_FIELD_OFFSET.
*/
switch (typeCodes[i]) {
case 'L':
case '[':
break;
default:
throw new InternalError();
}
}
}
/**
* Sets the serializable object fields of object obj using values from
* array vals starting at offset 0. The caller is responsible for
* ensuring that obj is of the proper type; however, attempts to set a
* field with a value of the wrong type will trigger an appropriate
* ClassCastException.
*/
throw new NullPointerException();
}
continue; // discard value
}
switch (typeCodes[i]) {
case 'L':
case '[':
{
throw new ClassCastException(
"cannot assign instance of " +
f.getName() + " of type " +
}
break;
default:
throw new InternalError();
}
}
}
}
/**
* Matches given set of serializable fields with serializable fields
* described by the given local class descriptor, and returns a
* subset of fields that match (non-matching fields are treated as filler,
* for which get operations return default values and set operations
* discard given values). Throws InvalidClassException if unresolvable
* type conflicts exist between the two sets of fields.
*/
throws InvalidClassException
{
// class irrelevant if no fields
}
do {
}
}
}
}
return (FieldReflector) entry;
} else if (entry instanceof EntryFuture) {
try {
}
}
if (entry instanceof FieldReflector) {
return (FieldReflector) entry;
} else if (entry instanceof InvalidClassException) {
throw (InvalidClassException) entry;
} else if (entry instanceof RuntimeException) {
throw (RuntimeException) entry;
} else {
}
}
/**
* FieldReflector cache lookup key. Keys are considered equal if they
* refer to the same class and equivalent field formats.
*/
private final int hash;
private final boolean nullClass;
{
ObjectStreamField f = fields[i];
}
}
public int hashCode() {
return hash;
}
if (obj == this) {
return true;
}
if (obj instanceof FieldReflectorKey) {
} else {
return false;
}
}
}
/**
* Matches given set of serializable fields with serializable fields
* obtained from the given local class descriptor (which contain bindings
* to reflective Field objects). Returns list of ObjectStreamFields in
* which each ObjectStreamField whose signature matches that of a local
* field contains a Field object for that field; unmatched
* of the returned ObjectStreamFields also reflect those of matched local
* ObjectStreamFields. Throws InvalidClassException if unresolvable type
* conflicts exist between the two sets of fields.
*/
throws InvalidClassException
{
/*
* Even if fields == localFields, we cannot simply return localFields
* here. In previous implementations of serialization,
* ObjectStreamField.getType() returned Object.class if the
* ObjectStreamField represented a non-primitive field and belonged to
* a non-local class descriptor. To preserve this (questionable)
* behavior, the ObjectStreamField instances returned by matchFields
* cannot report non-primitive types other than Object.class; hence
* localFields cannot be returned directly.
*/
{
"incompatible types for field " + f.getName());
}
m = new ObjectStreamField(
} else {
m = new ObjectStreamField(
}
}
}
if (m == null) {
m = new ObjectStreamField(
f.getName(), f.getSignature(), false);
}
matches[i] = m;
}
return matches;
}
/**
* Removes from the specified map any keys that have been enqueued
* on the specified reference queue.
*/
ConcurrentMap<? extends
{
}
}
/**
* Weak key for Class objects.
*
**/
/**
* saved value of the referent's identity hash code, to maintain
* a consistent hash code after the referent has been cleared
*/
private final int hash;
/**
* Create a new WeakClassKey to the given object, registered
* with a queue.
*/
}
/**
* Returns the identity hash code of the original referent.
*/
public int hashCode() {
return hash;
}
/**
* Returns true if the given object is this identical
* WeakClassKey instance, or, if this object's referent has not
* been cleared, if the given object is another WeakClassKey
* instance with the identical non-null referent as this one.
*/
if (obj == this) {
return true;
}
if (obj instanceof WeakClassKey) {
} else {
return false;
}
}
}
}