I need to develop an application in java where i can parse the .net application code and to generate the corresponding Java code. I heard that it is easy to implement Abstract Syntax Tree(AST) for .net code and later i can use that AST in my java application to generate corresponding java classes. NOTE : should not touch my .NET application code at any cost. So My target is i have to develop a java application which parse the .net code and construct the AST. Later, i can use this AST and can generate the corresponding java classes. I need to start up with basic "hello world" program.
-
See http://stackoverflow.com/questions/3455456/what-kinds-of-patterns-could-i-enforce-on-the-code-to-make-it-easier-to-translat/3460977#3460977 – Ira Baxter Nov 26 '13 at 10:50
2 Answers
I heard that it is easy to implement Abstract Syntax Tree(AST) for .net code
Easy is subjective. What you propose is deeply complex, even if you used a tool like Roslyn as a starting point. Also keep in mind that many .NET concepts don't even map to Java (delegates, events, dynamic, LINQ, true generics (rather than type erasure), custom value-types, etc). There are tools that do things like this as products for example IKVM and JNBridge. IKVM works by hosting Java bytecode as IL inside the CLI; I'm not entirely sure what JNBridge does, but it seems to work in both directions (unlike IKVM) - but note: these are not code translators.

- 1,026,079
- 266
- 2,566
- 2,900
Though not impossible, what you are trying to achieve is way too broad and needs lots of coding, patience, and time. First problem you have to solve is .Net is not a programming language but a framework and ready made code , many programming languages like C#, VB, VC++ and many more use .Net Framework .So, you have to first decide which programming language you want to target.
.Net library is very vast and contains thousands of classes and functions, I won't be surprised if the total number of functions are in the magnitude of 100,000.
It is not so easy to find a mapping between every .Net function and a Java function. You may not find equivalent methods at all. Not only methods, but some concepts also don't have equivalent implementations in Java for example.
Hello world program is easy because the number of methods that are used in it are limited and lines of code is minimal. But anything beyond that, it is not a straight forward solution you can achieve in short period of time.

- 4,339
- 2
- 27
- 51