0

我在http://www.eclipse.org/forums/index.php/t/367608/上问过同样的问题

我想将针对 UML 属性定义的构造型应用于关联中使用的属性。我遇到的问题是,在将构造型用于关联相关属性的情况下会引发 IllegalArgumentException。如果我将构造型应用于在类中用作属性的属性,一切都很好。

这是异常抛出部分的代码片段:

helper def: getStereotype(name: String): UML!Stereotype =
UML!Stereotype.allInstancesFrom('PRO') -> select(p | p.name = name) -> first();
-- ...
p1: UML!Property(

    upper <-a.associationEnds.first().conformance.upperBound,
    lower <- a.associationEnds.first().conformance.lowerBound,
    name <- a.associationEnds.first().name,
    type <- firstMemberType,
    opposite <- p2,
    isComposite <- true
),

p2: UML!Property(

        upper <-a.associationEnds.last().conformance.upperBound,
        lower <- a.associationEnds.last().conformance.lowerBound,
        name <- a.associationEnds.last().name,
        type <- secondMemberType,
        opposite <- p1
    ),

as:UML!Association(
        name <- a.name,
        ownedEnd <- Set{p2}
        navigableOwnedEnd <- Set{p1}
        )
    do {
p1.applyStereotype(thisModule.getStereotype('xsdElement')); -- here an exception is thrown: see below
}

引发以下 IllegalArgumentException。

Here appear some other resulting stacktraces.
......

Caused by: java.lang.IllegalArgumentException: org.eclipse.uml2.uml.internal.impl.StereotypeImpl@21ee05 (name: xsdElement, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false)
    at org.eclipse.uml2.uml.internal.operations.ElementOperations.applyStereotype(ElementOperations.java:1413)
    at org.eclipse.uml2.uml.internal.impl.ElementImpl.applyStereotype(ElementImpl.java:510)
    ... 18 more

我用过UML=http://www.eclipse.org/uml2/3.0.0/UML

似乎 p1 不再是一个属性。任何人的想法?会很好。谢谢,马丁

编辑1:

经过一番调试,我发现流程中方法的调用首先是成功的。在调用方法 finalizeModel 之前,一切都很好。当调用 ATL UML2ModelAdapter 中的方法 finalizeModel 时,会抛出堆栈跟踪:

Java Stack:
org.eclipse.m2m.atl.engine.emfvm.VMException
    at org.eclipse.m2m.atl.engine.emfvm.adapter.UML2ModelAdapter.finalizeModel(UML2ModelAdapter.java:51)
    at org.eclipse.m2m.atl.engine.emfvm.lib.ExecEnv.terminated(ExecEnv.java:2557)
    at org.eclipse.m2m.atl.engine.emfvm.ASM.run(ASM.java:210)
    at org.eclipse.m2m.atl.engine.emfvm.launch.EMFVMLauncher.internalLaunch(EMFVMLauncher.java:170)
    at org.eclipse.m2m.atl.engine.emfvm.launch.EMFVMUILauncher.launch(EMFVMUILauncher.java:46)
    at org.eclipse.m2m.atl.core.service.LauncherService.launch(LauncherService.java:136)
    at org.eclipse.m2m.atl.core.ui.launch.AtlLaunchConfigurationDelegate.launchOrDebug(AtlLaunchConfigurationDelegate.java:300)
    at org.eclipse.m2m.atl.core.ui.launch.AtlLaunchConfigurationDelegate.launch(AtlLaunchConfigurationDelegate.java:237)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:854)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:703)
    at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:937)
    at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1141)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.GeneratedMethodAccessor26.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.m2m.atl.engine.emfvm.adapter.UML2ModelAdapter.applyDelayedInvocations(UML2ModelAdapter.java:136)
    at org.eclipse.m2m.atl.engine.emfvm.adapter.UML2ModelAdapter.finalizeModel(UML2ModelAdapter.java:49)
    ... 12 more
Caused by: java.lang.IllegalArgumentException: org.eclipse.uml2.uml.internal.impl.StereotypeImpl@580b29 (name: xsdElement, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false)
    at org.eclipse.uml2.uml.internal.operations.ElementOperations.applyStereotype(ElementOperations.java:1413)
    at org.eclipse.uml2.uml.internal.impl.ElementImpl.applyStereotype(ElementImpl.java:510)
    ... 17 more
4

1 回答 1

0

我已经解决了我的问题。

问题是,我已将配置文件应用于从属包而不是根包。我已将关联添加到根包中。因此,每次尝试将刻板印象应用于根包都失败了,因为它不知道我的个人资料。

因此,只有当属性是关联的一部分时,属性相关构造型的应用才会崩溃。表示类属性的属性位于从属包中。

我还在以下位置发布了答案:http: //www.eclipse.org/forums/index.php/t/367608/

于 2012-07-17T12:12:01.073 回答