我在http://www.eclipse.org/forums/index.php/t/367608/
提出的同样问题我想将为UML-Property定义的构造型应用于关联中使用的属性。我遇到的问题是在对关联关联属性使用构造型的情况下抛出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不再是属性了。有人有想法吗?会很好。谢谢, 马丁
EDIT1:
在做了一些调试之后,我发现流中方法的调用是第一次成功。在调用方法finalizeModel之前,everthing很好。当调用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
答案 0 :(得分:0)
我已经解决了我的问题。
问题是,我已将配置文件应用于从属包而不是根包。我已将关联添加到根包中。因此,每次尝试将构造型应用于root-package都失败了,因为它对我的个人资料一无所知。
因此,当属性是关联的一部分时,属性关联的构造型的应用程序才会崩溃。表示类属性的属性位于从属包中。
发布了答案