Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » ArrayIndexOutOfBoundsException with ->at(1) although size is 2(java.util.NoSuchElementException with first() for the same LazyList)
ArrayIndexOutOfBoundsException with ->at(1) although size is 2 [message #1062599] Sun, 09 June 2013 18:30 Go to next message
Stefan L is currently offline Stefan LFriend
Messages: 13
Registered: July 2012
Junior Member
Hi again,

I encountered a weird problem which I'm not able to resolve.

In my example below, I try to access the first list entry, which is again a list containing two Lifelines. But somehow, I'm not able to access position 1 when using ->at(1) or ->first().

"getAssociations" returns a list (with length n). Each list entry contains another list (size is awlays 2). So it basically looks like the following:
[[light:Light:Lifeline, switch:Switch:Lifeline], [... , ...] ...]


Source Code:
lazy rule ClassOwnedAttributeAssociation {
	from rcv: UML2!"uml::Lifeline", snd: UML2!"uml::Lifeline"
	to
		t: UML2!"uml::Property" (
name <- (thisModule.getAssociations()->select(a | 
				if a->at(1) = rcv
				then 
					true
				else
					false
				endif))->flatten()->at(1).toString()
do {
		t; 
	}


Further the list gets flatten, resulting in a list with exactly two Lifelines. After this step, I just can't get any further Sad

The error occurs at the ->at(1) or ->first() respectively:
endif))->flatten()->at(1).toString()


Error Message when calling with ->at(1):
Exception in thread "main" org.eclipse.m2m.atl.emftvm.util.VMException: java.lang.ArrayIndexOutOfBoundsException
at public java.lang.Object org.eclipse.m2m.atl.emftvm.util.LazyList.at(int)
	Local variables: []
at rule ClassOwnedAttributeAssociation@applier#7(../AtlTransform/test/test.atl#[104:12-110:30])
	Local variables: [__trace__: TRACE!TraceLink = 78e12210:TRACE!TraceLink, rcv: UML2!uml::Lifeline = switch:Switch:UML2!Lifeline, snd: UML2!uml::Lifeline = switch:Switch:UML2!Lifeline, t: UML2!uml::Property = 7c2942ce:UML2!Property]
at rule Lifeline2Class@applier#41(../AtlTransform/test/test.atl#[192:31-197:7])
	Local variables: [__trace__: TRACE!TraceLink = 318fddfb:TRACE!TraceLink, s: UML2!uml::Lifeline = switch:Switch:UML2!Lifeline, t: UML2!uml::Class = switch:Switch:UML2!Class]
at static EMFTVM!ExecEnv::main() : Object(../AtlTransform/test/test.atl)
	Local variables: []
	at org.eclipse.m2m.atl.emftvm.util.EMFTVMUtil.invokeNative(EMFTVMUtil.java:1038)


Error Message when calling with ->first():
Exception in thread "main" org.eclipse.m2m.atl.emftvm.util.VMException: java.lang.UnsupportedOperationException: #native!org.eclipse.m2m.atl.emftvm.util.LazyList::at()
at rule ClassOwnedAttributeAssociation@applier#6(../AtlTransform/test/test.atl#[104:12-110:29])
	Local variables: [__trace__: TRACE!TraceLink = 78e12210:TRACE!TraceLink, rcv: UML2!uml::Lifeline = switch:Switch:UML2!Lifeline, snd: UML2!uml::Lifeline = switch:Switch:UML2!Lifeline, t: UML2!uml::Property = 7c2942ce:UML2!Property]
at rule Lifeline2Class@applier#41(../AtlTransform/test/test.atl#[192:31-197:7])
	Local variables: [__trace__: TRACE!TraceLink = 15b346d0:TRACE!TraceLink, s: UML2!uml::Lifeline = switch:Switch:UML2!Lifeline, t: UML2!uml::Class = switch:Switch:UML2!Class]
at static EMFTVM!ExecEnv::main() : Object(../AtlTransform/test/test.atl)
	Local variables: []
	at org.eclipse.m2m.atl.emftvm.impl.CodeBlockImpl.internalExecute(CodeBlockImpl.java:989)


I would appreciate some help.
Thanks!

Stefan

[Updated on: Sun, 09 June 2013 19:52]

Report message to a moderator

Re: ArrayIndexOutOfBoundsException with ->at(1) although size is 2 [message #1062678 is a reply to message #1062599] Mon, 10 June 2013 11:03 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 674
Registered: July 2009
Senior Member
Hello,

Have you tried to make a call to the debug() operation in order to display on the console the content of your list?
endif))->debug('Before')->flatten()->debug('After')->at(1).toString()

If you get such an error, it probably means that the actual list content is not what you think it is.


--------------------------------------------------------
Hugo Bruneliere, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
Nantes - France
--------------------------------------------------------
Re: ArrayIndexOutOfBoundsException with ->at(1) although size is 2 [message #1062682 is a reply to message #1062678] Mon, 10 June 2013 11:19 Go to previous message
Stefan L is currently offline Stefan LFriend
Messages: 13
Registered: July 2012
Junior Member
Actually I haven't used the debug feature before, but it just enlightened me. The rule is executed two times, at first with no inputs and a second time with inputs. So if there are no inputs, an access violation will indeed occur.

Thanks a lot.
Stefan

Previous Topic:Higher order transformation
Next Topic:Performance
Goto Forum:
  


Current Time: Fri Apr 19 02:27:52 GMT 2024

Powered by FUDForum. Page generated in 0.01842 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top