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.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.
538 /**
539 * Removes the value of the current carrier thread's copy of a thread-local.
540 */
541 void removeCarrierThreadLocal(CarrierThreadLocal<?> local);
542
543 /**
544 * Returns the current thread's scoped values cache
545 */
546 Object[] scopedValueCache();
547
548 /**
549 * Sets the current thread's scoped values cache
550 */
551 void setScopedValueCache(Object[] cache);
552
553 /**
554 * Return the current thread's scoped value bindings.
555 */
556 Object scopedValueBindings();
557
558 /**
559 * Returns the innermost mounted continuation
560 */
561 Continuation getContinuation(Thread thread);
562
563 /**
564 * Sets the innermost mounted continuation
565 */
566 void setContinuation(Thread thread, Continuation continuation);
567
568 /**
569 * The ContinuationScope of virtual thread continuations
570 */
571 ContinuationScope virtualThreadContinuationScope();
572
573 /**
574 * Parks the current virtual thread.
575 * @throws WrongThreadException if the current thread is not a virtual thread
576 */
577 void parkVirtualThread();
578
579 /**
580 * Parks the current virtual thread for up to the given waiting time.
581 * @param nanos the maximum number of nanoseconds to wait
582 * @throws WrongThreadException if the current thread is not a virtual thread
583 */
584 void parkVirtualThread(long nanos);
585
586 /**
587 * Re-enables a virtual thread for scheduling. If the thread was parked then
588 * it will be unblocked, otherwise its next attempt to park will not block
589 * @param thread the virtual thread to unpark
590 * @throws IllegalArgumentException if the thread is not a virtual thread
591 * @throws RejectedExecutionException if the scheduler cannot accept a task
592 */
593 void unparkVirtualThread(Thread thread);
594
595 /**
596 * Returns the virtual thread default scheduler.
597 */
598 Executor virtualThreadDefaultScheduler();
599
600 /**
601 * Creates a new StackWalker
602 */
603 StackWalker newStackWalkerInstance(Set<StackWalker.Option> options,
604 ContinuationScope contScope,
605 Continuation continuation);
606 /**
607 * Returns '<loader-name>' @<id> if classloader has a name
608 * explicitly set otherwise <qualified-class-name> @<id>
609 */
610 String getLoaderNameID(ClassLoader loader);
611
612 /**
613 * Copy the string bytes to an existing segment, avoiding intermediate copies.
614 */
615 void copyToSegmentRaw(String string, MemorySegment segment, long offset);
616
617 /**
618 * 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.stream.Stream;
48
49 import jdk.internal.loader.NativeLibraries;
50 import jdk.internal.misc.CarrierThreadLocal;
51 import jdk.internal.module.ServicesCatalog;
52 import jdk.internal.reflect.ConstantPool;
53 import jdk.internal.vm.Continuation;
54 import jdk.internal.vm.ContinuationScope;
55 import jdk.internal.vm.StackableScope;
56 import jdk.internal.vm.ThreadContainer;
57 import sun.reflect.annotation.AnnotationType;
58 import sun.nio.ch.Interruptible;
59
60 public interface JavaLangAccess {
61
62 /**
63 * Returns the list of {@code Method} objects for the declared public
64 * methods of this class or interface that have the specified method name
65 * and parameter types.
537 /**
538 * Removes the value of the current carrier thread's copy of a thread-local.
539 */
540 void removeCarrierThreadLocal(CarrierThreadLocal<?> local);
541
542 /**
543 * Returns the current thread's scoped values cache
544 */
545 Object[] scopedValueCache();
546
547 /**
548 * Sets the current thread's scoped values cache
549 */
550 void setScopedValueCache(Object[] cache);
551
552 /**
553 * Return the current thread's scoped value bindings.
554 */
555 Object scopedValueBindings();
556
557 /**
558 * Returns the native thread ID for the given platform thread or 0 if not set.
559 */
560 long nativeThreadID(Thread thread);
561
562 /**
563 * Sets the native thread ID for the current platform thread.
564 */
565 void setThreadNativeID(long id);
566
567 /**
568 * Returns the innermost mounted continuation
569 */
570 Continuation getContinuation(Thread thread);
571
572 /**
573 * Sets the innermost mounted continuation
574 */
575 void setContinuation(Thread thread, Continuation continuation);
576
577 /**
578 * The ContinuationScope of virtual thread continuations
579 */
580 ContinuationScope virtualThreadContinuationScope();
581
582 /**
583 * Parks the current virtual thread.
584 * @throws WrongThreadException if the current thread is not a virtual thread
585 */
586 void parkVirtualThread();
587
588 /**
589 * Parks the current virtual thread for up to the given waiting time.
590 * @param nanos the maximum number of nanoseconds to wait
591 * @throws WrongThreadException if the current thread is not a virtual thread
592 */
593 void parkVirtualThread(long nanos);
594
595 /**
596 * Re-enables a virtual thread for scheduling. If the thread was parked then
597 * it will be unblocked, otherwise its next attempt to park will not block
598 * @param thread the virtual thread to unpark
599 * @throws IllegalArgumentException if the thread is not a virtual thread
600 * @throws RejectedExecutionException if the scheduler cannot accept a task
601 */
602 void unparkVirtualThread(Thread thread);
603
604 /**
605 * Returns the default virtual thread scheduler.
606 */
607 Thread.VirtualThreadScheduler defaultVirtualThreadScheduler();
608
609 /**
610 * Returns true if using a custom default virtual thread scheduler.
611 */
612 boolean isCustomDefaultVirtualThreadScheduler();
613
614 /**
615 * Returns the scheduler for the given virtual thread.
616 */
617 Thread.VirtualThreadScheduler virtualThreadScheduler(Thread thread);
618
619 /**
620 * Creates a new StackWalker
621 */
622 StackWalker newStackWalkerInstance(Set<StackWalker.Option> options,
623 ContinuationScope contScope,
624 Continuation continuation);
625 /**
626 * Returns '<loader-name>' @<id> if classloader has a name
627 * explicitly set otherwise <qualified-class-name> @<id>
628 */
629 String getLoaderNameID(ClassLoader loader);
630
631 /**
632 * Copy the string bytes to an existing segment, avoiding intermediate copies.
633 */
634 void copyToSegmentRaw(String string, MemorySegment segment, long offset);
635
636 /**
637 * Are the string bytes compatible with the given charset?
|