13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package sun.misc;
27
28 import jdk.internal.vm.annotation.ForceInline;
29 import jdk.internal.misc.VM;
30 import jdk.internal.reflect.CallerSensitive;
31 import jdk.internal.reflect.Reflection;
32
33 import java.lang.reflect.Field;
34 import java.util.Set;
35
36
37 /**
38 * A collection of methods for performing low-level, unsafe operations.
39 * Although the class and all methods are public, use of this class is
40 * limited because only trusted code can obtain instances of it.
41 *
42 * <em>Note:</em> It is the resposibility of the caller to make sure
43 * arguments are checked before methods of this class are
44 * called. While some rudimentary checks are performed on the input,
45 * the checks are best effort and when performance is an overriding
46 * priority, as when methods of this class are optimized by the
47 * runtime compiler, some or all checks (if any) may be elided. Hence,
48 * the caller must not rely on the checks and corresponding
49 * exceptions!
50 *
51 * @author John R. Rose
52 * @see #getUnsafe
803 @ForceInline
804 public int pageSize() {
805 return theInternalUnsafe.pageSize();
806 }
807
808
809 /// random trusted operations from JNI:
810
811 /**
812 * Defines a class but does not make it known to the class loader or system dictionary.
813 * <p>
814 * For each CP entry, the corresponding CP patch must either be null or have
815 * the a format that matches its tag:
816 * <ul>
817 * <li>Integer, Long, Float, Double: the corresponding wrapper object type from java.lang
818 * <li>Utf8: a string (must have suitable syntax if used as signature or name)
819 * <li>Class: any java.lang.Class object
820 * <li>String: any object (not just a java.lang.String)
821 * <li>InterfaceMethodRef: (NYI) a method handle to invoke on that call site's arguments
822 * </ul>
823 * @param hostClass context for linkage, access control, protection domain, and class loader
824 * @param data bytes of a class file
825 * @param cpPatches where non-null entries exist, they replace corresponding CP entries in data
826 */
827 @ForceInline
828 public Class<?> defineAnonymousClass(Class<?> hostClass, byte[] data, Object[] cpPatches) {
829 return theInternalUnsafe.defineAnonymousClass(hostClass, data, cpPatches);
830 }
831
832 /**
833 * Allocates an instance but does not run any constructor.
834 * Initializes the class if it has not yet been.
835 */
836 @ForceInline
837 public Object allocateInstance(Class<?> cls)
838 throws InstantiationException {
839 return theInternalUnsafe.allocateInstance(cls);
840 }
841
842 /** Throws the exception without telling the verifier. */
843 @ForceInline
844 public void throwException(Throwable ee) {
845 theInternalUnsafe.throwException(ee);
846 }
847
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package sun.misc;
27
28 import jdk.internal.vm.annotation.ForceInline;
29 import jdk.internal.misc.VM;
30 import jdk.internal.reflect.CallerSensitive;
31 import jdk.internal.reflect.Reflection;
32
33 import java.lang.invoke.MethodHandles;
34 import java.lang.reflect.Field;
35 import java.util.Set;
36
37
38 /**
39 * A collection of methods for performing low-level, unsafe operations.
40 * Although the class and all methods are public, use of this class is
41 * limited because only trusted code can obtain instances of it.
42 *
43 * <em>Note:</em> It is the resposibility of the caller to make sure
44 * arguments are checked before methods of this class are
45 * called. While some rudimentary checks are performed on the input,
46 * the checks are best effort and when performance is an overriding
47 * priority, as when methods of this class are optimized by the
48 * runtime compiler, some or all checks (if any) may be elided. Hence,
49 * the caller must not rely on the checks and corresponding
50 * exceptions!
51 *
52 * @author John R. Rose
53 * @see #getUnsafe
804 @ForceInline
805 public int pageSize() {
806 return theInternalUnsafe.pageSize();
807 }
808
809
810 /// random trusted operations from JNI:
811
812 /**
813 * Defines a class but does not make it known to the class loader or system dictionary.
814 * <p>
815 * For each CP entry, the corresponding CP patch must either be null or have
816 * the a format that matches its tag:
817 * <ul>
818 * <li>Integer, Long, Float, Double: the corresponding wrapper object type from java.lang
819 * <li>Utf8: a string (must have suitable syntax if used as signature or name)
820 * <li>Class: any java.lang.Class object
821 * <li>String: any object (not just a java.lang.String)
822 * <li>InterfaceMethodRef: (NYI) a method handle to invoke on that call site's arguments
823 * </ul>
824 *
825 * @deprecated Use the {@link java.lang.invoke.MethodHandles.Lookup#defineHiddenClass(byte[], boolean, MethodHandles.Lookup.ClassOption...)}
826 * method.
827 *
828 * @param hostClass context for linkage, access control, protection domain, and class loader
829 * @param data bytes of a class file
830 * @param cpPatches where non-null entries exist, they replace corresponding CP entries in data
831 */
832 @ForceInline
833 @Deprecated(since = "14", forRemoval = false)
834 public Class<?> defineAnonymousClass(Class<?> hostClass, byte[] data, Object[] cpPatches) {
835 return theInternalUnsafe.defineAnonymousClass(hostClass, data, cpPatches);
836 }
837
838 /**
839 * Allocates an instance but does not run any constructor.
840 * Initializes the class if it has not yet been.
841 */
842 @ForceInline
843 public Object allocateInstance(Class<?> cls)
844 throws InstantiationException {
845 return theInternalUnsafe.allocateInstance(cls);
846 }
847
848 /** Throws the exception without telling the verifier. */
849 @ForceInline
850 public void throwException(Throwable ee) {
851 theInternalUnsafe.throwException(ee);
852 }
853
|