# Overview

> 📌 **Information**
>
> Version: **2.0.1**\
> Date: **2026/03/03**\
> Fork version: **25.12.19 (2025/12/20)**

[FlatBuffers](https://google.github.io/flatbuffers/) is an open-source cross-platform serialization library designed by
Google.
This project makes the Java API of this library available in the MicroEJ environment and deployable into MicroEJ
supported platforms.

This project contains:

- the original FlatBuffers API without RPC related integration
- its implementation, modified to compile against EDC API and eclasspath libraries
- its Java testsuite, modified to compile against FS API and to work around some limitations

# Usage

Add the following line to your `build.gradle.kts`:

    implementation("ej.library.runtime.flatbuffers:2.0.0")

# Requirements

This library requires the following Foundation Libraries:

- edc 1.3.7

# UTF-8

If com.google.flatbuffers.FlexBuffers are used, UTF-8 encoding has to be embedded.

If FlatBuffers are used and the `com.google.flatbuffers.Utf8Safe` implementation of `com.google.flatbuffers.Utf8` is
used (default), UTF-8 encoding does not have to be embedded.
However, if the `Utf8Old` implementation of `com.google.flatbuffers.Utf8` is used, UTF-8 encoding has to be embedded.
In order to use the `Utf8Old` implementation instead of the `com.google.flatbuffers.Utf8Safe` implementation,
the following code must be executed before loading the FlatBuffers:
`com.google.flatbuffers.Utf8.setDefault(new Utf8Old());`

See [MicroEJ Docs](https://docs.microej.com/en/latest/ApplicationDeveloperGuide/applicationOptions.html?highlight=utf#option-checkbox-embed-utf-8-encoding)
for more information on how to embed UTF-8 encoding.

# Schema Compiler

> 🚨 **Flatc compatibility**
> 
> This version requires **flatc v25.12.19** to convert your `.fbs` files.\
> Using a different version may cause unexpected errors or unpredictable behavior.
>
> Version: **25.12.19**\
> **[Download](https://github.com/google/flatbuffers/releases/tag/v25.12.19)** 

If an application uses `.fbs` files to describe the data structure, these files must be converted to Java code.
This is done by using the [FlatBuffers schema compiler](https://google.github.io/flatbuffers/flatbuffers_guide_using_schema_compiler.html).

The code generated by `flatc` must be post-processed to be compatible with MicroEJ.
Use the `flatc-microej` wrapper provided in the `tools/` directory:

```
tools\flatc-microej.bat [-o <output>] <input>
```

For example:

```
tools\flatc-microej.bat -o src/test/java schema.fbs
```

This requires python3 and `flatc.exe` in the `tools/` directory.

# Testsuite

The library implementation can be tested by running the `FlatBuffers Testsuite` launcher.
This launcher is configured to embed UTF-8 encoding and to specify a sufficient Java heap size.
It can be run on simulator or on device, on any platform with FS (`2.1` or compatible).

# Footprint

The footprint has been done with the current Testsuite.

_NB: There is only 2 tests added in the v2.0.0 version._

## Coverage

|          | Flatbuffers v2.0.0 🆕 | Flatbuffers v1.0.0 |
|:--------:|:---------------------:|:------------------:|
| Coverage |        70.22%         |       70.22%       |

## ROM footprint

|                             | Flatbuffers v2.0.0 🆕 | Flatbuffers v1.0.0 |
|:---------------------------:|:---------------------:|:------------------:|
|       ROM<br/>Library       |        20.3 KB        |      20.2 KB       |
| ROM<br/>Test/Implementation |        50.6 KB        |      47.5 KB       |


## RAM footprint

|             | Flatbuffers v2.0.0 🆕 | Flatbuffers v1.0.0 |
|:-----------:|:---------------------:|:------------------:|
|   RAM min   |        0.19 KB        |      0.19 KB       |
| RAM average |        8.91 KB        |      8.79 KB       |
|   RAM max   |       68.26 KB        |      68.26 KB      |

# Dependencies

_All dependencies are retrieved transitively by Gradle_.

# Source

This source code is based on [Google's Flatbuffers](https://github.com/google/flatbuffers).

# Restrictions

None.

---  

_Copyright 2022-2026 MicroEJ Corp. All rights reserved._
_This library is provided in source code for use, modification and test, subject to license terms._
_Any modification of the source code will break MicroEJ Corp. warranties on the whole library._
