{"id":36954623,"url":"https://github.com/elebras1/flecs-java","last_synced_at":"2026-05-23T16:01:02.371Z","repository":{"id":327276592,"uuid":"1101800308","full_name":"elebras1/flecs-java","owner":"elebras1","description":"Java wrapper for Flecs using FFM","archived":false,"fork":false,"pushed_at":"2026-04-18T11:22:09.000Z","size":1153,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-18T13:21:52.589Z","etag":null,"topics":["ecs","ffm-api","flecs","foreign-function-and-memory-api","gamedev","java"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elebras1.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-22T09:04:42.000Z","updated_at":"2026-04-18T11:22:14.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/elebras1/flecs-java","commit_stats":null,"previous_names":["elebras1/flecs-java"],"tags_count":32,"template":false,"template_full_name":null,"purl":"pkg:github/elebras1/flecs-java","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elebras1%2Fflecs-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elebras1%2Fflecs-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elebras1%2Fflecs-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elebras1%2Fflecs-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elebras1","download_url":"https://codeload.github.com/elebras1/flecs-java/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elebras1%2Fflecs-java/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33402174,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-23T04:15:53.637Z","status":"ssl_error","status_checked_at":"2026-05-23T04:15:53.242Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ecs","ffm-api","flecs","foreign-function-and-memory-api","gamedev","java"],"created_at":"2026-01-13T13:00:23.435Z","updated_at":"2026-05-23T16:01:02.358Z","avatar_url":"https://github.com/elebras1.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flecs-Java\n\n![Flecs](https://raw.githubusercontent.com/SanderMertens/flecs/master/docs/img/logo.png)\n\nJava bindings for [Flecs](https://github.com/SanderMertens/flecs) (v4.1.5) - A fast and flexible Entity Component System (ECS) using Java 25's Foreign Function \u0026 Memory API (FFM).\n\n## What is Flecs?\n\nFlecs is a powerful ECS framework written in C that provides high-performance data-oriented programming. This wrapper brings Flecs capabilities to Java while using Project Panama's FFM API.\n\n- **Multi-Platform**: Support for Linux, Windows, and macOS\n\n## Requirements\n\n### Runtime\n- **Java 25+**\n- **Gradle 9+**\n\n### Build from Source\n- **GCC or compatible C compiler** (for compiling the native Flecs library)\n- **jextract-25** (for generating Java FFM bindings when updating Flecs version)\n- **Supported Architectures**: \n  - Linux: x86_64, aarch64\n  - Windows: x86_64, aarch64\n  - macOS: x86_64, aarch64\n\n## Installation\n\n### Gradle\n\n```gradle\ndependencies {\n    implementation 'io.github.elebras1:flecs-java:0.9.0'\n    annotationProcessor 'io.github.elebras1:flecs-java:0.9.0'\n\n}\n```\n\n### Build from Source\n\n```bash\n# Clone repository\ngit clone https://github.com/elebras1/flecs-java.git\ncd flecs-java\n\n# Build (downloads Flecs, compiles natives)\n./gradlew build\n\n# Run examples\n./gradlew :examples:run\n```\n\n## Example\n\n```java\nimport io.github.elebras1.flecs.*;\nimport io.github.elebras1.flecs.annotation.Component;\n\n// Define components as records\n@Component\nrecord Position(float x, float y) {}\n\n@Component\nrecord Velocity(float dx, float dy) {}\n\npublic class Example {\n    public static void main(String[] args) {\n        World world = new World();\n        // Register components\n        world.component(Position.class);\n        world.component(Velocity.class);\n        \n        // Create entities\n        Entity player = world.obtainEntity(world.entity(\"Player\"));\n        player.set(new Position(0, 0))\n              .set(new Velocity(1, 0));\n        \n        Entity enemy = world.obtainEntity(world.entity(\"Enemy\"));\n        enemy.set(new Position(10, 5))\n             .set(new Velocity(-0.5f, 0));\n\n        // Set number of worker threads\n        world.setThreads(4);\n        \n        // Create a movement system\n        world.system(\"MoveSystem\")\n            .kind(FlecsConstants.EcsOnUpdate)\n            .with(Position.class)\n            .with(Velocity.class)\n            .multithreaded()\n            .iter(it -\u003e {\n                Field\u003cPosition\u003e positions = it.field(Position.class, 0);\n                Field\u003cVelocity\u003e velocities = it.field(Velocity.class, 1);\n                \n                for (int i = 0; i \u003c it.count(); i++) {\n                    PositionView positionView = positions.getMutView(i);\n                    VelocityView velocityView = velocities.getMutView(i);\n                    \n                    // Update position\n                    positionView.x(positionView.x() + velocityView.dx() * it.deltaTime());\n                    positionView.y(positionView.y() + velocityView.dy() * it.deltaTime());\n                }\n            });\n        \n        // Run simulation\n        for (int i = 0; i \u003c 10; i++) {\n            world.progress(0.016f); // 60 FPS\n        }\n        \n        // Query entities\n        Query query = world.query().with(Position.class).build();\n        query.each(Position.class, (entityId, pos) -\u003e {\n            Entity e = world.obtainEntity(entityId);\n            System.out.printf(\"%s: (%.2f, %.2f)%n\", e.getName(), pos.x(), pos.y());\n        });\n        \n        query.destroy();\n        \n        world.destroy();\n    }\n}\n```\n\n## Documentation\n\n- **[Flecs Manual](https://www.flecs.dev/flecs/)** - Official Flecs documentation\n- **[Examples](examples/src/main/java/com/github/elebras1/flecs/examples/)** - Code examples covering various features\n\n## Architecture\n\n### FFM API Integration\n\nFlecs-Java uses Java 25's Foreign Function \u0026 Memory API for direct C interop:\n- **Zero JNI overhead**: Direct native calls without marshalling\n- **Memory safety**: Arena-based memory management\n- **Type safety**: Strong typing with `MemorySegment` and layouts\n\n### Component System\n\nComponents are defined as Java records with the `@Component` annotation. An annotation processor generates the necessary memory layouts and accessor code at compile time.\n\n## Building\n\n### Build Process Overview\n\nThe build process automatically handles the following steps:\n\n1. **Download Flecs C Source** (`downloadFlecs`)\n2. **Compile Native Library** (`compileFlecsNative`)\n3. **Compile Annotation Processor** (`compileProcessor`)\n4. **Generate Java Source** (Annotation Processing Phase)\n5. **Package JAR**\n6. **Runtime Native Loading**\n\n### Updating FFM Bindings\n\nWhen updating the Flecs version, maintainers must regenerate the FFM bindings:\n\n```bash\n# (requires jextract-25 installed)\n./gradlew generateFlecsBindings\n```\n\nThis generates the Java FFM interface bindings from `flecs.h` and stores them in `src/main/generated/`. Regular users don't need to run this task.\n\n## Contributing\n\nThis wrapper currently implements core ECS functionality but does not yet support all Flecs features.\nFeel free to open an issue or pull request. All contributions are welcome!\n\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes\n4. Submit a pull request\n\nOr just report issues you encounter!\n\n## Support\n\n- **Issues**: [GitHub Issues](https://github.com/elebras1/flecs-java/issues)\n- **Flecs Discord**: [Join the community](https://discord.gg/flecs)\n\n## License\n\nFlecs-Java is licensed under the [MIT License](LICENSE).\n\nFlecs (the underlying C library) is also licensed under the MIT License. See the [Flecs repository](https://github.com/SanderMertens/flecs) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felebras1%2Fflecs-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felebras1%2Fflecs-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felebras1%2Fflecs-java/lists"}