< prev index next >

test/java/io/Serializable/subclass/Test.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 1998, 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. --- 1,7 ---- /* ! * Copyright (c) 1998, 2017, 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.
*** 24,47 **** /* * @test * @bug 4100915 * @summary Verify that [write/read]ObjectOverride methods get called. * Test verifies that ALL methods to write an object can ! * be overridden. Howver, the testing for reading an object * is incomplete. Only test that readObjectOverride is called. * An entire protocol would need to be implemented and written * out before being able to test the input side of the API. * * Also, would be appropriate that this program verify ! * that if SerializablePermission "enableSubclassImplamentation" * is not in the security policy and security is enabled, that * a security excepiton is thrown when constructing the * ObjectOutputStream subclass. * * * @compile AbstractObjectInputStream.java AbstractObjectOutputStream.java XObjectInputStream.java XObjectOutputStream.java Test.java * @run main Test */ import java.io.*; /** --- 24,48 ---- /* * @test * @bug 4100915 * @summary Verify that [write/read]ObjectOverride methods get called. * Test verifies that ALL methods to write an object can ! * be overridden. However, the testing for reading an object * is incomplete. Only test that readObjectOverride is called. * An entire protocol would need to be implemented and written * out before being able to test the input side of the API. * * Also, would be appropriate that this program verify ! * that if SerializablePermission "enableSubclassImplementation" * is not in the security policy and security is enabled, that * a security excepiton is thrown when constructing the * ObjectOutputStream subclass. * * * @compile AbstractObjectInputStream.java AbstractObjectOutputStream.java XObjectInputStream.java XObjectOutputStream.java Test.java * @run main Test + * @run main/othervm/policy=Allow.policy Test -expectSecurityException */ import java.io.*; /**
*** 127,139 **** os = new XObjectOutputStream(baos); if (expectSecurityException) throw new Error("Assertion failure. " + "Expected a security exception on previous line."); } catch (SecurityException e) { ! if (expectSecurityException) return; ! else throw e; } os.writeObject(new A()); os.close(); if (B.numWriteObjectCalled != 3) --- 128,141 ---- os = new XObjectOutputStream(baos); if (expectSecurityException) throw new Error("Assertion failure. " + "Expected a security exception on previous line."); } catch (SecurityException e) { ! if (expectSecurityException) { ! System.err.println("Caught expected security exception."); return; ! } throw e; } os.writeObject(new A()); os.close(); if (B.numWriteObjectCalled != 3)
< prev index next >