Top Description Fields Constructors Methods
org.apache.tomcat.util.compat

public Class JreCompat

extends Object
Class Inheritance
Known Direct Subclasses
org.apache.tomcat.util.compat.Jre16Compat
Imports
java.lang.reflect.Field, java.net.SocketAddress, java.nio.channels.ServerSocketChannel, .SocketChannel, org.apache.tomcat.util.res.StringManager

This is the base implementation class for JRE compatibility and provides an implementation based on Java 11. Sub-classes may extend this class and provide alternative implementations for later JRE versions

Field Summary

Modifier and TypeField and Description
private static final boolean
private static final JreCompat
private static final boolean
private static final boolean
private static final boolean
private static final boolean
private static final StringManager

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Object

Returns:

The thread buidler for virtual threads
createVirtualThreadBuilder
(String
The base name for the threads
name
)

Create a thread builder for virtual threads using the given name to name the threads.

public Object

Returns:

The executor, if any, that created the provided thread
getExecutor
(Thread
The thread to examine
thread
)

Obtains the executor, if any, used to create the provided thread.

public static JreCompat
public SocketAddress

Returns:

the socket address
getUnixDomainSocketAddress
(String
The path
path
)

Return Unix domain socket address for given path.

public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public ServerSocketChannel

Returns:

the server socket channel
openUnixDomainServerSocketChannel
()

Create server socket channel using the Unix domain socket ProtocolFamily.

public SocketChannel

Returns:

the socket channel
openUnixDomainSocketChannel
()

Create socket channel using the Unix domain socket ProtocolFamily.

public void
threadBuilderStart(Object
The thread builder to use to create a thread
threadBuilder
,
Runnable
The command to run
command
)

Create a thread with the given thread builder and use it to execute the given runnable.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

graalAvailableback to summary
private static final boolean graalAvailable
instanceback to summary
private static final JreCompat instance
jre16Availableback to summary
private static final boolean jre16Available
jre19Availableback to summary
private static final boolean jre19Available
jre21Availableback to summary
private static final boolean jre21Available
jre22Availableback to summary
private static final boolean jre22Available
smback to summary
private static final StringManager sm

Constructor Detail

JreCompatback to summary
public JreCompat()

Method Detail

createVirtualThreadBuilderback to summary
public Object createVirtualThreadBuilder(String name)

Create a thread builder for virtual threads using the given name to name the threads.

Parameters
name:String

The base name for the threads

Returns:Object

The thread buidler for virtual threads

getExecutorback to summary
public Object getExecutor(Thread thread) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException

Obtains the executor, if any, used to create the provided thread.

Parameters
thread:Thread

The thread to examine

Returns:Object

The executor, if any, that created the provided thread

Exceptions
NoSuchFieldException:
If a field used via reflection to obtain the executor cannot be found
SecurityException:
If a security exception occurs while trying to identify the executor
IllegalArgumentException:
If the instance object does not match the class of the field when obtaining a field value via reflection
IllegalAccessException:
If a field is not accessible due to access restrictions
getInstanceback to summary
public static JreCompat getInstance()
getUnixDomainSocketAddressback to summary
public SocketAddress getUnixDomainSocketAddress(String path)

Return Unix domain socket address for given path.

Parameters
path:String

The path

Returns:SocketAddress

the socket address

isGraalAvailableback to summary
public static boolean isGraalAvailable()
isJre16Availableback to summary
public static boolean isJre16Available()
isJre19Availableback to summary
public static boolean isJre19Available()
isJre21Availableback to summary
public static boolean isJre21Available()
isJre22Availableback to summary
public static boolean isJre22Available()
openUnixDomainServerSocketChannelback to summary
public ServerSocketChannel openUnixDomainServerSocketChannel()

Create server socket channel using the Unix domain socket ProtocolFamily.

Returns:ServerSocketChannel

the server socket channel

openUnixDomainSocketChannelback to summary
public SocketChannel openUnixDomainSocketChannel()

Create socket channel using the Unix domain socket ProtocolFamily.

Returns:SocketChannel

the socket channel

threadBuilderStartback to summary
public void threadBuilderStart(Object threadBuilder, Runnable command)

Create a thread with the given thread builder and use it to execute the given runnable.

Parameters
threadBuilder:Object

The thread builder to use to create a thread

command:Runnable

The command to run