🚧 WORK IN PROGRESS: 🚧 This repo is currently under development and is not intended for public usage yet.
protobuf4j is protobuf running as pure Java bytecode.
protoc is widely used by Java developers, unfortunately, invoking it and plugins requires native dependencies or relying on rewrites of the functionality.
By compiling protobuf to Wasm and Wasm to Java bytecode thanks to Chicory we don't need to port the original source code and we have 1:1 functionality out-of-the-box.
protobuf4j provides separate artifacts for different Protocol Buffers major versions:
| Artifact | Protobuf Version | Use When |
|---|---|---|
protobuf4j-v3 |
3.25.x | Your app uses protobuf-java 3.x |
protobuf4j-v4 |
4.28.x | Your app uses protobuf-java 4.x |
Which version should I use?
- Use the version that matches your application's
protobuf-javadependency - Most enterprise applications currently use v3
- v4 is the latest version but may have breaking changes from v3
Add protobuf4j-v3 as a Maven dependency:
<dependency>
<groupId>io.roastedroot</groupId>
<artifactId>protobuf4j-v3</artifactId>
<version>0.0.1</version>
</dependency>Add protobuf4j-v4 as a Maven dependency:
<dependency>
<groupId>io.roastedroot</groupId>
<artifactId>protobuf4j-v4</artifactId>
<version>0.0.1</version>
</dependency>To build this project, you'll need:
- Docker (for building WASM modules)
- JDK 11 or newer
- Maven
Build both WASM modules and all Maven artifacts:
# Build WASM modules for both v3 and v4
make build
# Build and install Maven artifacts
mvn clean installBuild only what you need:
# Build only v3
make build-v3
mvn install -pl core-v3
# Build only v4
make build-v4
mvn install -pl core-v4If you already have the WASM modules built:
# Just build/test Java code
mvn clean installprotobuf4j/
├── core-v3/ → protobuf4j-v3 artifact (Protobuf 3.25.x)
├── core-v4/ → protobuf4j-v4 artifact (Protobuf 4.28.x)
├── buildtools/ → WASM build config for v3
├── buildtools-v4/ → WASM build config for v4
└── wasm/ → Compiled WASM modules
This project stands on the shoulders of giants:
- go-protoc-gen-grpc-java - enables invoking protoc and plugins in pure Go thanks to wazero
- Chicory – a native JVM WebAssembly runtime