Looking for the Code Converter which converts C# to Java [closed] - java

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
Can anybody help me by suggesting the name of an converter which converts C# code to Java code. Actually, I have a tool which is written in C# code and I am trying to modify it. As I have no idea about C# and .NET framework, it seems difficult to me to convert the large code by my own. I found from some web information that there exist some tools which can convert C# to Java (may not be properly, however they can). Can anybody help me by suggesting some name of those tools.

Disclaimer: No tool is perfect.
However, if you still want to try then there are these converters available:
CS2J
JCLA : Convert Java-language code to C#
Grasshopper
CSharpJavaMerger
Tangible Software C# to Java Converter
Not a converter but a bridge between .NET and the JVM:
JNI4NetBridge

You are better off doing it by hand. I've used code conversion software before, and it just mucks everything up. Sure, it corrects a few syntax differences, but largely what you'll get is just a mess of code that doesn't compile right away anyway.
With a converter you'll have to do a lot of corrections anyway. Why not take the small amount of extra time it will take to convert it by hand and end up with better code?
Even if you don't know C#, it will be better to learn it and do the conversion by hand, as I said before you will have to do it anyway. C# and Java are not too different syntactically, but as #Marc pointed out above, there are certainly gaps in the language. Simple C# is easily translated to Java, of course having to use the Java BCL instead of the .NET, which certainly have their differences. As you get into more complicated C#, there are things that have no direct equivalent.
Keep in mind, that conversion projects can be extremely time-consuming and are extremely effective at swallowing money in a business environment.
A google search will yield you some commercial options, but I'm not going to post them here, simply because I'm against that sort of thing. There are some things you just can't automatically translate.

Related

java source parsing library for python [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
Ive been searching for a while and can't seem to find what im looking for. What I want to do is write a python script to report problems and enforce code standards in Java code. Everything I have found so far has been things to translate java into python or python into java and that isn't really what I want. Im looking for a python library that can parse a multi-thousand class project and present the source itself in python in such a way where I can write rules something like
every class must have class level javadoc
every class must have a #primaryContactName tag in class level javadoc
every class must have a #primaryContactEmail tag in class level javadoc
the authorized 3rd party library list is {1,2,3,4,5} are any libraries other than this
list used
all lists and maps fully type safe.
bla bla bla
I reallize that I can get a great deal of this info from javac with very little effort, and I may investigate using javac to make version work, but im looking to do something a bit more advanced where I can build in real analytics
I have done similar with XDoclet in the past, but that was primarily used to mantain metadata in the source code about what systems it was accessing and such, nothing really to this analytics level im looking for now.
Anyone come across a python library that would help out with this? I would consider other languages (java, c, etc) its simply in my current situation, python is easier to work with than anything else.

Reverse Engineering poorly documented Java from source [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 1 year ago.
Improve this question
I'm a systems engineer, recent college grad, and I've just been given a project that is exceptionally daunting.
We have a legacy system, we legally own the entire code and all rights to it. The problem is that the code is poorly documented, what little documentation is incomplete, sometimes wrong and the original devs are unavailable.
It uses a custom Perl build script requires a thousand modules from CPAN to work and I do not know Perl. Reverse engineering into UML has failed except with Doxygen and that is limited to just inheritance diagrams and call graphs.
I've obtained a massive chalkboard and I'm slowly trawling through the code, modeling packages and then the nested packages within.
My question is whether or not I'm approaching this reverse engineering from the right direction. I'm working close from the bottom trying to figure out what calls what while developing UML and writing a Design Document. I did a package diagram but it's hard to figure out what's going on at that high a level.
An academic paper I pulled up suggests I also make a new Requirements Document which would slow me down even more and I don't know if it's a good idea as the other developers are always busy trying to keep the legacy system up.
Are there any books out there that can help me and am I approaching this from the right angle? Should I hire a contract worker that knows Perl and JMX to assist me?
The book "Working Effectively with Legacy Code" by Michael Feathers will probably help you more than anything we can tell you here.
However, the most important thing you need to clarify for yourself (and from your question it sounds like it's not completely clear) is this: what is your goal? What do you want to achieve with this codebase?
If the answer is (as it sounds) "being able to effectively maintain the existing project", then trying to directly build a complete high-level model of the system may not be the most effective path. It's probably just too much at once to keep in mind.
In this case, I would try to understand only the use cases of the system that you currently need to modify; follow method calls through the code (pssibly using a debugger on the running system) to see what parts are involved. Do this for a few different use cases and you'll start to see patterns, then document those and gradually fit them together into a high-level image of the system.
This tool might assist you.
Or if the legacy system is written poorly it could just make a huge unreadable mess, but I hope it helps.
If it is a java code then a deep reverse engineering would be very helpful.
See a documentation at: http://www.ejb3.org/jar_file_reverse/jar_file_reverse.html

Java equivalent of Python's "construct" library [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
Is there a Java equivalent of Python's "construct" library? I want to write "structs" like so:
message = Struct("message",
UBInt8("protocol"),
UBInt16("length"),
MetaField("data", lambda ctx: ctx["length"])
)
It doesn't have to specifically be a library with some sort of abstraction using the Java language. I mean, it could be a "portable" format, with an API for parsing the documents. I guess this could work out with XML, but it would be be a lot more ugly.
I realize I could just inter-operate with Python, but I don't want to do that.
I've looked a lot around and all I could find was Ragel (www.complang.org/ragel), that can also produce Java code.
It looked too complex for me so I've started some work to port Construct to Java.
I suspect it would be easier to make something like that in Scala, Groovy or JavaScript.
Construct on GitHub: https://github.com/MostAwesomeDude/construct
java construct: https://github.com/ZiglioNZ/construct
I've spent a couple of days on it, mostly looking for equivalents of python's expressive classes.
The most useful java classes I've found are: java.util.Scanner, java.util.Formatter and java.nio.ByteBuffer.
It's a big task so I want to focus on something small like creating simple parsers and formatters for ByteBuffers.
[Update]
I've ported enough code to parse and build some of the protocols that come with Python Construct, such as ethernet, arp and ipv4. Check it out at https://github.com/ZiglioNZ/construct
[Update: new Release]
Java Construct 1.1.2 is now available, see release notes.
You can use DataInput/DataOutput (and their implementations) to convert any set of values from/to a set of bytes. This doesn't give you an object where you can use names to access the individual fields, though - you would have to create such yourself.
It depends a bit on what you want to do - do you have a fixed data format to send/receive on wire, or does this vary from time to time?

Java Bytecode Manipulation Library Suggestions [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 months ago.
Improve this question
I'm looking for a well-maintained Java bytecode manipulation library with an intuitive API. There seem to be quite a lot of them out there. Any suggestions on which ones to try?
The best answer to your question will be governed by your specific needs and objectives; if you can expand upon what you're trying to accomplish, I can perhaps offer a more tailored response.
In lieu of that, however, in my experience, ASM offers probably the best combination of maturity, flexibility, and ease-of-use:
It's under relatively active development: even though the latest release is from June 2009, developers are regularly making commits to their VCS.
It's already in wide use in a number of prominent Java products, such as AspectJ, Groovy, Cobertura, and many others, which promises a wide user-base and thus a wide community for support.
It's fairly thoroughly documented, and there are a number of tutorials, user guides, and reference documents available both from the OW2 Consortium and the community at large.
N.B. The comment #Yuri left below describes a situation I personally haven't yet encountered but that may potentially pose a significant obstacle. Keep his observation/experience in mind while evaluating the various bytecode manipulation libraries.
That actually depends on how you define intuitive ;-) I started using ASM two weeks ago for a certain task on my current project and it worked like a charm. It only took me a couple hours to understand it and be able to use it, but I wouldn't exactly call the API intuitive. But if you know a little bit about Java bytecode and are familiar with the visitor pattern, the learning curve is not very high, IMO.
Another advantage of ASM is that it is apparently bundled with the standard API at least in the Sun JDK, although in a different package (com.sun.xml.internal.ws.org.objectweb.asm and subpackages).
Take a look at this article :
http://www.pabrantes.net/blog/space/start/2008-03-24/1
A little old but still relevant.
ASM And Javassist are the most used ones now.
Bcel is dying.

Is there a way to transfer/translate the code written in Java to other languages? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
Theoretically this seems possible to me. So can Any one confirm this to me, if it's possible? and if there is such a software that does this?(like Java to C++ or C#)
And in general would it be possible to transfer languages like Java to server-side programing language like PHP?
Translating the syntactical elements of one language and producing another is not trivial but it's not impossible. A good parser can build syntax trees in one language and then emit another. The difficulty of porting code outside the context of simple "Hello World" type applications is twofold:
The libraries of one language will probably differ (e.g. WinForms vs Swing)
Some language features will have to be catered for: (lambda expressions, anonymous methods, different inheritance implementations etc).
It is possible, but the major problem is that Java has a very large runtime library which needs to be made available in the target language in order to be able to do a fully automatic conversion.
For the special case of Java -> .NET, you can use J# from Microsoft to compile it into a .NET assembly which can then be used. Also ikvm.net allows for running a JVM inside .NET.
For PHP I do not believe such a solution exist. You MAY be able to use gcj to create a native library which can be linked in, but I do not believe it is a feasible soultion.
What functionality do you need in PHP?
Visual Studio ships with a Java to C# translator, and even tough it does a pretty decent job, there's still a lot to clean up afterwards.
In my experience you really have to ask yourself if it makes sense to translate code from one language to another. What is the gain? Will the translated code be maintainable? If the answers to these questions point in the wrong direction, translating is probably not the right approach.
Google Web Toolkit does conversion from Java to JavaScript:
http://code.google.com/webtoolkit/overview.html
to answer your question, yup, theoretically this is indeed possible and practically such technology is used every day :)
The interesting thing, in my opinion, is that the Java converters typically convert by taking the bytecode, not the source code. Then it's, say, bytecode-to-ObjectiveC source code. For some converters (at least one opensource one) it's bytecode-to-XML then XML-to-target-language.
For example, the Uniwar application for the iPhone, which has been acclaimed by all and made its way to the appStore's top ten, as been written in Java (JME) and automatically converted from the Java bytecode. Reaching the top ten, even for a few days, means that this is deployed on a lot of machines ;)
In the Real-World [TM], Cobol-Java and, weirdly, Java-Cobol are not unheard of.
For all this to work that said you need a really good converter :)
Theoretically it is possible. But as others pointed out the main problem is to translate libraries.
Some time ago I made Java to Tcl(XOTcl) and Java to Python translators to evaluate the translation posibility. Search by java2tcl and yava2python.
They convert syntax but do not make relevant constructions translations (e.g. Java file operations to Python ones). That would require more development time.
In general my opinion is what such a translation may be possible. But only if your translator covers classes/libraries of the converted project.

Categories

Resources