Low-Level Requirements: Java Interface
The Java interface shall preserve integral coefficient values when transferring them between Java objects and the native library, provided the values are representable by the configured native coefficient type. It shall not reduce an otherwise representable coefficient to the range of Java's fixed-width primitive integers.
Exact numerical representations can require coefficients larger than the primitive integer types of the calling language.
Verification covers Java/native coefficient conversion contracts. Round-trip tests and conversion-path inspection verify value preservation within the configured native range. Values outside that range do not acquire arbitrary-precision support through the Java representation alone.
Round trips preserve positive, negative and zero coefficients; configurations with unbounded coefficients also preserve values beyond the range of the largest Java primitive integer; configured bounded ranges are respected.
interfaces/Java/parma_polyhedra_library/Coefficient.java; interfaces/Java/jni/ppl_java_common_inlines.hh, coefficient conversion helpers.
The Java interface shall provide explicit initialization and finalization of the native library after its native interface library has been loaded. Finalization shall release the interface's library-level resources, and subsequent initialization shall permit a new valid period of library use.
Loading a native library and initializing the numerical library are distinct lifecycle actions.
Verification covers Java native-library initialization, finalization and reinitialization. Lifecycle sequence tests and inspection verify release of library-level resources. Clients remain responsible for documented object-lifetime and initialization preconditions. Native object ownership is governed separately by 🔗 4. Java native object ownership, and thread entry by 🔗 6. Thread entry and shared-facility use.
A Java client loads the configured native library, initializes it, performs a supported operation, finalizes it, and completes a second valid initialization and finalization sequence.
interfaces/Java/README.java.md; interfaces/Java/parma_polyhedra_library/Parma_Polyhedra_Library.java; interfaces/Java/jni/ppl_java_common_inlines.hh, interface initialization and finalization helpers.
The Java interface shall report every native failure designated by its supported failure model through the Java exception mechanism, distinguishing the declared categories including invalid arguments, arithmetic overflow and resource exhaustion. Native C++ exceptions raised by supported operations shall be contained at the Java native-call boundary. An already pending Java exception shall be preserved.
Java clients need failures expressed through their language's exception mechanism.
Verification covers the Java failure model, host exception translation, pending-exception preservation and native exception containment. Failure injection and boundary-path inspection verify those contracts. Arithmetic-overflow cases require checked bounded coefficients, and resource-exhaustion checks may use controlled fault injection. A dedicated Java allocation-error class is not required; the current translation uses an exception with an out-of-memory description. No recovery from process termination or undefined behavior is implied.
Exercise supported failure categories and confirm that Java callers observe the declared category and diagnostic, including invalid arguments, checked-coefficient overflow, resource exhaustion and supported interruptions. Inspect native exception containment, failed host-object creation, and preservation of an already pending Java exception. Exercise MIP copy construction and Partial_Function index admission through their native exception boundaries, and receiver release or Java exceptions during argument-conversion callbacks.
interfaces/Java/jni/ppl_java_common_defs.hh, native exception boundary; interfaces/Java/jni/ppl_java_common.cc, exception translation helpers; interfaces/Java/jni/ppl_java_globals.cc and interfaces/Java/tests/Native_Handle_test1.java, MIP and partial-function boundary and callback regressions.
The Java interface shall distinguish owned native objects from borrowed native views. When explicit release or managed cleanup of an owned wrapper occurs, it shall release the owned native allocation without repeated cleanup releasing that allocation again. Creating a borrowed view shall not transfer ownership of the underlying allocation. The interface shall define the owner-lifetime and mutation-validity preconditions for each borrowed view.
Library-level finalization and Java wrapper lifetime are separate concerns; clients must know which wrapper owns an allocation and which operations can invalidate a view.
Verification covers owned-wrapper release and cleanup, borrowed views and their invalidation contracts. Lifecycle checks and JNI ownership analysis verify these behaviors. Managed cleanup timing remains a host-runtime concern; prompt garbage collection is not required. A wrapper may retain its owner where appropriate, but borrowing does not acquire ownership of the native allocation. No automatic invalid-view detection is required. Library lifecycle remains governed by 🔗 2. Java library lifecycle and failure cleanup by 🔗 3. Failure and resource safety.
Inspect native ownership marking and explicit-release and managed-cleanup paths. For MIP_Problem and Partial_Function, exercise explicit release, repeated finalization, both release/finalization orders and rejection of subsequent native access. Check receiver release during Java argument conversion before native use. Exercise owned copies, explicit release followed by managed cleanup, and collection of unreachable owned wrappers. Verify that borrowed-view cleanup does not delete its owner's native object, and review owner-lifetime and mutation-invalidation contracts for domain and solver views.
interfaces/Java/parma_polyhedra_library/PPL_Object.java: native wrapper storage; interfaces/Java/parma_polyhedra_library/ppl_interface_generator_java_classes_java_code.m4: generated release and finalization entry points; interfaces/Java/jni/ppl_interface_generator_java_classes_cc_code.m4: marked borrowing and owned-object cleanup; interfaces/Java/parma_polyhedra_library/PIP_Tree_Node.java: native solution-tree views; interfaces/Java/jni/ppl_java_globals.cc and interfaces/Java/tests/Native_Handle_test1.java: MIP and partial-function release and finalization.