Skip to content

yeaya/java.base

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

102 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

libjdk - Java Base Library

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

This project provides a complete C++ implementation of Java's core functionality, including:

  • Core Java Classes: Object, String, Integer, Boolean, Character, and all primitive wrapper classes
  • Collections Framework: Complete collection interfaces and implementations including HashMap, ArrayList, LinkedList, HashSet, TreeMap, etc.
  • I/O Operations: File handling, streams, and serialization
  • Concurrency: Thread management and synchronization primitives
  • Exception Handling: Complete exception hierarchy
  • Reflection: Class introspection and dynamic method invocation
  • Platform-specific Implementations: Native code for Windows, Linux, and macOS

Features

  • Cross-platform Support: Windows, Linux, and macOS
  • CMake Build System: Modern, portable build configuration
  • Comprehensive Testing: Extensive test suite included
  • OpenJDK Compatible: Based on OpenJDK 17.35
  • GPL Licensed: Free software with Classpath exception

Project Structure

java.base/
├── main/                   # Main source code
│   ├── share/              # Platform-independent code
│   │   ├── classes/        # Java class implementations
│   │   ├── include/        # Header files
│   │   └── native/         # Native implementations
│   ├── windows/            # Windows-specific code
│   ├── linux/              # Linux-specific code
│   └── macos/              # macOS-specific code
├── test/                   # Test suite
├── legal/                  # Legal notices and licenses
└── CMakeLists.txt          # Build configuration

Dependencies

This project includes several third-party libraries with appropriate licensing:

  • OpenJDK: Core Java implementation (GPL v2 with Classpath exception)
  • ICU: Internationalization support
  • zlib: Compression library
  • libffi: Foreign function interface
  • ASM: Bytecode manipulation
  • AES: Encryption support
  • Unicode: Character set support
  • CLDR: Locale data
  • wepoll: Windows event polling

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

To build the example/helloworld project, follow these steps:

  1. Clone java.base repository:

    git clone https://github.com/libjdk/java.base.git
  2. Create a build directory:

    mkdir java.base.build
  3. Run CMake to configure the java.base:

    cmake -S java.base -B java.base.build  -DCMAKE_BUILD_TYPE=Release
  4. Build the java.base and install it to the repository:

    cmake --build java.base.build --config Release --target install -j 8

Basic Example

#include <jcpp.h>

int main(int argc, char** argv) {
	return $System::launch(argc, argv, 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 with the Classpath exception, allowing linking with proprietary software. See the LICENSE file for details.

Legal Notices

This project includes code from various open source projects. See the legal/ directory for detailed licensing information for each component.

About

java.base module, libjdk is a C++ version JDK

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • C++ 94.9%
  • C 4.4%
  • Assembly 0.5%
  • CMake 0.2%
  • Objective-C 0.0%
  • DIGITAL Command Language 0.0%