Some odd code in the JDK

15 Sep 2005

This cropped up while testing Wouter Zelle's new UselessOverridingMethod rule. From JDK 1.4.2's java.awt.image.PixelGrabber:

public void setHints(int hints) {
  return;
}

Why the return; wouldn't this do just as well?

public void setHints(int hints) {}

This occurs several times in that source file. Blah.

Still though, it's not too bad in the end - the same bytecode is generated whether the return statement is in there or not. But it does look odd.