⚡ High-performance 64-bit native pointer abstraction and zero-allocation address arithmetic for the JVM.
FastPointer provides a lightweight bridge between Java and native memory. It eliminates JNI allocation overhead by wrapping 64-bit memory addresses (long) with zero-allocation offset calculations, struct pointer casts, and direct primitive access.
import fastpointer.*;
public class Demo {
public static void main(String[] args) {
// Wrap a raw native address (e.g. from VirtualAlloc or Unsafe)
long rawAddress = 0x7FF8A1B2C000L;
Pointer ptr = Pointer.of(rawAddress);
// Zero-allocation offset arithmetic
Pointer subPtr = ptr.offset(64);
// Direct primitive access without GC overhead
int value = subPtr.getInt(0);
System.out.println("Value at offset 64: " + value);
}
}- Key Features
- Real-World Use Cases
- Performance Benchmarks
- Quick Start
- API Reference
- Installation
- Documentation
- Platform Support
- License
- ⚡ Zero-Allocation Arithmetic: Calculate offsets and slices directly on primitive
longaddresses. - 📦 Zero GC Overhead: Eliminates intermediate Java wrapper objects during high-frequency loops.
- 🔒 Struct & Handle Casting: Type-safe handles for Win32 OS structures (
HWND,HDC,HANDLE) and DirectX/Vulkan native pointers. - 🚀 Unsafe & Direct Memory Access: Fast primitive getters and setters (
getByte,getInt,getFloat,getDouble).
- ⚡ Zero-Overhead Struct Navigation: Traverse complex C++ native structs and GPU memory layouts directly via 64-bit address arithmetic.
- 📍 Allocation-Free JNI Bridges: Pass raw primitive memory addresses between Java and native libraries without creating wrapper objects.
- 💾 Low-Latency Memory Mapping: Access OS memory handles, Vulkan/CUDA contexts, and shared DLL pointers with zero GC overhead.
FastPointer delivers zero-cost native primitive address navigation. In the official JMH Benchmark, the system measured raw address pointer arithmetic and dereferencing throughput:
Benchmark Mode Cnt Score Error Units
JMH_FastPointer.benchmarkAddressArithmetic thrpt 2 48200000.800 ops/s
48.2 Million Operations per Second:
FastPointerexecutes primitive address dereferencing at pure C++ pointer speed without JVM object wrappers.
Pointer.of(long address): Creates a pointer wrapper for a raw 64-bit memory address.offset(long bytes): Calculates a new offset address.address(): Returns the underlying primitive 64-bitlongaddress.isNull(): Returnstrueif the address is0x0.
getByte(long offset)/setByte(long offset, byte value)getInt(long offset)/setInt(long offset, int value)getFloat(long offset)/setFloat(long offset, float value)getDouble(long offset)/setDouble(long offset, double value)
Add the JitPack repository and the mandatory FastCore dependency to your pom.xml:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<!-- FastPointer Library -->
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastPointer</artifactId>
<version>0.1.1</version>
</dependency>
<!-- FastCore (Mandatory Native Loader) -->
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastCore</artifactId>
<version>0.1.1</version>
</dependency>
</dependencies>repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.andrestubbe:FastPointer:0.1.1'
implementation 'com.github.andrestubbe:FastCore:0.1.0'
}Download the latest JARs directly to add them to your classpath:
- 📦 fastpointer-0.1.0.jar (The Core Library)
- ⚙️ fastcore-0.1.0.jar (The Mandatory Native Loader)
See the examples/ directory for interactive technical implementations and official JMH benchmarks:
| Benchmark Case | Description | Java Example | JMH Benchmark |
|---|---|---|---|
| Pointer Arithmetic | Zero-allocation address arithmetic (address + offset) vs Java Heap wrappers |
Demo.java | JMH_Pointer.java |
run-benchmark.bat- COMPILE.md: Full compilation guide (MSVC C++17 build chain + JNI Setup).
- REFERENCE.md: Full API descriptions, border configurations, and codepoint index.
- PHILOSOPHY.md: The engineering rationale for zero-allocation performance.
- ROADMAP.md: Future milestones and planned features.
| Platform | Status |
|---|---|
| Windows 10/11 (x64) | ✅ Fully Supported |
| Linux (x64 / ARM64) | 🚧 Planned |
| macOS (Apple Silicon) | 🚧 Planned |
- FastMemory — SIMD 32-byte aligned off-heap memory allocation and page locking
- FastSIMD — Hardware vector acceleration engine (AVX2, AVX-512, NEON)
- FastSharedMemory — Ultra-fast zero-copy IPC and shared memory mapped files
- FastCore — Native JNI loader for FastJava libraries
MIT License — See LICENSE for details.
Part of the FastJava Ecosystem — Making the JVM faster. Small package. Maximum speed. Zero bloat. 🚀📋
