Skip to content

Fix isLibraryLoaded per-loader scope#233

Open
dlanov wants to merge 1 commit into
ros:rollingfrom
dlanov:fix-is-library-loaded-scope
Open

Fix isLibraryLoaded per-loader scope#233
dlanov wants to merge 1 commit into
ros:rollingfrom
dlanov:fix-is-library-loaded-scope

Conversation

@dlanov

@dlanov dlanov commented Jul 22, 2026

Copy link
Copy Markdown

Fixes #173.

Summary

ClassLoader::isLibraryLoaded() is documented to report whether a library is loaded within the scope of that specific loader.

The previous comparison used <= when comparing the number of metaobjects owned by the loader with the total number of metaobjects for the library. Because the loader-owned metaobjects are a subset of the total, this could report the library as loaded for an on-demand loader that had not loaded it.

Require the counts to match and add a regression test using two loaders for the same library. The test verifies that:

  • the on-demand loader initially reports the library as not loaded
  • it reports loaded after loadLibrary()
  • unloading it does not affect the other loader
  • the library is no longer globally loaded after the final loader unloads it

Testing

Validated in ros:rolling-ros-base:

  • colcon build --packages-select class_loader --cmake-args -DBUILD_TESTING=ON
  • colcon test --packages-select class_loader
  • 135 tests, 0 errors, 0 failures, 25 skipped
  • ClassLoaderTest.isLibraryLoadedScopedToLoader passed
  • git diff --check

Generative AI

Generative AI assisted with issue analysis, preparing the scoped edit, and test planning. I reviewed the complete diff and all test results.

Signed-off-by: Dennis Lanov <dennis.lanov@gmail.com>
@mergify

mergify Bot commented Jul 22, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

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.

Unnecessary conditional judgment in isLibraryLoaded ?

1 participant