Il codice da te postato sulla mia jdk 1.5 funziona senza nessun problema.