user918176 user918176 - 4 months ago 23
Java Question

How to prevent Java developers from using new language features?

Since Java SE 7 is EOL, upgrading to Java 8 is necessary. However there are business reasons to not allow the developers to use any of the new language features. The feature that is especially forbidden is lambdas.

How can the use of Java 7 features be enforced? The build system is based on Jenkins and there is also SonarQube available.


Other answers are partially right. Compiler must indeed be configured with -source 1.7 to check that no Java 8 lang features are used. But it does not prevent from using the new Java 8 APIs. A solution is to use the animal sniffer project to verify that only Java 7 APIs are used.

Here is a a sample of configuration for maven projects: