Bug 394376 - IllegalAccessException when computing the size of an empty SubSequence
Summary: IllegalAccessException when computing the size of an empty SubSequence
Status: UNCONFIRMED
Alias: None
Product: MMT.ATL
Classification: Modeling
Component: emfvm (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: mmt-atl.toolkit-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-15 05:44 EST by Andreas Brieg CLA
Modified: 2012-11-15 05:44 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Brieg CLA 2012-11-15 05:44:12 EST
The problem is in the following helper:

helper def: isEmpty(): Boolean =
	Sequence{}.subSequence(1, 0).size() = 0;

Upon invocation this helper will report an IllegalAccessException when size() is invoked on the SubSequence. The complete stacktrace is:

org.eclipse.m2m.atl.engine.emfvm.VMException: Could not invoke operation size on []
Java Stack:
org.eclipse.m2m.atl.engine.emfvm.VMException: Could not invoke operation size on []
	at org.eclipse.m2m.atl.engine.emfvm.adapter.EMFModelAdapter.invoke(EMFModelAdapter.java:762)
	at org.eclipse.m2m.atl.engine.emfvm.ASMOperation.exec(ASMOperation.java:425)
	at org.eclipse.m2m.atl.engine.emfvm.ASMOperation.exec(ASMOperation.java:388)
	at org.eclipse.m2m.atl.engine.emfvm.ASMOperation.exec(ASMOperation.java:388)
	at org.eclipse.m2m.atl.engine.emfvm.ASMOperation.exec(ASMOperation.java:388)
	at org.eclipse.m2m.atl.engine.emfvm.ASM.run(ASM.java:208)
	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:234)
	at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:855)
	at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:704)
	at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:1047)
	at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1251)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Caused by: java.lang.IllegalAccessException: Class org.eclipse.m2m.atl.engine.emfvm.adapter.EMFModelAdapter can not access a member of class java.util.Collections$EmptyList with modifiers "public"
	at sun.reflect.Reflection.ensureMemberAccess(Unknown Source)
	at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(Unknown Source)
	at java.lang.reflect.AccessibleObject.checkAccess(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.m2m.atl.engine.emfvm.adapter.EMFModelAdapter.invoke(EMFModelAdapter.java:760)
	... 15 more

The problem is that java.util.Collections.EmptyList is declared private. 

Should it even be legal to call subSequence with the above parameters?

Workaround:
Do proper checks before invoking subSequence and if it would result in an empty sequence, explicitly return an empty sequence.