MCPcopy Index your code
hub / github.com/TehLeo/junion

github.com/TehLeo/junion @1.2.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release 1.2.2 ↗ · + Follow
774 symbols 1,853 edges 46 files 79 documented · 10%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

(More Information available at this project's website) (Current version 1.2.1 (pre-release))

Project JUnion

Gitter chat Maven Central

Class Struct Diagram

Delivers struct types to Java programming language.

When creating arrays of int, we have two main options:

int[] intArray = new int[1000];  
Integer[] intBoxedArray = new Integer[1000];

How many bytes do intArray, intBoxedArray take to store 1000 ints?

intArray 4016 bytes 4*1000 + ~16(around 16 bytes for array header)

intBoxedArray 20016 bytes (4 + ~12 + ~4)*1000 + ~16 (exact number depends on VM)

That is almost 5x more!

Well, this teaches us to prefer primitive arrays over their boxed versions.

So what is this project about?

Consider

class Point { float x,y;}
Point[] arr = new Point[500];

arr takes 14016 bytes

The data consits of 500 points, 2 floats each, thus 4000 bytes should be enough.

If Point was a struct, arr would take ~4000 bytes.

Wouldn't it be nice to be able to create struct types in Java that code like class and work like structs?

With JUnion you can do just that by marking a class with @Struct annotation!

Create struct Vec3:

@Struct
public class Vec3 {
    public float x,y,z;
}

Afterwards you can use it as:

//Create a new struct array
Vec3[] arr = new Vec3[10];
arr[5].x = 10;
Vec3 v = arr[5];
...
//
ByteBuffer a = ByteBuffer.allocateDirect(10*Mem.sizeOf(Vec3.class))
   .order(ByteOrder.nativeOrder());
//Modify Direct Native Bytebuffer as it were a struct
Vec3[] arr = Mem.wrap(a, Mem.sizeOf(Vec3.class));
arr[5].x = 10;
...

For a list of features click here.

Why use struct types?

  • Struct types use less memory.
  • Have the performance of primitive types.
  • Allow you to set data in direct native ByteBuffers with class-like syntax.

Performance Test

alt text

Download

Check out the latest release

and usage/IDE integration guide here.

Support & Donations

Would you like to support JUnion? You can report bugs or request for new features here or chat here

Or would you like to make a donation? You can do so via PayPap

News & Info

Version 1.2.1 pre-release is now acessible here

Roadmap to JUnion 1.2.1 has been announced here

Wiki has been created and can be accessed here

Extension points exported contracts — how you extend this code

ArrayAllocator (Interface)
@author Juraj Papp [3 implementers]
junion/src/theleo/jstruct/allocator/ArrayAllocator.java
Allocator (Interface)
Allocator interface. The implementation of this interface is implements a thread-safe allocator or sigle-threaded alloc [2 …
junion/src/theleo/jstruct/allocator/Allocator.java
Bridge (Interface)
Defines an interface with methods used to retrieve and store values to memory. The first long argument is an address and [2 …
junion/src/theleo/jstruct/bridge/Bridge.java

Core symbols most depended-on inside this repo

name
called by 196
junioncompile/src/theleo/jstruct/plugin/ecj/Translator2.java
add
called by 175
junioncompile/src/theleo/jstruct/plugin/ecj/Translator.java
get
called by 143
junioncompile/src/theleo/jstruct/plugin/ecj/StructCache.java
getArray
called by 128
junion/src/theleo/jstruct/hidden/R1.java
setName
called by 102
junioncompile/src/theleo/jstruct/plugin/ecj/Translator.java
size
called by 79
junion/src/theleo/jstruct/util/StructList.java
replace
called by 73
junioncompile/src/theleo/jstruct/plugin/ecj/Translator2.java
add
called by 63
junioncompile/src/theleo/jstruct/plugin/ecj/Translator2.java

Shape

Method 682
Class 78
Enum 11
Interface 3

Languages

Java100%

Modules by API surface

junion/src/theleo/jstruct/bridge/DefaultBridge.java116 symbols
junion/src/theleo/jstruct/bridge/Bridge.java116 symbols
junion/src/theleo/jstruct/hidden/R1.java66 symbols
junioncompile/src/theleo/jstruct/plugin/ecj/Translator.java51 symbols
junioncompile/src/theleo/jstruct/plugin/ecj/BaseTranslator.java46 symbols
junioncompile/src/theleo/jstruct/plugin/ecj/Translator2.java43 symbols
juniontests/test/theleo/jstruct/testcase/UnitTest.java32 symbols
junioncompile/src/theleo/jstruct/plugin/jc/JStructPlugin.java30 symbols
junion/src/theleo/jstruct/util/StructList.java30 symbols
junioncompile/src/theleo/jstruct/plugin/ecj/StructCache.java29 symbols
junion/src/theleo/jstruct/Mem.java29 symbols
junion/src/theleo/jstruct/hidden/Mem0.java18 symbols

For agents

$ claude mcp add junion \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact