Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 354858 - [delegate] OCL problem with reflective api when object in use extends the EObject
Summary: [delegate] OCL problem with reflective api when object in use extends the EOb...
Status: CLOSED INVALID
Alias: None
Product: OCL
Classification: Modeling
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: OCL Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-16 12:39 EDT by Dmitriy Nesterenko CLA
Modified: 2013-05-20 11:36 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitriy Nesterenko CLA 2011-08-16 12:39:16 EDT
Build Identifier: 20110218-0911

any ocl evaluation against the object which extends EObject is failing.

problem is in EcoreEvaluationEnvironment.java
method :
	protected Exception checkOperationReflectionConsistency(Object source) {

		try {
			source.getClass().getDeclaredMethod(
				"eInvoke", int.class, EList.class); 
			return null;
		} catch (NoSuchMethodException e) {
			return e;
		} catch (SecurityException e) {
			throw new IllegalArgumentException(e);
		}
	}

getDeclaredMethod(..) should be replaced with getMethod(..), overwise every child of EObject will fail here unless it overrides the eInvoke method


Reproducible: Always
Comment 1 Ed Willink CLA 2011-08-16 13:14:13 EDT
checkOperationReflectionConsistency is a workaround to give fallback functionality for users who neglect to set OperationReflection true in their genmodel.

You can therefore 'workaround' this by setting OperationReflection true.

Did you not see the "Override of eInvoke(int,EList) not found for ''{0}'': set ''Operation Reflection'' true and re-genmodel." message?

If the code was modified as suggested, no diagnostic for the inappropriate genmodel setting would be issued. (In 3.0.0 you would just have got an unhelpful crash.)
Comment 2 Dmitriy Nesterenko CLA 2011-08-16 13:31:13 EDT
ok, sounds good.
but this is not my Object which extends EObject it is from teneo. below is an exception i got. I am not using the genmodel but only ecore. i thought that if you fix the root of the issue then nobody would have it anymore. 
but i guess if you said it is by design then i have to contact teneo team and remember about this issue next time i extend EObject myself.

!MESSAGE Override of eInvoke(int,EList) not found for 'lookup::MyTable': set 'Operation Reflection' true and re-genmodel.
!STACK 0
java.lang.NoSuchMethodException: org.eclipse.emf.teneo.hibernate.mapping.SerializableDynamicEObjectImpl.eInvoke(int, org.eclipse.emf.common.util.EList)
	at java.lang.Class.getDeclaredMethod(Class.java:1937)
Comment 3 Ed Willink CLA 2011-08-16 13:42:59 EDT
The 'root' of the problem is perhaps that GenModel could have a validation rule that if there are any invocation delegates, Operation Reflection could beneficially be true.

checkOperationReflectionConsistency was the best we could come up with within the confines of OCL 3.0.1 to warn users what their problem was. 3.0.0 just crashed.

It would appear that Teneo has a faulty genModel; raise a Bugzilla.

If you can contrive to call EcoreEvaluationEnvironment.setOperationReflectionCheckDisabled(true) you can silence the message, but you will continue to get less efficient fallback dynamic dispatch when direct dispatch could have been genmodelled.
Comment 4 Dmitriy Nesterenko CLA 2011-08-16 13:49:08 EDT
ok, thanks
the other work around is just to use custom EcoreEvaluationEnvironment and override the method mentioned before
Comment 5 Ed Willink CLA 2013-05-20 11:36:06 EDT
CLOSED after a year in the RESOLVED state.