Community
Participate
Working Groups
Cloned from: 322218: ClassCastException adding an object to an EList with objects of a custom data type https://bugs.eclipse.org/bugs/show_bug.cgi?id=322218 I my model I have an attribute which is a list of int[], EList<int[]>. int[] is defined as a custom data type in the model. As soon as I try to add anything to the list I get a ClassCastException. java.lang.ClassCastException: org.eclipse.emf.internal.cdo.revision.CDOListWithElementProxiesImpl cannot be cast to java.lang.String ERROR at org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl$25.convertToEMF(CDOTypeImpl.java:592) at org.eclipse.emf.internal.cdo.CDOStore.convertToEMF(CDOStore.java:581) at org.eclipse.emf.internal.cdo.CDOStore.get(CDOStore.java:176) at org.eclipse.emf.internal.cdo.CDOStore.isSet(CDOStore.java:194) at org.eclipse.emf.ecore.impl.EStoreEObjectImpl$BasicEStoreEList.isSet(EStoreEObjectImpl.java:161) at org.eclipse.emf.common.notify.impl.DelegatingNotifyingListImpl.addUnique(DelegatingNotifyingListImpl.java:280) at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:307) I can also trigger the error calling "eIsSet" for the same attribute.
I added this to model5.ecore: <eClassifiers xsi:type="ecore:EClass" name="GenListOfIntArray"> <eStructuralFeatures xsi:type="ecore:EAttribute" name="elements" upperBound="-1" eType="#//IntArray"/> </eClassifiers> <eClassifiers xsi:type="ecore:EDataType" name="IntArray" instanceClassName="int[]"/>
I added Bugzilla_322804_Test: public void testAddElementToCustomTypedList() throws Exception { CDOSession session = openSession(); CDOTransaction transaction = session.openTransaction(); CDOResource resource = transaction.createResource("/r1"); msg("Fill and commit a resource"); GenListOfIntArray object = getModel5Factory().createGenListOfIntArray(); resource.getContents().add(object); transaction.commit(); msg("Add int[] elements"); object.getElements().add(new int[] { 1, 2, 3, 4, 5 }); object.getElements().add(new int[] { 10, 20, 30, 40, 50 }); transaction.commit(); session.close(); } Committed to HEAD
The test passes. Closing as WORKSFORME. Please reopen if you can reproduce the problem.
Closing.