Some sun.misc internal APIs are deprectaed in JDK 9 and will be encapsulated or removed in a future release.
private static void blockedOn(Interruptible interruptible) { sun.misc.SharedSecrets.getJavaLangAccess().blockedOn(Thread.currentThread(), interruptible); }
RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw"); int fd = sun.misc.SharedSecrets.getJavaIOFileDescriptorAccess() .get(randomAccessFile.getFD());
@SuppressWarnings("restriction") public static long getJvmDirectMemoryUsed() { if (directMemoryUsage != null) { try { return ((AtomicLong) directMemoryUsage.get(null)).get(); } catch (Exception e) { if (log.isDebugEnabled()) { log.debug("Failed to get netty-direct-memory used count {}", e.getMessage()); } } } return sun.misc.SharedSecrets.getJavaNioAccess().getDirectBufferPool().getMemoryUsed(); }
private static volatile Console cons = null; public static Console console() { Console result = console; if (result == null) { synchronized (System.class) { result = console; if (result == null) { console = result =sun.misc.SharedSecrets.getJavaIOAccess().console(); } } } return result; }
if (clsLdr != null) try { URLClassPath path = SharedSecrets.getJavaNetAccess().getURLClassPath(clsLdr);
return cons.newInstance(); } else { JavaSecurityAccess jsa = SharedSecrets.getJavaSecurityAccess(); PrivilegedAction<?> pea = (PrivilegedAction<?>) new PrivilegedAction() { public Object run() {
/** * Gets the real POSIX file descriptor for use by custom jni calls. */ private int getFileDescriptor() throws IOException { final int fd = SharedSecrets.getJavaIOFileDescriptorAccess().get(getFD()); if(fd < 1) throw new IOException("failed to get POSIX file descriptor!"); return fd; }
@SuppressWarnings("restriction") public static long getJvmDirectMemoryUsed() { if (directMemoryUsage != null) { try { return ((AtomicLong) directMemoryUsage.get(null)).get(); } catch (Exception e) { if (log.isDebugEnabled()) { log.debug("Failed to get netty-direct-memory used count {}", e.getMessage()); } } } return sun.misc.SharedSecrets.getJavaNioAccess().getDirectBufferPool().getMemoryUsed(); }
/** * Returns the unique {@link java.io.Console Console} object associated * with the current Java virtual machine, if any. * * @return The system console, if any, otherwise <tt>null</tt>. * * @since 1.6 */ public static Console console() { if (cons == null) { synchronized (System.class) { cons = sun.misc.SharedSecrets.getJavaIOAccess().console(); } } return cons; }
private static void blockedOn(Interruptible interruptible) { sun.misc.SharedSecrets.getJavaLangAccess().blockedOn(Thread.currentThread(), interruptible); }
FileDescriptor fd = new FileDesciptor(); sun.misc.SharedSecrets.getJavaIOFileDescriptorAccess().set(fd,3); FileInputStream fin = new FileInputStream(fd);
private synchronized Map<Class<? extends Annotation>, Annotation> declaredAnnotations() { if (declaredAnnotations == null) { declaredAnnotations = AnnotationParser.parseAnnotations( annotations, sun.misc.SharedSecrets.getJavaLangAccess(). getConstantPool(getDeclaringClass()), getDeclaringClass()); } return declaredAnnotations; }
fdf.setAccessible(true); FileDescriptor fd = (FileDescriptor) fdf.get(s); int nativeFd = SharedSecrets.getJavaIOFileDescriptorAccess().get(fd); int localPort = (int) localPort0.invoke(dualStackPlainSocketImplClass, nativeFd); System.out.format("[local port=%s][exception=%s]\n", localPort, e.getMessage());
private static void blockedOn(Interruptible interruptible) { sun.misc.SharedSecrets.getJavaLangAccess().blockedOn(Thread.currentThread(), interruptible); }
sun.misc.JavaIOFileDescriptorAccess a = SharedSecrets.getJavaIOFileDescriptorAccess(); winHandle = LArrayNative.duplicateHandle(a.getHandle(raf.getFD()));
public static StackTraceElement getCaller() { Exception e = new Exception(); return sun.misc.SharedSecrets.getJavaLangAccess().getStackTraceElement(e, 2); }
sun.misc.JavaIOFileDescriptorAccess a = SharedSecrets.getJavaIOFileDescriptorAccess(); winHandle = LArrayNative.duplicateHandle(a.getHandle(raf.getFD()));
sun.misc.SharedSecrets.getJavaLangAccess().getEnumConstantsShared(MyEnumType.class)
@State(Scope.Benchmark) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MICROSECONDS) public class StackTraces { @Benchmark public StackTraceElement[] getStackTrace() { return new Exception().getStackTrace(); } @Benchmark public StackTraceElement getFast() { return sun.misc.SharedSecrets.getJavaLangAccess() .getStackTraceElement(new Exception(), 2); } }
sun.misc.SharedSecrets.getJavaLangAccess().getStackTraceElement()