changeset 11512:371fc17e38cc jdk8u66-b14

Merge
author asaha
date Mon, 14 Sep 2015 12:31:18 -0700
parents 7eac3bfb21cf (current diff) 64c3b5808a70 (diff)
children a3e744dbca07
files .hgtags
diffstat 3 files changed, 85 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Tue Sep 08 11:53:13 2015 -0500
+++ b/.hgtags	Mon Sep 14 12:31:18 2015 -0700
@@ -471,6 +471,7 @@
 22ae2d11ff54b758b648b5fcd6ea90e03a4c6781 jdk8u65-b11
 7eb9c6cf007cc6176ccb700f995a3e9b81746bfd jdk8u65-b12
 64ac5b0b4b9e7a587fc0606fada354c6fa4a7a86 jdk8u65-b13
+d26fd80f684d44fd9b16e84e585dda3757d4a19c jdk8u65-b14
 e9f82302d5fdef8a0976640e09363895e9dcde3c jdk8u66-b00
 64d7bd4e98150447916f210e3bfd6875a4c2728a jdk8u66-b01
 d8210091911b14930192abd3138ee37c281fb632 jdk8u66-b02
--- a/src/share/classes/java/io/ObjectStreamClass.java	Tue Sep 08 11:53:13 2015 -0500
+++ b/src/share/classes/java/io/ObjectStreamClass.java	Mon Sep 14 12:31:18 2015 -0700
@@ -855,7 +855,6 @@
      * types only.  Returns matching field, or null if no match found.
      */
     ObjectStreamField getField(String name, Class<?> type) {
-        requireInitialized();
         for (int i = 0; i < fields.length; i++) {
             ObjectStreamField f = fields[i];
             if (f.getName().equals(name)) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/io/ObjectInputStream/TestObjectStreamClass.java	Mon Sep 14 12:31:18 2015 -0700
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 8135043
+ * @summary ObjectStreamClass.getField(String) too restrictive
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamClass;
+import java.io.Serializable;
+
+public class TestObjectStreamClass {
+
+    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();
+    }
+
+    static class TestClass implements Serializable {
+        String str = "hello world";
+    }
+
+    static class TestObjectInputStream extends ObjectInputStream {
+        private ObjectStreamClass objectStreamClass;
+
+        public TestObjectInputStream(InputStream in) throws IOException {
+            super(in);
+        }
+
+        public ObjectStreamClass getDescriptor()
+            throws IOException, ClassNotFoundException
+        {
+            return objectStreamClass;
+        }
+
+        public ObjectStreamClass readClassDescriptor()
+            throws IOException, ClassNotFoundException
+        {
+            objectStreamClass = super.readClassDescriptor();
+            return objectStreamClass;
+        }
+    }
+}