|
From: Barrie T. <bae...@gm...> - 2015-08-28 01:19:18
|
On 28 August 2015 at 07:07, Peter Becker <pe...@pe...> wrote: > One note of warning: unless you compile against a corresponding JDK > nothing will stop you from picking up a method that won't be in an > earlier JDK. The result is a NoSuchMethodException (or something like > that) at runtime. > > And there is plenty of innocent looking stuff like this one, which was > introduced in 1.6: > http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#isEmpty() > > The only safe ways are to compile against the target JDK or to use > static code analysis tools. > I've not used it but maven animal sniffer plugin will throw exceptions in case like this. The documentation is not great, http://stackoverflow.com/a/4451057/552958 should give you enough to get going to enforce this on the minimum jre you want to run on and allow some comfort on the jdk you want to build against. |