CleanerJava25.java — netty Source File
Architecture documentation for CleanerJava25.java, a java file in the netty codebase.
Entity Profile
Relationship Graph
Source Code
/*
* Copyright 2025 The Netty Project
*
* The Netty Project licenses this file to you under the Apache License,
* version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at:
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.util.internal;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.nio.ByteBuffer;
import static java.lang.invoke.MethodType.methodType;
/**
* Provide a way to clean direct {@link ByteBuffer} instances on Java 24+,
* where we don't have {@code Unsafe} available, but we have memory segments.
*/
final class CleanerJava25 implements Cleaner {
private static final InternalLogger logger;
private static final MethodHandle INVOKE_ALLOCATOR;
static {
boolean suitableJavaVersion;
if (System.getProperty("org.graalvm.nativeimage.imagecode") != null) {
// native image supports this since 25, but we don't use PlatformDependent0 here, since
// we need to initialize CleanerJava25 at build time.
String v = System.getProperty("java.specification.version");
try {
suitableJavaVersion = Integer.parseInt(v) >= 25;
} catch (NumberFormatException e) {
suitableJavaVersion = false;
}
// also need to prevent initializing the logger at build time
logger = null;
} else {
// Only attempt to use MemorySegments on Java 25 or greater, because of the following JDK bugs:
// - https://bugs.openjdk.org/browse/JDK-8357145
// - https://bugs.openjdk.org/browse/JDK-8357268
suitableJavaVersion = PlatformDependent0.javaVersion() >= 25;
logger = InternalLoggerFactory.getInstance(CleanerJava25.class);
}
MethodHandle method;
Throwable error;
if (suitableJavaVersion) {
try {
// ... (165 more lines)
Domain
Subdomains
Source
Frequently Asked Questions
What does CleanerJava25.java do?
CleanerJava25.java is a source file in the netty codebase, written in java. It belongs to the CommonUtil domain, Internal subdomain.
Where is CleanerJava25.java in the architecture?
CleanerJava25.java is located at common/src/main/java/io/netty/util/internal/CleanerJava25.java (domain: CommonUtil, subdomain: Internal, directory: common/src/main/java/io/netty/util/internal).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free