Background:
We have a maven based java project that targets JRE 1.7, but the source code uses lambdas, so we use retrolambda to convert Java 8 source code to Java 7 . We also use the StreamSupport backport library when we need streams, a function. *, Optional, etc.
Using retrolambda involves setting the level of both source and target languages ββper project to 1.8.
Everything works fine if there are no dependencies on java8 classes or methods (for example, java.util.stream.* , java.util.Optional or methods introduced in java8 , for example Collection.forEach ). If there are such ways to use, then build passages, but it does not work at run time, when running under Java 8 JVM.
Question:
My goal is to fail the assembly when such dependencies exist. Is there a way to detect dependencies on new Java 8 classes / methods at build time?
I thought of two possible options, but I'm not sure if any of them is doable:
- Some kind of bytecode analyzer for detecting depdencies on predefined classes and methods. Are there such maven tools / plugins?
- Lint Rules (
lint4j ). Not sure if class / method dependency can be defined with lint
java maven java-8 lint retrolambda
Denis itskovich
source share