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

Bug 368818

Summary: ClassCastException when calling isSet on a list feature when notification disabled
Product: [Modeling] EMF Reporter: David Michonneau <davidmichonneau>
Component: CoreAssignee: Ed Merks <Ed.Merks>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
project with test to reproduce the issue none

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.