Examples of InvalidClassException


Examples of java.io.InvalidClassException

  throws IOException, InvalidClassException {

      for (int i = 0; i < fields.length; i++) {
          if (fields[i].getField() == null)
    // XXX I18N, Logging needed.
        throw new InvalidClassException(cl.getName(),
            "Nonexistent field " + fields[i].getName());

      try {
    switch (fields[i].getTypeCode()) {
        case 'B':
      byte byteValue = fields[i].getField().getByte( o ) ;
      orbStream.write_octet(byteValue);
      break;
        case 'C':
      char charValue = fields[i].getField().getChar( o ) ;
      orbStream.write_wchar(charValue);
      break;
        case 'F':
      float floatValue = fields[i].getField().getFloat( o ) ;
      orbStream.write_float(floatValue);
      break;
        case 'D' :
      double doubleValue = fields[i].getField().getDouble( o ) ;
      orbStream.write_double(doubleValue);
      break;
        case 'I':
      int intValue = fields[i].getField().getInt( o ) ;
      orbStream.write_long(intValue);
      break;
        case 'J':
      long longValue = fields[i].getField().getLong( o ) ;
      orbStream.write_longlong(longValue);
      break;
        case 'S':
      short shortValue = fields[i].getField().getShort( o ) ;
      orbStream.write_short(shortValue);
      break;
        case 'Z':
      boolean booleanValue = fields[i].getField().getBoolean( o ) ;
      orbStream.write_boolean(booleanValue);
      break;
        case '[':
        case 'L':
      Object objectValue = fields[i].getField().get( o ) ;
      writeObjectField(fields[i], objectValue);
      break;
        default:
      // XXX I18N, Logging needed.
      throw new InvalidClassException(cl.getName());
    }
      } catch (IllegalAccessException exc) {
    throw wrapper.illegalFieldAccess( exc, fields[i].getName() ) ;
      }
      }
View Full Code Here

Examples of java.io.InvalidClassException

        return resolveClass( desc.getName() );
    }

    public static InvalidClassException newInvalidClassException(Class clazz,
                                                                 Throwable cause) {
        InvalidClassException exception = new InvalidClassException( clazz.getName() );
        exception.initCause( cause );
        return exception;
    }
View Full Code Here

Examples of java.io.InvalidClassException

    StringBuilder buf = new StringBuilder();
    int p = 0;
    int version = ATNDeserializer.toInt(data[p++]);
    if (version != ATNDeserializer.SERIALIZED_VERSION) {
      String reason = String.format("Could not deserialize ATN with version %d (expected %d).", version, ATNDeserializer.SERIALIZED_VERSION);
      throw new UnsupportedOperationException(new InvalidClassException(ATN.class.getName(), reason));
    }

    UUID uuid = ATNDeserializer.toUUID(data, p);
    p += 8;
    if (!uuid.equals(ATNDeserializer.SERIALIZED_UUID)) {
      String reason = String.format(Locale.getDefault(), "Could not deserialize ATN with UUID %s (expected %s).", uuid, ATNDeserializer.SERIALIZED_UUID);
      throw new UnsupportedOperationException(new InvalidClassException(ATN.class.getName(), reason));
    }

    p++; // skip grammarType
    int maxType = ATNDeserializer.toInt(data[p++]);
    buf.append("max type ").append(maxType).append("\n");
View Full Code Here

Examples of java.io.InvalidClassException

    int p = 0;
    int version = toInt(data[p++]);
    if (version != SERIALIZED_VERSION) {
      String reason = String.format(Locale.getDefault(), "Could not deserialize ATN with version %d (expected %d).", version, SERIALIZED_VERSION);
      throw new UnsupportedOperationException(new InvalidClassException(ATN.class.getName(), reason));
    }

    UUID uuid = toUUID(data, p);
    p += 8;
    if (!SUPPORTED_UUIDS.contains(uuid)) {
      String reason = String.format(Locale.getDefault(), "Could not deserialize ATN with UUID %s (expected %s or a legacy UUID).", uuid, SERIALIZED_UUID);
      throw new UnsupportedOperationException(new InvalidClassException(ATN.class.getName(), reason));
    }

    boolean supportsPrecedencePredicates = isFeatureSupported(ADDED_PRECEDENCE_TRANSITIONS, uuid);
    boolean supportsLexerActions = isFeatureSupported(ADDED_LEXER_ACTIONS, uuid);
View Full Code Here

Examples of java.io.InvalidClassException

        return resolveClass( desc.getName() );
    }

    public static InvalidClassException newInvalidClassException(Class clazz,
                                                                 Throwable cause) {
        InvalidClassException exception = new InvalidClassException( clazz.getName() );
        exception.initCause( cause );
        return exception;
    }
View Full Code Here

Examples of java.io.InvalidClassException

            try {
                final Object clone = CLONE.invoke(orig);
                clones.put(orig, clone);
                return clone;
            } catch (IllegalAccessException e) {
                throw new InvalidClassException(orig.getClass().getName(), "Can't access clone() method: " + e);
            } catch (InvocationTargetException e) {
                throw new InvalidObjectException("Error invoking clone() method: " + e);
            }
        }
    }
View Full Code Here

Examples of java.io.InvalidClassException

    public <T> T create(final Class<T> clazz) throws InvalidClassException {
        final Constructor<T> constructor = getNewConstructor(clazz);
        try {
            return constructor.newInstance();
        } catch (InvocationTargetException e) {
            final InvalidClassException ice = new InvalidClassException(clazz.getName(), "Constructor threw an exception");
            ice.initCause(e);
            throw ice;
        } catch (IllegalAccessException e) {
            throw new InvalidClassException(clazz.getName(), "Illegal access exception occurred accessing the constructor: " + String.valueOf(e));
        } catch (InstantiationException e) {
            throw new InvalidClassException(clazz.getName(), "Instantiation exception: " + String.valueOf(e));
        }
    }
View Full Code Here

Examples of java.io.InvalidClassException

                SerializableField field = fields[i];
                writeUTF(field.getName());
                try {
                    writeClass(field.getType());
                } catch (ClassNotFoundException e) {
                    throw new InvalidClassException("Class of field was unloaded");
                }
                writeBoolean(field.isUnshared());
            }
        }
        Class<?> sc = objClass.getSuperclass();
View Full Code Here

Examples of java.io.InvalidClassException

                }
                ClassDescriptor superDescriptor = doReadClassDescriptor(readUnsignedByte());
                if (superDescriptor != null) {
                    final Class<?> superType = superDescriptor.getType();
                    if (! superType.isAssignableFrom(clazz)) {
                        throw new InvalidClassException(clazz.getName(), "Class does not extend stream superclass");
                    }
                    Class<?> cl = superClazz;
                    while (cl != superType) {
                        superDescriptor = new SerializableGapClassDescriptor(registry.lookup(cl), superDescriptor);
                        cl = cl.getSuperclass();
                    }
                } else if (superClazz != null) {
                    Class<?> cl = superClazz;
                    while (serializabilityChecker.isSerializable(cl)) {
                        superDescriptor = new SerializableGapClassDescriptor(registry.lookup(cl), superDescriptor);
                        cl = cl.getSuperclass();
                    }
                }
                final SerializableClass serializableClass = registry.lookup(clazz);
                final SerializableField[] fields = new SerializableField[cnt];
                for (int i = 0; i < cnt; i ++) {
                    fields[i] = serializableClass.getSerializableField(names[i], descriptors[i].getType(), unshareds[i]);
                }
                descriptor.setResult(new BasicSerializableClassDescriptor(serializableClass, superDescriptor, fields, classType));
                return descriptor;
            }
            case ID_EXTERNALIZABLE_CLASS: {
                final String className = readString();
                final long uid = readLong();
                final Class<?> clazz = classResolver.resolveClass(this, className, uid);
                final SimpleClassDescriptor descriptor = new SimpleClassDescriptor(clazz, ID_EXTERNALIZABLE_CLASS);
                classCache.add(descriptor);
                return descriptor;
            }
            case ID_EXTERNALIZER_CLASS: {
                final String className = readString();
                int idx = classCache.size();
                classCache.add(null);
                final Class<?> clazz = classResolver.resolveClass(this, className, 0L);
                final Externalizer externalizer = (Externalizer) readObject();
                final SimpleClassDescriptor descriptor = new ExternalizerClassDescriptor(clazz, externalizer);
                classCache.set(idx, descriptor);
                return descriptor;
            }

            case ID_ENUM_TYPE_CLASS: {
                final SimpleClassDescriptor descriptor = new SimpleClassDescriptor(classResolver.resolveClass(this, readString(), 0L), ID_ENUM_TYPE_CLASS);
                classCache.add(descriptor);
                return descriptor;
            }
            case ID_OBJECT_ARRAY_TYPE_CLASS: {
                final ClassDescriptor elementType = doReadClassDescriptor(readUnsignedByte());
                final SimpleClassDescriptor arrayDescriptor = new SimpleClassDescriptor(Array.newInstance(elementType.getType(), 0).getClass(), ID_OBJECT_ARRAY_TYPE_CLASS);
                classCache.add(arrayDescriptor);
                return arrayDescriptor;
            }

            case ID_CC_ARRAY_LIST: {
                return ClassDescriptors.CC_ARRAY_LIST;
            }
            case ID_CC_LINKED_LIST: {
                return ClassDescriptors.CC_LINKED_LIST;
            }

            case ID_CC_HASH_SET: {
                return ClassDescriptors.CC_HASH_SET;
            }
            case ID_CC_LINKED_HASH_SET: {
                return ClassDescriptors.CC_LINKED_HASH_SET;
            }
            case ID_CC_TREE_SET: {
                return ClassDescriptors.CC_TREE_SET;
            }

            case ID_CC_IDENTITY_HASH_MAP: {
                return ClassDescriptors.CC_IDENTITY_HASH_MAP;
            }
            case ID_CC_HASH_MAP: {
                return ClassDescriptors.CC_HASH_MAP;
            }
            case ID_CC_HASHTABLE: {
                return ClassDescriptors.CC_HASHTABLE;
            }
            case ID_CC_LINKED_HASH_MAP: {
                return ClassDescriptors.CC_LINKED_HASH_MAP;
            }
            case ID_CC_TREE_MAP: {
                return ClassDescriptors.CC_TREE_MAP;
            }

            case ID_CC_ENUM_SET: {
                return ClassDescriptors.CC_ENUM_SET;
            }
            case ID_CC_ENUM_MAP: {
                return ClassDescriptors.CC_ENUM_MAP;
            }

            case ID_ABSTRACT_COLLECTION: {
                return ClassDescriptors.ABSTRACT_COLLECTION;
            }
            case ID_ABSTRACT_LIST: {
                return ClassDescriptors.ABSTRACT_LIST;
            }
            case ID_ABSTRACT_QUEUE: {
                return ClassDescriptors.ABSTRACT_QUEUE;
            }
            case ID_ABSTRACT_SEQUENTIAL_LIST: {
                return ClassDescriptors.ABSTRACT_SEQUENTIAL_LIST;
            }
            case ID_ABSTRACT_SET: {
                return ClassDescriptors.ABSTRACT_SET;
            }

            case ID_CC_CONCURRENT_HASH_MAP: {
                return ClassDescriptors.CONCURRENT_HASH_MAP;
            }
            case ID_CC_COPY_ON_WRITE_ARRAY_LIST: {
                return ClassDescriptors.COPY_ON_WRITE_ARRAY_LIST;
            }
            case ID_CC_COPY_ON_WRITE_ARRAY_SET: {
                return ClassDescriptors.COPY_ON_WRITE_ARRAY_SET;
            }
            case ID_CC_VECTOR: {
                return ClassDescriptors.VECTOR;
            }
            case ID_CC_STACK: {
                return ClassDescriptors.STACK;
            }
            case ID_CC_ARRAY_DEQUE: {
                return ClassDescriptors.ARRAY_DEQUE;
            }
            case ID_CC_NCOPIES: {
                return ClassDescriptors.NCOPIES;
            }

            case ID_SINGLETON_MAP_OBJECT: {
                return ClassDescriptors.SINGLETON_MAP;
            }
            case ID_SINGLETON_SET_OBJECT: {
                return ClassDescriptors.SINGLETON_SET;
            }
            case ID_SINGLETON_LIST_OBJECT: {
                return ClassDescriptors.SINGLETON_LIST;
            }

            case ID_EMPTY_MAP_OBJECT: {
                return ClassDescriptors.EMPTY_MAP;
            }
            case ID_EMPTY_SET_OBJECT: {
                return ClassDescriptors.EMPTY_SET;
            }
            case ID_EMPTY_LIST_OBJECT: {
                return ClassDescriptors.EMPTY_LIST;
            }

            case ID_REVERSE_ORDER_OBJECT: {
                return ClassDescriptors.REVERSE_ORDER;
            }
            case ID_REVERSE_ORDER2_OBJECT: {
                return ClassDescriptors.REVERSE_ORDER2;
            }

            case ID_PAIR: {
                return ClassDescriptors.PAIR;
            }

            case ID_STRING_CLASS: {
                return ClassDescriptors.STRING_DESCRIPTOR;
            }
            case ID_OBJECT_CLASS: {
                return ClassDescriptors.OBJECT_DESCRIPTOR;
            }
            case ID_CLASS_CLASS: {
                return ClassDescriptors.CLASS_DESCRIPTOR;
            }
            case ID_ENUM_CLASS: {
                return ClassDescriptors.ENUM_DESCRIPTOR;
            }

            case ID_BOOLEAN_ARRAY_CLASS: {
                return ClassDescriptors.BOOLEAN_ARRAY;
            }
            case ID_BYTE_ARRAY_CLASS: {
                return ClassDescriptors.BYTE_ARRAY;
            }
            case ID_SHORT_ARRAY_CLASS: {
                return ClassDescriptors.SHORT_ARRAY;
            }
            case ID_INT_ARRAY_CLASS: {
                return ClassDescriptors.INT_ARRAY;
            }
            case ID_LONG_ARRAY_CLASS: {
                return ClassDescriptors.LONG_ARRAY;
            }
            case ID_CHAR_ARRAY_CLASS: {
                return ClassDescriptors.CHAR_ARRAY;
            }
            case ID_FLOAT_ARRAY_CLASS: {
                return ClassDescriptors.FLOAT_ARRAY;
            }
            case ID_DOUBLE_ARRAY_CLASS: {
                return ClassDescriptors.DOUBLE_ARRAY;
            }

            case ID_PRIM_BOOLEAN: {
                return ClassDescriptors.BOOLEAN;
            }
            case ID_PRIM_BYTE: {
                return ClassDescriptors.BYTE;
            }
            case ID_PRIM_CHAR: {
                return ClassDescriptors.CHAR;
            }
            case ID_PRIM_DOUBLE: {
                return ClassDescriptors.DOUBLE;
            }
            case ID_PRIM_FLOAT: {
                return ClassDescriptors.FLOAT;
            }
            case ID_PRIM_INT: {
                return ClassDescriptors.INT;
            }
            case ID_PRIM_LONG: {
                return ClassDescriptors.LONG;
            }
            case ID_PRIM_SHORT: {
                return ClassDescriptors.SHORT;
            }

            case ID_VOID: {
                return ClassDescriptors.VOID;
            }

            case ID_BOOLEAN_CLASS: {
                return ClassDescriptors.BOOLEAN_OBJ;
            }
            case ID_BYTE_CLASS: {
                return ClassDescriptors.BYTE_OBJ;
            }
            case ID_SHORT_CLASS: {
                return ClassDescriptors.SHORT_OBJ;
            }
            case ID_INTEGER_CLASS: {
                return ClassDescriptors.INTEGER_OBJ;
            }
            case ID_LONG_CLASS: {
                return ClassDescriptors.LONG_OBJ;
            }
            case ID_CHARACTER_CLASS: {
                return ClassDescriptors.CHARACTER_OBJ;
            }
            case ID_FLOAT_CLASS: {
                return ClassDescriptors.FLOAT_OBJ;
            }
            case ID_DOUBLE_CLASS: {
                return ClassDescriptors.DOUBLE_OBJ;
            }

            case ID_VOID_CLASS: {
                return ClassDescriptors.VOID_OBJ;
            }

            default: {
                throw new InvalidClassException("Unexpected class ID " + classType);
            }
        }
    }
View Full Code Here

Examples of java.io.InvalidClassException

                    final int idx = instanceCache.size();
                    instanceCache.add(obj);
                    try {
                        proxyInvocationHandler.set(obj, doReadNestedObject(unshared, "[proxy invocation handler]"));
                    } catch (IllegalAccessException e) {
                        throw new InvalidClassException(type.getName(), "Unable to set proxy invocation handler");
                    }
                    final Object resolvedObject = objectResolver.readResolve(obj);
                    if (unshared) {
                        instanceCache.set(idx, null);
                    } else if (obj != resolvedObject) {
                        instanceCache.set(idx, resolvedObject);
                    }
                    return resolvedObject;
                }
                case ID_WRITE_OBJECT_CLASS:
                case ID_SERIALIZABLE_CLASS: {
                    final SerializableClassDescriptor serializableClassDescriptor = (SerializableClassDescriptor) descriptor;
                    final SerializableClass serializableClass = serializableClassDescriptor.getSerializableClass();
                    final Object obj = serializableClass.callNonInitConstructor();
                    final int idx = instanceCache.size();
                    instanceCache.add(obj);
                    doInitSerializable(obj, serializableClassDescriptor);
                    final Object resolvedObject = objectResolver.readResolve(serializableClass.hasReadResolve() ? serializableClass.callReadResolve(obj) : obj);
                    if (unshared) {
                        instanceCache.set(idx, null);
                    } else if (obj != resolvedObject) {
                        instanceCache.set(idx, resolvedObject);
                    }
                    return resolvedObject;
                }
                case ID_EXTERNALIZABLE_CLASS: {
                    final Class<?> type = descriptor.getType();
                    final SerializableClass serializableClass = registry.lookup(type);
                    final BlockUnmarshaller blockUnmarshaller = getBlockUnmarshaller();
                    final Externalizable obj;
                    if (serializableClass.hasObjectInputConstructor()) {
                        obj = (Externalizable) serializableClass.callObjectInputConstructor(blockUnmarshaller);
                    } else if (serializableClass.hasNoArgConstructor()) {
                        obj = (Externalizable) serializableClass.callNoArgConstructor();
                    } else {
                        throw new InvalidClassException(type.getName(), "Class is non-public or has no public no-arg constructor");
                    }
                    final int idx = instanceCache.size();
                    instanceCache.add(obj);
                    obj.readExternal(blockUnmarshaller);
                    blockUnmarshaller.readToEndBlockData();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.