< prev index next >

src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java

Print this page

 26 package jdk.internal.access;
 27 
 28 import java.io.InputStream;
 29 import java.io.PrintStream;
 30 import java.lang.annotation.Annotation;
 31 import java.lang.foreign.MemorySegment;
 32 import java.lang.foreign.SymbolLookup;
 33 import java.lang.invoke.MethodHandle;
 34 import java.lang.invoke.MethodType;
 35 import java.lang.module.ModuleDescriptor;
 36 import java.lang.reflect.Executable;
 37 import java.lang.reflect.Method;
 38 import java.net.URI;
 39 import java.nio.charset.CharacterCodingException;
 40 import java.nio.charset.Charset;
 41 import java.security.ProtectionDomain;
 42 import java.util.List;
 43 import java.util.Map;
 44 import java.util.Set;
 45 import java.util.concurrent.ConcurrentHashMap;
 46 import java.util.concurrent.Executor;
 47 import java.util.concurrent.RejectedExecutionException;
 48 import java.util.function.BiFunction;
 49 import java.util.stream.Stream;
 50 
 51 import jdk.internal.loader.NativeLibraries;
 52 import jdk.internal.misc.CarrierThreadLocal;
 53 import jdk.internal.module.ServicesCatalog;
 54 import jdk.internal.reflect.ConstantPool;
 55 import jdk.internal.vm.Continuation;
 56 import jdk.internal.vm.ContinuationScope;
 57 import jdk.internal.vm.StackableScope;
 58 import jdk.internal.vm.ThreadContainer;
 59 import sun.reflect.annotation.AnnotationType;
 60 import sun.nio.ch.Interruptible;
 61 
 62 public interface JavaLangAccess {
 63 
 64     /**
 65      * Returns the list of {@code Method} objects for the declared public
 66      * methods of this class or interface that have the specified method name
 67      * and parameter types.
 68      */

556     /**
557      * Removes the value of the current carrier thread's copy of a thread-local.
558      */
559     void removeCarrierThreadLocal(CarrierThreadLocal<?> local);
560 
561     /**
562      * Returns the current thread's scoped values cache
563      */
564     Object[] scopedValueCache();
565 
566     /**
567      * Sets the current thread's scoped values cache
568      */
569     void setScopedValueCache(Object[] cache);
570 
571     /**
572      * Return the current thread's scoped value bindings.
573      */
574     Object scopedValueBindings();
575 










576     /**
577      * Returns the innermost mounted continuation
578      */
579     Continuation getContinuation(Thread thread);
580 
581     /**
582      * Sets the innermost mounted continuation
583      */
584     void setContinuation(Thread thread, Continuation continuation);
585 
586     /**
587      * The ContinuationScope of virtual thread continuations
588      */
589     ContinuationScope virtualThreadContinuationScope();
590 
591     /**
592      * Parks the current virtual thread.
593      * @throws WrongThreadException if the current thread is not a virtual thread
594      */
595     void parkVirtualThread();
596 
597     /**
598      * Parks the current virtual thread for up to the given waiting time.
599      * @param nanos the maximum number of nanoseconds to wait
600      * @throws WrongThreadException if the current thread is not a virtual thread
601      */
602     void parkVirtualThread(long nanos);
603 
604     /**
605      * Re-enables a virtual thread for scheduling. If the thread was parked then
606      * it will be unblocked, otherwise its next attempt to park will not block
607      * @param thread the virtual thread to unpark
608      * @throws IllegalArgumentException if the thread is not a virtual thread
609      * @throws RejectedExecutionException if the scheduler cannot accept a task
610      */
611     void unparkVirtualThread(Thread thread);
612 
613     /**
614      * Returns the virtual thread default scheduler.



















615      */
616     Executor virtualThreadDefaultScheduler();
617 
618     /**
619      * Creates a new StackWalker
620      */
621     StackWalker newStackWalkerInstance(Set<StackWalker.Option> options,
622                                        ContinuationScope contScope,
623                                        Continuation continuation);
624     /**
625      * Returns '<loader-name>' @<id> if classloader has a name
626      * explicitly set otherwise <qualified-class-name> @<id>
627      */
628     String getLoaderNameID(ClassLoader loader);
629 
630     /**
631      * Copy the string bytes to an existing segment, avoiding intermediate copies.
632      */
633     void copyToSegmentRaw(String string, MemorySegment segment, long offset);
634 
635     /**
636      * Are the string bytes compatible with the given charset?

 26 package jdk.internal.access;
 27 
 28 import java.io.InputStream;
 29 import java.io.PrintStream;
 30 import java.lang.annotation.Annotation;
 31 import java.lang.foreign.MemorySegment;
 32 import java.lang.foreign.SymbolLookup;
 33 import java.lang.invoke.MethodHandle;
 34 import java.lang.invoke.MethodType;
 35 import java.lang.module.ModuleDescriptor;
 36 import java.lang.reflect.Executable;
 37 import java.lang.reflect.Method;
 38 import java.net.URI;
 39 import java.nio.charset.CharacterCodingException;
 40 import java.nio.charset.Charset;
 41 import java.security.ProtectionDomain;
 42 import java.util.List;
 43 import java.util.Map;
 44 import java.util.Set;
 45 import java.util.concurrent.ConcurrentHashMap;

 46 import java.util.concurrent.RejectedExecutionException;
 47 import java.util.function.Supplier;
 48 import java.util.stream.Stream;
 49 
 50 import jdk.internal.loader.NativeLibraries;
 51 import jdk.internal.misc.CarrierThreadLocal;
 52 import jdk.internal.module.ServicesCatalog;
 53 import jdk.internal.reflect.ConstantPool;
 54 import jdk.internal.vm.Continuation;
 55 import jdk.internal.vm.ContinuationScope;
 56 import jdk.internal.vm.StackableScope;
 57 import jdk.internal.vm.ThreadContainer;
 58 import sun.reflect.annotation.AnnotationType;
 59 import sun.nio.ch.Interruptible;
 60 
 61 public interface JavaLangAccess {
 62 
 63     /**
 64      * Returns the list of {@code Method} objects for the declared public
 65      * methods of this class or interface that have the specified method name
 66      * and parameter types.
 67      */

555     /**
556      * Removes the value of the current carrier thread's copy of a thread-local.
557      */
558     void removeCarrierThreadLocal(CarrierThreadLocal<?> local);
559 
560     /**
561      * Returns the current thread's scoped values cache
562      */
563     Object[] scopedValueCache();
564 
565     /**
566      * Sets the current thread's scoped values cache
567      */
568     void setScopedValueCache(Object[] cache);
569 
570     /**
571      * Return the current thread's scoped value bindings.
572      */
573     Object scopedValueBindings();
574 
575     /**
576      * Returns the native thread ID for the given platform thread or 0 if not set.
577      */
578     long nativeThreadID(Thread thread);
579 
580     /**
581      * Sets the native thread ID for the current platform thread.
582      */
583     void setThreadNativeID(long id);
584 
585     /**
586      * Returns the innermost mounted continuation
587      */
588     Continuation getContinuation(Thread thread);
589 
590     /**
591      * Sets the innermost mounted continuation
592      */
593     void setContinuation(Thread thread, Continuation continuation);
594 
595     /**
596      * The ContinuationScope of virtual thread continuations
597      */
598     ContinuationScope virtualThreadContinuationScope();
599 
600     /**
601      * Parks the current virtual thread.
602      * @throws WrongThreadException if the current thread is not a virtual thread
603      */
604     void parkVirtualThread();
605 
606     /**
607      * Parks the current virtual thread for up to the given waiting time.
608      * @param nanos the maximum number of nanoseconds to wait
609      * @throws WrongThreadException if the current thread is not a virtual thread
610      */
611     void parkVirtualThread(long nanos);
612 
613     /**
614      * Re-enables a virtual thread for scheduling. If the thread was parked then
615      * it will be unblocked, otherwise its next attempt to park will not block
616      * @param thread the virtual thread to unpark
617      * @throws IllegalArgumentException if the thread is not a virtual thread
618      * @throws RejectedExecutionException if the scheduler cannot accept a task
619      */
620     void unparkVirtualThread(Thread thread);
621 
622     /**
623      * Returns the default virtual thread scheduler.
624      */
625     Thread.VirtualThreadScheduler defaultVirtualThreadScheduler();
626 
627     /**
628      * Returns true if using a custom default virtual thread scheduler.
629      */
630     boolean isCustomDefaultVirtualThreadScheduler();
631 
632     /**
633      * Returns the scheduler for the given virtual thread.
634      */
635     Thread.VirtualThreadScheduler virtualThreadScheduler(Thread thread);
636 
637     /**
638      * Invokes a supplier to produce a non-null result if this virtual thread is unmounted.
639      * @param supplyIfAlive invoked if this virtual thread is unmounted and alive. The
640      *      virtual thread is suspended while the supplier executes
641      * @param supplyIfNotAlive invoked if this virtual thread is not alive
642      * @return the result; {@code null} if mounted, suspended or in transition
643      */
644     <T> T supplyIfUnmounted(Thread thread, Supplier<T> supplyIfAlive, Supplier<T> supplyIfNotAlive);
645 
646     /**
647      * Creates a new StackWalker
648      */
649     StackWalker newStackWalkerInstance(Set<StackWalker.Option> options,
650                                        ContinuationScope contScope,
651                                        Continuation continuation);
652     /**
653      * Returns '<loader-name>' @<id> if classloader has a name
654      * explicitly set otherwise <qualified-class-name> @<id>
655      */
656     String getLoaderNameID(ClassLoader loader);
657 
658     /**
659      * Copy the string bytes to an existing segment, avoiding intermediate copies.
660      */
661     void copyToSegmentRaw(String string, MemorySegment segment, long offset);
662 
663     /**
664      * Are the string bytes compatible with the given charset?
< prev index next >