| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Security enhancements: - Enable strict compiler flags (-Werror, -Wextra, -Wconversion) - Add stack protection and buffer overflow detection - Implement proper object file compilation with security flags Version tracking: - Embed PROJECT_VERSION from Maven into native library - Add getVersion0() native method and VERSION constant - Log native library version on load Error handling improvements: - Enhance exception safety in JNI layer - Add proper unused parameter handling - Fix platform-specific conditional compilation Bug fixes: - Fix unused function warning with conditional compilation - Remove duplicate JNI_OnLoad definitions - Fix syntax error in MacOSX.c - Make MacOSX.c compilation conditional on Darwin platform Testing: - Add 27 comprehensive tests for new functionality - Test version tracking, library loading, and error handling - Verify thread safety and memory safety - Total test count increased from 70 to 97 tests All tests pass (97/97), build verified with mvn clean verify. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…ing; remove deprecated JNA version check
# Conflicts: # affinity-test/pom.xml # affinity/pom.xml
| Back | FazBrowse Home | New Git URL |
This PR hardens the Java-Thread-Affinity module across native code, affinity selection, and timing paths, while adding explicit architecture docs and quality profiles. It also introduces shared AGENTS.md guidance for AI and human contributors, and a Claude-specific helper file.
Functional changes
Affinity selection and JNA fallback
Refactored Affinity initialiser to:
Native JNI affinity and timer behaviour
Hardened NativeAffinity JNI layer:
Strengthened JNIClock:
Native build pipeline
Reworked affinity/src/main/c/Makefile:
Locking and inter-process coordination
Updated FileLockBasedLockChecker:
Tightened LockCheck helper methods (storePid, isLockFree) by making the synchronized flag placement conventional and explicit.
JNA-based affinity helpers
Enriched LinuxHelper, LinuxJNAAffinity, PosixJNAAffinity, WindowsJNAAffinity, OSXJNAAffinity, SolarisJNAAffinity, Utilities, and VersionHelper with class-level Javadoc capturing:
Normalised ThreadLocal naming (THREAD_ID → threadId) to better reflect intent and avoid Checkstyle noise.
Ensured LinuxJNAAffinity and PosixJNAAffinity handle missing native helpers gracefully (do not throw from static initialisers, rely on LOADED flags).
Ticker and affinity APIs
Documented BootClassPath, LockInventory, ticker packages, and affinity packages with package-info.java:
Adjusted MicroJitterSampler busy-wait loop to use an empty while body without a trailing semicolon in the same line, clarifying intent.
Tests and safety nets
Added/updated tests to cover new behaviour:
AffinitySelectionAndFallbackTest and AffinityJnaUnavailableSimulationTest verify default selection on Linux and fallback to NullAffinity when JNA is genuinely absent.
LinuxAffinityParityTest exercises JNI vs JNA affinity parity on Linux, validating that masks intersect correctly when set via either path.
JNIClockBasicBehaviourTest and updated JNIClockTest validate tick changes, monotonic nanoTime behaviour, concurrent access, and tolerance bounds compared to System.nanoTime.
NativeAffinityEdgeCaseTest, NativeAffinityErrorHandlingTest, NativeAffinityLibraryLoadingTest, NativeAffinityVersionTest, and NativeAffinityVersionIntegrationTest cover:
Updated existing tests:
Added an OSGi test package net.openhft.affinity.osgi with package-info.java describing its role in verifying bundle packaging and service exposure.
Docs and guidance
Introduced root-level AGENTS.md:
Added affinity/AGENTS.md to inherit repository rules and add module-specific guidelines (affinity purpose, build commands, quality gates, and platform guardrails).
Added CLAUDE.md with:
Architecture and requirements docs
Added affinity/src/main/docs/decision-log.adoc capturing key architectural choices:
Added affinity/src/main/docs/project-requirements.adoc:
Miscellaneous functional tweaks
Non-functional / quality changes
Quality profiles and static analysis
Introduced a quality Maven profile in:
Each quality profile:
Documented in TODO.md that affinity and affinity-test are now Checkstyle/SpotBugs-clean on Java 21 under the shared Chronicle configuration.
BOM and dependency alignment
Docs front-matter and AsciiDoc consistency
Added common header attributes to:
Marked code sections in README.adoc with opts=novalidate where appropriate to avoid spurious AsciiDoc validation warnings.
Standardised AsciiDoc formatting guidance in AGENTS.md and ensured the new docs follow the same rules (automatic section numbering, no manual prefixes, correct list indentation).
Repository TODO and compliance traceability
Introduced a repository-scoped TODO.md that:
Security and robustness improvements
Native code:
Java:
AGENTS.md now includes a security checklist reminding reviewers to assess validation, authorisation, resource exhaustion, timing, and secrets handling on every PR.
Notes for reviewers
Behavioural scope
Affinity semantics are preserved by design: JNA remains the default for affinity control, JNI remains opt-in via NativeAffinity, and NullAffinity is the safety net when native support is missing.
The main behaviour changes are:
Risk / impact
Risk is primarily around native integration on Linux/macOS; the new tests and error-handling paths are intended to reduce this by: