Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
53eef04
Remove unused imports and improve code readability in test classes
peter-lawrey Nov 19, 2025
a6de1b0
Add CLAUDE.md and GEMINI.md for project guidance and documentation
peter-lawrey Nov 19, 2025
d1fb50e
Refine documentation formatting for clarity and consistency
peter-lawrey Nov 19, 2025
a89ca85
Update GEMINI.md to enhance guidance for AI assistants and developers
peter-lawrey Nov 20, 2025
d14d481
Set compile scope for JetBrains annotations dependency
peter-lawrey Nov 20, 2025
784325c
Refactor StringUtils to use ISO-8859-1 encoding and clean up unused code
peter-lawrey Nov 20, 2025
2c07f1e
Merge remote-tracking branch 'origin/develop' into adv/develop
peter-lawrey Nov 20, 2025
c36c814
Code Analysis fixes
peter-lawrey Nov 21, 2025
78b7268
Code Analysis fixes
peter-lawrey Nov 21, 2025
1c4ce08
Code Analysis fixes
peter-lawrey Nov 21, 2025
719d323
Refactor MemoryUnit and HashTestSupport classes; add package-info doc…
peter-lawrey Nov 24, 2025
24373af
Remove unnecessary blank lines in various classes for improved code r…
peter-lawrey Nov 24, 2025
86edf04
Remove unnecessary blank lines in various classes for improved code r…
peter-lawrey Nov 24, 2025
ac9f60c
Make cleanupNonCleaningThreads synchronized to ensure thread safety
peter-lawrey Nov 24, 2025
0fc5dde
Remove unused import and ignore annotation in InvocationTargetRuntime…
peter-lawrey Nov 26, 2025
870c3ec
Mark multiple methods and classes as deprecated, scheduled for remova…
peter-lawrey Nov 27, 2025
f505e66
Remove unused HotMethod annotation from MediumEventLoop and MonitorEv…
peter-lawrey Nov 27, 2025
12d0c72
Enhance message retrieval logic in ExceptionKey; improve error handli…
peter-lawrey Nov 28, 2025
607519b
Merge branch 'adv/javadoc' into adv/develop
peter-lawrey Dec 1, 2025
ae6c04e
Merge branch 'adv/javadoc' into adv/develop
peter-lawrey Dec 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<dependency>
<groupId>net.openhft</groupId>
<artifactId>third-party-bom</artifactId>
<version>3.27ea5</version>
<version>3.27ea7</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -85,6 +85,7 @@
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<scope>compile</scope>
</dependency>

<!-- test dependencies -->
Expand Down
1 change: 1 addition & 0 deletions src/main/java/net/openhft/chronicle/core/Bootstrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* Contains the pieces which must be loaded first
*/
public class Bootstrap {
@Deprecated(/* make private in 2026 */)
public Bootstrap() {
}
static {
Expand Down
16 changes: 4 additions & 12 deletions src/main/java/net/openhft/chronicle/core/ChronicleInit.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ public final class ChronicleInit {
public static final String CHRONICLE_INIT_CLASS = "chronicle.init.runnable";
public static final String CHRONICLE_POSTINIT_CLASS = "chronicle.postinit.runnable";

private ChronicleInit() {
// Suppresses default constructor, ensuring non-instantiability.
}

static {
// Jvm#getProperty() does not make sense here - not initialized yet
String initRunnableClass = System.getProperty(CHRONICLE_INIT_CLASS);
Expand All @@ -58,6 +54,10 @@ private ChronicleInit() {
}
}

private ChronicleInit() {
// Suppresses default constructor, ensuring non-instantiability.
}

private static void runQuietly(Runnable runnable) {
try {
runnable.run();
Expand All @@ -66,14 +66,6 @@ private static void runQuietly(Runnable runnable) {
}
}

/**
* May be run multiple times, supposed to be idempotent
*/
@SuppressWarnings("EmptyMethod")
static void init() {
// No-op unless class is replaced
}

/**
* Should be only run once by Jvm.class static block
*/
Expand Down
82 changes: 50 additions & 32 deletions src/main/java/net/openhft/chronicle/core/Jvm.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sun.misc.Signal; // NOSONAR
import sun.misc.Signal;
import sun.misc.Unsafe;
import sun.nio.ch.Interruptible;

Expand All @@ -32,6 +32,8 @@
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.spi.AbstractInterruptibleChannel;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.*;
import java.util.Map.Entry;
Expand Down Expand Up @@ -98,8 +100,8 @@ public final class Jvm {
);
private static final MethodHandle onSpinWaitMH;
private static final ChainedSignalHandler signalHandlerGlobal;
private static boolean RESOURCE_TRACING;
private static final boolean PROC_EXISTS = new File(PROC).exists();
private static boolean RESOURCE_TRACING;
@SuppressWarnings("unused")
private static volatile Thread s_blackHole;

Expand Down Expand Up @@ -144,14 +146,18 @@ public final class Jvm {
if (DISABLE_DEBUG)
logger.info("-Ddisable.debug.info turned of debug logging");
if (logger.isInfoEnabled() && notJUnitTest)
logger.info(String.format("Chronicle core loaded from %s", Jvm.class.getProtectionDomain().getCodeSource().getLocation()));
logger.info("Chronicle core loaded from {}", Jvm.class.getProtectionDomain().getCodeSource().getLocation());
if (RESOURCE_TRACING && !Jvm.getBoolean("disable.resource.warning"))
logger.warn("Resource tracing is turned on. If you are performance testing or running in PROD you probably don't want this");
REPORT_UNOPTIMISED = Jvm.getBoolean("report.unoptimised");

ChronicleInit.postInit();
}

// Suppresses default constructor, ensuring non-instantiability.
private Jvm() {
}

private static MethodHandle getOnSpinWait() {
MethodType voidType = MethodType.methodType(void.class);
MethodHandles.Lookup lookup = MethodHandles.lookup();
Expand All @@ -170,10 +176,6 @@ private static MethodHandle getOnSpinWait() {
return null;
}

// Suppresses default constructor, ensuring non-instantiability.
private Jvm() {
}

public static void reportUnoptimised() {
if (!REPORT_UNOPTIMISED)
return;
Expand Down Expand Up @@ -207,7 +209,6 @@ else if (new File("../" + SYSTEM_PROPERTIES).exists())

public static void init() {
// force static initialisation
ChronicleInit.init();
}

private static void loadSystemProperties(final String name, final boolean wasSet) {
Expand All @@ -217,7 +218,7 @@ private static void loadSystemProperties(final String name, final boolean wasSet
if (is0 == null) {
File file = new File(name);
if (file.exists())
is0 = new FileInputStream(file);
is0 = Files.newInputStream(file.toPath());
}
try (InputStream is = is0) {
if (is == null) {
Expand Down Expand Up @@ -282,6 +283,7 @@ public static boolean isJava9Plus() {
/**
* @return if the major Java version is 12 or higher
*/
@Deprecated(/* to be removed in 2027, only used in tests */)
public static boolean isJava12Plus() {
return Bootstrap.isJava12Plus();
}
Expand Down Expand Up @@ -396,6 +398,7 @@ public static boolean isDebug() {
* @return if the JVM is running in flight recorder mode
*/
@SuppressWarnings("SameReturnValue")
@Deprecated(/* to be removed in 2027 */)
public static boolean isFlightRecorder() {
return IS_FLIGHT_RECORDER;
}
Expand Down Expand Up @@ -568,6 +571,7 @@ public static <V> V getValue(@NotNull Object target, @NotNull final String field
* @param lock to log
* @return the lock.toString plus a stack trace.
*/
@Deprecated(/* to be removed in 2027 */)
public static String lockWithStack(@NotNull final ReentrantLock lock) {
final Thread t = getValue(lock, "sync/exclusiveOwnerThread");
if (t == null) {
Expand Down Expand Up @@ -602,6 +606,7 @@ public static long fieldOffset(final Class<?> clazz, final String fieldName) {
* @return the accumulated amount of memory in bytes used by direct ByteBuffers
* or 0 if the value cannot be determined
*/
@Deprecated(/* to be removed in 2027, only used in tests */)
public static long usedDirectMemory() {
return ReserveMemoryHolder.reservedMemory.get();
}
Expand All @@ -611,6 +616,7 @@ public static long usedDirectMemory() {
*
* @return the accumulated amount of memory used in bytes by UnsafeMemory.allocate()
*/
@Deprecated(/* to be removed in 2027, only used in tests */)
public static long usedNativeMemory() {
return UnsafeMemory.INSTANCE.nativeMemoryUsed();
}
Expand Down Expand Up @@ -749,6 +755,7 @@ public static void setThreadLocalExceptionHandlers(@Nullable final ExceptionHand
((ThreadLocalisedExceptionHandler) DEBUG).threadLocalHandler(debug);
}

@Deprecated(/* to be removed in 2027 */)
public static void setThreadLocalExceptionHandlers(@Nullable final ExceptionHandler error,
@Nullable final ExceptionHandler warn,
@Nullable final ExceptionHandler debug,
Expand Down Expand Up @@ -860,6 +867,7 @@ public static void safepoint() {
}
}

@Deprecated(/* to be removed in 2027, only used in tests */)
public static boolean areOptionalSafepointsEnabled() {
return SAFEPOINT_ENABLED;
}
Expand All @@ -873,6 +881,7 @@ public static boolean areOptionalSafepointsEnabled() {
* @return if there is a class name that ends with the provided {@code endsWith} string
* when examining the current stack trace of depth at most up to the provided {@code maxDepth}
*/
@Deprecated(/* to be removed in 2027 */)
public static boolean stackTraceEndsWith(final String endsWith, final int maxDepth) {
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
for (int i = maxDepth + 2; i < stackTrace.length; i++)
Expand Down Expand Up @@ -908,6 +917,7 @@ public static boolean isMacArm() {
* @see ClassMetrics
*/
@NotNull
@Deprecated(/* to be removed in 2027, only used in tests */)
public static ClassMetrics classMetrics(final Class<?> clazz) throws IllegalArgumentException {
return CLASS_METRICS_MAP.computeIfAbsent(clazz, Jvm::getClassMetrics);
}
Expand Down Expand Up @@ -958,6 +968,7 @@ private static void validateClassMetrics(final Class<?> c,
* if the user's home director cannot be determined
*/
@NotNull
@Deprecated(/* to be removed in 2027 */)
public static String userHome() {
return System.getProperty("user.home", ".");
}
Expand Down Expand Up @@ -1220,6 +1231,7 @@ public void interrupt(Thread target) {
ci.interrupt();
}

@SuppressWarnings({"EmptyMethod", "unused"})
public void postInterrupt() {
// added in Java 23+
}
Expand Down Expand Up @@ -1335,21 +1347,25 @@ public static boolean isProcessAlive(long pid) {
@SuppressWarnings("deprecation")
private static boolean isProcessAlive0(final long pid, final String command) {

Process process = null;
try {
InputStreamReader isReader = new InputStreamReader(
getRuntime().exec(command).getInputStream());

final BufferedReader bReader = new BufferedReader(isReader);
String strLine;
while ((strLine = bReader.readLine()) != null) {
if (strLine.contains(" " + pid + " ") || strLine.startsWith(pid + " ")) {
return true;
process = getRuntime().exec(command);
try (BufferedReader bReader = new BufferedReader(
new InputStreamReader(process.getInputStream(), StandardCharsets.UTF_8))) {
String strLine;
while ((strLine = bReader.readLine()) != null) {
if (strLine.contains(" " + pid + " ") || strLine.startsWith(pid + " ")) {
return true;
}
}
}

return false;
} catch (Exception ex) {
return true;
} finally {
if (process != null) {
process.destroy();
}
}
}

Expand Down Expand Up @@ -1523,6 +1539,17 @@ public static String getPackageName(Class<?> clazz) {
return PackageNameUtil.getPackageName(clazz);
}

private static boolean isJUnitTest0() {
for (StackTraceElement[] stackTrace : Thread.getAllStackTraces().values()) {
for (StackTraceElement element : stackTrace) {
if (element.getClassName().contains(".junit")) {
return true;
}
}
}
return false;
}

public interface SignalHandler {
/**
* Handle a Signal
Expand Down Expand Up @@ -1569,7 +1596,7 @@ private Safepoint() {
public static void force() {
// trick only works from Java 9+
//noinspection StatementWithEmptyBody
for (int i = 0; i < one; i++) ;
for (int i = 0; i < one; i++);
}
}

Expand Down Expand Up @@ -1632,21 +1659,9 @@ public void handle(final Signal signal) {
}
}

private static boolean isJUnitTest0() {
for (StackTraceElement[] stackTrace : Thread.getAllStackTraces().values()) {
for (StackTraceElement element : stackTrace) {
if (element.getClassName().contains(".junit")) {
return true;
}
}
}
return false;
}

static class ReserveMemoryHolder {
private ReserveMemoryHolder() {
}
static final Supplier<Long> reservedMemory;

static {
Supplier<Long> reservedMemoryGetter;
try {
Expand All @@ -1666,6 +1681,9 @@ private ReserveMemoryHolder() {
}
reservedMemory = reservedMemoryGetter;
}

private ReserveMemoryHolder() {
}
}

static class MaxMemoryHolder {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/openhft/chronicle/core/LicenceCheck.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.time.temporal.ChronoUnit;
import java.util.function.BiConsumer;

import static java.nio.charset.StandardCharsets.UTF_8;
import static net.openhft.chronicle.core.Jvm.startup;
import static net.openhft.chronicle.core.Jvm.warn;

Expand Down Expand Up @@ -72,7 +73,7 @@ static void licenceExpiry(String product, Class<?> caller, BiConsumer<Long, Stri
if (key == null || !key.contains(product + '.')) {
String expiryDateFile = product + ".expiry-date";
try {
String source = new String(IOTools.readFile(LicenceCheck.class, expiryDateFile));
String source = new String(IOTools.readFile(LicenceCheck.class, expiryDateFile), UTF_8);
LocalDate expiryDate = LocalDate.parse(source.trim());
long days = ChronoUnit.DAYS.between(LocalDate.now(), expiryDate);
if (days < 0)
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/net/openhft/chronicle/core/Maths.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
@SuppressWarnings({"java:S1940", "java:S3358"})
public final class Maths {

// Suppresses default constructor, ensuring non-instantiability.
private Maths() {
}

/**
* Numbers larger than this are whole numbers due to representation error.
*/
Expand All @@ -42,6 +38,10 @@ private Maths() {
FIVES[i] = 5 * FIVES[i - 1];
}

// Suppresses default constructor, ensuring non-instantiability.
private Maths() {
}

/**
* Rounds the value to a fixed number of decimal places.
* The result is within one ulp of the mathematical rounding and
Expand All @@ -66,6 +66,7 @@ public static double roundN(double d, int digits) {
* @param d value to round
* @return rounded value
*/
@Deprecated(/* to be removed in 2027 */)
public static double roundNup(double d, int digits) {
if (d < 0)
return -roundNup(-d, digits);
Expand Down
Loading