views:

377

answers:

5

JNI is a peculiar little corner of the universe. I was wondering if there is a market there for specialty contract work.

From what I can tell: (1) JNI usage is rather rare these days. (2) Most devs are not as good at it as they might think. (3) Being rare, it is a labor to come up to speed (again) when called upon to do so.

The potential negatives seem to be that (1) there are some 3rd party tools that make it easier and (2) many JNI projects are such small one-offs that they wouldn't be worth the effort or (3) the projects involve odd configurations that would require being on-site often or full-time.

So, is there a living (or part of one) to be made on JNI?


UPDATE: Thanks to everyone for their feedback and realistic assessments.

+1  A: 

Doubt it - it'd be too rare a requirement on most projects to hire a resource specifically for JNI related work and you can normally find somebody on a team that remembers enough C++.

Plus, Swig makes it pretty straight forward to do JNI anyway.

Still, it never hurts to have JNI experience in your bag of tricks...

Nick Holt
+1  A: 

Well working with JNI one must assume that you would have to have more than basic knowledge of at least two languages, namely C/C++ and Java. Working with JNI I experienced, that you have to be very well aware of e.g. memory management in the C part of your code and any mistake in the communication or in any other native part is likely to break/crash the whole JVM (not the nice Java Exception Handling way ;).

JNI comes into play, when it is too hard to convert legacy C/C++ code and to low level hardware communication. Depending on what you want to do you have to know the library/sofware you try to attach via JNI very well, too (because it is very likely that it is quite old and/or doesn't follow recent architecture standards).

So I doubt that it will be enough for a living but rather an additional skill because you will always have to deal with both parts in a whole.

Daff
+2  A: 

A market for JNI specifically ? I don't believe so.

Tooling like Swig and JNA make life relatively easy. Additionally, the interfaces I typically see being adapted are designed such that there are only a few methods (perhaps only the one), passing command objects. This means only one method has to be bridged and maintained, and consequently the amount of JNI written is tiny.

Brian Agnew
Besides, it is *recommended* that the amount of JNI code is minimum. You should write whatever you can in the Java code before the JNI call or after it.
Bruno Rothgiesser
Unfortunately I tend to see the one-method mechanism reflected in the Java API, which isn't really ideal. I'd like the rich API maintained in the client code and have the one-method mechanism hidden from view :-( The other downside is that it's not necessarily the most performant option
Brian Agnew
+3  A: 

I currently have the pleasure to rewrite a lot of JNI code with a view to improving the Java to C++ communications performance on my client's project, so there is demand for this sort of skill but it's not something I would bank a career on. At the end of the day it's a small effort compared to the overall effort involved in the project and usually you can create a reasonably working implementation if/when you're fairly competent in both languages. I'm by no means a JNI expert but have a decent background in C++ and reasonable Java.

As some of the other posters have pointed out, pretty much the only reason for existence of JNI these days is so you can glue a library that exports a C interface onto a Java project. In most cases, there is not much of a performance benefit of reimplementing Java code in C as JVMs are pretty good at generating machine code on the fly already. Plus, once you get outside Java, you have the worst of both worlds in the sense that you have to manually manage resources in both C/C++ and to a certain extent in Java by dropping hints to the JVM. It's not a particularly pleasant place to be IMHO and normally you'd try to keep the JNI part as small as possible so you'll transistion from the JNI code into your library as quickly as possible. Basically, you're writing an object translation layer if you use JNI as an interface from Java into C++.

As it has been pointed out there are tools like SWIG that can simplify this task already so as a career path I would think it's a bit of a dead end. That said, I consider it another tool in the toolbox I can offer to my clients and I do think it's useful if you have a foot in both the Java and the C++ camps. People who can do both languages well are pretty rare in my experience so I would concentrate on that instead of the layer that glues them together.

Timo Geusch
A: 

JNI development is very error prone and time consuming. Given the alternatives available today I would not recommend anyone to use JNI directly.

Someone already mentioned JNA which is an open source pure java wrapper over JNI. Commercial alternative is JInvoke which I used in a project before and was very satisfied.

Gregory Mostizky