Skip to content

Bugs: identitymap for datatype attributes#129

Open
h-man2 wants to merge 5 commits intomasterfrom
bugs/identitymap_for_datatype_attributes
Open

Bugs: identitymap for datatype attributes#129
h-man2 wants to merge 5 commits intomasterfrom
bugs/identitymap_for_datatype_attributes

Conversation

@h-man2
Copy link
Copy Markdown
Contributor

@h-man2 h-man2 commented Apr 20, 2026

When datatypes are imported mutiple times via indirect imports attributes cannot be identified by identity, only by their attributes owner and name.

h-man2 added 2 commits April 20, 2026 17:23
This lead to an error if datatypes where imported indirectly.
- new language features
- javadoc
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes incorrect attribute identity handling for data type instances when the same data type is brought into a model multiple times via indirect imports, so attribute slots can be looked up by logical identity (owner + name) rather than object identity.

Changes:

  • Switch MDataTypeValueState attribute-slot storage from IdentityHashMap to HashMap to enable equality-based key lookup.
  • Add/modernize MAttribute equality support by providing a hashCode() implementation consistent with equals(...).
  • Extend the Time example data type with a before(other: Time) operation.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
use-core/src/main/resources/examples/Documentation/Imports/Time.use Adds a before operation to the Time data type example.
use-core/src/main/java/org/tzi/use/uml/sys/MDataTypeValueState.java Uses HashMap for attribute slots to avoid identity-based lookup failures across repeated imports.
use-core/src/main/java/org/tzi/use/uml/mm/MAttribute.java Adds hashCode() (and minor Javadoc/equals modernization) so attributes behave correctly as hash keys.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread use-core/src/main/resources/examples/Documentation/Imports/Time.use Outdated
Comment thread use-core/src/main/java/org/tzi/use/uml/mm/MAttribute.java
Comment thread use-core/src/main/java/org/tzi/use/uml/sys/MDataTypeValueState.java
h-man2 and others added 3 commits April 21, 2026 13:27
Just chaining implies is not enough

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Added test with different imports. Before the fix, invariant "businessHours" failed with output "N/A"
…tributes' into bugs/identitymap_for_datatype_attributes
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes datatype attribute slot lookup when the same datatype is imported multiple times (e.g., via indirect imports), so attribute access works based on semantic equality rather than object identity.

Changes:

  • Switch datatype value state attribute-slot storage from IdentityHashMap to HashMap.
  • Add hashCode() to MAttribute to align with existing equals() semantics (owner + name), enabling correct hashed lookups.
  • Add a new shell integration test (with indirect-imported Date/Time/DateTime datatypes) to reproduce/guard the scenario; update import documentation example to include Time::before.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
use-gui/src/it/resources/testfiles/shell/t133_imports.use New model exercising indirect imports and datatype attribute navigation (time.hour, etc.).
use-gui/src/it/resources/testfiles/shell/t133_imports.in New shell script asserting the scenario executes and invariants pass.
use-gui/src/it/resources/testfiles/shell/imports/t133_import_time.use New Time datatype used by the indirect-import test.
use-gui/src/it/resources/testfiles/shell/imports/t133_import_datetime.use New DateTime datatype that indirectly imports Date and Time.
use-gui/src/it/resources/testfiles/shell/imports/t133_import_date.use New Date datatype used by the indirect-import test.
use-core/src/main/resources/examples/Documentation/Imports/Time.use Documentation example extended with Time::before.
use-core/src/main/java/org/tzi/use/uml/sys/MDataTypeValueState.java Use HashMap for datatype attribute slots to allow equality-based lookup.
use-core/src/main/java/org/tzi/use/uml/mm/MAttribute.java Add hashCode() consistent with equals() for reliable hashed map/set behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

)

getEasterSunday() : Date =
// Following Gauss algorithm to calculate eastern
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