Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Association linking attempts to instantiate abstract class #1160

Closed
TimLethbridge opened this issue Nov 24, 2017 · 1 comment · Fixed by #1217
Closed

Association linking attempts to instantiate abstract class #1160

TimLethbridge opened this issue Nov 24, 2017 · 1 comment · Fixed by #1217
Assignees
Labels
associations Related to umple associations bug Crashes or wrong results Component-SemanticsAndGen Related to code generators in general and the meaning of Umple models Diffic-Easy Should be obvious how to fix it and doable in less than a week by an experienced Umple developer Priority-VHigh This is a critical problem that needs immedate solution as it is blocking users

Comments

@TimLethbridge
Copy link
Member

The following Umple code generates invalid code that attempts to instantiate an abstract class. This problem only occurs due to the 1 end of the association. If the multiplicity is changed to 0..1, then the problem is not present.

class A {
  // The generated method A.addMyB() tries to instantiate the abstract class B.
  1 -- 0..* B myBs;
}

class B {  abstract; }

This problem was flagged by @gmussbacher gunter.mussbacher@mcgill.ca and is a high priority for his work. He might comment further.

Potential Solution 1: Detect associations which have multiplicity 1 at one end, and an abstract class at the other and and either:
a) Disallow such associations with an error
b) Raise a warning, and treat as a 1..* (similar to the way we handle directed associations
c) Simply avoid generating such a method in this exact case only

Option c is suggested.

@TimLethbridge TimLethbridge added associations Related to umple associations bug Crashes or wrong results Component-SemanticsAndGen Related to code generators in general and the meaning of Umple models Diffic-Easy Should be obvious how to fix it and doable in less than a week by an experienced Umple developer Priority-VHigh This is a critical problem that needs immedate solution as it is blocking users labels Nov 24, 2017
TimLethbridge added a commit that referenced this issue Dec 19, 2017
Fixes #1160 wrongly instantiating abstract class
@TimLethbridge TimLethbridge reopened this Jan 26, 2018
@TimLethbridge TimLethbridge modified the milestones: Dec 2017 for release 1.27, April 2018 for release 1.28 Jan 26, 2018
@TimLethbridge
Copy link
Member Author

PR #1187, it turns out, didn't fix all cases of this problem. Additional templates need to be adjusted in the same way. This should be straightforward. But we need to find all relevant templates this time.

The user reported the following case:

class A {
  // The generated method A.addMyB() tries to instantiate the abstract class B.
  // The problem has been fixed for multiplicity * but still occurs with any multiplicity greater than 1.
  1 -- 0..2 B myBs;
}

class B {
  abstract;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
associations Related to umple associations bug Crashes or wrong results Component-SemanticsAndGen Related to code generators in general and the meaning of Umple models Diffic-Easy Should be obvious how to fix it and doable in less than a week by an experienced Umple developer Priority-VHigh This is a critical problem that needs immedate solution as it is blocking users
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant