I’d say it’s the bug in the Sun compiler reported here and here, because if you change your line to the one below it works with both, which seems to be exactly what is described in the bug reports.
return GenericsTest2.<T>readObject(new ObjectInputStream(new FileInputStream(file)));