Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ Regenerate after editing `.fbs`/`.proto` (both generators are in-house, no exter
Both schema languages are compiled in-process to MemorySegment-native Java, with no
`flatc`/`protoc` and no `com.google.flatbuffers`/`protobuf-java` runtime (ADR 0017):
- **`.fbs` → `fbs-gen`** (`io.github.dfa1.vortex.fbsgen`): generates readers extending
`FbsTable`/`FbsStruct` and builders over `FbsBuilder` (all in `io.github.dfa1.vortex.fbsrt`).
`FbsTable`/`FbsStruct` and builders over `FbsBuilder`, all in the same generated package
`io.github.dfa1.vortex.fbs`. The runtime base classes `FbsTable`/`FbsStruct` are
package-private (only generated readers extend them); `FbsBuilder` is public because the
writer module assembles FlatBuffers with it.
- **`.proto` → `proto-gen`**: one record per message with static `decode(MemorySegment, long,
long)` + `encode()` operating directly on a segment.

Expand Down
2 changes: 0 additions & 2 deletions core/src/main/java/io/github/dfa1/vortex/fbs/FbsArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

package io.github.dfa1.vortex.fbs;

import io.github.dfa1.vortex.fbsrt.FbsBuilder;
import io.github.dfa1.vortex.fbsrt.FbsTable;
import java.lang.foreign.MemorySegment;
import javax.annotation.processing.Generated;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

package io.github.dfa1.vortex.fbs;

import io.github.dfa1.vortex.fbsrt.FbsBuilder;
import io.github.dfa1.vortex.fbsrt.FbsTable;
import java.lang.foreign.MemorySegment;
import javax.annotation.processing.Generated;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

package io.github.dfa1.vortex.fbs;

import io.github.dfa1.vortex.fbsrt.FbsBuilder;
import io.github.dfa1.vortex.fbsrt.FbsTable;
import java.lang.foreign.MemorySegment;
import javax.annotation.processing.Generated;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

package io.github.dfa1.vortex.fbs;

import io.github.dfa1.vortex.fbsrt.FbsBuilder;
import io.github.dfa1.vortex.fbsrt.FbsTable;
import java.lang.foreign.MemorySegment;
import javax.annotation.processing.Generated;

Expand Down
2 changes: 0 additions & 2 deletions core/src/main/java/io/github/dfa1/vortex/fbs/FbsBinary.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

package io.github.dfa1.vortex.fbs;

import io.github.dfa1.vortex.fbsrt.FbsBuilder;
import io.github.dfa1.vortex.fbsrt.FbsTable;
import java.lang.foreign.MemorySegment;
import javax.annotation.processing.Generated;

Expand Down
2 changes: 0 additions & 2 deletions core/src/main/java/io/github/dfa1/vortex/fbs/FbsBool.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

package io.github.dfa1.vortex.fbs;

import io.github.dfa1.vortex.fbsrt.FbsBuilder;
import io.github.dfa1.vortex.fbsrt.FbsTable;
import java.lang.foreign.MemorySegment;
import javax.annotation.processing.Generated;

Expand Down
2 changes: 0 additions & 2 deletions core/src/main/java/io/github/dfa1/vortex/fbs/FbsBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

package io.github.dfa1.vortex.fbs;

import io.github.dfa1.vortex.fbsrt.FbsBuilder;
import io.github.dfa1.vortex.fbsrt.FbsStruct;
import java.lang.foreign.MemorySegment;
import javax.annotation.processing.Generated;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.dfa1.vortex.fbsrt;
package io.github.dfa1.vortex.fbs;

import static io.github.dfa1.vortex.encoding.PTypeIO.LE_DOUBLE;
import static io.github.dfa1.vortex.encoding.PTypeIO.LE_FLOAT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

package io.github.dfa1.vortex.fbs;

import io.github.dfa1.vortex.fbsrt.FbsBuilder;
import io.github.dfa1.vortex.fbsrt.FbsTable;
import java.lang.foreign.MemorySegment;
import javax.annotation.processing.Generated;

Expand Down
2 changes: 0 additions & 2 deletions core/src/main/java/io/github/dfa1/vortex/fbs/FbsDType.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

package io.github.dfa1.vortex.fbs;

import io.github.dfa1.vortex.fbsrt.FbsBuilder;
import io.github.dfa1.vortex.fbsrt.FbsTable;
import java.lang.foreign.MemorySegment;
import javax.annotation.processing.Generated;

Expand Down
2 changes: 0 additions & 2 deletions core/src/main/java/io/github/dfa1/vortex/fbs/FbsDecimal.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

package io.github.dfa1.vortex.fbs;

import io.github.dfa1.vortex.fbsrt.FbsBuilder;
import io.github.dfa1.vortex.fbsrt.FbsTable;
import java.lang.foreign.MemorySegment;
import javax.annotation.processing.Generated;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

package io.github.dfa1.vortex.fbs;

import io.github.dfa1.vortex.fbsrt.FbsBuilder;
import io.github.dfa1.vortex.fbsrt.FbsTable;
import java.lang.foreign.MemorySegment;
import javax.annotation.processing.Generated;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

package io.github.dfa1.vortex.fbs;

import io.github.dfa1.vortex.fbsrt.FbsBuilder;
import io.github.dfa1.vortex.fbsrt.FbsTable;
import java.lang.foreign.MemorySegment;
import javax.annotation.processing.Generated;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

package io.github.dfa1.vortex.fbs;

import io.github.dfa1.vortex.fbsrt.FbsBuilder;
import io.github.dfa1.vortex.fbsrt.FbsTable;
import java.lang.foreign.MemorySegment;
import javax.annotation.processing.Generated;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

package io.github.dfa1.vortex.fbs;

import io.github.dfa1.vortex.fbsrt.FbsBuilder;
import io.github.dfa1.vortex.fbsrt.FbsTable;
import java.lang.foreign.MemorySegment;
import javax.annotation.processing.Generated;

Expand Down
2 changes: 0 additions & 2 deletions core/src/main/java/io/github/dfa1/vortex/fbs/FbsFooter.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

package io.github.dfa1.vortex.fbs;

import io.github.dfa1.vortex.fbsrt.FbsBuilder;
import io.github.dfa1.vortex.fbsrt.FbsTable;
import java.lang.foreign.MemorySegment;
import javax.annotation.processing.Generated;

Expand Down
2 changes: 0 additions & 2 deletions core/src/main/java/io/github/dfa1/vortex/fbs/FbsLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

package io.github.dfa1.vortex.fbs;

import io.github.dfa1.vortex.fbsrt.FbsBuilder;
import io.github.dfa1.vortex.fbsrt.FbsTable;
import java.lang.foreign.MemorySegment;
import javax.annotation.processing.Generated;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

package io.github.dfa1.vortex.fbs;

import io.github.dfa1.vortex.fbsrt.FbsBuilder;
import io.github.dfa1.vortex.fbsrt.FbsTable;
import java.lang.foreign.MemorySegment;
import javax.annotation.processing.Generated;

Expand Down
2 changes: 0 additions & 2 deletions core/src/main/java/io/github/dfa1/vortex/fbs/FbsList.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

package io.github.dfa1.vortex.fbs;

import io.github.dfa1.vortex.fbsrt.FbsBuilder;
import io.github.dfa1.vortex.fbsrt.FbsTable;
import java.lang.foreign.MemorySegment;
import javax.annotation.processing.Generated;

Expand Down
2 changes: 0 additions & 2 deletions core/src/main/java/io/github/dfa1/vortex/fbs/FbsNull.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

package io.github.dfa1.vortex.fbs;

import io.github.dfa1.vortex.fbsrt.FbsBuilder;
import io.github.dfa1.vortex.fbsrt.FbsTable;
import java.lang.foreign.MemorySegment;
import javax.annotation.processing.Generated;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

package io.github.dfa1.vortex.fbs;

import io.github.dfa1.vortex.fbsrt.FbsBuilder;
import io.github.dfa1.vortex.fbsrt.FbsTable;
import java.lang.foreign.MemorySegment;
import javax.annotation.processing.Generated;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

package io.github.dfa1.vortex.fbs;

import io.github.dfa1.vortex.fbsrt.FbsBuilder;
import io.github.dfa1.vortex.fbsrt.FbsTable;
import java.lang.foreign.MemorySegment;
import javax.annotation.processing.Generated;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

package io.github.dfa1.vortex.fbs;

import io.github.dfa1.vortex.fbsrt.FbsBuilder;
import io.github.dfa1.vortex.fbsrt.FbsTable;
import java.lang.foreign.MemorySegment;
import javax.annotation.processing.Generated;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

package io.github.dfa1.vortex.fbs;

import io.github.dfa1.vortex.fbsrt.FbsBuilder;
import io.github.dfa1.vortex.fbsrt.FbsStruct;
import java.lang.foreign.MemorySegment;
import javax.annotation.processing.Generated;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.dfa1.vortex.fbsrt;
package io.github.dfa1.vortex.fbs;

import static io.github.dfa1.vortex.encoding.PTypeIO.LE_DOUBLE;
import static io.github.dfa1.vortex.encoding.PTypeIO.LE_FLOAT;
Expand All @@ -15,7 +15,9 @@
/// vtable: every field lives at a compile-time-constant byte offset from the
/// struct position, and every field is always present. Generated accessors read
/// directly at `position + fieldOffset`.
public class FbsStruct {
///
/// Package-private: only the generated struct accessors in this package extend it.
class FbsStruct {

/// The backing buffer.
protected MemorySegment seg;
Expand Down
2 changes: 0 additions & 2 deletions core/src/main/java/io/github/dfa1/vortex/fbs/FbsStruct_.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

package io.github.dfa1.vortex.fbs;

import io.github.dfa1.vortex.fbsrt.FbsBuilder;
import io.github.dfa1.vortex.fbsrt.FbsTable;
import java.lang.foreign.MemorySegment;
import javax.annotation.processing.Generated;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.dfa1.vortex.fbsrt;
package io.github.dfa1.vortex.fbs;

import static io.github.dfa1.vortex.encoding.PTypeIO.LE_DOUBLE;
import static io.github.dfa1.vortex.encoding.PTypeIO.LE_FLOAT;
Expand Down Expand Up @@ -28,7 +28,9 @@
/// expected to have framed the FlatBuffer from a trusted region. File-level framing
/// (segment offsets/lengths, trailer, postscript) is range-checked upstream by the
/// reader's `IoBounds`; intra-FlatBuffer fields are not.
public class FbsTable {
///
/// Package-private: only the generated table accessors in this package extend it.
class FbsTable {

/// The backing buffer (typically a zero-copy slice of the mmap'd file).
protected MemorySegment seg;
Expand All @@ -54,7 +56,7 @@ protected final void init(MemorySegment segment, long position) {
/// @param segment buffer whose first 4 bytes hold the uoffset to the root table
/// @param start byte position of the buffer start within `segment`
/// @return the absolute position of the root table
public static long rootPosition(MemorySegment segment, long start) {
static long rootPosition(MemorySegment segment, long start) {
return start + segment.get(LE_INT, start);
}

Expand Down
2 changes: 0 additions & 2 deletions core/src/main/java/io/github/dfa1/vortex/fbs/FbsUnion.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

package io.github.dfa1.vortex.fbs;

import io.github.dfa1.vortex.fbsrt.FbsBuilder;
import io.github.dfa1.vortex.fbsrt.FbsTable;
import java.lang.foreign.MemorySegment;
import javax.annotation.processing.Generated;

Expand Down
2 changes: 0 additions & 2 deletions core/src/main/java/io/github/dfa1/vortex/fbs/FbsUtf8.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

package io.github.dfa1.vortex.fbs;

import io.github.dfa1.vortex.fbsrt.FbsBuilder;
import io.github.dfa1.vortex.fbsrt.FbsTable;
import java.lang.foreign.MemorySegment;
import javax.annotation.processing.Generated;

Expand Down
2 changes: 0 additions & 2 deletions core/src/main/java/io/github/dfa1/vortex/fbs/FbsVariant.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

package io.github.dfa1.vortex.fbs;

import io.github.dfa1.vortex.fbsrt.FbsBuilder;
import io.github.dfa1.vortex.fbsrt.FbsTable;
import java.lang.foreign.MemorySegment;
import javax.annotation.processing.Generated;

Expand Down
2 changes: 1 addition & 1 deletion docs/adr/0017-in-house-flatbuffers-codegen.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ the in-house path matches byte-for-byte on the full integration suite.

## Known limitations

- **No intra-FlatBuffer bounds checks** in the `fbsrt` read path (e.g.
- **No intra-FlatBuffer bounds checks** in the `FbsTable`/`FbsStruct` read path (e.g.
`FbsTable.readStringAt` allocates `new byte[len]` with `len` from the blob).
Same posture as the previous `com.google.flatbuffers` runtime; file-level framing
is range-checked upstream by `IoBounds`, intra-FlatBuffer fields are not. Trusted-blob
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
/// The wire layout is the standard FlatBuffers binary format — see [FbsTable]/[FbsBuilder].
public final class CodeGen {

private static final String RUNTIME_PACKAGE = "io.github.dfa1.vortex.fbsrt";

/// Prefix applied to every emitted Java class name so the generated wire-format
/// classes (`Array`, `DType`, `Bool`, `List`, …) do not collide with project or JDK
/// types of the same name. Schema files keep the upstream (unprefixed) names; the
Expand Down Expand Up @@ -75,8 +73,7 @@ private static String className(String schemaName) {
private String emitTable(Ast.TableDecl table) {
String name = className(table.name());
StringBuilder sb = new StringBuilder();
sb.append(preamble("import " + RUNTIME_PACKAGE + ".FbsBuilder;\nimport " + RUNTIME_PACKAGE
+ ".FbsTable;\nimport java.lang.foreign.MemorySegment;\n"));
sb.append(preamble("import java.lang.foreign.MemorySegment;\n"));
sb.append("/// Reader and builder for the `").append(table.name()).append("` FlatBuffers table.\n");
sb.append(GENERATED_ANNOTATION);
sb.append("public final class ").append(name).append(" extends FbsTable {\n\n");
Expand Down Expand Up @@ -257,8 +254,7 @@ private String emitStruct(Ast.StructDecl struct) {
String name = className(struct.name());
TypeRegistry.StructLayout layout = registry.layoutOf(struct);
StringBuilder sb = new StringBuilder();
sb.append(preamble("import " + RUNTIME_PACKAGE + ".FbsBuilder;\nimport " + RUNTIME_PACKAGE
+ ".FbsStruct;\nimport java.lang.foreign.MemorySegment;\n"));
sb.append(preamble("import java.lang.foreign.MemorySegment;\n"));
sb.append("/// Reader and builder for the `").append(struct.name()).append("` FlatBuffers struct (inline, ")
.append(layout.size()).append(" bytes).\n");
sb.append(GENERATED_ANNOTATION);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.dfa1.vortex.reader;

import io.github.dfa1.vortex.fbsrt.FbsBuilder;
import io.github.dfa1.vortex.fbs.FbsBuilder;
import io.github.dfa1.vortex.core.VortexException;
import io.github.dfa1.vortex.proto.ProtoScalarValue;
import org.junit.jupiter.api.Nested;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.dfa1.vortex.reader;

import io.github.dfa1.vortex.encoding.PTypeIO;
import io.github.dfa1.vortex.fbsrt.FbsBuilder;
import io.github.dfa1.vortex.fbs.FbsBuilder;
import io.github.dfa1.vortex.core.DType;
import io.github.dfa1.vortex.core.VortexException;
import io.github.dfa1.vortex.fbs.FbsArray;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import io.github.dfa1.vortex.fbs.FbsArrayNode;
import io.github.dfa1.vortex.fbs.FbsBuffer;
import io.github.dfa1.vortex.fbsrt.FbsBuilder;
import io.github.dfa1.vortex.fbs.FbsBuilder;
import io.github.dfa1.vortex.core.DType;
import io.github.dfa1.vortex.reader.array.Array;
import io.github.dfa1.vortex.reader.array.UnknownArray;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.dfa1.vortex.reader;

import io.github.dfa1.vortex.fbsrt.FbsBuilder;
import io.github.dfa1.vortex.fbs.FbsBuilder;
import static io.github.dfa1.vortex.reader.MalformedFiles.buildFooter;
import static io.github.dfa1.vortex.reader.MalformedFiles.buildI64Dtype;
import static io.github.dfa1.vortex.reader.MalformedFiles.buildPostscript;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.dfa1.vortex.reader;

import io.github.dfa1.vortex.fbsrt.FbsBuilder;
import io.github.dfa1.vortex.fbs.FbsBuilder;
import io.github.dfa1.vortex.fbs.FbsArraySpec;
import io.github.dfa1.vortex.fbs.FbsFooter;
import io.github.dfa1.vortex.fbs.FbsLayout;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.dfa1.vortex.reader;

import io.github.dfa1.vortex.fbsrt.FbsBuilder;
import io.github.dfa1.vortex.fbs.FbsBuilder;
import io.github.dfa1.vortex.fbs.FbsArraySpec;
import io.github.dfa1.vortex.fbs.FbsLayoutSpec;
import org.junit.jupiter.api.Test;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.dfa1.vortex.reader;

import io.github.dfa1.vortex.fbsrt.FbsBuilder;
import io.github.dfa1.vortex.fbs.FbsBuilder;
import io.github.dfa1.vortex.core.VortexException;
import io.github.dfa1.vortex.fbs.FbsArraySpec;
import io.github.dfa1.vortex.fbs.FbsFooter;
Expand Down
Loading
Loading