Have you thought about using Java 5 foreach loops?

for(ICompilationUnit iCompilationUnit : packageFragment.getCompilationUnits()){
...
}