{"id":22684144,"url":"https://github.com/tehleo/junion","last_synced_at":"2025-10-16T06:03:18.536Z","repository":{"id":57723535,"uuid":"130706391","full_name":"TehLeo/junion","owner":"TehLeo","description":"Delivers struct types for Java programming language.","archived":false,"fork":false,"pushed_at":"2024-03-05T21:38:18.000Z","size":19435,"stargazers_count":177,"open_issues_count":6,"forks_count":10,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-07-19T23:28:59.072Z","etag":null,"topics":["java","struct","types"],"latest_commit_sha":null,"homepage":"https://tehleo.github.io/junion/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TehLeo.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":"docs/support.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-23T14:09:11.000Z","updated_at":"2025-05-28T09:35:49.000Z","dependencies_parsed_at":"2025-01-10T07:35:09.294Z","dependency_job_id":"ac4cdf43-3c9a-4244-ab8a-f9dccc295631","html_url":"https://github.com/TehLeo/junion","commit_stats":{"total_commits":88,"total_committers":1,"mean_commits":88.0,"dds":0.0,"last_synced_commit":"95df1359085143c1bab39c5b4e71a7217e34e17a"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/TehLeo/junion","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TehLeo%2Fjunion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TehLeo%2Fjunion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TehLeo%2Fjunion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TehLeo%2Fjunion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TehLeo","download_url":"https://codeload.github.com/TehLeo/junion/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TehLeo%2Fjunion/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279161309,"owners_count":26116919,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-16T02:00:06.019Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["java","struct","types"],"created_at":"2024-12-09T21:17:01.723Z","updated_at":"2025-10-16T06:03:18.500Z","avatar_url":"https://github.com/TehLeo.png","language":"Java","funding_links":["https://www.paypal.me/JurajPapp"],"categories":[],"sub_categories":[],"readme":"(More Information available at this project's [website](https://tehleo.github.io/junion/))\n(Current version [1.2.2 EA (Early-Access)](https://github.com/TehLeo/junion/releases))\n# Project JUnion\n[![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/JUnionChat/Lobby)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.tehleo/junion/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.tehleo/junion)\n\n![Class Struct Diagram](docs/drawing.png)\n\n**Delivers struct types to Java programming language.** \n\nWhen creating arrays of int, we have two main options:\n```java\nint[] intArray = new int[1000];  \nInteger[] intBoxedArray = new Integer[1000];\n```\n**How many bytes do** ```intArray, intBoxedArray``` **take to store 1000 ints?**\n\n```intArray``` 4016 bytes ```4*1000 + ~16(around 16 bytes for array header)``` \u003cbr\u003e\n```intBoxedArray``` 20016 bytes ```(4 + ~12 + ~4)*1000 + ~16``` (exact number depends on VM)\n\n**That is almost 5x more!** \u003cbr\u003e\nWell, this teaches us to prefer primitive arrays over their boxed versions. \u003cbr\u003e\nSo what is this project about?\n\nConsider\n```java\nclass Point { float x,y;}\nPoint[] arr = new Point[500];\n```\n```arr``` takes 14016 bytes \u003cbr\u003e\nThe data consits of 500 points, 2 floats each, thus 4000 bytes should be enough.\u003cbr\u003e\nIf Point was a **struct**, ```arr``` would take ~4000 bytes.\n\nWouldn't it be nice to be able to create struct types in Java that code like class and work like structs?\n\nWith JUnion you can do just that by marking a class with @Struct annotation!\n\n**Create struct Vec3:**\n\n```java\n@Struct\npublic class Vec3 {\n    public float x,y,z;\n}\n```\n\n**Afterwards you can use it as:**\n\n```java\n//Create a new struct array\nVec3[] arr = new Vec3[10];\narr[5].x = 10;\nVec3 v = arr[5];\n...\n//\nByteBuffer a = ByteBuffer.allocateDirect(10*Mem.sizeOf(Vec3.class))\n   .order(ByteOrder.nativeOrder());\n//Modify Direct Native Bytebuffer as it were a struct\nVec3[] arr = Mem.wrap(a, Mem.sizeOf(Vec3.class));\narr[5].x = 10;\n...\n```\n\nFor a list of features [click here](https://tehleo.github.io/junion/features.html).\n\n**Why use struct types?**\n\n* Struct types use less memory.\n* Have the performance of primitive types.\n* Allow you to set data in direct native ByteBuffers with class-like syntax.\n\n**Performance Test**\n\n![alt text](docs/testarrayperf75.png)\n\n## Download\n\nCheck out the [latest release](https://github.com/TehLeo/junion/releases)\n\nand usage/IDE integration [guide here.](https://tehleo.github.io/junion/install.html)\n\n## Support \u0026 Donations\n\nWould you like to support JUnion? You can report bugs or request for new features [here](https://github.com/TehLeo/junion/issues) or [chat here](https://gitter.im/JUnionChat/Lobby)\n\nOr would you like to make a donation?\nYou can do so [via PayPap](https://www.paypal.me/JurajPapp)\n\n## News \u0026 Info\n\n**Status of JUnion 1.2.2:**\n\nJUnion 1.2.2 EA (Early-Access) is now [available here](https://github.com/TehLeo/junion/releases)\n\n**List of changes:**\n\n- can allocate struct arrays on heap, off-heap, stack, the syntax uses annotation, eg:\n```\nVec3[] arr = new Vec3[10]; //default currently allocates on heap\nVec3[] arr = new @Heap Vec3[10];\nVec3[] arr2 = new @Direct Vec3[10];\nVec3[] arr4 = new @DirectBuffer Vec3[10];\nVec3[] arr5 = new @Stack Vec3[10];\nVec3[] arr7 = new @Heap(ArrayType.Byte) Vec3[10]; //underlying data is Java byte[] array\n```\n- the underlying storage can be retrieved as Java array/Buffer with `Mem.getJavaArray(arr)` and `Mem.getJavaBuffer(arr)`\n- added StructType class, which can be used to find information about a struct\n- added StructList, which serves as a resizable struct array, it stores its elements as data not as references (not yet finished)\n- Array allocation is done through ArrayAllocator interface and can be customized by the user if needed\n- Bridge interface serves as the link between the application and ram. The default bridge interface DefaultBridge uses Unsafe to read and write memory. \n- added MemInit class which stores related settings, such as setting the bridge interface, allocator interface to use, etc.\n\nFinishing the current release/Documentation/tests are now planned to finalize 1.2.x release.\n\nRoadmap to JUnion 1.2.x has been announced [here](https://github.com/TehLeo/junion/issues/3) \n\nWiki has been created and can be accessed [here](https://tehleo.github.io/junion/wiki/index.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftehleo%2Fjunion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftehleo%2Fjunion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftehleo%2Fjunion/lists"}