OutputStream.java revision 832:b33379591dea
1/*
2 * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.  Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25/*
26 * Licensed Materials - Property of IBM
27 * RMI-IIOP v1.0
28 * Copyright IBM Corp. 1998 1999  All Rights Reserved
29 *
30 */
31
32package org.omg.CORBA_2_3.portable;
33
34import java.io.SerializablePermission;
35import java.security.AccessController;
36import java.security.PrivilegedAction;
37
38/**
39 * OutputStream provides interface for writing of all of the mapped IDL type
40 * to the stream. It extends org.omg.CORBA.portable.OutputStream, and defines
41 * new methods defined by CORBA 2.3.
42 *
43 * @see org.omg.CORBA.portable.OutputStream
44 * @author  OMG
45 * @since   JDK1.2
46 */
47
48public abstract class OutputStream extends org.omg.CORBA.portable.OutputStream {
49
50    private static final String ALLOW_SUBCLASS_PROP = "jdk.corba.allowOutputStreamSubclass";
51    private static final boolean allowSubclass = AccessController.doPrivileged(
52        new PrivilegedAction<Boolean>() {
53            @Override
54            public Boolean run() {
55            String prop = System.getProperty(ALLOW_SUBCLASS_PROP);
56                return prop == null ? false :
57                           (prop.equalsIgnoreCase("false") ? false : true);
58            }
59        });
60
61    private static Void checkPermission() {
62        SecurityManager sm = System.getSecurityManager();
63        if (sm != null) {
64            if (!allowSubclass)
65                sm.checkPermission(new
66                    SerializablePermission("enableSubclassImplementation"));
67        }
68        return null;
69    }
70    private OutputStream(Void ignore) { }
71
72    /**
73     * Create a new instance of this class.
74     *
75     * @implNote
76     * Throws SecurityException if SecurityManager is installed and
77     * enableSubclassImplementation SerializablePermission
78     * is not granted or jdk.corba.allowOutputStreamSubclass system
79     * property is either not set or is set to 'false'.
80     */
81    public OutputStream() {
82        this(checkPermission());
83    }
84
85    /**
86     * Marshals a value type to the output stream.
87     * @param value is the acutal value to write
88     */
89    public void write_value(java.io.Serializable value) {
90        throw new org.omg.CORBA.NO_IMPLEMENT();
91    }
92
93    /**
94     * Marshals a value type to the output stream.
95     * @param value is the acutal value to write
96     * @param clz is the declared type of the value to be marshaled
97     */
98    public void write_value(java.io.Serializable value, java.lang.Class clz) {
99        throw new org.omg.CORBA.NO_IMPLEMENT();
100    }
101
102    /**
103     * Marshals a value type to the output stream.
104     * @param value is the acutal value to write
105     * @param repository_id identifies the type of the value type to
106     * be marshaled
107     */
108    public void write_value(java.io.Serializable value, String repository_id) {
109        throw new org.omg.CORBA.NO_IMPLEMENT();
110    }
111
112    /**
113     * Marshals a value type to the output stream.
114     * @param value is the acutal value to write
115     * @param factory is the instance of the helper to be used for marshaling
116     * the boxed value
117     */
118    public void write_value(java.io.Serializable value, org.omg.CORBA.portable.BoxedValueHelper factory) {
119        throw new org.omg.CORBA.NO_IMPLEMENT();
120    }
121
122    /**
123     * Marshals a value object or a stub object.
124     * @param obj the actual value object to marshal or the stub to be marshalled
125     */
126    public void write_abstract_interface(java.lang.Object obj) {
127        throw new org.omg.CORBA.NO_IMPLEMENT();
128    }
129
130}
131