Attempt to resolve issues with Java 8

Proposal towards issues like #4500. I don't like this approach, it's kind of ugly.

Theoretically, this should also work with IntelliJ et. al. but I didn't feel like I could test them appropriately, as I do not use them regularly.