Home » Modeling » ATL » Problems with ATL Programatically
Problems with ATL Programatically [message #1750275] |
Mon, 19 December 2016 07:41  |
Eclipse User |
|
|
|
Hello,
I found this topic "https://www.eclipse.org/forums/index.php/t/1066454/0/unread/" and it save me a lot of time, thank you very much to the authors.
However i still have a problem. When i run the ATL with Eclipse Launcher, the ATL runs perfectly, but programatically throws the following exception.
Exception:
Exception in thread "main" org.eclipse.m2m.atl.emftvm.util.VMException: Cannot set properties for regular objects: null
at Object::refSetValue(propname: String, value: Object) : Object(OCL)
Local variables: [OclUndefined, 'type', 'teste']
at static EMFTVM!ExecEnv::createSteriotype(nameSteriotype: String, typeSteriotype: String) : KDM!Stereotype#7(file:///teste_1.atl#[25:3-25:103])
Local variables: [nameSteriotype: String = 'teste', typeSteriotype: String = 'teste']
at rule createSteriotypes@applier#12(file:///teste_1.atl#[18:18-18:62])
Local variables: [__trace__: TRACE!TraceLink = 4a00d9cf:TRACE!TraceLink, segment: KDM!Segment = 6aa8e115:KDM!Segment, violationExtensionFamily: KDM!ExtensionFamily = 6f1c29b7:KDM!ExtensionFamily]
at static EMFTVM!ExecEnv::main() : Object(file:///teste_1.atl)
Local variables: []
at org.eclipse.m2m.atl.emftvm.util.OCLOperations$18.execute(OCLOperations.java:503)
at org.eclipse.m2m.atl.emftvm.impl.CodeBlockImpl.invoke(CodeBlockImpl.java:2357)
at org.eclipse.m2m.atl.emftvm.impl.CodeBlockImpl.internalExecute(CodeBlockImpl.java:854)
at org.eclipse.m2m.atl.emftvm.impl.CodeBlockImpl.execute(CodeBlockImpl.java:726)
at org.eclipse.m2m.atl.emftvm.impl.CodeBlockImpl.invokeStatic(CodeBlockImpl.java:2459)
at org.eclipse.m2m.atl.emftvm.impl.CodeBlockImpl.internalExecute(CodeBlockImpl.java:858)
at org.eclipse.m2m.atl.emftvm.impl.CodeBlockImpl.execute(CodeBlockImpl.java:726)
at org.eclipse.m2m.atl.emftvm.impl.RuleImpl$WithApplierWithoutPostApplyCbState.applyFor(RuleImpl.java:1210)
at org.eclipse.m2m.atl.emftvm.impl.RuleImpl$IsNotAbstractState.apply(RuleImpl.java:986)
at org.eclipse.m2m.atl.emftvm.impl.RuleImpl.apply(RuleImpl.java:2213)
at org.eclipse.m2m.atl.emftvm.impl.ExecEnvImpl.matchAllSingle(ExecEnvImpl.java:2244)
at org.eclipse.m2m.atl.emftvm.impl.ExecEnvImpl.run(ExecEnvImpl.java:2092)
at br.ufscar.kdm_manager.core.executionEngines.atlEngine.impl.atlEngines.ATLExecutionEngineUniqueParameters.launch(ATLExecutionEngineUniqueParameters.java:115)
at br.ufscar.kdm_manager.core.executionEngines.atlEngine.impl.atlEngines.ATLExecutionEngineUniqueParameters.main(ATLExecutionEngineUniqueParameters.java:143)
ATL:
-- @nsURI KDM=http://www.eclipse.org/MoDisco/kdm/kdm
-- @atlcompiler emftvm
module teste_1;
create OUT : KDM
refining IN : KDM;
rule createSteriotypes{
from
segment: KDM!Segment
to
segmentTo: KDM!Segment(
extension <- violationExtensionFamily
),
violationExtensionFamily: KDM!ExtensionFamily(
name <- 'API-VIOLATIONS STERIOTYPES',
stereotype <- thisModule.createSteriotype('teste','teste'),
stereotype <- thisModule.createSteriotype('teste2','teste2')
)
}
helper def : createSteriotype(nameSteriotype: String, typeSteriotype: String) :
KDM!Stereotype =
KDM!Stereotype.newInstance().refSetValue('name', nameSteriotype).refSetValue('type', typeSteriotype)
;
Could someone help me?
|
|
|
Re: Problems with ATL Programatically [message #1751045 is a reply to message #1750275] |
Tue, 03 January 2017 16:08   |
Eclipse User |
|
|
|
Somehow, your second invocation of "refSetValue()" is called on OclUndefined instead of the KDM!Stereotype instance. I'm not sure why. I should warn you that the reflective way of creating new metaclass instances -- "KDM!Stereotype.newInstance()" -- is not as safe as using a called or lazy rule. There were a couple other problems with your transformation re. property multiplicity (your code would only work with the normal ATL runtimes, not EMFTVM). Here's the code that works for me:
-- @nsURI KDM=http://www.eclipse.org/MoDisco/kdm/kdm
-- @atlcompiler emftvm
module teste_1;
create OUT : KDM
refining IN : KDM;
rule createSteriotypes{
from
segment: KDM!Segment
to
segmentTo: KDM!Segment(
extension <- Sequence{violationExtensionFamily}
),
violationExtensionFamily: KDM!ExtensionFamily(
name <- 'API-VIOLATIONS STERIOTYPES',
stereotype <- Sequence{
thisModule.createSteriotype('teste','teste'),
thisModule.createSteriotype('teste2','teste2')}
)
}
lazy rule createSteriotype {
from
nameSteriotype : String,
typeSteriotype : String
to
stereotype : KDM!Stereotype (
name <- nameSteriotype,
type <- typeSteriotype)
}
|
|
| | | |
Re: Problems with ATL Programatically [message #1752331 is a reply to message #1752327] |
Sat, 21 January 2017 12:36  |
Eclipse User |
|
|
|
Hello again folks,
I'm new in ATL and I have one more problem.
I know that EMFTVM (in the refining module) see the IN and OUT model are one and the same model.
But I'm trying to use two IN models where one model gets elements from the other (keeping the elements from the first one and copying the elements from the second one to the first).
On models loading if I try to use
env.registerInOutModel("IN", inModel);
env.registerInputModel("IN2", inModel2);
i get the exception
Exception in thread "main" org.eclipse.m2m.atl.emftvm.util.VMException: java.lang.IllegalArgumentException: Cannot set properties of 64e7619d:Segment, as it is contained in an input model
at rule copySteriotypes@applier#3(file:///teste_2.atl#[15:4-15:21])
Local variables: [__trace__: TRACE!TraceLink = 329dbdbf:TRACE!TraceLink, segment: KDM!Segment = 64e7619d:Segment, test: KDM!ExtensionFamily = 1b266842:ExtensionFamily]
at static EMFTVM!ExecEnv::main() : Object(file:///teste_2.atl)
Local variables: []
at org.eclipse.m2m.atl.emftvm.impl.CodeBlockImpl.internalExecute(CodeBlockImpl.java:987)
at org.eclipse.m2m.atl.emftvm.impl.CodeBlockImpl.execute(CodeBlockImpl.java:726)
at org.eclipse.m2m.atl.emftvm.impl.RuleImpl$WithApplierWithoutPostApplyCbState.applyFor(RuleImpl.java:1210)
at org.eclipse.m2m.atl.emftvm.impl.RuleImpl$IsNotAbstractState.apply(RuleImpl.java:986)
at org.eclipse.m2m.atl.emftvm.impl.RuleImpl.apply(RuleImpl.java:2213)
at org.eclipse.m2m.atl.emftvm.impl.ExecEnvImpl.matchAllSingle(ExecEnvImpl.java:2244)
at org.eclipse.m2m.atl.emftvm.impl.ExecEnvImpl.run(ExecEnvImpl.java:2092)
at br.ufscar.kdm_manager.core.executionEngines.atlEngine.impl.atlEngines.ATLExecutionEngineRefiningModuleTwoParameters.launch(ATLExecutionEngineRefiningModuleTwoParameters.java:299)
at br.ufscar.kdm_manager.core.executionEngines.atlEngine.impl.atlEngines.ATLExecutionEngineRefiningModuleTwoParameters.main(ATLExecutionEngineRefiningModuleTwoParameters.java:355)
Caused by: java.lang.IllegalArgumentException: Cannot set properties of 64e7619d:Segment, as it is contained in an input model
at org.eclipse.m2m.atl.emftvm.util.EMFTVMUtil.set(EMFTVMUtil.java:560)
at org.eclipse.m2m.atl.emftvm.impl.CodeBlockImpl.set(CodeBlockImpl.java:1691)
at org.eclipse.m2m.atl.emftvm.impl.CodeBlockImpl.internalExecute(CodeBlockImpl.java:777)
... 8 more
and if i try to use
env.registerInOutModel("IN", inModel);
env.registerInputModel("IN2", inModel2);
i get the exception
Exception in thread "main" org.eclipse.m2m.atl.emftvm.util.VMException: java.util.ConcurrentModificationException
at public java.lang.Object org.eclipse.m2m.atl.emftvm.util.LazyCollection.iterate(java.lang.Object,org.eclipse.m2m.atl.emftvm.CodeBlock)
Local variables: []
at static EMFTVM!ExecEnv::getAllStereotype() : KDM!Stereotype#5(file:///teste_2.atl#[24:2-27:3])
Local variables: []
at rule copySteriotypes@applier#10(file:///teste_2.atl#[19:18-19:47])
Local variables: [__trace__: TRACE!TraceLink = 4b34fff9:TRACE!TraceLink, segment: KDM!Segment = 495ee280:Segment, test: KDM!ExtensionFamily = 421e361:ExtensionFamily]
at static EMFTVM!ExecEnv::main() : Object(file:///teste_2.atl)
Local variables: []
at org.eclipse.m2m.atl.emftvm.util.EMFTVMUtil.invokeNative(EMFTVMUtil.java:1139)
at org.eclipse.m2m.atl.emftvm.impl.CodeBlockImpl.invoke(CodeBlockImpl.java:2353)
at org.eclipse.m2m.atl.emftvm.impl.CodeBlockImpl.internalExecute(CodeBlockImpl.java:854)
at org.eclipse.m2m.atl.emftvm.impl.CodeBlockImpl.execute(CodeBlockImpl.java:726)
at org.eclipse.m2m.atl.emftvm.impl.CodeBlockImpl.invokeStatic(CodeBlockImpl.java:2401)
at org.eclipse.m2m.atl.emftvm.impl.CodeBlockImpl.internalExecute(CodeBlockImpl.java:858)
at org.eclipse.m2m.atl.emftvm.impl.CodeBlockImpl.execute(CodeBlockImpl.java:726)
at org.eclipse.m2m.atl.emftvm.impl.RuleImpl$WithApplierWithoutPostApplyCbState.applyFor(RuleImpl.java:1210)
at org.eclipse.m2m.atl.emftvm.impl.RuleImpl$IsNotAbstractState.apply(RuleImpl.java:986)
at org.eclipse.m2m.atl.emftvm.impl.RuleImpl.apply(RuleImpl.java:2213)
at org.eclipse.m2m.atl.emftvm.impl.ExecEnvImpl.matchAllSingle(ExecEnvImpl.java:2244)
at org.eclipse.m2m.atl.emftvm.impl.ExecEnvImpl.run(ExecEnvImpl.java:2092)
at br.ufscar.kdm_manager.core.executionEngines.atlEngine.impl.atlEngines.ATLExecutionEngineRefiningModuleTwoParameters.launch(ATLExecutionEngineRefiningModuleTwoParameters.java:299)
at br.ufscar.kdm_manager.core.executionEngines.atlEngine.impl.atlEngines.ATLExecutionEngineRefiningModuleTwoParameters.main(ATLExecutionEngineRefiningModuleTwoParameters.java:355)
Caused by: java.util.ConcurrentModificationException
at java.util.ArrayList$Itr.checkForComodification(Unknown Source)
at java.util.ArrayList$Itr.next(Unknown Source)
at org.eclipse.m2m.atl.emftvm.util.LazyCollection$UnionIterator.next(LazyCollection.java:807)
at org.eclipse.m2m.atl.emftvm.util.LazyCollection$UnionIterator.next(LazyCollection.java:802)
at org.eclipse.m2m.atl.emftvm.util.LazyCollection.iterate(LazyCollection.java:2287)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.m2m.atl.emftvm.util.EMFTVMUtil.invokeNative(EMFTVMUtil.java:1133)
... 13 more
regarding the ATL the code is
-- @nsURI KDM=http://www.eclipse.org/MoDisco/kdm/kdm
-- @nsURI KDM2=http://www.eclipse.org/MoDisco/kdm/kdm
-- @atlcompiler emftvm
module teste_2;
create OUT : KDM
refining IN: KDM, IN2 : KDM2;
rule copySteriotypes{
from
segment: KDM!Segment
to
segmentTo: KDM!Segment(
extension <- test
),
test: KDM!ExtensionFamily(
name <- 'API-VIOLATIONS STERIOTYPES',--thisModule.getNameExtension(),
stereotype <- thisModule.getAllStereotype()
)
}
helper def : getAllStereotype() : KDM!Stereotype =
KDM2!Stereotype.allInstances() -> iterate( stereotype ; elements : OrderedSet(KDM!Stereotype) =
OrderedSet{} |
elements.append(thisModule.copyStereotype(stereotype))
)
;
lazy rule copyStereotype {
from
stereotypeIn: KDM2!Stereotype
to
stereotype : KDM!Stereotype (
name <- stereotypeIn.name,
type <- stereotypeIn.type)
}
--helper def : copyStereotype(stereotype: KDM2!Stereotype) :
-- KDM!Stereotype =
-- KDM!Stereotype.newInstance().refSetValue('name', stereotype.refGetValue('name')).refSetValue('type', stereotype.refGetValue('type'))
--;
--helper def : getNameExtension() : String = KDM2!ExtensionFamily.allInstances().first().name;--refGetValue('name');
i tryed to search options but i can not found a solution.
I can not discover that the problem is with the programatically call or if is the ATL, with the commented part the Eclipse Launcher works fine but with the lazy rule the Eclipse Launcher do not works and programatically i get the exceptions.
Can anyone help me?
|
|
|
Goto Forum:
Current Time: Wed Jul 23 11:01:38 EDT 2025
Powered by FUDForum. Page generated in 0.30003 seconds
|