Skip to content

fix: split MeosLibrary into 4 public static sub-interfaces (ARM64/Windows/macOS fix)#12

Closed
estebanzimanyi wants to merge 120 commits into
MobilityDB:mainfrom
estebanzimanyi:fix/multimodule-with-split-interface
Closed

fix: split MeosLibrary into 4 public static sub-interfaces (ARM64/Windows/macOS fix)#12
estebanzimanyi wants to merge 120 commits into
MobilityDB:mainfrom
estebanzimanyi:fix/multimodule-with-split-interface

Conversation

@estebanzimanyi
Copy link
Copy Markdown
Member

Summary

The single flat MeosLibrary JNR-FFI interface (1685 methods) causes a
MethodTooLargeException on ARM64 / Windows / macOS: JNR-FFI generates a
proxy whose <clinit>()V initialises native dispatch for every method, and
1685 methods exceeds the JVM 64 KB bytecode limit.

This PR fixes the issue by splitting the interface into four public static
sub-interfaces (~421 methods each), each loaded by a separate JNR-FFI proxy.

Changes

jmeos-core/src/main/java/functions/functions.java

  • MeosLibraryPartA/B/C/D — four public static sub-interfaces (~421 methods
    each); each backed by its own JNR-FFI proxy (_meos_a/b/c/d), keeping every
    proxy <clinit>()V well under 64 KB
  • All 1685 public static wrapper methods updated to call the correct proxy
    directly (no reflection overhead on the hot path)
  • MeosLibrary retained as a backward-compat shim that extends all four parts;
    MeosLibrary.meos now points to a lightweight java.lang.reflect.Proxy
    delegate that routes calls via a pre-built dispatch map — existing callers
    continue to work unchanged
  • Sub-interfaces are public static (not private) so JNR-FFI's
    AsmClassLoader can load them without an IllegalAccessError

Cleanup (files that should not have been committed in PR #9):

  • Removes jar/JMEOS.jar (generated artifact)
  • Removes jmeos-core/src/libmeos.so (stray copy; the intentional bundled
    resource remains at jmeos-core/src/main/resources/lib/libmeos.so)
  • Removes *.class files (BuilderUtils.class, Pair.class)
  • Removes debug artifacts (intspanset_output.txt, time/test.java)
  • Extends .gitignore to prevent recurrence

Stacking

This PR is stacked on top of PR #9 (JashanReel:fix-tests-using-docker) and
should be merged after that PR is cleaned up and landed.

Test plan

  • mvn test -pl jmeos-core passes on Linux x86_64 (current CI)
  • No MethodTooLargeException on ARM64 / macOS / Windows once PR JMEOS 1.3 #9 base is merged
  • MeosLibrary.meos.methodName() still works via the reflection delegate

Notes for reviewer

The critical invariant is that sub-interfaces must be declared public static
(not private or package-private). JNR-FFI's AsmClassLoader.defineClass()
loads them as separate classes; a non-public inner interface causes
IllegalAccessError at proxy generation time.

62727 and others added 30 commits February 5, 2026 12:11
…o run them & added .idea personal config files in the .gitignore
…n of temporal_to_tsequence (temporal.c) which was still given a string as the interpolation type instead of an integer & added TestLogger in order to trace the lifecycle of each test and the parameters used
…tInst has no interpolation but it used to be tested as a LINEAR one
…y geom_in, pgis_geography_in by geog_in, adapted ConversionUtils & TPoint files accordingly
…point_as_text now tspatial_as_text, tpoint_to_stbox now tspatial_to_stbox, tpoint_srid now tspatial_srid: tpoint_round, tpoint_start_value, tpoint_end_value left
… with a single instance or a discret sequence set of TGeogPoint/TGeomPoint, fixed assertion using a STEP print verification (Interp=Step
- Replace meos.h with v1.3 and add meos_geo.h
- Update FunctionsExtractor and Generator to support new headers and types
- Fix existing tests to match MEOS
…into java + the resulting generated csv files
JashanReel and others added 23 commits April 23, 2026 09:35
…ks multiple times and outputs the average of the performances
…jmeos-core for the core code, deleted example programs/notebooks to move them in a new repository
A single flat JNR-FFI interface with 1685 methods exceeds the JVM
64 KB bytecode limit per method in its generated <clinit>()V proxy,
causing MethodTooLargeException on ARM64 / Windows / macOS.

Split into MeosLibraryPartA/B/C/D (≈ 421 methods each), each loaded
by a separate JNR-FFI proxy. The public static wrappers are updated
to call the correct proxy directly. The original MeosLibrary interface
is kept as a backward-compat shim (extends all four parts); its
INSTANCE field now points to a lightweight reflection delegate instead
of a direct JNR-FFI proxy.

Also removes junk files that should never have been committed:
  - jar/JMEOS.jar (generated artifact)
  - jmeos-core/src/libmeos.so (stray copy at wrong path; the
    intentional bundled resource is under src/main/resources/lib/)
  - *.class files (BuilderUtils.class, Pair.class)
  - debug artifacts (intspanset_output.txt, time/test.java)

.gitignore extended to prevent recurrence.
@estebanzimanyi
Copy link
Copy Markdown
Member Author

CONFL diagnosis: Same structural drift root cause as #15/#16/#17. PR #9 (merged) already established the multi-module layout (codegen/ + jmeos-core/); this PR's intent (split interface into 4 sub-interfaces) overlaps with the now-merged multi-module split.

Path forward: Identify what this PR adds beyond what #9 already delivered. If #9 covers the multi-module + split-interface goal, this PR can be closed as superseded. If there's residual content (e.g., specific sub-interface naming, additional split logic), cherry-pick the deltas onto current main and re-target file paths. Worth a re-read against the post-#9 state to determine which.

@estebanzimanyi
Copy link
Copy Markdown
Member Author

Superseded by #19. PR #19's regenerated GeneratedFunctions.java already splits the JNR-FFI surface into 4 sub-interfaces automatically (MeosLibraryPartA / PartB / PartC / PartD), matching this PR's intent without the structural-rebase friction the pre-multi-module paths surfaced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants