JavaLangAccess.java 5.9 KB
Newer Older
D
duke 已提交
1
/*
2
 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
D
duke 已提交
3 4 5 6
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
7
 * published by the Free Software Foundation.  Oracle designates this
D
duke 已提交
8
 * particular file as subject to the "Classpath" exception as provided
9
 * by Oracle in the LICENSE file that accompanied this code.
D
duke 已提交
10 11 12 13 14 15 16 17 18 19 20
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
21 22 23
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
D
duke 已提交
24 25 26 27
 */

package sun.misc;

28
import java.lang.annotation.Annotation;
29
import java.lang.reflect.Executable;
30
import java.security.AccessControlContext;
31
import java.util.Map;
32

L
lei.yul 已提交
33
import com.alibaba.rcm.internal.AbstractResourceContainer;
Y
yunyao.zxl 已提交
34 35
import com.alibaba.wisp.engine.WispEngine;
import com.alibaba.wisp.engine.WispTask;
D
duke 已提交
36 37 38 39 40 41
import sun.reflect.ConstantPool;
import sun.reflect.annotation.AnnotationType;
import sun.nio.ch.Interruptible;

public interface JavaLangAccess {
    /** Return the constant pool for a class. */
42
    ConstantPool getConstantPool(Class<?> klass);
D
duke 已提交
43 44

    /**
45
     * Compare-And-Swap the AnnotationType instance corresponding to this class.
D
duke 已提交
46 47
     * (This method only applies to annotation types.)
     */
48
    boolean casAnnotationType(Class<?> klass, AnnotationType oldType, AnnotationType newType);
D
duke 已提交
49 50 51 52 53

    /**
     * Get the AnnotationType instance corresponding to this class.
     * (This method only applies to annotation types.)
     */
54
    AnnotationType getAnnotationType(Class<?> klass);
D
duke 已提交
55

56 57 58 59 60
    /**
     * Get the declared annotations for a given class, indexed by their types.
     */
    Map<Class<? extends Annotation>, Annotation> getDeclaredAnnotationMap(Class<?> klass);

61 62 63 64 65 66
    /**
     * Get the array of bytes that is the class-file representation
     * of this Class' annotations.
     */
    byte[] getRawClassAnnotations(Class<?> klass);

67 68 69 70 71 72 73 74 75 76 77 78
    /**
     * Get the array of bytes that is the class-file representation
     * of this Class' type annotations.
     */
    byte[] getRawClassTypeAnnotations(Class<?> klass);

    /**
     * Get the array of bytes that is the class-file representation
     * of this Executable's type annotations.
     */
    byte[] getRawExecutableTypeAnnotations(Executable executable);

D
duke 已提交
79 80 81 82 83 84 85 86 87
    /**
     * Returns the elements of an enum class or null if the
     * Class object does not represent an enum type;
     * the result is uncloned, cached, and shared by all callers.
     */
    <E extends Enum<E>> E[] getEnumConstantsShared(Class<E> klass);

    /** Set thread's blocker field. */
    void blockedOn(Thread t, Interruptible b);
88

89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
    /**
     * Registers a shutdown hook.
     *
     * It is expected that this method with registerShutdownInProgress=true
     * is only used to register DeleteOnExitHook since the first file
     * may be added to the delete on exit list by the application shutdown
     * hooks.
     *
     * @params slot  the slot in the shutdown hook array, whose element
     *               will be invoked in order during shutdown
     * @params registerShutdownInProgress true to allow the hook
     *               to be registered even if the shutdown is in progress.
     * @params hook  the hook to be registered
     *
     * @throw IllegalStateException if shutdown is in progress and
     *          the slot is not valid to register.
     */
    void registerShutdownHook(int slot, boolean registerShutdownInProgress, Runnable hook);
107 108 109 110 111 112 113 114 115 116

    /**
     * Returns the number of stack frames represented by the given throwable.
     */
    int getStackTraceDepth(Throwable t);

    /**
     * Returns the ith StackTraceElement for the given throwable.
     */
    StackTraceElement getStackTraceElement(Throwable t, int i);
117 118 119 120 121 122 123 124 125 126

    /**
     * Returns a new string backed by the provided character array. The
     * character array is not copied and must never be modified after the
     * String is created, in order to fulfill String's contract.
     *
     * @param chars the character array to back the string
     * @return a newly created string whose content is the character array
     */
    String newStringUnsafe(char[] chars);
127 128 129 130 131 132

    /**
     * Returns a new Thread with the given Runnable and an
     * inherited AccessControlContext.
     */
    Thread newThreadWithAcc(Runnable target, AccessControlContext acc);
133 134 135 136 137

    /**
     * Invokes the finalize method of the given object.
     */
    void invokeFinalize(Object o) throws Throwable;
L
lei.yul 已提交
138 139 140 141 142 143 144 145 146 147 148 149

    /**
     * Set the value of {@code thread.resourceContainer}
     *
     * @param thread target thread to be modified
     */
    void setResourceContainer(Thread thread, AbstractResourceContainer container);

    /**
     * Get the reference to the thread attached {@code ResourceContainer}
     */
    AbstractResourceContainer getResourceContainer(Thread thread);
L
lei.yul 已提交
150 151 152 153 154

    /**
     * Get the reference to the thread's inherited {@code ResourceContainer}
     */
    AbstractResourceContainer getInheritedResourceContainer(Thread thread);
Y
yunyao.zxl 已提交
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173

    /**
     * Returns a reference to the currently executing thread object.
     */
    Thread currentThread0();

    void yield0();

    void setWispTask(Thread thread, WispTask task);

    WispTask getWispTask(Thread thread);

    void setWispAlive(Thread thread, boolean b);

    boolean isInSameNative(Thread thread);

    void threadExit(Thread thread);

    void wispBooted();
D
duke 已提交
174
}