Community
Participate
Working Groups
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.
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.
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.