Parma Polyhedra Library requirements
Low-Level Requirements: Java Interface
PPL-LLR-000204
1. Java coefficient value preservation UID: PPL-LLR-000204 STATUS: APPROVED COMPONENT: JAVA_INTERFACE APPLICABILITY: IF_JAVA VERIFICATION_METHODS: Test, Review RELATIONS (Parent): RELATIONS (Child): STATEMENT:

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.

RATIONALE:

Exact numerical representations can require coefficients larger than the primitive integer types of the calling language.

COMMENT:

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.

VERIFICATION_CRITERIA:

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.

SOURCE:

interfaces/Java/parma_polyhedra_library/Coefficient.java; interfaces/Java/jni/ppl_java_common_inlines.hh, coefficient conversion helpers.

  • 1. Java integral coefficient exchange UID: PPL-SPEC-001688 STATUS: APPROVED COMPONENT: JAVA_INTERFACE APPLICABILITY: IF_JAVA VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: Java VISIBILITY: Public RELATIONS (Parent): STATEMENT:

    Coefficient shall hold the integer supplied through its integer, decimal string or BigInteger constructor, and copying and getBigInteger shall preserve that value. toString shall return its decimal representation. bits shall return the configured native coefficient width, or zero for unbounded native coefficients.

    For a valid coefficient representable by the native coefficient type, conversion through a supported native operation and back to Java shall preserve its integral value, including its sign and zero. Conversion shall use the full decimal value, without narrowing it through int or long. In an unbounded configuration this includes integers outside both primitive ranges. Native arithmetic retains its configured range and policy; Java's BigInteger does not extend that range. Checked out-of-range conversion shall use 🔗 3. Java native failure and pending-exception protocol.

    RATIONALE:

    Exchanging the decimal integer avoids truncating an exact coefficient to a host primitive width.

    INTERFACE:

    Package parma_polyhedra_library.

    Coefficient(int i);
    Coefficient(long l);
    Coefficient(java.math.BigInteger bi);
    Coefficient(String s);
    Coefficient(Coefficient c);
    java.math.BigInteger getBigInteger();
    String toString();
    static native int bits();
    

    Native exchange occurs in coefficient-bearing expressions, constraints, generators and solver queries. String input shall be a valid decimal integer; BigInteger and copy inputs shall be non-null.

    VERIFICATION_CRITERIA:

    Round-trip zero, signed small values, configured endpoints and, when unbounded, values larger than 64 bits through a native constant objective. Check checked-range failures separately from valid native arithmetic.

    SOURCE:

    interfaces/Java/parma_polyhedra_library/Coefficient.java; interfaces/Java/jni/ppl_java_common_inlines.hh; interfaces/Java/tests/Native_Handle_test1.java.

PPL-LLR-000205
2. Java library lifecycle UID: PPL-LLR-000205 STATUS: APPROVED COMPONENT: JAVA_INTERFACE APPLICABILITY: IF_JAVA VERIFICATION_METHODS: Test, Review RELATIONS (Parent): RELATIONS (Child): STATEMENT:

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.

RATIONALE:

Loading a native library and initializing the numerical library are distinct lifecycle actions.

COMMENT:

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.

VERIFICATION_CRITERIA:

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.

SOURCE:

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.

  • 2. Java library initialization and finalization UID: PPL-SPEC-001689 STATUS: APPROVED COMPONENT: JAVA_INTERFACE APPLICABILITY: IF_JAVA VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: Java VISIBILITY: Public RELATIONS (Parent): STATEMENT:

    After loading the configured JNI library, initialize_library shall establish native library state and the Java class cache before supported operations. finalize_library shall release that cache, the calling thread's variable stringifier and deterministic-timeout state, and the native initialization owner. A later initialization shall establish a new valid period of use.

    Clients shall release owned objects, cease using borrowed views, and end worker thread participation before finalization. Requests shall alternate valid initialization and finalization; duplicate library requests are outside this protocol. Participating workers shall obey 🔗 6. Thread entry and shared-facility use.

    RATIONALE:

    JNI loading, Java class caching and native initialization have distinct resource lifetimes.

    INTERFACE:

    Package parma_polyhedra_library, class Parma_Polyhedra_Library.

    public static native void initialize_library();
    public static native void finalize_library();
    

    The JNI library shall first be loaded using the host's native-library loading mechanism. The initializing thread owns the library lifecycle.

    VERIFICATION_CRITERIA:

    Load the JNI library and complete two initialize/use/release/finalize cycles, checking native coefficient and solver operations during each cycle. Inspect class-reference and thread-resource cleanup.

    SOURCE:

    interfaces/Java/parma_polyhedra_library/Parma_Polyhedra_Library.java; interfaces/Java/jni/ppl_java_globals.cc; interfaces/Java/jni/ppl_java_common_inlines.hh; interfaces/Java/tests/Native_Handle_test1.java.

PPL-LLR-000206
3. Java boundary exception translation UID: PPL-LLR-000206 STATUS: APPROVED COMPONENT: JAVA_INTERFACE APPLICABILITY: IF_JAVA VERIFICATION_METHODS: Test, Review RELATIONS (Parent): RELATIONS (Child): STATEMENT:

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.

RATIONALE:

Java clients need failures expressed through their language's exception mechanism.

COMMENT:

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.

VERIFICATION_CRITERIA:

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.

SOURCE:

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.

  • 3. Java native failure and pending-exception protocol UID: PPL-SPEC-001690 STATUS: APPROVED COMPONENT: JAVA_INTERFACE APPLICABILITY: IF_JAVA VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: Java VISIBILITY: Public RELATIONS (Parent): STATEMENT:

    Supported JNI numerical entry points shall contain native exceptions. Native invalid_argument, domain_error, length_error, logic_error and overflow_error shall become the corresponding Java binding exceptions. Supported native interruption shall become Timeout_Exception. Allocation failure shall become a Java exception describing out-of-memory failure; other standard and unexpected native exceptions shall become RuntimeException with a diagnostic.

    A Java exception already pending after a host callback or object creation shall be returned to Java without replacement by a translated native exception. Argument-conversion callbacks shall complete before native access to a receiver that they may release; released receivers shall be rejected. Host-runtime termination and undefined behavior are outside the failure model.

    RATIONALE:

    A host callback failure and a false numerical result must remain distinguishable, and a pending exception carries the original Java cause.

    INTERFACE:

    Package parma_polyhedra_library: native methods of numerical wrappers and Parma_Polyhedra_Library. The reported exception classes are Invalid_Argument_Exception, Domain_Error_Exception, Length_Error_Exception, Logic_Error_Exception, Overflow_Error_Exception, Timeout_Exception and java.lang.RuntimeException. A pending host exception retains its object identity. Operations require the lifecycle of 🔗 2. Java library initialization and finalization.

    VERIFICATION_CRITERIA:

    Check invalid dimensions, released receivers, copy and index admission, release during callbacks, and identity of a callback-thrown exception. Check checked conversion overflow in bounded checked configurations. Inspect every native failure category and failed JNI allocation path; use controlled injection for allocation and otherwise inaccessible failures.

    SOURCE:

    interfaces/Java/jni/ppl_java_common_defs.hh; interfaces/Java/jni/ppl_java_common.cc; interfaces/Java/jni/ppl_java_globals.cc; interfaces/Java/tests/Native_Handle_test1.java.

  • PPL-SPEC-001729
    7. Java dimension limits and exact native counts UID: PPL-SPEC-001729 STATUS: APPROVED COMPONENT: JAVA_INTERFACE APPLICABILITY: IF_JAVA VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Internal RELATIONS (Parent): STATEMENT:

    For an unsigned integral native type, java_dimension_limit shall return the smaller of the supplied native limit and the greatest Java long value. java_unsigned_value shall return the exact supplied count when representable by Java long and otherwise throw std::overflow_error. check_java_dimension_growth shall check the current dimension and both successive increments against that effective limit without unsigned wraparound. It shall throw std::length_error if the resulting dimension is inadmissible, before either increment is applied to the numerical object.

    JNI count queries for PIP parameter dimensions, constraints and artificial parameters shall return the corresponding native cardinalities. They require valid problem/node handles; wrapper failures follow 🔗 3. Java native failure and pending-exception protocol. A constraint count already represented by a signed iterator difference shall be representable by Java long; other unsigned count conversion uses the checked conversion above.

    RATIONALE:

    Java uses a signed count type even when the native count type is unsigned; admission must precede mutation and must not narrow a value silently.

    INTERFACE:

    Namespace Parma_Polyhedra_Library::Interfaces::Java:

    template <typename Unsigned> jlong java_dimension_limit(Unsigned limit);
    template <typename Unsigned> jlong java_unsigned_value(Unsigned value);
    template <typename Unsigned>
    void check_java_dimension_growth(Unsigned current, Unsigned first,
                                     Unsigned second, Unsigned limit);
    

    Unsigned shall be an unsigned integral type. JNI queries implement PIP_Problem.number_of_parameter_space_dimensions, PIP_Problem.number_of_constraints and PIP_Tree_Node.number_of_artificials.

    VERIFICATION_CRITERIA:

    Check unsigned types narrower than, equal to and wider than Java's positive range; zero, exact-limit and overflowing counts; and each increment at the remaining-capacity boundary. Confirm rejection precedes object mutation. Inspect all three JNI cardinality queries against their native collections.

    SOURCE:

    interfaces/Java/jni/ppl_java_limits.hh; interfaces/Java/jni/ppl_java_globals.cc; interfaces/Java/tests/unsignedlimits1.cc.

PPL-LLR-000436
4. Java native object ownership UID: PPL-LLR-000436 STATUS: APPROVED COMPONENT: JAVA_INTERFACE APPLICABILITY: IF_JAVA VERIFICATION_METHODS: Test, Analysis, Review RELATIONS (Parent): RELATIONS (Child): STATEMENT:

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.

RATIONALE:

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.

COMMENT:

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.

VERIFICATION_CRITERIA:

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.

SOURCE:

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.

  • PPL-SPEC-001691
    4. Java owned wrappers and borrowed views UID: PPL-SPEC-001691 STATUS: APPROVED COMPONENT: JAVA_INTERFACE APPLICABILITY: IF_JAVA VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: Java VISIBILITY: Public RELATIONS (Parent): STATEMENT:

    An owned numerical wrapper shall release its native allocation through explicit free or managed finalization, without a later cleanup deleting that allocation again. Copy construction shall produce an independent native object. Borrowed-wrapper cleanup shall not delete the underlying owned object.

    Factories shall bind view owners before allocating native cursor storage, or retain native results in an exception-safe owner until all fallible publication steps complete. Failed JNI allocation or native computation shall leave no stranded native result. Replacing a ranking-function output shall release its previous value while preserving ownership of the output wrapper.

    MIP and partial-function wrappers shall reject native access after release. Powerset cursors and disjuncts shall retain their owner, validate its current generation, and reject stale use; disjuncts shall be read-only and copying one shall produce an independent writable object. Cursor operations shall reject boundary and foreign-owner misuse. Mutating or potentially normalizing a powerset shall invalidate its dependent views except for the documented cursor returned by single removal. Stable metadata queries shall preserve them.

    PIP tree views shall retain their problem owner and reject access after owner release or a mutation invalidating the captured tree generation. View cleanup shall leave independently owned problems usable. Managed cleanup timing is controlled by the JVM. Clients shall obey 🔗 2. Java library initialization and finalization and the operation-specific borrowing and synchronization prerequisites.

    RATIONALE:

    Host reachability and native ownership differ; generation checks prevent views from referring to replaced native storage.

    INTERFACE:

    Package parma_polyhedra_library: PPL_Object subclasses, owned numerical constructors and copy constructors, free and managed finalize methods; PIP solution-tree accessors; configured powerset begin_iterator, end_iterator, iterator copying, traversal and get_disjunct methods. Released MIP/partial-function access and invalid borrowed access shall report Invalid_Argument_Exception. A borrowed view is not an independently owned native allocation.

    VERIFICATION_CRITERIA:

    Check both release/finalization orders, repeated cleanup, independent copies, released access and release during conversion. Check powerset owner retention, stale and read-only views, cursor bounds and owner checks; check PIP owner retention and mutation invalidation. Inspect concrete generated finalizers and use allocation-sensitive checks for owned cleanup. Inject JNI object/token and native allocation failures into cursor, partition and ranking-output factories.

    SOURCE:

    interfaces/Java/parma_polyhedra_library/PPL_Object.java; interfaces/Java/jni/ppl_interface_generator_java_classes_cc_code.m4; interfaces/Java/jni/ppl_java_globals.cc; interfaces/Java/tests/Native_Handle_test1.java; interfaces/Java/tests/Powerset_Lifetime_test1.java; interfaces/Java/tests/PIP_Lifetime_test1.java; interfaces/Java/tests/Native_Publication_test1.java; interfaces/Java/tests/jni_native_publication_test.cc.