jdk/src/java.base/share/classes/jdk/internal/reflect/ReflectionFactory.java
author redestad
Thu, 21 Apr 2016 13:39:53 +0200
changeset 37593 824750ada3d6
parent 37363 329dba26ffd2
child 37781 71ed5645f17c
permissions -rw-r--r--
8154231: Simplify access to System properties from JDK code Reviewed-by: rriggs, chegar, weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
15510
898d924a7efd 8004698: Implement Core Reflection for Type Annotations
jfranck
parents: 14342
diff changeset
     2
 * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
37363
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents: 33674
diff changeset
    26
package jdk.internal.reflect;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.lang.reflect.Field;
15510
898d924a7efd 8004698: Implement Core Reflection for Type Annotations
jfranck
parents: 14342
diff changeset
    29
import java.lang.reflect.Executable;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.lang.reflect.Method;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.lang.reflect.Constructor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.lang.reflect.Modifier;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.security.Permission;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.security.PrivilegedAction;
37593
824750ada3d6 8154231: Simplify access to System properties from JDK code
redestad
parents: 37363
diff changeset
    35
import java.util.Properties;
21672
33014eb0cb79 8028055: (reflect) invoking Method/Constructor in anonymous classes breaks with -Dsun.reflect.noInflation=true
jfranck
parents: 15510
diff changeset
    36
import sun.reflect.misc.ReflectUtil;
37593
824750ada3d6 8154231: Simplify access to System properties from JDK code
redestad
parents: 37363
diff changeset
    37
import sun.security.action.GetPropertyAction;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
/** <P> The master factory for all reflective objects, both those in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    java.lang.reflect (Fields, Methods, Constructors) as well as their
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    delegates (FieldAccessors, MethodAccessors, ConstructorAccessors).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    </P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    <P> The methods in this class are extremely unsafe and can cause
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    subversion of both the language and the verifier. For this reason,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    they are all instance methods, and access to the constructor of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    this factory is guarded by a security check, in similar style to
33674
566777f73c32 8140606: Update library code to use internal Unsafe
chegar
parents: 32268
diff changeset
    48
    {@link jdk.internal.misc.Unsafe}. </P>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
public class ReflectionFactory {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    private static boolean initted = false;
27489
cf53b2c02ebb 8062771: Core reflection should use final fields whenever possible
martin
parents: 25859
diff changeset
    54
    private static final Permission reflectionFactoryAccessPerm
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        = new RuntimePermission("reflectionFactoryAccess");
27489
cf53b2c02ebb 8062771: Core reflection should use final fields whenever possible
martin
parents: 25859
diff changeset
    56
    private static final ReflectionFactory soleInstance = new ReflectionFactory();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    // Provides access to package-private mechanisms in java.lang.reflect
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    private static volatile LangReflectAccess langReflectAccess;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    // "Inflation" mechanism. Loading bytecodes to implement
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    // Method.invoke() and Constructor.newInstance() currently costs
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    // 3-4x more than an invocation via native code for the first
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    // invocation (though subsequent invocations have been benchmarked
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    // to be over 20x faster). Unfortunately this cost increases
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    // startup time for certain applications that use reflection
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    // intensively (but only once per class) to bootstrap themselves.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    // To avoid this penalty we reuse the existing JVM entry points
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    // for the first few invocations of Methods and Constructors and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    // then switch to the bytecode-based implementations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    // Package-private to be accessible to NativeMethodAccessorImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    // and NativeConstructorAccessorImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    private static boolean noInflation        = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    private static int     inflationThreshold = 15;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    private ReflectionFactory() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * A convenience class for acquiring the capability to instantiate
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * reflective objects.  Use this instead of a raw call to {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * #getReflectionFactory} in order to avoid being limited by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * permissions of your callers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * <p>An instance of this class can be used as the argument of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * <code>AccessController.doPrivileged</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    public static final class GetReflectionFactoryAction
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
    90
        implements PrivilegedAction<ReflectionFactory> {
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
    91
        public ReflectionFactory run() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            return getReflectionFactory();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * Provides the caller with the capability to instantiate reflective
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * <p> First, if there is a security manager, its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * <code>checkPermission</code> method is called with a {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * java.lang.RuntimePermission} with target
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * <code>"reflectionFactoryAccess"</code>.  This may result in a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * security exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * <p> The returned <code>ReflectionFactory</code> object should be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * carefully guarded by the caller, since it can be used to read and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * write private data and invoke private methods, as well as to load
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * unverified bytecodes.  It must never be passed to untrusted code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * @exception SecurityException if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     *             <code>checkPermission</code> method doesn't allow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     *             access to the RuntimePermission "reflectionFactoryAccess".  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    public static ReflectionFactory getReflectionFactory() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        SecurityManager security = System.getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        if (security != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
            // TO DO: security.checkReflectionFactoryAccess();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            security.checkPermission(reflectionFactoryAccessPerm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        return soleInstance;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    //--------------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    // Routines used by java.lang.reflect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    /** Called only by java.lang.reflect.Modifier's static initializer */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    public void setLangReflectAccess(LangReflectAccess access) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        langReflectAccess = access;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * Note: this routine can cause the declaring class for the field
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * be initialized and therefore must not be called until the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * first get/set of this field.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * @param field the field
28056
0cab6eb92852 8065172: More core reflection final and volatile annotations
martin
parents: 27489
diff changeset
   139
     * @param override true if caller has overridden accessibility
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    public FieldAccessor newFieldAccessor(Field field, boolean override) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        checkInitted();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        return UnsafeFieldAccessorFactory.newFieldAccessor(field, override);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    public MethodAccessor newMethodAccessor(Method method) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        checkInitted();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
21672
33014eb0cb79 8028055: (reflect) invoking Method/Constructor in anonymous classes breaks with -Dsun.reflect.noInflation=true
jfranck
parents: 15510
diff changeset
   149
        if (noInflation && !ReflectUtil.isVMAnonymousClass(method.getDeclaringClass())) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            return new MethodAccessorGenerator().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                generateMethod(method.getDeclaringClass(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                               method.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                               method.getParameterTypes(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                               method.getReturnType(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                               method.getExceptionTypes(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                               method.getModifiers());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            NativeMethodAccessorImpl acc =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                new NativeMethodAccessorImpl(method);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
            DelegatingMethodAccessorImpl res =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                new DelegatingMethodAccessorImpl(acc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
            acc.setParent(res);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
            return res;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
10342
ca0984bc9d32 7077389: Reflection classes do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   167
    public ConstructorAccessor newConstructorAccessor(Constructor<?> c) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        checkInitted();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
   170
        Class<?> declaringClass = c.getDeclaringClass();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        if (Modifier.isAbstract(declaringClass.getModifiers())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
            return new InstantiationExceptionConstructorAccessorImpl(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        if (declaringClass == Class.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            return new InstantiationExceptionConstructorAccessorImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                ("Can not instantiate java.lang.Class");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        // Bootstrapping issue: since we use Class.newInstance() in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        // the ConstructorAccessor generation process, we have to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        // break the cycle here.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        if (Reflection.isSubclassOf(declaringClass,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                                    ConstructorAccessorImpl.class)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            return new BootstrapConstructorAccessorImpl(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
21672
33014eb0cb79 8028055: (reflect) invoking Method/Constructor in anonymous classes breaks with -Dsun.reflect.noInflation=true
jfranck
parents: 15510
diff changeset
   186
        if (noInflation && !ReflectUtil.isVMAnonymousClass(c.getDeclaringClass())) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            return new MethodAccessorGenerator().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                generateConstructor(c.getDeclaringClass(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                                    c.getParameterTypes(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                                    c.getExceptionTypes(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                                    c.getModifiers());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            NativeConstructorAccessorImpl acc =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                new NativeConstructorAccessorImpl(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            DelegatingConstructorAccessorImpl res =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                new DelegatingConstructorAccessorImpl(acc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            acc.setParent(res);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            return res;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    //--------------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    // Routines used by java.lang
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    /** Creates a new java.lang.reflect.Field. Access checks as per
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        java.lang.reflect.AccessibleObject are not overridden. */
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
   210
    public Field newField(Class<?> declaringClass,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                          String name,
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
   212
                          Class<?> type,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                          int modifiers,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                          int slot,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                          String signature,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                          byte[] annotations)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        return langReflectAccess().newField(declaringClass,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                                            name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                                            type,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                                            modifiers,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                                            slot,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                                            signature,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                                            annotations);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    /** Creates a new java.lang.reflect.Method. Access checks as per
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        java.lang.reflect.AccessibleObject are not overridden. */
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
   229
    public Method newMethod(Class<?> declaringClass,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                            String name,
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
   231
                            Class<?>[] parameterTypes,
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
   232
                            Class<?> returnType,
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
   233
                            Class<?>[] checkedExceptions,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
                            int modifiers,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
                            int slot,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                            String signature,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                            byte[] annotations,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                            byte[] parameterAnnotations,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                            byte[] annotationDefault)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        return langReflectAccess().newMethod(declaringClass,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                                             name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                                             parameterTypes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                                             returnType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
                                             checkedExceptions,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                                             modifiers,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
                                             slot,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                                             signature,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                                             annotations,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
                                             parameterAnnotations,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                                             annotationDefault);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    /** Creates a new java.lang.reflect.Constructor. Access checks as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        per java.lang.reflect.AccessibleObject are not overridden. */
10342
ca0984bc9d32 7077389: Reflection classes do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   256
    public Constructor<?> newConstructor(Class<?> declaringClass,
ca0984bc9d32 7077389: Reflection classes do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   257
                                         Class<?>[] parameterTypes,
ca0984bc9d32 7077389: Reflection classes do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   258
                                         Class<?>[] checkedExceptions,
ca0984bc9d32 7077389: Reflection classes do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   259
                                         int modifiers,
ca0984bc9d32 7077389: Reflection classes do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   260
                                         int slot,
ca0984bc9d32 7077389: Reflection classes do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   261
                                         String signature,
ca0984bc9d32 7077389: Reflection classes do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   262
                                         byte[] annotations,
ca0984bc9d32 7077389: Reflection classes do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   263
                                         byte[] parameterAnnotations)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        return langReflectAccess().newConstructor(declaringClass,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                                                  parameterTypes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                                                  checkedExceptions,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                                                  modifiers,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
                                                  slot,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
                                                  signature,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
                                                  annotations,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                                                  parameterAnnotations);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    /** Gets the MethodAccessor object for a java.lang.reflect.Method */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    public MethodAccessor getMethodAccessor(Method m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        return langReflectAccess().getMethodAccessor(m);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    /** Sets the MethodAccessor object for a java.lang.reflect.Method */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    public void setMethodAccessor(Method m, MethodAccessor accessor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        langReflectAccess().setMethodAccessor(m, accessor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    /** Gets the ConstructorAccessor object for a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        java.lang.reflect.Constructor */
10342
ca0984bc9d32 7077389: Reflection classes do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   287
    public ConstructorAccessor getConstructorAccessor(Constructor<?> c) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        return langReflectAccess().getConstructorAccessor(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    /** Sets the ConstructorAccessor object for a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        java.lang.reflect.Constructor */
10342
ca0984bc9d32 7077389: Reflection classes do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   293
    public void setConstructorAccessor(Constructor<?> c,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                                       ConstructorAccessor accessor)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        langReflectAccess().setConstructorAccessor(c, accessor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    /** Makes a copy of the passed method. The returned method is a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        "child" of the passed one; see the comments in Method.java for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        details. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    public Method copyMethod(Method arg) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        return langReflectAccess().copyMethod(arg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
32268
9fe7ee60d49d 8073056: Repeating annotations throws java.security.AccessControlException with a SecurityManager
jfranck
parents: 29986
diff changeset
   306
    /** Makes a copy of the passed method. The returned method is NOT
9fe7ee60d49d 8073056: Repeating annotations throws java.security.AccessControlException with a SecurityManager
jfranck
parents: 29986
diff changeset
   307
     * a "child" but a "sibling" of the Method in arg. Should only be
9fe7ee60d49d 8073056: Repeating annotations throws java.security.AccessControlException with a SecurityManager
jfranck
parents: 29986
diff changeset
   308
     * used on non-root methods. */
9fe7ee60d49d 8073056: Repeating annotations throws java.security.AccessControlException with a SecurityManager
jfranck
parents: 29986
diff changeset
   309
    public Method leafCopyMethod(Method arg) {
9fe7ee60d49d 8073056: Repeating annotations throws java.security.AccessControlException with a SecurityManager
jfranck
parents: 29986
diff changeset
   310
        return langReflectAccess().leafCopyMethod(arg);
9fe7ee60d49d 8073056: Repeating annotations throws java.security.AccessControlException with a SecurityManager
jfranck
parents: 29986
diff changeset
   311
    }
9fe7ee60d49d 8073056: Repeating annotations throws java.security.AccessControlException with a SecurityManager
jfranck
parents: 29986
diff changeset
   312
9fe7ee60d49d 8073056: Repeating annotations throws java.security.AccessControlException with a SecurityManager
jfranck
parents: 29986
diff changeset
   313
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    /** Makes a copy of the passed field. The returned field is a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        "child" of the passed one; see the comments in Field.java for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        details. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    public Field copyField(Field arg) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        return langReflectAccess().copyField(arg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    /** Makes a copy of the passed constructor. The returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        constructor is a "child" of the passed one; see the comments
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        in Constructor.java for details. */
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
   324
    public <T> Constructor<T> copyConstructor(Constructor<T> arg) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        return langReflectAccess().copyConstructor(arg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
15510
898d924a7efd 8004698: Implement Core Reflection for Type Annotations
jfranck
parents: 14342
diff changeset
   328
    /** Gets the byte[] that encodes TypeAnnotations on an executable.
898d924a7efd 8004698: Implement Core Reflection for Type Annotations
jfranck
parents: 14342
diff changeset
   329
     */
898d924a7efd 8004698: Implement Core Reflection for Type Annotations
jfranck
parents: 14342
diff changeset
   330
    public byte[] getExecutableTypeAnnotationBytes(Executable ex) {
898d924a7efd 8004698: Implement Core Reflection for Type Annotations
jfranck
parents: 14342
diff changeset
   331
        return langReflectAccess().getExecutableTypeAnnotationBytes(ex);
898d924a7efd 8004698: Implement Core Reflection for Type Annotations
jfranck
parents: 14342
diff changeset
   332
    }
898d924a7efd 8004698: Implement Core Reflection for Type Annotations
jfranck
parents: 14342
diff changeset
   333
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    //--------------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    // Routines used by serialization
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
10342
ca0984bc9d32 7077389: Reflection classes do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   340
    public Constructor<?> newConstructorForSerialization
ca0984bc9d32 7077389: Reflection classes do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   341
        (Class<?> classToInstantiate, Constructor<?> constructorToCall)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        // Fast path
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        if (constructorToCall.getDeclaringClass() == classToInstantiate) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
            return constructorToCall;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        ConstructorAccessor acc = new MethodAccessorGenerator().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
            generateSerializationConstructor(classToInstantiate,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
                                             constructorToCall.getParameterTypes(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
                                             constructorToCall.getExceptionTypes(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
                                             constructorToCall.getModifiers(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
                                             constructorToCall.getDeclaringClass());
10342
ca0984bc9d32 7077389: Reflection classes do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   354
        Constructor<?> c = newConstructor(constructorToCall.getDeclaringClass(),
ca0984bc9d32 7077389: Reflection classes do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   355
                                          constructorToCall.getParameterTypes(),
ca0984bc9d32 7077389: Reflection classes do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   356
                                          constructorToCall.getExceptionTypes(),
ca0984bc9d32 7077389: Reflection classes do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   357
                                          constructorToCall.getModifiers(),
ca0984bc9d32 7077389: Reflection classes do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   358
                                          langReflectAccess().
ca0984bc9d32 7077389: Reflection classes do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   359
                                          getConstructorSlot(constructorToCall),
ca0984bc9d32 7077389: Reflection classes do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   360
                                          langReflectAccess().
ca0984bc9d32 7077389: Reflection classes do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   361
                                          getConstructorSignature(constructorToCall),
ca0984bc9d32 7077389: Reflection classes do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   362
                                          langReflectAccess().
ca0984bc9d32 7077389: Reflection classes do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   363
                                          getConstructorAnnotations(constructorToCall),
ca0984bc9d32 7077389: Reflection classes do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   364
                                          langReflectAccess().
ca0984bc9d32 7077389: Reflection classes do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   365
                                          getConstructorParameterAnnotations(constructorToCall));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        setConstructorAccessor(c, acc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        return c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    //--------------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    // Internals only below this point
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    static int inflationThreshold() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
        return inflationThreshold;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
    /** We have to defer full initialization of this class until after
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        the static initializer is run since java.lang.reflect.Method's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        static initializer (more properly, that for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        java.lang.reflect.AccessibleObject) causes this class's to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        run, before the system properties are set up. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    private static void checkInitted() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        if (initted) return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
37593
824750ada3d6 8154231: Simplify access to System properties from JDK code
redestad
parents: 37363
diff changeset
   387
        // Tests to ensure the system properties table is fully
824750ada3d6 8154231: Simplify access to System properties from JDK code
redestad
parents: 37363
diff changeset
   388
        // initialized. This is needed because reflection code is
824750ada3d6 8154231: Simplify access to System properties from JDK code
redestad
parents: 37363
diff changeset
   389
        // called very early in the initialization process (before
824750ada3d6 8154231: Simplify access to System properties from JDK code
redestad
parents: 37363
diff changeset
   390
        // command-line arguments have been parsed and therefore
824750ada3d6 8154231: Simplify access to System properties from JDK code
redestad
parents: 37363
diff changeset
   391
        // these user-settable properties installed.) We assume that
824750ada3d6 8154231: Simplify access to System properties from JDK code
redestad
parents: 37363
diff changeset
   392
        // if System.out is non-null then the System class has been
824750ada3d6 8154231: Simplify access to System properties from JDK code
redestad
parents: 37363
diff changeset
   393
        // fully initialized and that the bulk of the startup code
824750ada3d6 8154231: Simplify access to System properties from JDK code
redestad
parents: 37363
diff changeset
   394
        // has been run.
824750ada3d6 8154231: Simplify access to System properties from JDK code
redestad
parents: 37363
diff changeset
   395
824750ada3d6 8154231: Simplify access to System properties from JDK code
redestad
parents: 37363
diff changeset
   396
        if (System.out == null) {
824750ada3d6 8154231: Simplify access to System properties from JDK code
redestad
parents: 37363
diff changeset
   397
            // java.lang.System not yet fully initialized
824750ada3d6 8154231: Simplify access to System properties from JDK code
redestad
parents: 37363
diff changeset
   398
            return;
824750ada3d6 8154231: Simplify access to System properties from JDK code
redestad
parents: 37363
diff changeset
   399
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
37593
824750ada3d6 8154231: Simplify access to System properties from JDK code
redestad
parents: 37363
diff changeset
   401
        Properties props = GetPropertyAction.getProperties();
824750ada3d6 8154231: Simplify access to System properties from JDK code
redestad
parents: 37363
diff changeset
   402
        String val = props.getProperty("sun.reflect.noInflation");
824750ada3d6 8154231: Simplify access to System properties from JDK code
redestad
parents: 37363
diff changeset
   403
        if (val != null && val.equals("true")) {
824750ada3d6 8154231: Simplify access to System properties from JDK code
redestad
parents: 37363
diff changeset
   404
            noInflation = true;
824750ada3d6 8154231: Simplify access to System properties from JDK code
redestad
parents: 37363
diff changeset
   405
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
37593
824750ada3d6 8154231: Simplify access to System properties from JDK code
redestad
parents: 37363
diff changeset
   407
        val = props.getProperty("sun.reflect.inflationThreshold");
824750ada3d6 8154231: Simplify access to System properties from JDK code
redestad
parents: 37363
diff changeset
   408
        if (val != null) {
824750ada3d6 8154231: Simplify access to System properties from JDK code
redestad
parents: 37363
diff changeset
   409
            try {
824750ada3d6 8154231: Simplify access to System properties from JDK code
redestad
parents: 37363
diff changeset
   410
                inflationThreshold = Integer.parseInt(val);
824750ada3d6 8154231: Simplify access to System properties from JDK code
redestad
parents: 37363
diff changeset
   411
            } catch (NumberFormatException e) {
824750ada3d6 8154231: Simplify access to System properties from JDK code
redestad
parents: 37363
diff changeset
   412
                throw new RuntimeException("Unable to parse property sun.reflect.inflationThreshold", e);
824750ada3d6 8154231: Simplify access to System properties from JDK code
redestad
parents: 37363
diff changeset
   413
            }
824750ada3d6 8154231: Simplify access to System properties from JDK code
redestad
parents: 37363
diff changeset
   414
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
37593
824750ada3d6 8154231: Simplify access to System properties from JDK code
redestad
parents: 37363
diff changeset
   416
        initted = true;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    private static LangReflectAccess langReflectAccess() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
        if (langReflectAccess == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
            // Call a static method to get class java.lang.reflect.Modifier
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
            // initialized. Its static initializer will cause
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
            // setLangReflectAccess() to be called from the context of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
            // java.lang.reflect package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
            Modifier.isPublic(Modifier.PUBLIC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        return langReflectAccess;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
}