I have a library which I am currently developing with target compatibility to JDK 6. I like to take advantage of Java 8 feature, like lambdas. The code and APIs will greatly profit from Java 8.
I would like to offer versions of the library for Java 6 and Java 8, e.g., where a certain part is only available in the Java 8 version.
Now there are a few core classes which might have their different source version (the legacy Java 6 version and the new Java 8 version).
What is the best practice of doing this? In Objective-C or C++ I would consider using a preprocessor directive.