Package java.io

Examples of java.io.InvalidClassException


                    fieldToValueMap.put(fields[i].getName(),
                                        new Double(doubleValue));
                    break;
                default:
                    // XXX I18N, logging needed.
                    throw new InvalidClassException(currentClassDesc.getName());
            }
        }

        /* Read and set object fields from the input stream. */
        if (currentClassDesc.objFields > 0) {
View Full Code Here


                // What to do if it's null?
                writeObjectField(field, value);
                break;
            default:
                // XXX I18N, Logging needed.
                throw new InvalidClassException(currentClassDesc.getName());
            }
    }
View Full Code Here

        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

        }

        localClassDesc = lookupInternal(cl);
        if (localClassDesc == null)
            // XXX I18N, logging needed
            throw new InvalidClassException(cl.getName(),
                                            "Local class not compatible");
        if (suid != localClassDesc.suid) {

            /* Check for exceptional cases that allow mismatched suid. */

            /* Allow adding Serializable or Externalizable
             * to a later release of the class.
             */
            boolean addedSerialOrExtern =
                isNonSerializable() || localClassDesc.isNonSerializable();

            /* Disregard the serialVersionUID of an array
             * when name and cl.Name differ. If resolveClass() returns
             * an array with a different package name,
             * the serialVersionUIDs will not match since the fully
             * qualified array class is used in the
             * computation of the array's serialVersionUID. There is
             * no way to set a permanent serialVersionUID for an array type.
             */

            boolean arraySUID = (cl.isArray() && ! cl.getName().equals(name));

            if (! arraySUID && ! addedSerialOrExtern ) {
                // XXX I18N, logging needed
                throw new InvalidClassException(cl.getName(),
                                                "Local class not compatible:" +
                                                " stream classdesc serialVersionUID=" + suid +
                                                " local class serialVersionUID=" + localClassDesc.suid);
            }
        }

        /* compare the class names, stripping off package names. */
        if (! compareClassNames(name, cl.getName(), '.'))
            // XXX I18N, logging needed
            throw new InvalidClassException(cl.getName(),
                         "Incompatible local class name. " +
                         "Expected class name compatible with " +
                         name);

        /*
         * Test that both implement either serializable or externalizable.
         */

        // The next check is more generic, since it covers the
        // Proxy case, the JDK 1.3 serialization code has
        // both checks
        //if ((serializable && localClassDesc.externalizable) ||
        //    (externalizable && localClassDesc.serializable))
        //    throw new InvalidClassException(localCl.getName(),
        //            "Serializable is incompatible with Externalizable");

        if ((serializable != localClassDesc.serializable) ||
            (externalizable != localClassDesc.externalizable) ||
            (!serializable && !externalizable))

            // XXX I18N, logging needed
            throw new InvalidClassException(cl.getName(),
                                            "Serialization incompatible with Externalization");

        /* Set up the reflected Fields in the class where the value of each
         * field in this descriptor should be stored.
         * Each field in this ObjectStreamClass (the source) is located (by
         * name) in the ObjectStreamClass of the class(the destination).
         * In the usual (non-versioned case) the field is in both
         * descriptors and the types match, so the reflected Field is copied.
         * If the type does not match, a InvalidClass exception is thrown.
         * If the field is not present in the class, the reflected Field
         * remains null so the field will be read but discarded.
         * If extra fields are present in the class they are ignored. Their
         * values will be set to the default value by the object allocator.
         * Both the src and dest field list are sorted by type and name.
         */

        ObjectStreamField[] destfield =
            (ObjectStreamField[])localClassDesc.fields;
        ObjectStreamField[] srcfield =
            (ObjectStreamField[])fields;

        int j = 0;
    nextsrc:
        for (int i = 0; i < srcfield.length; i++ ) {
            /* Find this field in the dest*/
            for (int k = j; k < destfield.length; k++) {
                if (srcfield[i].getName().equals(destfield[k].getName())) {
                    /* found match */
                    if (srcfield[i].isPrimitive() &&
                        !srcfield[i].typeEquals(destfield[k])) {
                        // XXX I18N, logging needed
                        throw new InvalidClassException(cl.getName(),
                                                        "The type of field " +
                                                        srcfield[i].getName() +
                                                        " of class " + name +
                                                        " is incompatible.");
                    }
View Full Code Here

                break;
            case CHRONO_PERIOD_TYPE:
                ((ChronoPeriodImpl) object).writeExternal(out);
                break;
            default:
                throw new InvalidClassException("Unknown serialized type");
        }
    }
View Full Code Here

                break;
            case ZOTRULE:
                ((ZoneOffsetTransitionRule) object).writeExternal(out);
                break;
            default:
                throw new InvalidClassException("Unknown serialized type");
        }
    }
View Full Code Here

            Class<?> c = output.classQueue.poll();
            String expected = osc.getName();
            String found = (c == null) ? null : c.getName();

            if (!expected.equals(found)) {
                throw new InvalidClassException("Classes desynchronized: " + "found " + found + " when expecting "
                        + expected);
            }

            return c;
        }
View Full Code Here

          throw e;
        }
        if (object instanceof JmxMonitorListener) {
          listener = (JmxMonitorListener) object;
        } else {
          throw new InvalidClassException(
                  "Invalid Monitor Formatter Class:"
                          + formatterListenerClass
                          + ".The Monitor Requires a Formatter Which Implements:org.apache.uima.aae.jmx.monitor.JmxMonitorListener");
        }
      } else {
View Full Code Here

    {
      obj = objIn.readObject();
    }
    catch (ClassNotFoundException ex)
    {
      throw new InvalidClassException(ex.toString());
    }
   
    return obj;
  }
View Full Code Here

    throws IOException, ClassNotFoundException
    {
        long svId = s.readLong();
        if (svId != serialVersionUID)
        {
            throw new InvalidClassException(this.getClass().getSimpleName());
        }
       
        creationalContext = (CreationalContext<S>) s.readObject();

        String id = (String) s.readObject();
View Full Code Here

TOP

Related Classes of java.io.InvalidClassException

Copyright © 2018 www.massapicom. 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.