Move custom code from aj to java (part 1).