Java Code Examples for java.io.ObjectStreamClass#getField()
The following examples show how to use
java.io.ObjectStreamClass#getField() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestObjectStreamClass.java From dragonwell8_jdk with GNU General Public License v2.0 | 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 2
Source File: TestObjectStreamClass.java From TencentKona-8 with GNU General Public License v2.0 | 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
Source File: TestObjectStreamClass.java From openjdk-jdk8u with GNU General Public License v2.0 | 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
Source File: TestObjectStreamClass.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 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 5
Source File: TestObjectStreamClass.java From openjdk-jdk9 with GNU General Public License v2.0 | 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 6
Source File: TestObjectStreamClass.java From jdk8u-jdk with GNU General Public License v2.0 | 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 7
Source File: TestObjectStreamClass.java From hottub with GNU General Public License v2.0 | 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 8
Source File: BaseReturnValue.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { GetField fields = stream.readFields(); fromVariable = (String) fields.get("fromVariable", null); // the fields of BaseCommonReturnValue were originally in this class. // if deserializing an old object, we need to manually copy the values into the parent class. ObjectStreamClass streamClass = fields.getObjectStreamClass(); if (streamClass.getField("toVariable") != null) { this.toVariable = (String) fields.get("toVariable", null); } if (streamClass.getField("calculation") != null) { this.calculation = (CalculationEnum) fields.get("calculation", null); } if (streamClass.getField("incrementerFactoryClassName") != null) { this.incrementerFactoryClassName = (String) fields.get("incrementerFactoryClassName", null); } }
Example 9
Source File: TestObjectStreamClass.java From jdk8u_jdk with GNU General Public License v2.0 | 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 10
Source File: ObjectStreamFieldTest.java From j2objc with Apache License 2.0 | 6 votes |
/** * java.io.ObjectStreamField#getType() */ public void test_getType_Deserialized() throws IOException, ClassNotFoundException { ByteArrayOutputStream baos = new ByteArrayOutputStream(1024); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(new SerializableObject()); oos.close(); baos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); SerializableObject obj = (SerializableObject) ois.readObject(); ObjectStreamClass oc = obj.getObjectStreamClass(); ObjectStreamField field = oc.getField("i"); assertEquals(Object.class, field.getType()); }
Example 11
Source File: ObjectStreamFieldTest.java From j2objc with Apache License 2.0 | 6 votes |
/** * java.io.ObjectStreamField#getType() */ public void test_getType_MockObjectInputStream() throws IOException, ClassNotFoundException { ByteArrayOutputStream baos = new ByteArrayOutputStream(1024); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(new SerializableObject()); oos.close(); baos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); MockObjectInputStream ois = new MockObjectInputStream(bais); ois.readObject(); ObjectStreamClass oc = ois.getObjectStreamClass(); ObjectStreamField field = oc.getField("i"); assertEquals(Object.class, field.getType()); }
Example 12
Source File: DesignCell.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { GetField fields = in.readFields(); rowSpan = (Integer) fields.get("rowSpan", null); //DesignBaseCell fields were originally (until 6.11) in this class //read the values from the stream object if present and set them in the parent ObjectStreamClass streamClass = fields.getObjectStreamClass(); if (streamClass.getField("defaultStyleProvider") != null) { defaultStyleProvider = (JRDefaultStyleProvider) fields.get("defaultStyleProvider", null); } if (streamClass.getField("style") != null) { style = (JRStyle) fields.get("style", null); } if (streamClass.getField("styleNameReference") != null) { styleNameReference = (String) fields.get("styleNameReference", null); } if (streamClass.getField("box") != null) { box = (JRLineBox) fields.get("box", null); } if (streamClass.getField("height") != null) { height = (Integer) fields.get("height", null); } if (streamClass.getField("propertiesMap") != null) { propertiesMap = (JRPropertiesMap) fields.get("propertiesMap", null); } }
Example 13
Source File: CompiledCell.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { GetField fields = in.readFields(); rowSpan = (Integer) fields.get("rowSpan", null); //CompiledBaseCell fields were originally (until 6.11) in this class //read the values from the stream object if present and set them in the parent ObjectStreamClass streamClass = fields.getObjectStreamClass(); if (streamClass.getField("defaultStyleProvider") != null) { defaultStyleProvider = (JRDefaultStyleProvider) fields.get("defaultStyleProvider", null); } if (streamClass.getField("style") != null) { style = (JRStyle) fields.get("style", null); } if (streamClass.getField("styleNameReference") != null) { styleNameReference = (String) fields.get("styleNameReference", null); } if (streamClass.getField("box") != null) { box = (JRLineBox) fields.get("box", null); } if (streamClass.getField("height") != null) { height = (Integer) fields.get("height", null); } if (streamClass.getField("propertiesMap") != null) { propertiesMap = (JRPropertiesMap) fields.get("propertiesMap", null); } }