re-implement fix for #6 without using com.sun classes