src/jdk.unsupported/share/classes/sun/reflect/ReflectionFactory.java
author mbalao
Tue, 12 Nov 2019 00:30:55 -0300
changeset 59158 438337c846fb
parent 51882 f6e15aa9c16e
permissions -rw-r--r--
8233404: System property to set the number of PBE iterations in JCEKS keystores Reviewed-by: weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37363
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
     1
/*
51882
f6e15aa9c16e 8211121: Remove sun.reflect.ReflectionFactory::newInstanceForSerialization
lancea
parents: 47400
diff changeset
     2
 * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
37363
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
     4
 *
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    10
 *
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    15
 * accompanied this code).
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    16
 *
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    20
 *
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    23
 * questions.
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    24
 */
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    25
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    26
package sun.reflect;
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    27
41608
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
    28
import java.io.OptionalDataException;
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
    29
import java.lang.invoke.MethodHandle;
37363
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    30
import java.lang.reflect.Constructor;
41608
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
    31
import java.lang.reflect.InvocationTargetException;
37363
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    32
import java.security.AccessController;
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    33
import java.security.Permission;
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    34
import java.security.PrivilegedAction;
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    35
41608
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
    36
/**
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
    37
 * ReflectionFactory supports custom serialization.
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
    38
 * Its methods support the creation of uninitialized objects, invoking serialization
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
    39
 * private methods for readObject, writeObject, readResolve, and writeReplace.
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
    40
 * <p>
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
    41
 * ReflectionFactory access is restricted, if a security manager is active,
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
    42
 * unless the permission {@code RuntimePermission("reflectionFactoryAccess")}
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
    43
 * is granted.
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
    44
 */
37363
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    45
public class ReflectionFactory {
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    46
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    47
    private static final ReflectionFactory soleInstance = new ReflectionFactory();
41608
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
    48
    private static final jdk.internal.reflect.ReflectionFactory delegate = AccessController.doPrivileged(
37363
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    49
            new PrivilegedAction<jdk.internal.reflect.ReflectionFactory>() {
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    50
                public jdk.internal.reflect.ReflectionFactory run() {
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    51
                    return jdk.internal.reflect.ReflectionFactory.getReflectionFactory();
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    52
                }
41608
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
    53
            });
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
    54
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
    55
    private ReflectionFactory() {}
37363
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    56
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    57
    private static final Permission REFLECTION_FACTORY_ACCESS_PERM
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    58
            = new RuntimePermission("reflectionFactoryAccess");
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    59
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    60
    /**
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    61
     * Provides the caller with the capability to instantiate reflective
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    62
     * objects.
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    63
     *
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    64
     * <p> First, if there is a security manager, its {@code checkPermission}
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    65
     * method is called with a {@link java.lang.RuntimePermission} with target
41608
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
    66
     * {@code "reflectionFactoryAccess"}.  This may result in a security
37363
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    67
     * exception.
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    68
     *
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    69
     * <p> The returned {@code ReflectionFactory} object should be carefully
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    70
     * guarded by the caller, since it can be used to read and write private
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    71
     * data and invoke private methods, as well as to load unverified bytecodes.
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    72
     * It must never be passed to untrusted code.
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    73
     *
41608
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
    74
     * @return the ReflectionFactory
37363
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    75
     * @throws SecurityException if a security manager exists and its
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    76
     *         {@code checkPermission} method doesn't allow access to
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    77
     *         the RuntimePermission "reflectionFactoryAccess".
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    78
     */
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    79
    public static ReflectionFactory getReflectionFactory() {
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    80
        SecurityManager security = System.getSecurityManager();
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    81
        if (security != null) {
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    82
            security.checkPermission(REFLECTION_FACTORY_ACCESS_PERM);
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    83
        }
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    84
        return soleInstance;
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    85
    }
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    86
41608
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
    87
    /**
41827
710feffff038 8168980: Reinstate sun.reflect.ReflectionFactory.newConstructorForSerialization(Class,Constructor)
chegar
parents: 41608
diff changeset
    88
     * Returns an accessible constructor capable of creating instances
710feffff038 8168980: Reinstate sun.reflect.ReflectionFactory.newConstructorForSerialization(Class,Constructor)
chegar
parents: 41608
diff changeset
    89
     * of the given class, initialized by the given constructor.
710feffff038 8168980: Reinstate sun.reflect.ReflectionFactory.newConstructorForSerialization(Class,Constructor)
chegar
parents: 41608
diff changeset
    90
     *
710feffff038 8168980: Reinstate sun.reflect.ReflectionFactory.newConstructorForSerialization(Class,Constructor)
chegar
parents: 41608
diff changeset
    91
     * @param cl the class to instantiate
710feffff038 8168980: Reinstate sun.reflect.ReflectionFactory.newConstructorForSerialization(Class,Constructor)
chegar
parents: 41608
diff changeset
    92
     * @param constructorToCall the constructor to call
710feffff038 8168980: Reinstate sun.reflect.ReflectionFactory.newConstructorForSerialization(Class,Constructor)
chegar
parents: 41608
diff changeset
    93
     * @return an accessible constructor
710feffff038 8168980: Reinstate sun.reflect.ReflectionFactory.newConstructorForSerialization(Class,Constructor)
chegar
parents: 41608
diff changeset
    94
     */
710feffff038 8168980: Reinstate sun.reflect.ReflectionFactory.newConstructorForSerialization(Class,Constructor)
chegar
parents: 41608
diff changeset
    95
    public Constructor<?> newConstructorForSerialization(Class<?> cl,
710feffff038 8168980: Reinstate sun.reflect.ReflectionFactory.newConstructorForSerialization(Class,Constructor)
chegar
parents: 41608
diff changeset
    96
                                                         Constructor<?> constructorToCall)
710feffff038 8168980: Reinstate sun.reflect.ReflectionFactory.newConstructorForSerialization(Class,Constructor)
chegar
parents: 41608
diff changeset
    97
    {
710feffff038 8168980: Reinstate sun.reflect.ReflectionFactory.newConstructorForSerialization(Class,Constructor)
chegar
parents: 41608
diff changeset
    98
        return delegate.newConstructorForSerialization(cl,
710feffff038 8168980: Reinstate sun.reflect.ReflectionFactory.newConstructorForSerialization(Class,Constructor)
chegar
parents: 41608
diff changeset
    99
                                                       constructorToCall);
710feffff038 8168980: Reinstate sun.reflect.ReflectionFactory.newConstructorForSerialization(Class,Constructor)
chegar
parents: 41608
diff changeset
   100
    }
710feffff038 8168980: Reinstate sun.reflect.ReflectionFactory.newConstructorForSerialization(Class,Constructor)
chegar
parents: 41608
diff changeset
   101
710feffff038 8168980: Reinstate sun.reflect.ReflectionFactory.newConstructorForSerialization(Class,Constructor)
chegar
parents: 41608
diff changeset
   102
    /**
41608
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   103
     * Returns an accessible no-arg constructor for a class.
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   104
     * The no-arg constructor is found searching the class and its supertypes.
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   105
     *
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   106
     * @param cl the class to instantiate
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   107
     * @return a no-arg constructor for the class or {@code null} if
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   108
     *     the class or supertypes do not have a suitable no-arg constructor
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   109
     */
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   110
    public final Constructor<?> newConstructorForSerialization(Class<?> cl)
37363
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
   111
    {
41608
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   112
        return delegate.newConstructorForSerialization(cl);
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   113
    }
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   114
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   115
    /**
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   116
     * Returns an accessible no-arg constructor for an externalizable class to be
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   117
     * initialized using a public no-argument constructor.
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   118
     *
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   119
     * @param cl the class to instantiate
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   120
     * @return A no-arg constructor for the class; returns {@code null} if
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   121
     *     the class does not implement {@link java.io.Externalizable}
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   122
     */
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   123
    public final Constructor<?> newConstructorForExternalization(Class<?> cl) {
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   124
        return delegate.newConstructorForExternalization(cl);
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   125
    }
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   126
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   127
    /**
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   128
     * Returns a direct MethodHandle for the {@code readObject} method on
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   129
     * a Serializable class.
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   130
     * The first argument of {@link MethodHandle#invoke} is the serializable
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   131
     * object and the second argument is the {@code ObjectInputStream} passed to
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   132
     * {@code readObject}.
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   133
     *
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   134
     * @param cl a Serializable class
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   135
     * @return  a direct MethodHandle for the {@code readObject} method of the class or
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   136
     *          {@code null} if the class does not have a {@code readObject} method
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   137
     */
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   138
    public final MethodHandle readObjectForSerialization(Class<?> cl) {
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   139
        return delegate.readObjectForSerialization(cl);
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   140
    }
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   141
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   142
    /**
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   143
     * Returns a direct MethodHandle for the {@code readObjectNoData} method on
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   144
     * a Serializable class.
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   145
     * The first argument of {@link MethodHandle#invoke} is the serializable
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   146
     * object and the second argument is the {@code ObjectInputStream} passed to
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   147
     * {@code readObjectNoData}.
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   148
     *
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   149
     * @param cl a Serializable class
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   150
     * @return  a direct MethodHandle for the {@code readObjectNoData} method
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   151
     *          of the class or {@code null} if the class does not have a
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   152
     *          {@code readObjectNoData} method
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   153
     */
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   154
    public final MethodHandle readObjectNoDataForSerialization(Class<?> cl) {
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   155
        return delegate.readObjectNoDataForSerialization(cl);
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   156
    }
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   157
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   158
    /**
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   159
     * Returns a direct MethodHandle for the {@code writeObject} method on
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   160
     * a Serializable class.
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   161
     * The first argument of {@link MethodHandle#invoke} is the serializable
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   162
     * object and the second argument is the {@code ObjectOutputStream} passed to
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   163
     * {@code writeObject}.
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   164
     *
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   165
     * @param cl a Serializable class
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   166
     * @return  a direct MethodHandle for the {@code writeObject} method of the class or
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   167
     *          {@code null} if the class does not have a {@code writeObject} method
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   168
     */
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   169
    public final MethodHandle writeObjectForSerialization(Class<?> cl) {
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   170
        return delegate.writeObjectForSerialization(cl);
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   171
    }
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   172
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   173
    /**
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   174
     * Returns a direct MethodHandle for the {@code readResolve} method on
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   175
     * a serializable class.
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   176
     * The single argument of {@link MethodHandle#invoke} is the serializable
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   177
     * object.
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   178
     *
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   179
     * @param cl the Serializable class
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   180
     * @return  a direct MethodHandle for the {@code readResolve} method of the class or
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   181
     *          {@code null} if the class does not have a {@code readResolve} method
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   182
     */
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   183
    public final MethodHandle readResolveForSerialization(Class<?> cl) {
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   184
        return delegate.readResolveForSerialization(cl);
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   185
    }
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   186
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   187
    /**
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   188
     * Returns a direct MethodHandle for the {@code writeReplace} method on
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   189
     * a serializable class.
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   190
     * The single argument of {@link MethodHandle#invoke} is the serializable
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   191
     * object.
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   192
     *
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   193
     * @param cl the Serializable class
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   194
     * @return  a direct MethodHandle for the {@code writeReplace} method of the class or
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   195
     *          {@code null} if the class does not have a {@code writeReplace} method
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   196
     */
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   197
    public final MethodHandle writeReplaceForSerialization(Class<?> cl) {
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   198
        return delegate.writeReplaceForSerialization(cl);
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   199
    }
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   200
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   201
    /**
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   202
     * Returns true if the class has a static initializer.
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   203
     * The presence of a static initializer is used to compute the serialVersionUID.
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   204
     * @param cl a serializable class
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   205
     * @return {@code true} if the class has a static initializer,
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   206
     *          otherwise {@code false}
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   207
     */
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   208
    public final boolean hasStaticInitializerForSerialization(Class<?> cl) {
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   209
        return delegate.hasStaticInitializerForSerialization(cl);
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   210
    }
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   211
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   212
    /**
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   213
     * Returns a new OptionalDataException with {@code eof} set to {@code true}
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   214
     * or {@code false}.
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   215
     * @param bool the value of {@code eof} in the created OptionalDataException
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   216
     * @return  a new OptionalDataException
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   217
     */
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   218
    public final OptionalDataException newOptionalDataExceptionForSerialization(boolean bool) {
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   219
        Constructor<OptionalDataException> cons = delegate.newOptionalDataExceptionForSerialization();
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   220
        try {
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   221
            return cons.newInstance(bool);
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   222
        } catch (InstantiationException|IllegalAccessException|InvocationTargetException ex) {
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   223
            throw new InternalError("unable to create OptionalDataException", ex);
bb724835848f 8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents: 37363
diff changeset
   224
        }
37363
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
   225
    }
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
   226
}