Adding an operation that returns a set in an implementation class throws an exception.

Issue #263 resolved
Omar Alam created an issue

I was trying to add the operation keySet() in the HashMap implementation class, in the Association concern (see attached figure). The operation keySet() is added but its return type (which is a Set) is missing. The tool throws the following exception:

ca.mcgill.cs.sel.ram.impl.OperationImpl@6b584128 (name: keySet) (abstract: false, visibility: public, static: false, partial: false, operationType: Normal) : returnTypeDefined (if self.returnType.oclIsInvalid().or(self.returnType.oclIsUndefined()) then false else let sv : ram::StructuralView[?] = self.oclContainer().oclAsType(ram::Classifier).oclContainer().oclAsType(ram::StructuralView) in sv.types->includes(self.returnType).or(sv.oclContainer().oclAsType(ram::Aspect).containsTypeInEnumsOrClasses(self.returnType)) endif)
'NavigableObject' rather than 'OclVoid' value required
Exception in thread "Animation Thread" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at java.util.ArrayList.RangeCheck(ArrayList.java:547)
    at java.util.ArrayList.get(ArrayList.java:322)
    at ca.mcgill.sel.ram.validator.ValidationManager.update(ValidationManager.java:402)
    at org.mt4j.components.MTComponent.updateComponent(MTComponent.java:1858)
    at org.mt4j.components.MTCanvas.drawUpdateRecursive(MTCanvas.java:323)
    at org.mt4j.components.MTCanvas.drawUpdateRecursive(MTCanvas.java:431)
    at org.mt4j.components.MTCanvas.drawUpdateRecursive(MTCanvas.java:393)
    at org.mt4j.components.MTCanvas.drawAndUpdateCanvas(MTCanvas.java:308)
    at org.mt4j.sceneManagement.AbstractScene.drawAndUpdate(AbstractScene.java:170)
    at org.mt4j.AbstractMTApplication.runApplication(AbstractMTApplication.java:381)
    at org.mt4j.AbstractMTApplication.draw(AbstractMTApplication.java:272)
    at processing.core.PApplet.handleDraw(PApplet.java:1603)
    at processing.core.PApplet.run(PApplet.java:1502)
    at java.lang.Thread.run(Thread.java:695)

Comments (5)

  1. Matthias Schoettle

    The reason is that Set<Key> is imported and then it tries to find Set<Key> (in your case), but it cannot be found, because types of type Class are ignored when determining the complete class name including generics (in RamModelUtils.getClassNameWithGenerics(...).

  2. Matthias Schoettle

    Resolves #263: Adds handling of a RAM class so that its name is added to the overall class name (if a Class is the generic type). This ignores the actual textual representation (i.e., partial is omitted) of the class, but it is done uniformly for this case.

    → <<cset 5644188445da>>

  3. Log in to comment