gary-rowe / hid4java

A cross-platform Java Native Access (JNA) wrapper for the libusb/hidapi library. Works out of the box on Windows/Mac/Linux.
MIT License
229 stars 71 forks source link

Support Java 1.6 (and below if possible) #11

Closed andyrozman closed 9 years ago

andyrozman commented 9 years ago

Hi !

I have application which is built with Java 1.5. Is there specific reason, why Java 7 is used... I have seen that JNA 4 is done with 1.7, is this the only reason? Would it be possible to create 1.5 binaries? I mean I can build them, question is what was reason to use J7?

Take care, Andy

gary-rowe commented 9 years ago

The reason for Java 7 was that Java 6 (and earlier) has reached end of life and continued use should not be encouraged. I would urge you to upgrade your JVMs to 1.7 if possible.

Obviously, if that is not possible due to environment restrictions then the code is open source under MIT licence so you should be able to recompile it to a lower byte code level. I've not done this myself but I'd be interested in the outcome so I could add it to the support notes.

andyrozman commented 9 years ago

When making a library that others can use, it is good to go with oldest version you can (this would be probably 1.5 in your case since Generics are used), so that as many as possible can use it... I tried using in on Java 5, but there were some issues:

gary-rowe commented 9 years ago

I accept your point about targeting as low a JVM as you can, but there comes a time when backwards compatibility becomes a burden to the main codebase.

I could remove the @Override annotations but it feels wrong to remove that safety net. It's good programming practice to allow the compiler to warn when code isn't actually overriding/implementing a method. This annotation is compatible with Java 6.

When selecting JNA I just went for the latest since it is most likely to have the least bugs and most mature code.

Overall, I could just about be convinced to lower the minimum JVM to 1.6 but I just can't condone 1.5 on the grounds that it's been EOL since October 2009.

andyrozman commented 9 years ago

I agree with Java 5 here... If you implement some method (from Interface) you don't override it you implement it...

Even if you support just Java 6, you would need to go with latest JNA 3.x release.

I work for professional company and I know that one some projects we still use Java 5 (custom implementations).

gary-rowe commented 9 years ago

OK, I'll look into aligning with Java 6 on my next refresh of the project.

gary-rowe commented 9 years ago

Made various adjustments to support Java6 and JNA 3.5.2.

Ready for review and close.

gary-rowe commented 9 years ago

Code is now compiled under JDK1.6.