Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Multiple ANTLR versions using Xtext and third party library in a standalone application
Multiple ANTLR versions using Xtext and third party library in a standalone application [message #558316] Sat, 11 September 2010 06:55 Go to next message
Acher is currently offline AcherFriend
Messages: 9
Registered: July 2009
Junior Member
Hi,

I am using Xtext and its parsing facilities to implement an interpreter.
In addition, I am using a third party library that parses some other parts of the interpreter.

The third party library relies on ANTLR 3.1.3 whereas Xtext relies on 3.0.0 -- if I am not wrong. Here comes my issue since I need to mixin the two versions of ANTLR -- for Xtext and for the third party library.

Depending on the order I export entries in the Java build path, I have one of the following error:

(1) Exception in thread "main" java.lang.SecurityException: class "org.antlr.runtime.RecognizerSharedState"'s signer information does not match signer information of other classes in the same package
at java.lang.ClassLoader.checkCerts(ClassLoader.java:807)
at java.lang.ClassLoader.preDefineClass(ClassLoader.java:488)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:626)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
......
call to the third library fails

(2) Exception in thread "main" java.lang.NoSuchFieldError: ruleMemo
at org.xtext.example.mydsl.parser.antlr.internal.InternalFMLPar ser. <init>(InternalFMLParser.java:53)
at org.xtext.example.mydsl.parser.antlr.internal.InternalFMLPar ser. <init>(InternalFMLParser.java:70)
at org.xtext.example.mydsl.parser.antlr.FMLParser.createParser( FMLParser.java:40)
at org.xtext.example.mydsl.parser.antlr.FMLParser.parse(FMLPars er.java:26)
at org.eclipse.xtext.parser.antlr.AbstractAntlrParser.doParse(A bstractAntlrParser.java:57)


Surprisingly, when I deploy the application as an Eclipse plugin, there is no problem -- Xtext and the third party library can collaborate and there is no conflict with ANTLR versions.

Have you got any idea why does it work well when deploying as an Eclipse plugin?
Have you ever been confronted with such situations (collaborations of two ANTLR versions?)?
Can I force Xtext to work with ANTLR 3.1.3?

More generally, have you got any idea on how to resolve this problem?

Thank you for your support

Mathieu

PS: I have the feeling that this is related to org.antlr.runtime
PS2: The packrat parser seems to be abandoned. Am I wrong?

[Updated on: Sat, 11 September 2010 07:16]

Report message to a moderator

Re: Multiple ANTLR versions using Xtext and third party library in a standalone application [message #558329 is a reply to message #558316] Sat, 11 September 2010 09:27 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
Am 9/11/10 8:55 AM, schrieb Acher:
> Hi,
> I am using Xtext and its parsing facilities to implement an interpreter.
> In addition, I am using a third party library that parses some other
> parts of the interpreter.
> The third party library relies on ANTLR 3.1.3 whereas Xtext relies on
> 3.0.0 -- if I am not wrong. Here comes my issue since I need to mixin
> the two versions of ANTLR -- for Xtext and for the third party library.
> Depending on the order I export entries in the Java build path, I have
> one of the following error:
> (1) Exception in thread "main" java.lang.SecurityException: class
> "org.antlr.runtime.RecognizerSharedState"'s signer information does not
> match signer information of other classes in the same package
> at java.lang.ClassLoader.checkCerts(ClassLoader.java:807)
> at java.lang.ClassLoader.preDefineClass(ClassLoader.java:488)
> at java.lang.ClassLoader.defineClassCond(ClassLoader.java:626)
> at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
> .....
> call to the third library fails
>
> (2) Exception in thread "main" java.lang.NoSuchFieldError: ruleMemo
> at org.xtext.example.mydsl.parser.antlr.internal.InternalFMLPar ser.
> <init>(InternalFMLParser.java:53)
> at org.xtext.example.mydsl.parser.antlr.internal.InternalFMLPar ser.
> <init>(InternalFMLParser.java:70)
> at org.xtext.example.mydsl.parser.antlr.FMLParser.createParser(
> FMLParser.java:40)
> at org.xtext.example.mydsl.parser.antlr.FMLParser.parse(FMLPars
> er.java:26)
> at org.eclipse.xtext.parser.antlr.AbstractAntlrParser.doParse(A
> bstractAntlrParser.java:57)
>
>
> Surprisingly, when I deploy the application as an Eclipse plugin, there
> is no problem -- Xtext and the third party library can collaborate and
> there is no conflict with ANTLR versions.

The magic of OSGi makes this possible.

> Have you got any idea why does it work well when deploying as an Eclipse
> plugin? Have you ever been confronted with such situations
> (collaborations of two ANTLR versions?)?

Because OSGi gives every bundle (jar) its own classloader, which only
sees the direct dependencies. As Xtext depends on ANTLR 3.0.x it uses
that bundle.

Can I force Xtext to work with
> ANTLR 3.1.3?

You could try to use the ANTLR 3.1.3 parser generator and the runtime
library. But I'm almost sure they are not compatible (haven't tried though).

> More generally, have you got any idea on how to resolve this problem?

Running your application within an OSGi container should help.

Sven

--
--
Need professional support for Xtext or other Eclipse Modeling technologies?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : http://blog.efftinge.de
Re: Multiple ANTLR versions using Xtext and third party library in a standalone application [message #693839 is a reply to message #558329] Thu, 07 July 2011 09:58 Go to previous messageGo to next message
Julien Bigot is currently offline Julien BigotFriend
Messages: 26
Registered: July 2009
Junior Member
Does this mean that it has become impossible to build an xtext application out of eclipse, for example as part of an ant build or is there a workaround ?
Re: Multiple ANTLR versions using Xtext and third party library in a standalone application [message #695626 is a reply to message #693839] Tue, 12 July 2011 07:48 Go to previous message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Julien,

Xtext 2.0 requires Antlr runtime 3.2.0 and exactly that version while
Xtext 1.0 required Antlr 3.0.1.
It is not compatible to older or newer versions of the parser generator.
You can build Xtext application out of Eclipse without any problems as
long as you have a clean classpath. OSGi takes care of this in Eclipse
itself while you have to make sure that your dependencies are correct in
a plain Java process.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

On 07.07.11 11:58, Julien Bigot wrote:
> Does this mean that it has become impossible to build an xtext
> application out of eclipse, for example as part of an ant build or is
> there a workaround ?
Previous Topic:Testcoverage of a grammar
Next Topic:[xtext2] Scoping & Fragments
Goto Forum:
  


Current Time: Thu Apr 25 12:26:13 GMT 2024

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

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

Back to the top