Skip to content

yeaya/libjdk

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

libjdk

License Platforms

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.

Overview

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.

Features

  • 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

Supported Modules

The project includes implementations of the following Java modules:

Core Modules

Networking & Communication

Database & Transactions

Desktop & UI

Management & Monitoring

Additional Modules

Core Runtime Features

Reflection Support

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

Garbage Collection

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

Performance Characteristics

  • 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

Requirements

  • 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)

Building

Basic Build

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 Release

Project Structure

libjdk/
├── 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 implementation
  • test/ - Test suites
  • legal/ - Legal notices and attributions
  • CMakeLists.txt - Module build configuration
  • README.md - Module documentation

Usage

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);
	});
}

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Ensure all tests pass
  6. Submit a pull request

License

This project is licensed under the GNU General Public License v2.0 with the Classpath Exception. See the LICENSE file for details.

Acknowledgments

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.

Version

Current version: 17.35

Support

For questions, issues, or contributions, please refer to the project's issue tracker or contact the maintainers.

About

libjdk is a C++ version JDK

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 98.9%
  • Other 1.1%