Question

I've got a medium sized (25k lines code, 25k lines tests) codebase in java, and would like to port it to run on a CLR as well as the JVM.

Only the main class, and a few testing utilities deal with the file system or OS in any way. The rest of the code uses the generic collections APIs extensively, java.util.regex, java.net (but not URL or URLConnection), java.io for charset encoding/decoding, java.text for unicode normalization, and org.w3c.dom for XML manipulation.

Is it possible to get most of the codebase compiling under both J# and Java, and then port the rest?

If so, what kind of pitfalls am I likely to run into?

thanks in advance, mike

Was it helpful?

Solution

Check out IKVM: http://www.ikvm.net/

It allows you to run (specially compiled) Java code inside the .Net CLR.

Some of my colleages have used it successfully with a Java codebase of 1 million+ lines of code.

OTHER TIPS

Pitfalls:

  • Anything like this scares the heck out of me. The number of really subtle bugs waiting to happen is huge.
  • J# only supports Java 1.1.4 AFAIK - goodbye generics etc.
  • Visual Studio 2008 doesn't support J# - basically it's a dead project.

I suspect that you'd actually find it simpler to rewrite it in C# (including learning C# if you don't already know it - it's a joy). You'll end up with a more idiomatically .NET-like library that way as well, if that's relevant: if you ever want another .NET developer to consume your code, they're likely to be far happier with a "pure" .NET project than one using J#.

The downside is that going forward, any changes would also need to be made in two places. There's certainly pain there, but I really think you'll have a better experience using "normal" .NET.

As Jon pointed out: J# is pretty dead.

Running your (normal) Java code on .NET using IKVM might be an alternative, 'though.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top