Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Deriving model from binary class files
Deriving model from binary class files [message #1821382] Wed, 12 February 2020 08:42 Go to next message
Mirko Raner is currently offline Mirko RanerFriend
Messages: 98
Registered: July 2009
Location: New York City, NY
Member
I've been working on a JVM-based programming language for a while. The language is somewhat similar to Java, but has some extensions and some restrictions compared to plain Java. Notably, due to some of the extensions, the source code cannot generally be translated to Java source code, and there is a compiler back end that directly produces JVM bytecode from the AST/domain model.

Now, in addition to the primary source files, I want to incorporate pre-compiled libraries, just like one would include additional JARs on the class path (in fact, the libraries are just that, plain JARs). To compile source code against these JARs I somehow need to infer, at least partially, the domain model and AST based on the content of the JAR. I basically need classes and method signatures (no method implementations), so that the scope provider can resolve cross-references to elements that are defined in the library.

For some reason, I'm having a hard time finding existing examples of this kind of mechanism in other Xtext languages. I already have a simple implementation of IJvmModelInferrer, but since I'd like to infer domain elements (not JVM types) this does not seem the right spot for what I'm trying to do. IResourceServiceProvider and its related interfaces (e.g., IResourceDescription.Manager) seem more promising, but I can't quite put all the pieces together.

I am also wondering if I'm not making all this too complicated, and there is already some brilliantly simple mechanism to facilitate what I'm trying to do (as there often is with Xtext and EMF :-) )

Long story short: what is the recommended or standard mechanism to generate models/ASTs for binary libraries (that don't come with sources) so that they can be linked with another model that is generated from source?
Re: Deriving model from binary class files [message #1821441 is a reply to message #1821382] Thu, 13 February 2020 06:34 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13641
Registered: July 2009
Senior Member
there is no ootb solution. you might have a look what Xtype/Xbase does do work with JvmTypes (if you could simply reuse these it would be the easiest solution)
also: if you ship a predefined lib, why no ship dsl files there too


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Deriving model from binary class files [message #1821446 is a reply to message #1821441] Thu, 13 February 2020 08:38 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6878
Registered: July 2009
Senior Member
Hi

The MoDisco project has Model Discovery as its underlying raison d'etre. There are capabilities to create UML and so EMF models from Java classes/projects. This might be exactly what you need.

Note that MoDisco has been rescued from termination and so is now on life support. It was discovered that the UML functionality had been broken for at least six years, but with the latest 1.5.1M2 build [1] you should find that provided you go direct from Java to UML without using a KDM intermediate, it might work.

Regards

Ed Willink

[1] http://www.eclipse.org/downloads/download.php?file=//modeling/mdt/modisco/downloads/drops/1.5.1/S202002051026/modisco-Update-1.5.1M2.zip
Re: Deriving model from binary class files [message #1821598 is a reply to message #1821446] Mon, 17 February 2020 06:11 Go to previous message
Mirko Raner is currently offline Mirko RanerFriend
Messages: 98
Registered: July 2009
Location: New York City, NY
Member
Thanks for the responses, Christian and Ed, and my apologies for double-posting (I was experiencing high server latency when I posted, and I must have hit refresh).
Thanks for confirming that there is no quick and easy solution that I was missing, Christian. It seems to be a very model-specific task, so it makes sense that there is not a lot of room to automate and standardize things there.
I will check out MoDisco, though. Thanks for posting a link to the project, Ed.
Previous Topic:Programmatically set target platform to manage external libraries
Next Topic:Resource validation after opening it in editor
Goto Forum:
  


Current Time: Tue Oct 27 23:50:10 GMT 2020

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

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

Back to the top