Convert C # to pure java?

Possible duplicate:
Is there an effective tool to convert c # to java?

I am not very knowledgeable in Java and have a lot of C # that I would like to translate into Java syntax so that it becomes compiled.

Reason: Android and Google Cloud

I know that APIs / Platforms have different structures, but we say that we do not need 100% compatibility, but simply to translate "core functionalitet". As I found out, the GUI itself is one story. But instead of rewriting each SWITCH-CASE, rebuild each class, etc., It would be nice to "match" objects with Java equal, and then recompile on the Android / Google platform.

I am sure that there would be something that cannot be translated as “C # the only thing” - but just like every language can generate .NET / MONO, I thought Java → .Net could exist, and so also also a decompiler seems to be?

So, are there any simple ways to overcome this translation using Frameworks, SDK or other similar methods that will automatically occupy 80-95% of the task?

+4
source share
3 answers

Take a look here: JSC .

But also, there are some C # concepts that don’t easilyli translate to java.

+1
source

.NET and Mono are compatible because both are virtual machines that run C # code. Grasshopper claims to let you run .NET classes on the JVM, but I have not used it. It will not work at all for Android, because Android is not a JVM, but rather Dalvik .

The differences between C # and Java are more than “structural,” as you put it, and translating from one language to another is more complicated than I think you understand.

0
source

I know that Microsoft has a tool that should help convert Java to C #, but given that a large number of Java application reference libraries are outside the main system (apache is the most striking example), this type of tool will be a monumental task.

C # also has data types that are not generally supported in Java, such as unsigned types and objects allocated by stacks. Writing CLR byte code translations in Java would be really difficult. And if you use lambda functions in your code, kiss this idea goodbye.

Then there is the fact that not all Java features are available for the Davlik JVM.

I'm not a microsoft fanatic, but here is a comparison of two languages ​​that will give you an idea of ​​why I doubt this tool exists.

http://en.wikipedia.org/wiki/Comparison_of_C_Sharp_and_Java

0
source

Source: https://habr.com/ru/post/1336979/


All Articles