Why doesn't Sun do a C# to Java byte code compiler?

后端 未结 18 1903
清酒与你
清酒与你 2021-02-01 01:20

We Want to Run Our C# Code on the JVM

My company has a large C# code base. Well over half of this code is our core engine for creating, reading, modifying, calculating

18条回答
  •  天涯浪人
    2021-02-01 02:10

    "So, we would like to build a Java version of our core engine, ideally without maintaining a separate Java source code base."

    Basically, you want to compile your C# code unmodified, and have it run in a Java-only environment.

    IKVM is not what you want. IKVM is three main things.

    a. ikvm - CLI implementation of a Java virtual machine (note that this uses Classpath (now OpenJDK) for the Java class library).

    b. ikvmc - Compiles java bytecode to CLI bytecode.

    c. ikvmstub - Generates java stub classes that call CLI code.

    Note that all of these tools depend on CLI at runtime. What you want is exactly the opposite of IKVM, which is of course MVKI (Most Venerable Kompiler Intermediary) :):

    a. mvki - Java implementation of a CLI virtual machine (presumably this would use Mono or DotGNU for the class library).

    b. mvkic - Compiles CLI bytecode to Java bytecode.

    c. mvkistub - Generates CLI stub classes that call Java

    Note that none of these would require an existing implementation of the .NET Framework at runtime, so they should be satisfactory to your Java-only customers.

    Unfortunately, as far as I know MVKI does not exist, so you're best off doing a manual port (which would inevitably be cleaner, albeit more work).

    Edit: Based on the description of Mainsoft, it appears to be similar to MVKI, though I'm not sure what they do for the class library, and unlike IKVM it's not FOSS.

提交回复
热议问题