test/java/io/Serializable/enum/mismatchedTypecode/Test.java

Print this page




   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20  * CA 95054 USA or visit www.sun.com if you need additional information or
  21  * have any questions.
  22  */
  23 
  24 /* @test
  25  * @bug 4838379
  26  * @summary Verify that TC_OBJECT followed by a class descriptor for an enum
  27  *          class results in an InvalidClassException, as does TC_ENUM followed
  28  *          by a class descriptor for a non-enum class.
  29  *
  30  * @compile -source 1.5 Test.java
  31  * @run main Test
  32  */
  33 
  34 import java.io.*;
  35 
  36 enum Foo { bar }
  37 
  38 class TestObjectOutputStream extends ObjectOutputStream {
  39 
  40     static ObjectStreamClass fooDesc = ObjectStreamClass.lookup(Foo.class);
  41     static ObjectStreamClass integerDesc =
  42         ObjectStreamClass.lookup(Integer.class);
  43 
  44     TestObjectOutputStream(OutputStream out) throws IOException {
  45         super(out);
  46     }
  47 
  48     protected void writeClassDescriptor(ObjectStreamClass desc)
  49         throws IOException
  50     {
  51         if (desc == fooDesc) {




   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20  * CA 95054 USA or visit www.sun.com if you need additional information or
  21  * have any questions.
  22  */
  23 
  24 /* @test
  25  * @bug 4838379
  26  * @summary Verify that TC_OBJECT followed by a class descriptor for an enum
  27  *          class results in an InvalidClassException, as does TC_ENUM followed
  28  *          by a class descriptor for a non-enum class.



  29  */
  30 
  31 import java.io.*;
  32 
  33 enum Foo { bar }
  34 
  35 class TestObjectOutputStream extends ObjectOutputStream {
  36 
  37     static ObjectStreamClass fooDesc = ObjectStreamClass.lookup(Foo.class);
  38     static ObjectStreamClass integerDesc =
  39         ObjectStreamClass.lookup(Integer.class);
  40 
  41     TestObjectOutputStream(OutputStream out) throws IOException {
  42         super(out);
  43     }
  44 
  45     protected void writeClassDescriptor(ObjectStreamClass desc)
  46         throws IOException
  47     {
  48         if (desc == fooDesc) {