unsuccessfully tried to work around JDK bug 8044546, but code looks still somewhat better, so I keep it for now