Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

Update to Guice 5.0.1+ #393

Closed
spoenemann opened this issue Jul 14, 2017 · 84 comments
Closed

Update to Guice 5.0.1+ #393

spoenemann opened this issue Jul 14, 2017 · 84 comments
Assignees
Milestone

Comments

@spoenemann
Copy link
Member

spoenemann commented Jul 14, 2017

From the Guice 4 release notes:

Java8 runtime compatibility for Guice core & all extensions.

When working on Java 8 projects with the current Xtext version (and thus Guice 3), I often get exceptions like this when Guice tries to create proper error messages for invalid configurations:

com.google.inject.internal.util.$ComputationException: java.lang.ArrayIndexOutOfBoundsException: 34949
	at com.google.inject.internal.util.$MapMaker$StrategyImpl.compute(MapMaker.java:553)
	at com.google.inject.internal.util.$MapMaker$StrategyImpl.compute(MapMaker.java:419)
	at com.google.inject.internal.util.$CustomConcurrentHashMap$ComputingImpl.get(CustomConcurrentHashMap.java:2041)
	at com.google.inject.internal.util.$StackTraceElements.forMember(StackTraceElements.java:53)
	at com.google.inject.internal.Errors.formatInjectionPoint(Errors.java:712)
	at com.google.inject.internal.Errors.formatSource(Errors.java:684)
	at com.google.inject.internal.Errors.format(Errors.java:555)
	at com.google.inject.ConfigurationException.getMessage(ConfigurationException.java:70)
	at java.lang.Throwable.getLocalizedMessage(Throwable.java:391)
	at java.lang.Throwable.toString(Throwable.java:480)
	at java.lang.String.valueOf(String.java:2994)
	at java.io.PrintWriter.println(PrintWriter.java:754)
	at java.lang.Throwable$WrappedPrintWriter.println(Throwable.java:764)
	at java.lang.Throwable.printStackTrace(Throwable.java:655)
	at java.lang.Throwable.printStackTrace(Throwable.java:721)
	at org.junit.runner.notification.Failure.getTrace(Failure.java:75)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestListener.testFailure(JUnit4TestListener.java:91)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestListener.testFailure(JUnit4TestListener.java:69)
	at org.junit.runner.notification.SynchronizedRunListener.testFailure(SynchronizedRunListener.java:63)
	at org.junit.runner.notification.RunNotifier$4.notifyListener(RunNotifier.java:142)
	at org.junit.runner.notification.RunNotifier$SafeNotifier.run(RunNotifier.java:72)
	at org.junit.runner.notification.RunNotifier.fireTestFailures(RunNotifier.java:138)
	at org.junit.runner.notification.RunNotifier.fireTestFailure(RunNotifier.java:132)
	at org.junit.internal.runners.model.EachTestNotifier.addFailure(EachTestNotifier.java:23)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:329)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 34949
	at com.google.inject.internal.asm.$ClassReader.<init>(Unknown Source)
	at com.google.inject.internal.asm.$ClassReader.<init>(Unknown Source)
	at com.google.inject.internal.asm.$ClassReader.<init>(Unknown Source)
	at com.google.inject.internal.util.$LineNumbers.<init>(LineNumbers.java:62)
	at com.google.inject.internal.util.$StackTraceElements$1.apply(StackTraceElements.java:36)
	at com.google.inject.internal.util.$StackTraceElements$1.apply(StackTraceElements.java:33)
	at com.google.inject.internal.util.$MapMaker$StrategyImpl.compute(MapMaker.java:549)
	... 38 more

When I run the same code with Guice 4.1.0, I get a proper com.google.inject.ConfigurationException instead.

Here is the CQ https://dev.eclipse.org/ipzilla/show_bug.cgi?id=23134

@cdietrich
Copy link
Member

would need a new com.google.inject on orbit

@nbhusare
Copy link
Contributor

nbhusare commented Aug 1, 2017

I am facing a similar issue after migrating to Xtext 2.12. PS error below.
Any plans for the fix ?

Caused by: com.google.inject.internal.util.$ComputationException: com.google.inject.internal.util.$ComputationException: com.google.inject.internal.util.$ComputationException: com.google.inject.internal.util.$ComputationException: com.google.inject.internal.util.$ComputationException: com.google.inject.internal.util.$ComputationException: com.google.inject.internal.util.$ComputationException: java.lang.StackOverflowError
	at com.google.inject.internal.util.$MapMaker$StrategyImpl.compute(MapMaker.java:553)
	at com.google.inject.internal.util.$MapMaker$StrategyImpl.compute(MapMaker.java:419)
	at com.google.inject.internal.util.$CustomConcurrentHashMap$ComputingImpl.get(CustomConcurrentHashMap.java:2041)
	at com.google.inject.internal.FailableCache.get(FailableCache.java:50)
	at com.google.inject.internal.ConstructorInjectorStore.get(ConstructorInjectorStore.java:49)
	at com.google.inject.internal.ConstructorBindingImpl.initialize(ConstructorBindingImpl.java:125)
	at com.google.inject.internal.InjectorImpl.initializeJitBinding(InjectorImpl.java:521)
	at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:847)
	at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:772)
	at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:256)
	at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:205)
	at com.google.inject.internal.InjectorImpl.createImplementedByBinding(InjectorImpl.java:732)
	at com.google.inject.internal.InjectorImpl.createUninitializedBinding(InjectorImpl.java:618)
	at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:845)
	at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:772)
	at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:256)
	at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:205)
	at com.google.inject.internal.InjectorImpl.getInternalFactory(InjectorImpl.java:853)
	at com.google.inject.internal.SingleFieldInjector.<init>(SingleFieldInjector.java:41)
	at com.google.inject.internal.MembersInjectorStore.getInjectors(MembersInjectorStore.java:125)
	at com.google.inject.internal.MembersInjectorStore.createWithListeners(MembersInjectorStore.java:95)
	at com.google.inject.internal.MembersInjectorStore.access$000(MembersInjectorStore.java:34)
	at com.google.inject.internal.MembersInjectorStore$1.create(MembersInjectorStore.java:42)
	at com.google.inject.internal.MembersInjectorStore$1.create(MembersInjectorStore.java:39)

@nbhusare
Copy link
Contributor

nbhusare commented Aug 2, 2017

When I run the same code with Guice 4.1.0, I get a proper com.google.inject.ConfigurationException instead.

@spoenemann - Do you mind sharing the exception trace after you updated to Guice 4.1.0.

@mmews-n4
Copy link

mmews-n4 commented Mar 27, 2018

N4JS says: meToo

Finding problems that are caused by Guice is difficult, especially when getting these kinds of stacktraces as shown above. I myself get this a lot when working on the Xtext project 'N4JS' and it is just time-killing to identify the true Guice error.

The related Guice ticket was: google/guice#757
Stackoverflow says: Guice 3.0 is incompatible with Java 8

It would be appreciated if you put Guice 4+ into orbit and align the project dependencies. Thank you.

@cdietrich
Copy link
Member

cdietrich commented Mar 27, 2018

Problems/Tasks to consider.

  • i have no idea what to do to get a thing to orbit
  • needs coordination on cross project dev
  • for such a CQ for Photon it is already too late
  • side effects of having both guice 3 and guice 4 in orbit
  • which 4x version to take?
  • which of the transitive deps do we need(x)
  • update of guava (to 23.*) needed?

=> would be a post photon task
@szarnekow what do you think

(x)

/Users/dietrich/.m2/repository/com/google/inject/guice/4.2.0/guice-4.2.0.jar
/Users/dietrich/.m2/repository/javax/inject/javax.inject/1/javax.inject-1.jar
/Users/dietrich/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar
/Users/dietrich/.m2/repository/com/google/guava/guava/23.6-android/guava-23.6-android.jar
/Users/dietrich/.m2/repository/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9.jar
/Users/dietrich/.m2/repository/org/checkerframework/checker-compat-qual/2.0.0/checker-compat-qual-2.0.0.jar
/Users/dietrich/.m2/repository/com/google/errorprone/error_prone_annotations/2.1.3/error_prone_annotations-2.1.3.jar
/Users/dietrich/.m2/repository/com/google/j2objc/j2objc-annotations/1.1/j2objc-annotations-1.1.jar
/Users/dietrich/.m2/repository/org/codehaus/mojo/animal-sniffer-annotations/1.14/animal-sniffer-annotations-1.14.jar
Import-Package: com.google.common.base;version="[23.6,24)",com.google.
 common.cache;version="[23.6,24)",com.google.common.collect;version="[
 23.6,24)",com.google.common.primitives;version="[23.6,24)",javax.inje
 ct,org.aopalliance.intercept

@cdietrich
Copy link
Member

#393

@ujhelyiz
Copy link
Member

N4JS says: meToo

Finding problems that are caused by Guice is difficult, especially when getting these kinds of stacktraces as shown above. I myself get this a lot when working on the Xtext project 'N4JS' and it is just time-killing to identify the true Guice error.

The related Guice ticket was: google/guice#757
Stackoverflow says: Guice 3.0 is incompatible with Java 8

I was hit by the same issue yesterday, and I have found that there is a workaround while remaining with Guice 3.0: instead of relying on the normal jar, the no-aop jar should work as expected (basically, it does not contain the old ASM version that is incompatible with. Orbit contains this jar, so Eclipse plug-ins should not be included; for Maven/Gradle you should define the no-aop classifier (see related VIATRA change).

In the long term, migrating to Guice 4 seems fine, but in the meantime this gives back the detailed error information of Guice.

@cdietrich
Copy link
Member

see also eclipse/xtext-eclipse#1048

@cdietrich
Copy link
Member

we already use guice 4 in xtext gradle plugin for memory leak reasons

@cdietrich
Copy link
Member

cc @szarnekow

@raner
Copy link

raner commented Nov 25, 2019

Lately, I'm getting a new variant of this extremely annoying problem. Whenever I change something with the Guice bindings that doesn't quite jive, I get something like this:

java.lang.OutOfMemoryError: Java heap space
	at java.util.Arrays.copyOf(Arrays.java:3332)
	at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:137)
	at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:121)
	at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:421)
	at java.lang.StringBuffer.append(StringBuffer.java:272)
	at java.io.StringWriter.write(StringWriter.java:112)
	at java.io.PrintWriter.write(PrintWriter.java:456)
	at java.io.PrintWriter.write(PrintWriter.java:473)
	at java.io.PrintWriter.print(PrintWriter.java:603)
	at java.io.PrintWriter.println(PrintWriter.java:756)
	at java.lang.Throwable$WrappedPrintWriter.println(Throwable.java:764)
	at java.lang.Throwable.printEnclosedStackTrace(Throwable.java:695)
	at java.lang.Throwable.printEnclosedStackTrace(Throwable.java:709)
	at java.lang.Throwable.printEnclosedStackTrace(Throwable.java:709)
	at java.lang.Throwable.printEnclosedStackTrace(Throwable.java:709)
	at java.lang.Throwable.printEnclosedStackTrace(Throwable.java:709)
	at java.lang.Throwable.printEnclosedStackTrace(Throwable.java:709)
	at java.lang.Throwable.printEnclosedStackTrace(Throwable.java:709)
	at java.lang.Throwable.printEnclosedStackTrace(Throwable.java:709)
	at java.lang.Throwable.printEnclosedStackTrace(Throwable.java:709)
	at java.lang.Throwable.printEnclosedStackTrace(Throwable.java:709)
...

Only when I set a breakpoint in Throwable.printEnclosedStackTrace I see the Guice stack trace:

com.google.inject.internal.util.$MapMaker$StrategyImpl.compute(MapMaker.java:553)
com.google.inject.internal.util.$MapMaker$StrategyImpl.compute(MapMaker.java:419)
com.google.inject.internal.util.$CustomConcurrentHashMap$ComputingImpl.get(CustomConcurrentHashMap.java:2041)
com.google.inject.internal.FailableCache.get(FailableCache.java:50)
com.google.inject.internal.ConstructorInjectorStore.get(ConstructorInjectorStore.java:49)
com.google.inject.internal.ConstructorBindingImpl.initialize(ConstructorBindingImpl.java:125)
com.google.inject.internal.InjectorImpl.initializeJitBinding(InjectorImpl.java:521)
com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:847)
com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:772)
com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:256)
com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:205)
com.google.inject.internal.InjectorImpl.getInternalFactory(InjectorImpl.java:853)
com.google.inject.internal.FactoryProxy.notify(FactoryProxy.java:46)
com.google.inject.internal.ProcessedBindingData.runCreationListeners(ProcessedBindingData.java:50)
com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:133)
com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:106)
com.google.inject.Guice.createInjector(Guice.java:95)
com.google.inject.Guice.createInjector(Guice.java:72)
com.google.inject.Guice.createInjector(Guice.java:62)
fxxx.tests.FxxxInjectorProvider$1.createInjector(FxxxInjectorProvider.java:38)
fxxx.FxxxStandaloneSetupGenerated.createInjectorAndDoEMFRegistration(FxxxStandaloneSetupGenerated.java:37)
fxxx.tests.FxxxInjectorProvider.internalCreateInjector(FxxxInjectorProvider.java:40)
fxxx.tests.FxxxInjectorProvider.getInjector(FxxxInjectorProvider.java:28)
fxxx.tests.FxxxInjectorProvider.setupRegistry(FxxxInjectorProvider.java:65)
org.eclipse.xtext.testing.XtextRunner.methodBlock(XtextRunner.java:43)
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
org.junit.runners.ParentRunner.run(ParentRunner.java:363)
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)

@cdietrich
Copy link
Member

cdietrich commented Nov 25, 2019

there are 3 arguments against an update right now

@miklossy
Copy link
Contributor

I also encountered this problem recently. The problem is really annoying in case something is misconfigured in Guice not to get a readable error message.

@cdietrich Maybe we can schedule this update to Xtext 2.23?

@miklossy
Copy link
Contributor

miklossy commented May 4, 2020

Since other people gave positive feedback:

The beta looks very promising!

we should also test that beta version with the Xtext code base.

@cdietrich
Copy link
Member

cdietrich commented May 6, 2020

WrappingInjectorProvider has more problems with guice 4

com.google.inject.CreationException: Unable to create injector, see the following errors:

1) Binding to core guice framework type is not allowed: Stage.
  at [unknown source] (via modules: com.google.inject.util.Modules$OverrideModule -> org.eclipse.xtext.testing.smoketest.internal.WrappingInjectorProvider$1)

1 error
	at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:554)
	at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:161)
	at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:108)
	at com.google.inject.Guice.createInjector(Guice.java:87)
	at com.google.inject.Guice.createInjector(Guice.java:69)
	at com.google.inject.Guice.createInjector(Guice.java:59)
	at org.eclipse.xtext.testing.smoketest.internal.WrappingInjectorProvider.createInjector(WrappingInjectorProvider.java:73)
	at org.eclipse.xtext.testing.smoketest.internal.WrappingInjectorProvider.<init>(WrappingInjectorProvider.java:48)
	at org.eclipse.xtext.testing.smoketest.internal.InjectorCache.wrap(InjectorCache.java:30)
	at org.eclipse.xtext.testing.smoketest.internal.AbstractScenarioRunner.getOrCreateInjectorProvider(AbstractScenarioRunner.java:126)
	at org.eclipse.xtext.testing.smoketest.internal.AbstractParallelScenarioRunner$1.evaluate(AbstractParallelScenarioRunner.java:65)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.eclipse.xtext.testing.smoketest.internal.AllScenariosRunner.runChild(AllScenariosRunner.java:67)
	at org.eclipse.xtext.testing.smoketest.internal.AllScenariosRunner.runChild(AllScenariosRunner.java:1)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runners.Suite.runChild(Suite.java:128)
	at org.junit.runners.Suite.runChild(Suite.java:27)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:542)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:770)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:464)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)

com.google.inject.CreationException: Unable to create injector, see the following errors:

1) Binding to core guice framework type is not allowed: Stage.
  at [unknown source] (via modules: com.google.inject.util.Modules$OverrideModule -> org.eclipse.xtext.testing.smoketest.internal.WrappingInjectorProvider$1)

1 error
	at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:554)
	at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:161)
	at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:108)
	at com.google.inject.Guice.createInjector(Guice.java:87)
	at com.google.inject.Guice.createInjector(Guice.java:69)
	at com.google.inject.Guice.createInjector(Guice.java:59)
	at org.eclipse.xtext.testing.smoketest.internal.WrappingInjectorProvider.createInjector(WrappingInjectorProvider.java:73)
	at org.eclipse.xtext.testing.smoketest.internal.WrappingInjectorProvider.<init>(WrappingInjectorProvider.java:48)
	at org.eclipse.xtext.testing.smoketest.internal.InjectorCache.wrap(InjectorCache.java:30)
	at org.eclipse.xtext.testing.smoketest.internal.AbstractScenarioRunner.getOrCreateInjectorProvider(AbstractScenarioRunner.java:126)
	at org.eclipse.xtext.testing.smoketest.internal.AbstractParallelScenarioRunner$1.evaluate(AbstractParallelScenarioRunner.java:65)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.eclipse.xtext.testing.smoketest.internal.AllScenariosRunner.runChild(AllScenariosRunner.java:67)
	at org.eclipse.xtext.testing.smoketest.internal.AllScenariosRunner.runChild(AllScenariosRunner.java:1)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runners.Suite.runChild(Suite.java:128)
	at org.junit.runners.Suite.runChild(Suite.java:27)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:542)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:770)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:464)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)

com.google.inject.CreationException: Unable to create injector, see the following errors:

1) Binding to core guice framework type is not allowed: Stage.
  at [unknown source] (via modules: com.google.inject.util.Modules$OverrideModule -> org.eclipse.xtext.testing.smoketest.internal.WrappingInjectorProvider$1)

1 error
	at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:554)
	at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:161)
	at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:108)
	at com.google.inject.Guice.createInjector(Guice.java:87)
	at com.google.inject.Guice.createInjector(Guice.java:69)
	at com.google.inject.Guice.createInjector(Guice.java:59)
	at org.eclipse.xtext.testing.smoketest.internal.WrappingInjectorProvider.createInjector(WrappingInjectorProvider.java:73)
	at org.eclipse.xtext.testing.smoketest.internal.WrappingInjectorProvider.<init>(WrappingInjectorProvider.java:48)
	at org.eclipse.xtext.testing.smoketest.internal.InjectorCache.wrap(InjectorCache.java:30)
	at org.eclipse.xtext.testing.smoketest.internal.AbstractScenarioRunner.getOrCreateInjectorProvider(AbstractScenarioRunner.java:126)
	at org.eclipse.xtext.testing.smoketest.internal.AbstractParallelScenarioRunner$1.evaluate(AbstractParallelScenarioRunner.java:65)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.eclipse.xtext.testing.smoketest.internal.AllScenariosRunner.runChild(AllScenariosRunner.java:67)
	at org.eclipse.xtext.testing.smoketest.internal.AllScenariosRunner.runChild(AllScenariosRunner.java:1)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runners.Suite.runChild(Suite.java:128)
	at org.junit.runners.Suite.runChild(Suite.java:27)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:542)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:770)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:464)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)

com.google.inject.CreationException: Unable to create injector, see the following errors:

1) Binding to core guice framework type is not allowed: Stage.
  at [unknown source] (via modules: com.google.inject.util.Modules$OverrideModule -> org.eclipse.xtext.testing.smoketest.internal.WrappingInjectorProvider$1)

1 error
	at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:554)
	at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:161)
	at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:108)
	at com.google.inject.Guice.createInjector(Guice.java:87)
	at com.google.inject.Guice.createInjector(Guice.java:69)
	at com.google.inject.Guice.createInjector(Guice.java:59)
	at org.eclipse.xtext.testing.smoketest.internal.WrappingInjectorProvider.createInjector(WrappingInjectorProvider.java:73)
	at org.eclipse.xtext.testing.smoketest.internal.WrappingInjectorProvider.<init>(WrappingInjectorProvider.java:48)
	at org.eclipse.xtext.testing.smoketest.internal.InjectorCache.wrap(InjectorCache.java:30)
	at org.eclipse.xtext.testing.smoketest.internal.AbstractScenarioRunner.getOrCreateInjectorProvider(AbstractScenarioRunner.java:126)
	at org.eclipse.xtext.testing.smoketest.internal.AbstractParallelScenarioRunner$1.evaluate(AbstractParallelScenarioRunner.java:65)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.eclipse.xtext.testing.smoketest.internal.AllScenariosRunner.runChild(AllScenariosRunner.java:67)
	at org.eclipse.xtext.testing.smoketest.internal.AllScenariosRunner.runChild(AllScenariosRunner.java:1)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runners.Suite.runChild(Suite.java:128)
	at org.junit.runners.Suite.runChild(Suite.java:27)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:542)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:770)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:464)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)

com.google.inject.CreationException: Unable to create injector, see the following errors:

1) Binding to core guice framework type is not allowed: Stage.
  at [unknown source] (via modules: com.google.inject.util.Modules$OverrideModule -> org.eclipse.xtext.testing.smoketest.internal.WrappingInjectorProvider$1)

1 error
	at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:554)
	at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:161)
	at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:108)
	at com.google.inject.Guice.createInjector(Guice.java:87)
	at com.google.inject.Guice.createInjector(Guice.java:69)
	at com.google.inject.Guice.createInjector(Guice.java:59)
	at org.eclipse.xtext.testing.smoketest.internal.WrappingInjectorProvider.createInjector(WrappingInjectorProvider.java:73)
	at org.eclipse.xtext.testing.smoketest.internal.WrappingInjectorProvider.<init>(WrappingInjectorProvider.java:48)
	at org.eclipse.xtext.testing.smoketest.internal.InjectorCache.wrap(InjectorCache.java:30)
	at org.eclipse.xtext.testing.smoketest.internal.AbstractScenarioRunner.getOrCreateInjectorProvider(AbstractScenarioRunner.java:126)
	at org.eclipse.xtext.testing.smoketest.internal.AbstractParallelScenarioRunner$1.evaluate(AbstractParallelScenarioRunner.java:65)
	at org.junit.runners.PareInjectorntRunner.run(ParentRunner.java:363)
	at org.eclipse.xtext.testing.smoketest.internal.AllScenariosRunner.runChild(AllScenariosRunner.java:67)
	at org.eclipse.xtext.testing.smoketest.internal.AllScenariosRunner.runChild(AllScenariosRunner.java:1)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runners.Suite.runChild(Suite.java:128)
	at org.junit.runners.Suite.runChild(Suite.java:27)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:542)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:770)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:464)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)

which can be fixed with if (!Injector.class.equals(typeLiteral) && !Logger.class.equals(typeLiteral) && !Stage.class.equals(typeLiteral)) {

@miklossy
Copy link
Contributor

miklossy commented May 8, 2020

See #1479

@cdietrich
Copy link
Member

cdietrich commented Jun 22, 2020

IndentationAwarePartialParsingTests sometimes hangs with Guice 4.x (beta)

x.log

@cdietrich
Copy link
Member

the guice 4 fix for Java 11 is now on Guice master, but there is no release yet

@cdietrich
Copy link
Member

fix is still not released. so: move to 2.24

@cdietrich cdietrich modified the milestones: Release_2.23, Release_2.24 Aug 21, 2020
@cdietrich cdietrich modified the milestones: Release_2.24, Release_2.25 Sep 28, 2020
@cdietrich cdietrich changed the title Update to Guice 4 Update to Guice 4/5 Oct 28, 2020
@LorenzoBettini
Copy link
Contributor

Should I test it in other projects of mine? They are not toy examples anyway ;)

@cdietrich
Copy link
Member

cdietrich commented May 30, 2021

There were race conditions in parallel injection we bypassed with some additional singletons but I am not sure I we catched all.
Am not sure if such problems can be found with your examples

@szarnekow
Copy link
Contributor

Should I test it in other projects of mine? They are not toy examples anyway ;)

That would be extremely helpful. The more feedback we can gather, the better.

@cdietrich
Copy link
Member

looks like we should also package org.aopalliance to the update site in case orbit is not configured

@cdietrich
Copy link
Member

cdietrich commented Jun 9, 2021

@LorenzoBettini
Copy link
Contributor

Since it might not be trivial to test with Guice 5 with the Xtext, MWE2 p2 repositories and especially with the Maven repositories (at least, it wasn't for me at the beginning), there are the steps I used:

  • make sure you change possible version ranges in features and bundles to include Xtext 2.26
  • make sure you update in your POM the versions of Xtext and MWE2, typically something like
<xtextVersion>2.26.0-SNAPSHOT</xtextVersion>
<mwe2Version>2.12.2-SNAPSHOT</mwe2Version>
  • configure the SNAPSHOT repositories in your parent POM provided by Christian (make sure these are the only repositories, in particular, don't use any other Maven snapshot repositories):
  <repositories>
    <repository>
      <id>xtext-lib-repository</id>
      <name>xtext-lib-repository</name>
      <url>https://ci.eclipse.org/xtext/job/xtext-lib/job/cd_guice501/lastSuccessfulBuild/artifact/build/maven-repository/</url>
    </repository>
    <repository>
      <id>xtext-core-repository</id>
      <name>xtext-core-repository</name>
      <url>https://ci.eclipse.org/xtext/job/xtext-core/job/cd_guice501/lastSuccessfulBuild/artifact/build/maven-repository/</url>
    </repository>
    <repository>
      <id>xtext-extras-repository</id>
      <name>xtext-extras-repository</name>
      <url>https://ci.eclipse.org/xtext/job/xtext-extras/job/cd_guice501/lastSuccessfulBuild/artifact/build/maven-repository/</url>
    </repository>
    <repository>
      <id>xtext-maven-repository</id>
      <name>xtext-maven-repository</name>
      <url>https://ci.eclipse.org/xtext/job/xtext-maven/job/cd_guice501/lastSuccessfulBuild/artifact/build/maven-repository/</url>
    </repository>
    <repository>
      <id>xtext-xtend-repository</id>
      <name>xtext-xtend-repository</name>
      <url>https://ci.eclipse.org/xtext/job/xtext-xtend/job/cd_guice501/lastSuccessfulBuild/artifact/build/maven-repository/</url>
    </repository>
    <repository>
      <id>xtext-web-repository</id>
      <name>xtext-web-repository</name>
      <url>https://ci.eclipse.org/xtext/job/xtext-web/job/cd_guice501/lastSuccessfulBuild/artifact/build/maven-repository/</url>
    </repository>
    <repository>
      <id>xtext-mwe-repository</id>
      <name>xtext-mwe-repository</name>
      <url>https://ci.eclipse.org/mwe/job/mwe2/job/cd_mweGuice5Experimentb/lastSuccessfulBuild/artifact/git-repo/my-local-snapshots-dir/</url>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <id>xtext-lib-plugin-repository</id>
      <name>xtext-lib-plugin-repository</name>
      <url>https://ci.eclipse.org/xtext/job/xtext-lib/job/cd_guice501/lastSuccessfulBuild/artifact/build/maven-repository/</url>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </pluginRepository>
    <pluginRepository>
      <id>xtext-core-plugin-repository</id>
      <name>xtext-core-plugin-repository</name>
      <url>https://ci.eclipse.org/xtext/job/xtext-core/job/cd_guice501/lastSuccessfulBuild/artifact/build/maven-repository/</url>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </pluginRepository>
    <pluginRepository>
      <id>xtext-extras-plugin-repository</id>
      <name>xtext-extras-plugin-repository</name>
      <url>https://ci.eclipse.org/xtext/job/xtext-extras/job/cd_guice501/lastSuccessfulBuild/artifact/build/maven-repository/</url>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </pluginRepository>
    <pluginRepository>
      <name>xtext-maven-plugin-repository</name>
      <id>xtext-maven-plugin-repository</id>
      <url>https://ci.eclipse.org/xtext/job/xtext-maven/job/cd_guice501/lastSuccessfulBuild/artifact/build/maven-repository/</url>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </pluginRepository>
    <pluginRepository>
      <name>xtext-xtend-plugin-repository</name>
      <id>xtext-xtend-plugin-repository</id>
      <url>https://ci.eclipse.org/xtext/job/xtext-xtend/job/cd_guice501/lastSuccessfulBuild/artifact/build/maven-repository/</url>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </pluginRepository>
    <pluginRepository>
      <id>xtext-web-plugin-repository</id>
      <name>xtext-web-plugin-repository</name>
      <url>https://ci.eclipse.org/xtext/job/xtext-web/job/cd_guice501/lastSuccessfulBuild/artifact/build/maven-repository/</url>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </pluginRepository>
    <pluginRepository>
      <id>xtext-mwe-plugin-repository</id>
      <name>xtext-mwe-plugin-repository</name>
      <url>https://ci.eclipse.org/mwe/job/mwe2/job/cd_mweGuice5Experimentb/lastSuccessfulBuild/artifact/git-repo/my-local-snapshots-dir/</url>
      <releases><enabled>false</enabled></releases>
      <snapshots><enabled>true</enabled></snapshots>
    </pluginRepository>
  </pluginRepositories>
  • change your .target file with something like that:
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="org.eclipse.emf.mwe2.launcher.feature.group" version="0.0.0"/>
<repository location="https://ci.eclipse.org/mwe/job/mwe2/job/cd_mweGuice5Experimentb/lastSuccessfulBuild/artifact/git-repo/maven/org.eclipse.emf.mwe2.repository/target/repository/"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="org.eclipse.xtext.sdk.feature.group" version="0.0.0"/>
<repository location="https://ci.eclipse.org/xtext/job/xtext-umbrella/job/cd_guice501/lastSuccessfulBuild/artifact/build/p2-repository/"/>
</location>

and then happy testing! ;)

@LorenzoBettini
Copy link
Contributor

Also Jbase works with Guice 5 (and MWE2 2.12.2), all tests are green: LorenzoBettini/jbase#112

@cdietrich
Copy link
Member

unfortunately we still see ooms with the new guice. we dont know yet what is causing this.

@cdietrich
Copy link
Member

Unexpected error in standalone compiler: Java heap space
java.lang.OutOfMemoryError: Java heap space
	at java.base/java.util.Arrays.copyOf(Arrays.java:3689)
	at java.base/java.util.ArrayList.grow(ArrayList.java:238)
	at java.base/java.util.ArrayList.grow(ArrayList.java:243)
	at java.base/java.util.ArrayList.add(ArrayList.java:486)
	at java.base/java.util.ArrayList.add(ArrayList.java:499)
	at com.google.common.collect.AbstractMapBasedMultimap.put(AbstractMapBasedMultimap.java:194)
	at com.google.common.collect.AbstractListMultimap.put(AbstractListMultimap.java:115)
	at com.google.inject.internal.CycleDetectingLock$CycleDetectingLockFactory$ReentrantCycleDetectingLock.addAllLockIdsAfter(CycleDetectingLock.java:300)
	at com.google.inject.internal.CycleDetectingLock$CycleDetectingLockFactory$ReentrantCycleDetectingLock.detectPotentialLocksCycle(CycleDetectingLock.java:257)
	at com.google.inject.internal.CycleDetectingLock$CycleDetectingLockFactory$ReentrantCycleDetectingLock.lockOrDetectPotentialLocksCycle(CycleDetectingLock.java:149)
	at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:160)
	at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:45)
	at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:60)
	at com.google.inject.internal.SingleFieldInjector.inject(SingleFieldInjector.java:50)
	at com.google.inject.internal.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:146)
	at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:124)
	at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:91)
	at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:296)
	at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:60)
	at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:1100)
	at org.eclipse.xtext.resource.XtextResourceFactory.createResource(XtextResourceFactory.java:20)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.createResource(ResourceSetImpl.java:434)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandCreateResource(ResourceSetImpl.java:243)
	at org.eclipse.xtext.resource.XtextResourceSet.getResource(XtextResourceSet.java:261)
	at org.eclipse.xtext.resource.SynchronizedXtextResourceSet.getResource(SynchronizedXtextResourceSet.java:25)
	at org.eclipse.xtext.builder.resourceloader.AbstractResourceLoader.loadResource(AbstractResourceLoader.java:47)
	at org.eclipse.xtext.builder.resourceloader.ParallelResourceLoader.loadResource(ParallelResourceLoader.java:131)
	at org.eclipse.xtext.builder.resourceloader.ParallelResourceLoader$ParallelLoadOperation$ResourceLoadJob.run(ParallelResourceLoader.java:179)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)

@cdietrich
Copy link
Member

cdietrich commented Aug 2, 2021

startingpoint for injection chain is xtextresource.serializer
so it looks like the new singleton on serializer makes it worse
with xtextresource.

@cdietrich
Copy link
Member

reproducer

package org.xtext.example.mydsl.tests;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

import org.eclipse.emf.common.util.URI;
import org.eclipse.xtext.resource.XtextResourceFactory;
import org.junit.jupiter.api.Test;
import org.xtext.example.mydsl.MyDslStandaloneSetup;

import com.google.inject.Injector;

public class DullyTest {
	
	@Test
	public void testIt() throws InterruptedException, ExecutionException {
		Injector in = new MyDslStandaloneSetup().createInjectorAndDoEMFRegistration();
		int nThreads = 32;
		ExecutorService threadPool = Executors.newFixedThreadPool(nThreads);
		List<Future> fl = new ArrayList<>();
		for (int i = 0; i < 32; i++) {
			XtextResourceFactory rf = in.getInstance(XtextResourceFactory.class);
			fl.add(threadPool.submit(()->rf.createResource(URI.createURI("dummy.mydsl"))));
		}
		for (Future f : fl) {
			f.get();
		}
		threadPool.shutdown();
	}

}

@cdietrich
Copy link
Member

see also google/guice#1510

@cdietrich
Copy link
Member

cdietrich commented Aug 2, 2021

java.util.concurrent.ExecutionException: com.google.inject.ProvisionException: Unable to provision, see the following errors:

1) [Guice/CircularProxyDisabled]: Found a circular dependency involving IContextFinder, and circular dependencies are disabled.
  at ContextFinder.class(ContextFinder.java:51)
  while locating ContextFinder
  at AssignmentFinder.contextFinder(AssignmentFinder.java:48)
      \_ for field contextFinder
  at AssignmentFinder.class(AssignmentFinder.java:48)
  while locating AssignmentFinder
  at ContextFinder.assignmentFinder(ContextFinder.java:51)
      \_ for field assignmentFinder
  at ContextFinder.class(ContextFinder.java:51)
  while locating ContextFinder
  at Serializer.contextFinder(Serializer.java:59)
      \_ for field contextFinder
  at Serializer.class(Serializer.java:59)
  while locating Serializer
  at XtextResource.serializer(XtextResource.java:478)
      \_ for field serializer
  while locating LazyLinkingResource
  while locating XtextResource

Learn more:
  https://github.com/google/guice/wiki/CIRCULAR_PROXY_DISABLED

1 error

======================
Full classname legend:
======================
AssignmentFinder:    "org.eclipse.xtext.serializer.sequencer.AssignmentFinder"
ContextFinder:       "org.eclipse.xtext.serializer.sequencer.ContextFinder"
IContextFinder:      "org.eclipse.xtext.serializer.sequencer.IContextFinder"
LazyLinkingResource: "org.eclipse.xtext.linking.lazy.LazyLinkingResource"
Serializer:          "org.eclipse.xtext.serializer.impl.Serializer"
XtextResource:       "org.eclipse.xtext.resource.XtextResource"
========================
End of classname legend:
========================

	at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
	at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
	at org.xtext.example.mydsl.tests.DullyTest.testIt(DullyTest.java:30)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:688)
	at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
	at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
	at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:210)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:206)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:131)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:65)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:84)
	at org.eclipse.jdt.internal.junit5.runner.JUnit5TestReference.run(JUnit5TestReference.java:98)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:529)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:756)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
Caused by: com.google.inject.ProvisionException: Unable to provision, see the following errors:

1) [Guice/CircularProxyDisabled]: Found a circular dependency involving IContextFinder, and circular dependencies are disabled.
  at ContextFinder.class(ContextFinder.java:51)
  while locating ContextFinder
  at AssignmentFinder.contextFinder(AssignmentFinder.java:48)
      \_ for field contextFinder
  at AssignmentFinder.class(AssignmentFinder.java:48)
  while locating AssignmentFinder
  at ContextFinder.assignmentFinder(ContextFinder.java:51)
      \_ for field assignmentFinder
  at ContextFinder.class(ContextFinder.java:51)
  while locating ContextFinder
  at Serializer.contextFinder(Serializer.java:59)
      \_ for field contextFinder
  at Serializer.class(Serializer.java:59)
  while locating Serializer
  at XtextResource.serializer(XtextResource.java:478)
      \_ for field serializer
  while locating LazyLinkingResource
  while locating XtextResource

Learn more:
  https://github.com/google/guice/wiki/CIRCULAR_PROXY_DISABLED

1 error

======================
Full classname legend:
======================
AssignmentFinder:    "org.eclipse.xtext.serializer.sequencer.AssignmentFinder"
ContextFinder:       "org.eclipse.xtext.serializer.sequencer.ContextFinder"
IContextFinder:      "org.eclipse.xtext.serializer.sequencer.IContextFinder"
LazyLinkingResource: "org.eclipse.xtext.linking.lazy.LazyLinkingResource"
Serializer:          "org.eclipse.xtext.serializer.impl.Serializer"
XtextResource:       "org.eclipse.xtext.resource.XtextResource"
========================
End of classname legend:
========================

	at com.google.inject.internal.InternalProvisionException.toProvisionException(InternalProvisionException.java:251)
	at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:1103)
	at org.eclipse.xtext.resource.XtextResourceFactory.createResource(XtextResourceFactory.java:20)
	at org.xtext.example.mydsl.tests.DullyTest.lambda$0(DullyTest.java:27)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
1) [Guice/CircularProxyDisabled]: Found a circular dependency involving IConcreteSyntaxDiagnosticProvider, and circular dependencies are disabled.
  while locating ConcreteSyntaxDiagnosticProvider
  at AssignmentQuantityAllocator.diagnosticProvider(AssignmentQuantityAllocator.java:43)
      \_ for field diagnosticProvider
  while locating AssignmentQuantityAllocator
  at ConcreteSyntaxDiagnosticProvider.quantityAllocator(ConcreteSyntaxDiagnosticProvider.java:43)
      \_ for field quantityAllocator
  while locating ConcreteSyntaxDiagnosticProvider
  at ConcreteSyntaxValidator.diagnosticProvider(ConcreteSyntaxValidator.java:45)
      \_ for field diagnosticProvider
  while locating ConcreteSyntaxValidator
  at Serializer.validator(Serializer.java:59)
      \_ for field validator
  at Serializer.class(Serializer.java:59)
  while locating Serializer
  at XtextResource.serializer(XtextResource.java:478)
      \_ for field serializer
  while locating LazyLinkingResource
  while locating XtextResource

@cdietrich
Copy link
Member

binary compatibility really is pita here

@cdietrich
Copy link
Member

cdietrich commented Aug 2, 2021

public class IndentationAwareTestLanguageRuntimeModule extends org.eclipse.xtext.parser.indentation.AbstractIndentationAwareTestLanguageRuntimeModule {
	@Override
	public void configure(Binder binder) {
//		binder.disableCircularProxies();
		super.configure(binder);
		binder.bind(IContextFinder.class).to(ContextFinder.class).asEagerSingleton();
	}
}

seems to work for my test as well as IndentationAwarePartialParsingTests,
or at least decreases liklyhood

wonder why ruled this out before (comment says did not work from gradle)
it indeed does not work, cause at a pit TerminalsGrammarAccess cannot load xtextbin (anymore)
maybe thats also a bug in test framework.

@cdietrich
Copy link
Member

cdietrich commented Aug 2, 2021

here is a reproducer for the terminals problem

import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;

/**
 * @author cdietrich - Initial contribution and API
 */
@RunWith(Suite.class)
@SuiteClasses({IndentationAwareLanguageSuite.class,
	IndentationAwarePartialParsingTests.class})
public class XSuite {

}

org.eclipse.xtext.testing.smoketest.internal.AbstractParallelScenarioRunner.childrenInvoker(RunNotifier)
does not seem to be called for nested suites.

correction: it is but it looks like too late
correction: looks intentional org.eclipse.xtext.testing.smoketest.internal.WrappingInjectorProvider.WrappingInjectorProvider(IInjectorProvider)
creates the wrapped injector early.
then i wonder why the xtextbin is gone

the two WrappingInjectorProvider
wonder if setupRegistry needs to be called before create injector

#616

@cdietrich
Copy link
Member

cdietrich commented Aug 3, 2021

maybe we also can remove all the singletons to
and just introduce GrammarConstraintProvider as a new singleton,
but i am not sure if this is the constraints is the only reason we cache/singleton
but we still have stuff like RuleNames as singletons too.
so i assume this does not solve the problem but just makes it less likely. or its no problem because no cycle involved

cd_guice501...cd_guice501xy

@cdietrich cdietrich self-assigned this Aug 16, 2021
@cdietrich
Copy link
Member

🎉 Fixed in Xtext 2.26 🎉

@szarnekow
Copy link
Contributor

Excellent work @cdietrich!

@LorenzoBettini
Copy link
Contributor

Indeed! Can't wait to :)

@cdietrich
Copy link
Member

cdietrich commented Oct 1, 2021

Hi all,

I am pleased to announce the availability of Xtext 2.26.0.M2.
This is the first version that won't explode with Java 17 thanks to an update to Google Guice 5.0
(run with Java 17 against 8/11 target, running against 17 will follow next year when platform/jdt and other upstream dependencies also support it)
We also did some changes to how recovery builds are scheduled eclipse/xtext-eclipse#1710

Release Notes (WIP) are at https://github.com/eclipse/xtext/blob/website-master/xtext-website/_posts/releasenotes/2022-01-31-version-2-26-0.md

For both we strongly encourage you to test and give feedback.

You can find the milestone at https://download.eclipse.org/modeling/tmf/xtext/updates/milestones/S202110010541/
and http://www.eclipse.org/modeling/download.php?file=/modeling/tmf/xtext/downloads/drops/2.26.0/S202110010541/tmf-xtext-Update-2.26.0.M2.zip
and soon on Maven Central

(suitable mwe verison is 2.12.2.M1 / https://download.eclipse.org/modeling/emft/mwe/updates/milestones/S202108160852/)

Happy Xtexting

Thanks and Regards
Christian

mabauer added a commit to mabauer/tinyscript that referenced this issue Jan 12, 2022
This is done by inforcing Guice 5.0.1 (instead of Guice 3.x) whereever possible. A proper solution will pe possible with Xtext 2.26 (see eclipse/xtext-core#393)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests