Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] Nested generic types can't be committed
[CDO] Nested generic types can't be committed [message #901167] Fri, 10 August 2012 08:06 Go to next message
Anders  Jönsson is currently offline Anders JönssonFriend
Messages: 33
Registered: January 2012
Member
Hi,

I have a problem with models using generic types in a nested way. This works in java and now also in EMF (See bug 380624):

public abstract class EventStream< P extends EventStream<P,C>,C extends Event<P,C>> {
private List<C> events;
...
}
public class Event< P extends EventStream<P,C>,C extends Event<P,C>> {
private P parent;
...
}

Link to recently fixed EMF bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=380624

When trying to save this model with CDO it goes into an infinite loop.
(See also attached test case)

Here is the stack trace:

org.eclipse.emf.cdo.util.CommitException: java.lang.StackOverflowError
at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl.commit(CDOTransactionImpl.java:1148)
at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl.commit(CDOTransactionImpl.java:1154)
at com.riiplan.lab.generics1.nested.test.NestedGenericTypes_1Test.testSaveNestedGenericTypes(NestedGenericTypes_1Test.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:168)
at org.eclipse.net4j.util.tests.AbstractOMTest.runBare(AbstractOMTest.java:218)
at org.eclipse.emf.cdo.tests.config.impl.ConfigTest.runBare(ConfigTest.java:526)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at org.eclipse.net4j.util.tests.AbstractOMTest.run(AbstractOMTest.java:264)
at junit.framework.TestSuite.runTest(TestSuite.java:243)
at junit.framework.TestSuite.run(TestSuite.java:238)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.StackOverflowError
at org.eclipse.emf.ecore.util.EObjectEList.resolve(EObjectEList.java:109)
at org.eclipse.emf.common.util.BasicEList.get(BasicEList.java:348)
at org.eclipse.emf.common.util.AbstractEList$EIterator.doNext(AbstractEList.java:703)
at org.eclipse.emf.common.util.AbstractEList$EIterator.next(AbstractEList.java:690)
at org.eclipse.emf.internal.cdo.util.CompletePackageClosure.handleEGenericTypes(CompletePackageClosure.java:151)
at org.eclipse.emf.internal.cdo.util.CompletePackageClosure.handleETypeParameter(CompletePackageClosure.java:186)
at org.eclipse.emf.internal.cdo.util.CompletePackageClosure.handleEGenericType(CompletePackageClosure.java:167)
at org.eclipse.emf.internal.cdo.util.CompletePackageClosure.handleEGenericTypes(CompletePackageClosure.java:153)
at org.eclipse.emf.internal.cdo.util.CompletePackageClosure.handleEGenericType(CompletePackageClosure.java:166)
at org.eclipse.emf.internal.cdo.util.CompletePackageClosure.handleEGenericTypes(CompletePackageClosure.java:153)
at org.eclipse.emf.internal.cdo.util.CompletePackageClosure.handleETypeParameter(CompletePackageClosure.java:186)
at org.eclipse.emf.internal.cdo.util.CompletePackageClosure.handleEGenericType(CompletePackageClosure.java:167)
at org.eclipse.emf.internal.cdo.util.CompletePackageClosure.handleEGenericTypes(CompletePackageClosure.java:153)
at org.eclipse.emf.internal.cdo.util.CompletePackageClosure.handleEGenericType(CompletePackageClosure.java:166)
at org.eclipse.emf.internal.cdo.util.CompletePackageClosure.handleEGenericTypes(CompletePackageClosure.java:153)
at org.eclipse.emf.internal.cdo.util.CompletePackageClosure.handleETypeParameter(CompletePackageClosure.java:186)
at org.eclipse.emf.internal.cdo.util.CompletePackageClosure.handleEGenericType(CompletePackageClosure.java:167)
this goes on and on and on and on...


Here is the testcase (real stuff in attachment):
(There is a class Activity extends EventStream<Activity, ActivityEvent> and a class ActivityEvent extends Event<Activity, ActivityEvent>)

public void testSaveNestedGenericTypes() throws Exception {
CDOSession session1 = openSession();
CDOTransaction transaction1 = session1.openTransaction();
CDOResource resource = transaction1.createResource(getResourcePath("/lab/resource"));

Root newRoot = getNestedFactory().createRoot();
resource.getContents().add(newRoot);

// Create an EventStream of type Activity
Activity activity1 = getNestedFactory().createActivity();
activity1.setName("activity1");
newRoot.getActivities().add(activity1);
// Add Events of Type ActivityEvent
for (int i = 0; i < 5; i++) {
ActivityEvent activityEvent = getNestedFactory().createActivityEvent();
activityEvent.setParent(activity1);
}

// This commit fails, caused by:
// java.lang.StackOverflowError in at org.eclipse.emf.ecore.util.EObjectEList.resolve(EObjectEList.java:109)
transaction1.commit();
session1.close();

CDOSession session2 = openSession();
CDOTransaction transaction2 = session2.openTransaction();
CDOResource resource2 = transaction2.getOrCreateResource(getResourcePath("/lab/resource"));
Root readRoot = (Root)resource2.getContents().get(0);
Activity readActivity = readRoot.getActivities().get(0);
assertEquals(5, readActivity.getEvents().size());
}

Best Regards
///Anders
Re: [CDO] Nested generic types can't be committed [message #901184 is a reply to message #901167] Fri, 10 August 2012 08:42 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 5587
Registered: July 2009
Senior Member
Hi Anders,

Can you please submit a bugzilla so that I can look at it ASAP?

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Am 10.08.2012 10:06, schrieb Anders Jönsson:
> Hi,
>
> I have a problem with models using generic types in a nested way. This works in java and now also in EMF (See bug 380624):
>
> public abstract class EventStream< P extends EventStream<P,C>,C extends Event<P,C>> {
> private List<C> events;
> ..
> }
> public class Event< P extends EventStream<P,C>,C extends Event<P,C>> {
> private P parent;
> ..
> }
>
> Link to recently fixed EMF bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=380624
>
> When trying to save this model with CDO it goes into an infinite loop.
> (See also attached test case)
>
> Here is the stack trace:
>
> org.eclipse.emf.cdo.util.CommitException: java.lang.StackOverflowError
> at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl.commit(CDOTransactionImpl.java:1148)
> at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl.commit(CDOTransactionImpl.java:1154)
> at com.riiplan.lab.generics1.nested.test.NestedGenericTypes_1Test.testSaveNestedGenericTypes(NestedGenericTypes_1Test.java:40)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at junit.framework.TestCase.runTest(TestCase.java:168)
> at org.eclipse.net4j.util.tests.AbstractOMTest.runBare(AbstractOMTest.java:218)
> at org.eclipse.emf.cdo.tests.config.impl.ConfigTest.runBare(ConfigTest.java:526)
> at junit.framework.TestResult$1.protect(TestResult.java:110)
> at junit.framework.TestResult.runProtected(TestResult.java:128)
> at junit.framework.TestResult.run(TestResult.java:113)
> at junit.framework.TestCase.run(TestCase.java:124)
> at org.eclipse.net4j.util.tests.AbstractOMTest.run(AbstractOMTest.java:264)
> at junit.framework.TestSuite.runTest(TestSuite.java:243)
> at junit.framework.TestSuite.run(TestSuite.java:238)
> at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
> at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
> at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
> Caused by: java.lang.StackOverflowError
> at org.eclipse.emf.ecore.util.EObjectEList.resolve(EObjectEList.java:109)
> at org.eclipse.emf.common.util.BasicEList.get(BasicEList.java:348)
> at org.eclipse.emf.common.util.AbstractEList$EIterator.doNext(AbstractEList.java:703)
> at org.eclipse.emf.common.util.AbstractEList$EIterator.next(AbstractEList.java:690)
> at org.eclipse.emf.internal.cdo.util.CompletePackageClosure.handleEGenericTypes(CompletePackageClosure.java:151)
> at org.eclipse.emf.internal.cdo.util.CompletePackageClosure.handleETypeParameter(CompletePackageClosure.java:186)
> at org.eclipse.emf.internal.cdo.util.CompletePackageClosure.handleEGenericType(CompletePackageClosure.java:167)
> at org.eclipse.emf.internal.cdo.util.CompletePackageClosure.handleEGenericTypes(CompletePackageClosure.java:153)
> at org.eclipse.emf.internal.cdo.util.CompletePackageClosure.handleEGenericType(CompletePackageClosure.java:166)
> at org.eclipse.emf.internal.cdo.util.CompletePackageClosure.handleEGenericTypes(CompletePackageClosure.java:153)
> at org.eclipse.emf.internal.cdo.util.CompletePackageClosure.handleETypeParameter(CompletePackageClosure.java:186)
> at org.eclipse.emf.internal.cdo.util.CompletePackageClosure.handleEGenericType(CompletePackageClosure.java:167)
> at org.eclipse.emf.internal.cdo.util.CompletePackageClosure.handleEGenericTypes(CompletePackageClosure.java:153)
> at org.eclipse.emf.internal.cdo.util.CompletePackageClosure.handleEGenericType(CompletePackageClosure.java:166)
> at org.eclipse.emf.internal.cdo.util.CompletePackageClosure.handleEGenericTypes(CompletePackageClosure.java:153)
> at org.eclipse.emf.internal.cdo.util.CompletePackageClosure.handleETypeParameter(CompletePackageClosure.java:186)
> at org.eclipse.emf.internal.cdo.util.CompletePackageClosure.handleEGenericType(CompletePackageClosure.java:167)
> this goes on and on and on and on...
>
>
> Here is the testcase (real stuff in attachment):
> (There is a class Activity extends EventStream<Activity, ActivityEvent> and a class ActivityEvent extends Event<Activity, ActivityEvent>)
>
> public void testSaveNestedGenericTypes() throws Exception {
> CDOSession session1 = openSession();
> CDOTransaction transaction1 = session1.openTransaction();
> CDOResource resource = transaction1.createResource(getResourcePath("/lab/resource"));
>
> Root newRoot = getNestedFactory().createRoot();
> resource.getContents().add(newRoot);
>
> // Create an EventStream of type Activity
> Activity activity1 = getNestedFactory().createActivity();
> activity1.setName("activity1");
> newRoot.getActivities().add(activity1);
> // Add Events of Type ActivityEvent
> for (int i = 0; i < 5; i++) {
> ActivityEvent activityEvent = getNestedFactory().createActivityEvent();
> activityEvent.setParent(activity1);
> }
>
> // This commit fails, caused by:
> // java.lang.StackOverflowError in at org.eclipse.emf.ecore.util.EObjectEList.resolve(EObjectEList.java:109)
> transaction1.commit();
> session1.close();
>
> CDOSession session2 = openSession();
> CDOTransaction transaction2 = session2.openTransaction();
> CDOResource resource2 = transaction2.getOrCreateResource(getResourcePath("/lab/resource"));
> Root readRoot = (Root)resource2.getContents().get(0);
> Activity readActivity = readRoot.getActivities().get(0);
> assertEquals(5, readActivity.getEvents().size());
> }
>
> Best Regards
> ///Anders
Re: [CDO] Nested generic types can't be committed [message #901190 is a reply to message #901184] Fri, 10 August 2012 09:03 Go to previous message
Anders  Jönsson is currently offline Anders JönssonFriend
Messages: 33
Registered: January 2012
Member
This is now Bug 386989 - [CDO] Nested generic types can't be committed

///Anders
Previous Topic:Deleting one way reference
Next Topic:Group plugins to categories
Goto Forum:
  


Current Time: Fri Dec 19 15:22:36 GMT 2014

Powered by FUDForum. Page generated in 0.03055 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software