Akka Protobuf V3 is a shaded version of the Google protobuf runtime library that renames com.google.protobuf.** to akka.protobufv3.internal.** to avoid conflicts with other protobuf versions used in applications.
npx @tessl/cli install tessl/maven-com-typesafe-akka--akka-protobuf-v3_2-13@2.8.0Akka Protobuf V3 is a shaded version of the Google protobuf runtime library that renames com.google.protobuf.** to akka.protobufv3.internal.** to avoid conflicts with other protobuf versions used in applications. This is an internal utility library used by other Akka modules that require protobuf serialization.
All classes are in the akka.protobufv3.internal package namespace (shaded from com.google.protobuf).
import akka.protobufv3.internal.Message;
import akka.protobufv3.internal.ByteString;
import akka.protobufv3.internal.CodedInputStream;
import akka.protobufv3.internal.CodedOutputStream;For Scala projects:
import akka.protobufv3.internal.{Message, ByteString, CodedInputStream, CodedOutputStream}import akka.protobufv3.internal.*;
// Create a ByteString from UTF-8 text
ByteString data = ByteString.copyFromUtf8("Hello, Protocol Buffers!");
// Convert back to string
String text = data.toStringUtf8();
// Serialize ByteString to byte array
byte[] bytes = data.toByteArray();
// Create ByteString from byte array
ByteString restored = ByteString.copyFrom(bytes);
// Parse a message from bytes (example with a hypothetical UserMessage)
// UserMessage message = UserMessage.parseFrom(bytes);Akka Protobuf V3 provides the complete Protocol Buffers Java runtime with several key components:
Message, MessageLite, builders)CodedInputStream, CodedOutputStream, ByteString)Descriptors.*)Timestamp, Duration, Any, wrapper typesJsonFormat)ExtensionRegistry)TextFormat)All functionality is identical to the original Google protobuf-java 3.16.3 library, but with package names changed from com.google.protobuf.** to akka.protobufv3.internal.** to avoid version conflicts in the Akka ecosystem.
Core interfaces and abstract classes for protocol buffer messages, builders, and parsing. Provides the foundation for all protobuf message operations.
interface Message extends MessageLite, MessageOrBuilder {
// Core message interface with full functionality
}
interface MessageLite {
// Lite message interface with minimal functionality
}
abstract class AbstractMessage implements Message {
// Partial implementation of Message interface
}
abstract class GeneratedMessageV3 extends AbstractMessage {
// Base class for generated protocol buffer messages
}Binary serialization, deserialization, and I/O operations for protocol buffer messages. Includes ByteString utilities and coded streams.
class ByteString {
static ByteString copyFrom(byte[] bytes);
static ByteString copyFromUtf8(String text);
byte[] toByteArray();
String toStringUtf8();
ByteString substring(int beginIndex);
ByteString concat(ByteString other);
}
class CodedInputStream {
static CodedInputStream newInstance(byte[] buf);
static CodedInputStream newInstance(InputStream input);
// Read methods for various protobuf types
}
class CodedOutputStream {
static CodedOutputStream newInstance(byte[] flatArray);
static CodedOutputStream newInstance(OutputStream output);
// Write methods for various protobuf types
}Runtime reflection API for dynamically working with protocol buffer message types, fields, and schemas without generated code.
class Descriptors {
static class Descriptor {
// Describes a message type
String getName();
String getFullName();
List<FieldDescriptor> getFields();
}
static class FieldDescriptor {
// Describes a field in a message
String getName();
FieldType getType();
boolean isRepeated();
}
static class FileDescriptor {
// Describes a .proto file
String getName();
List<Descriptor> getMessageTypes();
}
}
class DynamicMessage implements Message {
// Can represent arbitrary message types given a Descriptor
static DynamicMessage newBuilder(Descriptor type);
}Standard protocol buffer types including timestamps, durations, Any messages, and wrapper types for primitives.
class Timestamp implements Message {
// Represents a point in time
long getSeconds();
int getNanos();
static Builder newBuilder();
}
class Duration implements Message {
// Represents a span of time
long getSeconds();
int getNanos();
static Builder newBuilder();
}
class Any implements Message {
// Contains an arbitrary serialized message
String getTypeUrl();
ByteString getValue();
static Builder newBuilder();
}Utilities for converting protocol buffer messages to and from JSON format, with configurable options and type registry support.
class JsonFormat {
static class Parser {
// Parse JSON to protobuf message
Parser ignoringUnknownFields();
Parser usingTypeRegistry(TypeRegistry registry);
void merge(String json, Message.Builder builder);
}
static class Printer {
// Convert protobuf message to JSON
Printer includingDefaultValueFields();
Printer preservingProtoFieldNames();
String print(MessageOrBuilder message);
}
static Parser parser();
static Printer printer();
}Human-readable text representation of protocol buffer messages for debugging, logging, and configuration files.
class TextFormat {
// Utilities for converting messages to/from text format
static String printToString(MessageOrBuilder message);
static void merge(Readable input, Message.Builder builder) throws IOException;
static Printer printer();
static Parser parser();
}
class TextFormatParseException extends IOException {
// Exception thrown when text format parsing fails
String getMessage();
int getLine();
int getColumn();
}Support for protocol buffer extensions allowing fields to be added to messages without modifying the original .proto files.
class Extension<ContainingType, Type> {
// Represents a protocol buffer extension
}
class ExtensionRegistry {
// Registry for protocol buffer extensions
static ExtensionRegistry newInstance();
void add(Extension<?, ?> extension);
ExtensionRegistry getUnmodifiable();
}
class ExtensionRegistryLite {
// Lite version of extension registry
static ExtensionRegistryLite newInstance();
}Exception types and error handling mechanisms for protocol buffer operations.
class InvalidProtocolBufferException extends IOException {
// Exception thrown when parsing invalid protocol buffer data
static InvalidProtocolBufferException truncatedMessage();
static InvalidProtocolBufferException negativeSize();
static InvalidProtocolBufferException malformedVarint();
static InvalidProtocolBufferException invalidTag();
static InvalidProtocolBufferException invalidEndTag();
static InvalidProtocolBufferException invalidWireType();
static InvalidProtocolBufferException recursionLimitExceeded();
static InvalidProtocolBufferException sizeLimitExceeded();
}
class UnknownFieldSet implements MessageLite {
// Container for fields that were parsed but not recognized
static UnknownFieldSet getDefaultInstance();
static Builder newBuilder();
Map<Integer, Field> asMap();
boolean hasField(int number);
Field getField(int number);
}