Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 677
David Michael Gang Avatar asked Jul 23 '18 06:07

David Michael Gang


Video Answer


1 Answers

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.

like image 90
GhostCat Avatar answered Sep 23 '22 01:09

GhostCat