Is there a third-party library to detect the use of a Java 1.5 library when compiling with a 1.5 compiler with -source 1.4 and -target 1.4?
I could use a 1.4 rt.jar in the bootclasspath however I hope there is a better way. To be used, for example, to fail the compile/build if a newer library is used.
The curiously named Animal Sniffer is designed for this task. See Kohsuke’s blog post Compiling with JDK6 and running on JDK5
It’s packaged as a Maven Plugin (an example of usage is given in this answer), but can also be invoked programmatically: