Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 368818 - ClassCastException when calling isSet on a list feature when notification disabled
Summary: ClassCastException when calling isSet on a list feature when notification dis...
Status: CLOSED FIXED
Alias: None
Product: EMF
Classification: Modeling
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Ed Merks CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-17 07:26 EST by David Michonneau CLA
Modified: 2012-03-31 14:24 EDT (History)
0 users

See Also:


Attachments
project with test to reproduce the issue (12.81 KB, application/x-zip-compressed)
2012-01-17 07:28 EST, David Michonneau CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Michonneau CLA 2012-01-17 07:26:05 EST
Build Identifier: Version: Helios Service Release 2 Build id: 20110218-0911

When notification is disabled when generating the model, calling isSetXXX() on a list will trigger a ClassCastException.

        A a = AFactory.eINSTANCE.createA();
        B b = AFactory.eINSTANCE.createB();
        a.getBs().add(b);
        a.isSetBs(); // classcastexception here

java.lang.ClassCastException: org.eclipse.emf.ecore.util.BasicInternalEList cannot be cast to org.eclipse.emf.ecore.util.InternalEList$Unsettable
	at a.impl.AImpl.isSetBs(AImpl.java:94)
	at emfplayground.Unset.list(Unset.java:17)
	at 

The bug is in the generated code:
    public EList<B> getBs() {
        if (bs == null) {
            bs = new BasicInternalEList<B>(B.class);
        }
        return bs;
    }

Reproducible: Always
Comment 1 David Michonneau CLA 2012-01-17 07:28:08 EST
Created attachment 209614 [details]
project with test to reproduce the issue
Comment 2 Ed Merks CLA 2012-01-17 12:13:12 EST
The fix is committed to git master for 2.8.

I added a BasicInternalEList.Unique, but it's only used if the Runtime Version is set to 2.8 in the GenModel, which is the default unless it's set to something else explicitly.
Comment 3 Ed Merks CLA 2012-03-31 14:24:13 EDT
The changes are available in the M6 build.