Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext and Java 16
Xtext and Java 16 [message #1841507] Wed, 19 May 2021 13:05 Go to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
Hi

has anyone tried to build an Xtext language with Java 16?
I made a very quick experiment with Maven/Tycho and the build fails when executing MWE2 itself with the following trace. I bet it's due to the more restrictive module access and maybe to Guice trying to do that (see the end of the trace)?

[INFO] --- exec-maven-plugin:3.0.0:java (mwe2Launcher) @ io.github.lorenzobettini.tychoxbasetestlanguage ---
0    [org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main()] ERROR mf.mwe2.launch.runtime.Mwe2Launcher  - com.google.inject.internal.util.$ComputationException: java.lang.ExceptionInInitializerError
com.google.inject.internal.util.$ComputationException: com.google.inject.internal.util.$ComputationException: java.lang.ExceptionInInitializerError
	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.initializeBinding(InjectorImpl.java:507)
	at com.google.inject.internal.AbstractBindingProcessor$Processor$1.run(AbstractBindingProcessor.java:159)
	at com.google.inject.internal.ProcessedBindingData.initializeBindings(ProcessedBindingData.java:44)
	at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:122)
	at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:106)
	at com.google.inject.Guice.createInjector(Guice.java:95)
	at com.google.inject.Guice.createInjector(Guice.java:72)
	at com.google.inject.Guice.createInjector(Guice.java:62)
	at org.eclipse.emf.mwe2.language.Mwe2StandaloneSetupGenerated.createInjector(Mwe2StandaloneSetupGenerated.java:47)
	at org.eclipse.emf.mwe2.language.Mwe2StandaloneSetupGenerated.createInjectorAndDoEMFRegistration(Mwe2StandaloneSetupGenerated.java:41)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:76)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:37)
	at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:254)
	at java.base/java.lang.Thread.run(Thread.java:831)
Caused by: com.google.inject.internal.util.$ComputationException: java.lang.ExceptionInInitializerError
	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.MembersInjectorStore.get(MembersInjectorStore.java:65)
	at com.google.inject.internal.ConstructorInjectorStore.createConstructor(ConstructorInjectorStore.java:73)
	at com.google.inject.internal.ConstructorInjectorStore.access$000(ConstructorInjectorStore.java:28)
	at com.google.inject.internal.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:36)
	at com.google.inject.internal.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:32)
	at com.google.inject.internal.FailableCache$1.apply(FailableCache.java:39)
	at com.google.inject.internal.util.$MapMaker$StrategyImpl.compute(MapMaker.java:549)
	... 19 more
Caused by: java.lang.ExceptionInInitializerError
	at com.google.inject.internal.cglib.reflect.$FastClassEmitter.<init>(FastClassEmitter.java:67)
	at com.google.inject.internal.cglib.reflect.$FastClass$Generator.generateClass(FastClass.java:72)
	at com.google.inject.internal.cglib.core.$DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
	at com.google.inject.internal.cglib.core.$AbstractClassGenerator.create(AbstractClassGenerator.java:216)
	at com.google.inject.internal.cglib.reflect.$FastClass$Generator.create(FastClass.java:64)
	at com.google.inject.internal.BytecodeGen.newFastClass(BytecodeGen.java:207)
	at com.google.inject.internal.SingleMethodInjector.createMethodInvoker(SingleMethodInjector.java:49)
	at com.google.inject.internal.SingleMethodInjector.<init>(SingleMethodInjector.java:38)
	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)
	at com.google.inject.internal.FailableCache$1.apply(FailableCache.java:39)
	at com.google.inject.internal.util.$MapMaker$StrategyImpl.compute(MapMaker.java:549)
	... 29 more
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @42554467
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:357)
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
	at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
	at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
	at com.google.inject.internal.cglib.core.$ReflectUtils$2.run(ReflectUtils.java:56)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:312)
	at com.google.inject.internal.cglib.core.$ReflectUtils.<clinit>(ReflectUtils.java:46)
	... 44 more


Re: Xtext and Java 16 [message #1841508 is a reply to message #1841507] Wed, 19 May 2021 13:39 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
did you test with the guice 501 branch?
https://github.com/eclipse/xtext-core/issues/393

or simply force the use of guice 5.0.1 on the mwe call?

might also be the problem is e.g. an outdated exec plugin


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Wed, 19 May 2021 15:45]

Report message to a moderator

Re: Xtext and Java 16 [message #1841512 is a reply to message #1841508] Wed, 19 May 2021 15:59 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
Exec plugin is the latest version.
I'll try with forcing Guice, which I guess it's the main problem


Re: Xtext and Java 16 [message #1841514 is a reply to message #1841512] Wed, 19 May 2021 16:47 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
problem is mwe has dependency to guice 3
unfortunately there is no easy way to get a maven repo with a patch

see also https://ci.eclipse.org/mwe/job/mwe2/job/cd_mweGuice5Experiment/lastSuccessfulBuild/artifact/git-repo/my-local-snapshots-dir/


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Thu, 20 May 2021 06:14]

Report message to a moderator

Re: Xtext and Java 16 [message #1841540 is a reply to message #1841514] Thu, 20 May 2021 09:14 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
So I guess there's nothing we can do right now?

Re: Xtext and Java 16 [message #1841548 is a reply to message #1841540] Thu, 20 May 2021 11:05 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
if you build a bunch of all the temporary plugins it should work
https://github.com/itemis/xtext-reference-projects/tree/cd_lala_xxxx/greetings-tycho/2.26.0-J11

as i dont get any feedback on the new guice at all i dont know if it ever will make it to master


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext and Java 16 [message #1841596 is a reply to message #1841548] Fri, 21 May 2021 12:23 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
So independently from Guice 5, actually I managed to build and test (also with Maven/Tycho) Xtext DSLs with Java 16!
The problem was the MWE2 launch, and I was trying to pass the (now required with Java 16) VM argument "--illegal-access=permit" (which used to be the default up to Java 16, where it became "=deny", that's why I was getting that error) to the Java execution of the "exec-maven-plugin". However, there's no way to pass a VM option to that plugin. That's actually documented (https://www.mojohaus.org/exec-maven-plugin/java-mojo.html#systemProperties: "A list of system properties to be passed. Note: as the execution is not forked, some system properties required by the JVM cannot be passed here. Use MAVEN_OPTS or the exec:exec instead.". So the solution is to specify "--illegal-access=permit" when you run the Maven build.
For example in the m2e launch configuration

<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="--illegal-access=permit"/>


Build and tests are now working!



Re: Xtext and Java 16 [message #1843038 is a reply to message #1841596] Mon, 12 July 2021 19:10 Go to previous messageGo to next message
Michael Bischoff is currently offline Michael BischoffFriend
Messages: 19
Registered: August 2012
Junior Member
Given that Java 17 rampdown 2 is in 3 days from now and Java 17 will ignore the "--illegal-access=permit" option (at least, that is my understanding of JEP 403), I am a bit concerned that this workaround will not do any more for Java 17.
This would make the upgrade to guice 5 a "must have" in order to use Xtext with Java 17.
I would like to support testing and help to get Xtext 2.26.0 shipped with guice 5, but I have limited knowledge of Eclipse internals.
Is there any description, how I could help testing?
Re: Xtext and Java 16 [message #1843045 is a reply to message #1843038] Tue, 13 July 2021 05:59 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Checking OCL and QVTd, the import package for com.google.inject is unconstrained by version, so provided other projects take the same policy and only use Guice transitively, you only need to see whether projects that directly use Guice work. Check Xtext out in your workspace, check the com.google.inject bounds in *.MF and ensure that only 5.x is available. Guice is so fundamental, that I would expect it to just work or be an obvious disaster, potentially subject to a couple of trivial API evolution fixes that you could anticipate by reading the release notes. For Guava every change seems to be 'major' but we have given up caring....

Regards

Ed Willink
Re: Xtext and Java 16 [message #1843046 is a reply to message #1843038] Tue, 13 July 2021 06:19 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
Michael Bischoff wrote on Mon, 12 July 2021 19:10
Given that Java 17 rampdown 2 is in 3 days from now and Java 17 will ignore the "--illegal-access=permit" option (at least, that is my understanding of JEP 403), I am a bit concerned that this workaround will not do any more for Java 17.
This would make the upgrade to guice 5 a "must have" in order to use Xtext with Java 17.
I would like to support testing and help to get Xtext 2.26.0 shipped with guice 5, but I have limited knowledge of Eclipse internals.
Is there any description, how I could help testing?


Instead of "--illegal-access" you can use

--add-opens java.base/java.lang=ALL-UNNAMED


Concerning testing, I left detailed instructions here: https://github.com/eclipse/xtext-core/issues/393#issuecomment-859685083


Re: Xtext and Java 16 [message #1843061 is a reply to message #1843046] Tue, 13 July 2021 20:09 Go to previous messageGo to next message
Michael Bischoff is currently offline Michael BischoffFriend
Messages: 19
Registered: August 2012
Junior Member
Thanks a lot, I'll give it a try the next days.
Re: Xtext and Java 16 [message #1843169 is a reply to message #1843061] Sat, 17 July 2021 21:43 Go to previous messageGo to next message
Michael Bischoff is currently offline Michael BischoffFriend
Messages: 19
Registered: August 2012
Junior Member
I did a couple of tests.

1) The Java 17 EA (build 31) works with option "--add-opens java.base/java.lang=ALL-UNNAMED" (which more or less negates jigsaw)
2) With the test instructions by Lorenzo, I was able to almost build my DSLs using the Christian's xtext guice snapshot (build date July 13th) , without any of the above compiler options.
It worked with Java 11 and Java 16. Java 17 failed due to Tycho (I used 2.3, support for Java 17 will be added in 2.4, but due to https://github.com/eclipse/tycho/issues/179 it looks like that one will not be usable with Xtext, which is a blocker)
The "almost" refers to some dependency issue in the final step, building the update site (very likely due to some mistake on my side which I did not yet spot), and some warnings about version mismatches in the build logs:
WARNING: Skipping conflicting project org.eclipse.emf.common at 'archive:file:/home/mbi/.m2/repository/org/eclipse/emf/org.eclipse.emf.common/2.22.0/org.eclipse.emf.common-2.22.0.jar!/' and using 'archive:file:/home/mbi/.m2/repository/p2/osgi/bundle/org.eclipse.emf.common/2.19.0.v20200324-0932/org.eclipse.emf.common-2.19.0.v20200324-0932.jar!/' instead.
Jul 17, 2021 10:28:51 PM org.eclipse.emf.mwe.utils.StandaloneSetup registerMapping

WARNING: Skipping conflicting project org.eclipse.equinox.app at 'archive:file:/home/mbi/.m2/repository/org/eclipse/platform/org.eclipse.equinox.app/1.5.100/org.eclipse.equinox.app-1.5.100.jar!/' and using 'archive:file:/home/mbi/.m2/repository/p2/osgi/bundle/org.eclipse.equinox.app/1.4.500.v20200422-1833/org.eclipse.equinox.app-1.4.500.v20200422-1833.jar!/' instead.

WARNING: Skipping conflicting project org.eclipse.core.contenttype at 'archive:file:/home/mbi/.m2/repository/org/eclipse/platform/org.eclipse.core.contenttype/3.7.900/org.eclipse.core.contenttype-3.7.900.jar!/' and using 'archive:file:/home/mbi/.m2/repository/p2/osgi/bundle/org.eclipse.core.contenttype/3.7.700.v20200517-1644/org.eclipse.core.contenttype-3.7.700.v20200517-1644.jar!/' instead.

I could not yet test using the generated plugins, due to the issues with the update site, I will follow up those next week. The current branch is here: https://github.com/jpaw/bonaparte-dsl/tree/guice5test
Re: Xtext and Java 16 [message #1843171 is a reply to message #1843169] Sun, 18 July 2021 06:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
this might be a variant of https://github.com/eclipse/xtext-maven/issues/146 (tycho 2.4 knowing build.properties and thus these and the exec-plugin extra deps interfering

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext and Java 16 [message #1843198 is a reply to message #1843171] Mon, 19 July 2021 21:37 Go to previous message
Michael Bischoff is currently offline Michael BischoffFriend
Messages: 19
Registered: August 2012
Junior Member
xtext-maven-plugin was not yet used (these mismatches occurred when creating the plugins), but I found the issues, they have been caused by some outdated version specified in MANIFEST.MF files, combined with also outdated eclipse download URLs in the target files.
There are still some remaining (but minor) version mismatches, no none at major or minor release, only at build number.
I could work around the updatesite problem by assigning a fixed release (do I need a local p2 repo to build SNAPSHOT / qualifier update sites?)

Good news #1: I can build the DSL using java 11 without any guice warnings. (I used tycho 2.3)
Good news #2: I can use the generated DSLs with the guice5 branch of Xtext and java11 or java17-ea without any special maven / compiler options and without any warning. => The branch works for me and I vote for merging into master.
Previous Topic:Problems changing hover size & colors (Xtext 2.24)
Next Topic:XtextDocument/Node does not update offset ?
Goto Forum:
  


Current Time: Thu Mar 28 11:21:37 GMT 2024

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

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

Back to the top