libjdk is a comprehensive C++ implementation of the Java Development Kit (JDK), providing native C++ libraries that mirror the functionality of Java's core libraries and modules. While it provides Java-like APIs, it runs as native C++ code without requiring a Java Virtual Machine.
libjdk is a complete C++ reimplementation of the Java Development Kit, offering native performance while maintaining compatibility with Java's API design patterns. This project provides C++ libraries that correspond to Java's modular system, allowing developers to leverage Java's well-designed APIs in C++ applications.
- Complete JDK Implementation: Full implementation of Java's core libraries and modules
- Cross-Platform Support: Supports Windows, Linux, and macOS
- Modular Architecture: Follows Java's module system for clean separation of concerns
- Native Performance: C++ implementation provides better performance than JNI
- Reflection Support: Complete reflection API implementation for runtime type inspection and manipulation
- High-Performance Garbage Collection: Ultra-low latency automatic memory management with sub-millisecond pause times
- CMake Build System: Modern, cross-platform build configuration
- Comprehensive Testing: Extensive test suites for each module
The project includes implementations of the following Java modules:
- java.base - Core Java classes and utilities
- java.compiler - Java compiler API
- java.logging - Logging framework
- java.xml - XML processing
- java.xml.crypto - XML cryptography
- java.net.http - HTTP client
- java.rmi - Remote Method Invocation
- java.naming - Naming and directory services
- java.security.sasl - SASL authentication
- java.security.jgss - Generic Security Services
- java.sql - Database connectivity
- java.sql.rowset - RowSet implementations
- java.transaction.xa - XA transaction support
- java.desktop - Desktop applications
- java.datatransfer - Data transfer operations
- java.prefs - User preferences
- java.management - Management and monitoring
- java.management.rmi - RMI-based management
- java.instrument - Java instrumentation
- java.scripting - Scripting engine
- jdk.compiler - JDK compiler tools
- jdk.httpserver - HTTP server
- jdk.charsets - Character set support
- jdk.localedata - Locale data
- jdk.net - Network utilities
- jdk.unsupported - Unsupported APIs
- jdk.jartool - jar tool
- jdk.zipfs - ZIP file system
- java.se - Java SE platform
libjdk provides comprehensive reflection capabilities that allow runtime inspection and manipulation of classes, methods, fields, and annotations:
- Class Introspection: Get class information, superclasses, interfaces, and modifiers
- Method Reflection: Invoke methods dynamically, inspect method signatures and annotations
- Field Access: Read and modify field values, including private fields
- Constructor Reflection: Create object instances using constructor reflection
- Annotation Processing: Access and process runtime annotations
- Generic Type Information: Full support for Java generics and type parameters
- Proxy Generation: Dynamic proxy creation for interface implementations
libjdk implements high-performance, low-latency automatic memory management:
- Ultra-Low Latency: Sub-millisecond pause times for real-time applications
- High Throughput: Optimized for maximum application performance
- Predictable Pauses: Bounded pause times for consistent application behavior
- Memory Efficiency: Advanced algorithms for optimal memory utilization
- Automatic Memory Management: No manual memory allocation/deallocation required
- Memory Monitoring: Built-in tools for monitoring memory usage and GC performance
- Weak References: Support for weak, soft, and phantom references
- Finalization: Automatic cleanup of resources when objects become unreachable
- Pause Time: < 1ms for most operations
- Throughput: > 95% application time utilization
- Scalability: Efficient handling of large heaps (GB+)
- Real-time Ready: Suitable for latency-sensitive applications
- CMake: Version 3.23 or higher
- C++ Compiler: Supporting C++17 or later
- Platform Support:
- Windows (x86_64, aarch64)
- Linux (x86_64, aarch64)
- macOS (x86_64, aarch64)
git clone --recursive https://github.com/libjdk/libjdk libjdk
mkdir build
cmake -S libjdk -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_TEST=ON -G Ninja
cmake --build build --config Releaselibjdk/
├── CMakeLists.txt # Main build configuration
├── libs/ # Module implementations
│ ├── java.base/ # Core Java functionality
│ ├── java.compiler/ # Compiler API
│ ├── java.logging/ # Logging framework
│ └── ... # Other modules
├── LICENSE # GPL v2 license with the Classpath Exception
└── README.md # This file
Each module follows a consistent structure:
main/- Source code implementationtest/- Test suiteslegal/- Legal notices and attributionsCMakeLists.txt- Module build configurationREADME.md- Module documentation
After building and installing, you can use the libraries in your C++ projects:
#include <jcpp.h>
int main(int argc, char** argv) {
return $System::launch(argc, argv, false, nullptr, []($StringArray* args)->void {
$System::out->println("hello, world"_s);
});
}- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
This project is licensed under the GNU General Public License v2.0 with the Classpath Exception. See the LICENSE file for details.
This project is based on the OpenJDK source code and follows Java's API design principles. Special thanks to the OpenJDK community for their excellent work on the Java platform.
Current version: 17.35
For questions, issues, or contributions, please refer to the project's issue tracker or contact the maintainers.