Implementation of Workaround proposod by Joe Wang in bug JDK-8028111.
Reference: https://bugs.openjdk.java.net/browse/JDK-8028111