Is it possible to use ConcurrentHashmap compute with java 7 source level?

David Michael Gang :

We have an old project using gwt 2.6 and therefore we need to compile with -source 1.7 option.

The JRE and JDK used are 1.8, but compile with 1.7 source code option.

We want to use the new compute function from ConcurrentHashMap which is only available from java 8. When using eclipse and maven everything compiled well. On the other hand IntelliJ is complaining. My question is, will it work or will we have issues with it?

Will this project run?

Searching in google for ConcurrentHashmap compute, java 8 and source code level 1.7 did not give any info.

GhostCat salutes Monica C. :

If at all, this would require a lot of careful "manual" work.

When you look at this question for example, you can find that there are various different ideas how people want to enable "stream based" functional programming with Java 7. Maybe, after doing a lot of research, you might be able to find similar things regarding such "enhanced collection" features.

But then, all of that might be quite fragile. The fact that some examples might work fine wouldn't mean that you would be able to run a large production code base on a Java 7 VM.

Thus more of a non-answer here: be careful how to invest your time and energy. Instead of trying to backport libraries to Java 7, rather look into moving your whole project onto Java8 at least. Especially keeping in mind that the release cadence for Java has changed significantly, and going with outdated Java versions for many years is simply even less desirable compared to a few years ago.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=68626&siteId=1