Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 352269

Summary: IllegalArgumentException when loading a model containing a Changeable=false reference with the OPTION_DEFER_IDREF_RESOLUTION set to true.
Product: [Modeling] EMF Reporter: Svetlin <svetlin.mladenov>
Component: XML/XMIAssignee: Ed Merks <Ed.Merks>
Status: RESOLVED WONTFIX QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
A test project to help reproduce the problem. none

Description Svetlin CLA 2011-07-16 08:12:23 EDT
Build Identifier: 20100917-0705

When trying to load an instance of a particular model which contains a reference that is changeable=false using an XMIResourceImpl and the option XMLResource.OPTION_DEFER_IDREF_RESOLUTION set to true I always get an IllegalArgumentException telling me that the const feature "is not a valid changeable feature". If I remove the XMLResource.OPTION_DEFER_IDREF_RESOLUTION option everything works perfectly.

I attach a test project.

Reproducible: Always

Steps to Reproduce:
1. Import the attached project (EmfPersConstRef.tar)
2. Run testmodel.test.TestMain as Java Application.
Comment 1 Svetlin CLA 2011-07-16 08:18:49 EDT
Created attachment 199783 [details]
A test project to help reproduce the problem.

Import the attached java project and run testmodel.test.TestMain as Java Project to reproduce the problem and see a stack trace.
Comment 2 Ed Merks CLA 2011-07-16 13:52:42 EDT
I'm really not sure what you're expecting.  Firstly, making one end of a bidirectional reference is a little odd, but fine, you want to force editing to happen from the other end.  That means you should never directly set the one end...

But then you decide not to make that end transient?  Why? You've decided not to allow it to be set but the serializer will save the value and the deserializer will try to set it.

It seems to me you have a few choices.  One, make the non-changeable end transient; of course that only makes sense if the ends of the references will always be in the same document, so resolveProxies would also have to be false.  Otherwise, the serializer need to be able to set the value from both ends so you can't make it unchangeable.  Better to suppress the setter from the public API (see EcoreUtil.setSuppressedVisibility) so that the client can't easily set the value but reflectively, it's still possible (for the serializer) to set the value reflectively.