src/jdk.unsupported/share/classes/sun/reflect/Reflection.java
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 44668 jdk/src/jdk.unsupported/share/classes/sun/reflect/Reflection.java@1197afaf020a
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
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
/*
44668
1197afaf020a 8177723: Suppress lint removal warning in java.se.ee and jdk.unsupported
darcy
parents: 37363
diff changeset
     2
 * Copyright (c) 2001, 2017, 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
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    28
public class Reflection {
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    29
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    30
    private Reflection() { }
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    31
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    32
    /**
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    33
     * @deprecated This method is an internal API and will be removed.
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    34
     * Use {@link StackWalker} to walk the stack and obtain the caller class
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    35
     * with {@link StackWalker.StackFrame#getDeclaringClass} instead.
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    36
     */
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    37
    @Deprecated(forRemoval=true)
44668
1197afaf020a 8177723: Suppress lint removal warning in java.se.ee and jdk.unsupported
darcy
parents: 37363
diff changeset
    38
    @SuppressWarnings("removal") // Reflection.getCallerClass
37363
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    39
    public static Class<?> getCallerClass(int depth) {
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    40
        if (depth < 0)
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    41
            throw new InternalError("depth must be positive");
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    42
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    43
        // increase depth to account for delegation to the internal impl
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    44
        return jdk.internal.reflect.Reflection.getCallerClass(depth + 1);
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    45
    }
329dba26ffd2 8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
diff changeset
    46
}