Package java.io

Examples of java.io.ObjectStreamClass$FieldReflectorKey


    /**
     * @tests serilization
     */
    public void test_objectStreamClass_getFields() throws Exception {
        //Regression for HARMONY-2674
        ObjectStreamClass objectStreamClass = ObjectStreamClass
                .lookup(File.class);
        ObjectStreamField[] objectStreamFields = objectStreamClass.getFields();
        assertEquals(1, objectStreamFields.length);
        ObjectStreamField objectStreamField = objectStreamFields[0];
        assertEquals("path", objectStreamField.getName());
        assertEquals(String.class, objectStreamField.getType());
    }
View Full Code Here


                PATTERNSYNTAXEXCEPTION_COMPARATOR);
    }
   
    //Regression test for HARMONY-3787
    public void test_objectStreamField() {
        ObjectStreamClass objectStreamClass = ObjectStreamClass
                .lookup(PatternSyntaxException.class);
        assertNotNull(objectStreamClass.getField("desc"));
    }
View Full Code Here

        this.noArgConstructor = noArgConstructor;
        this.objectInputConstructor = objectInputConstructor;
        this.readResolve = readResolve;
        this.writeReplace = writeReplace;
        nonInitConstructor = lookupNonInitConstructor(subject);
        final ObjectStreamClass objectStreamClass = ObjectStreamClass.lookup(subject);
        effectiveSerialVersionUID = objectStreamClass == null ? 0L : objectStreamClass.getSerialVersionUID(); // todo find a better solution
        final HashMap<String, SerializableField> fieldsByName = new HashMap<String, SerializableField>();
        for (SerializableField serializableField : fields = getSerializableFields(subject)) {
            fieldsByName.put(serializableField.getName(), serializableField);
        }
        this.fieldsByName = fieldsByName;
View Full Code Here

                }
            }
            catch (SecurityException ex){
            }

            ObjectStreamClass objStreamClass;
            ClassMap[] mapping=reader.readMagicNumberMapping();
            if(mapping != null) {
                Short m;
                for(int i=0; i < mapping.length; i++) {
                    m=new Short(mapping[i].getMagicNumber());
View Full Code Here

        else
            return i.shortValue();
    }

    public ObjectStreamClass getObjectStreamClassFromMagicNumber(short magic_number) {
        ObjectStreamClass retval=null;
        retval=streamMapId.get(magic_number);
        return retval;
    }
View Full Code Here

        }
    }


    protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException {
        ObjectStreamClass retval;
        short magic_num=super.readShort();

        if(conf == null || magic_num == -1) {
            return super.readClassDescriptor();
        }
View Full Code Here

        return super.resolveClass(desc);
    }

    @Override
    protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException {
        final ObjectStreamClass objectStreamClass = super.readClassDescriptor();
        if (OLD_CLASS_NAME_COLUMN_TYPE.equals(objectStreamClass.getName())) {
            final ObjectStreamClass result = ObjectStreamClass.lookup(LegacyColumnType.class);
            return result;
        }
        return objectStreamClass;
    }
View Full Code Here

            }

            @Override
            public void writeFieldsToStream(final Map<String, Object> fields) {
                final Class<?> currentType = currentTypeRef[0];
                final ObjectStreamClass objectStreamClass = ObjectStreamClass.lookup(currentType);

                writer.startNode(ELEMENT_DEFAULT);
                for (final String name : fields.keySet()) {
                    if (!mapper.shouldSerializeMember(currentType, name)) {
                        continue;
                    }
                    final ObjectStreamField field = objectStreamClass.getField(name);
                    final Object value = fields.get(name);
                    if (field == null) {
                        throw new ObjectAccessException("Class "
                            + value.getClass().getName()
                            + " may not write a field named '"
                            + name
                            + "'");
                    }
                    if (value != null) {
                        ExtendedHierarchicalStreamWriterHelper.startNode(writer, mapper.serializedMember(source
                            .getClass(), name), value.getClass());
                        if (field.getType() != value.getClass() && !field.getType().isPrimitive()) {
                            final String attributeName = mapper.aliasForSystemAttribute(ATTRIBUTE_CLASS);
                            if (attributeName != null) {
                                writer.addAttribute(attributeName, mapper.serializedClass(value.getClass()));
                            }
                        }
                        context.convertAnother(value);
                        writer.endNode();
                    }
                }
                writer.endNode();
            }

            @Override
            public void defaultWriteObject() {
                boolean writtenDefaultFields = false;

                final Class<?> currentType = currentTypeRef[0];
                final ObjectStreamClass objectStreamClass = ObjectStreamClass.lookup(currentType);
                if (objectStreamClass == null) {
                    return;
                }

                for (final ObjectStreamField field : objectStreamClass.getFields()) {
                    final Object value = readField(field, currentType, source);
                    if (value != null) {
                        if (!writtenClassWrapper[0]) {
                            writer.startNode(mapper.serializedClass(currentType));
                            writtenClassWrapper[0] = true;
View Full Code Here

                        fields.put(name, value);
                        reader.moveUp();
                    }
                } else if (reader.getNodeName().equals(ELEMENT_DEFAULT)) {
                    // New format introduced in XStream 1.1.1
                    final ObjectStreamClass objectStreamClass = ObjectStreamClass.lookup(currentType[0]);
                    while (reader.hasMoreChildren()) {
                        reader.moveDown();
                        final String name = mapper.realMember(currentType[0], reader.getNodeName());
                        if (mapper.shouldSerializeMember(currentType[0], name)) {
                            final String classAttribute = HierarchicalStreams.readClassAttribute(reader, mapper);
                            Class<?> type;
                            if (classAttribute != null) {
                                type = mapper.realClass(classAttribute);
                            } else {
                                final ObjectStreamField field = objectStreamClass.getField(name);
                                if (field == null) {
                                    throw new MissingFieldException(currentType[0].getName(), name);
                                }
                                type = field.getType();
                            }
View Full Code Here

  public void test (TestHarness harness)
  {
    Class pc = Proxy.getProxyClass(this.getClass().getClassLoader(),
           new Class[] { Comparable.class });
    ObjectStreamClass osc = ObjectStreamClass.lookup (pc);

    harness.check(osc.getSerialVersionUID(), 0, "zero serialVersionUID");
    ObjectStreamField[] osfs = osc.getFields();
    harness.check(osfs != null && osfs.length == 0, "zero ObjectStreamFields");
    harness.check(osc.getField("any"), null, "getField(any) returns null");
    harness.check(osc.getField("h"), null, "getField(h) returns null");
  }
View Full Code Here

TOP

Related Classes of java.io.ObjectStreamClass$FieldReflectorKey

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.