Skip to content

fix: register java.util.HashSet in OWLAPIMapper to fix get_punned_iris() - #280

Merged
Demirrr merged 1 commit into
developfrom
fix/278-hashset-mapping
Sep 16, 2026
Merged

Demirrr merged 1 commit into
developfrom
fix/278-hashset-mapping

Conversation

@Demirrr

@Demirrr Demirrr commented Sep 16, 2026

Copy link
Copy Markdown
Member

Summary

  • Fixes a bug reported in Expose more Java-side methods for SyncOntology #278 (Expose more Java-side methods for SyncOntology #278 (comment)): SyncOntology.get_punned_iris() raised RuntimeError: Inconsistent hierarchy whenever the ontology actually contained a punned IRI.
  • getPunnedIRIs() returns a concrete java.util.HashSet when non-empty. OWLAPIMapper.map_() (a functools.singledispatchmethod) had no exact registration for HashSet, so it fell back to MRO-based dispatch over JPype's dynamically-generated Java class proxies, which can't always produce a consistent C3 linearization — hence the crash. This is the same failure mode LinkedHashSet was already patched for previously.
  • Fix: register HashSet directly alongside the existing LinkedHashSet/ArrayList/List/Set registrations, so singledispatch hits its exact-type fast path instead of the MRO resolver.

Test plan

  • Reproduced the exact traceback from the issue with the reporter's repro script before the fix, confirmed it's fixed after
  • Added test_get_punned_iris_with_punning in tests/test_sync_ontology.py, reproducing the issue's punning scenario (verified it fails with the pre-fix code and passes with the fix)
  • ruff check owlapy --line-length=200 passes
  • tests/test_sync_ontology.py, tests/test_owlapi_mapper.py, tests/test_owlapy_ontology_management.py all pass (39 passed)
  • Updated CHANGELOG.md's [Unreleased] section

🤖 Generated with Claude Code

getPunnedIRIs() returns a concrete java.util.HashSet whenever the
ontology has at least one punned IRI. OWLAPIMapper.map_() had no exact
registration for it, so functools.singledispatch fell back to
MRO-based dispatch over JPype's dynamic Java-class proxies, which
raised "RuntimeError: Inconsistent hierarchy" -- the same failure mode
LinkedHashSet was already patched for. Register HashSet the same way.

Fixes #278

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.44%. Comparing base (5851191) to head (6edc750).
⚠️ Report is 8 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #280      +/-   ##
===========================================
+ Coverage    83.34%   83.44%   +0.09%     
===========================================
  Files           67       67              
  Lines        12408    12521     +113     
===========================================
+ Hits         10342    10448     +106     
- Misses        2066     2073       +7     
Flag Coverage Δ
unittests 83.44% <100.00%> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Demirrr
Demirrr merged commit b1e662c into develop Sep 16, 2026
4 checks passed
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