Thursday, March 5, 2009

JDeveloper code editor "rabbit in a hat" magic trick

Sometimes it is not the bug itself; but how you report them that gets the smile. Take for example this test case for a bug in JDeveloper provided by fellow web service team member Alan Davis.

Create a new java file called Class1 and paste in the following text.

package project1

public class Class1
{
   public void method()
   {
     /** */
     class Foo extends ArrayList
     {
         /*
          *          /| |\
          *         | |_| |
          *         | |_| |          And for my next trick,
          *         | . . |          not only will I make the
          *         \  @  /          rabbit disappear, but
          *       ===========        I will make the hat
          *       |_       _|        vanish too...
          *         |      |
          *         |      |
          *         |______|
          */
     };
   
     doIt(); // Comment
   }
   void doIt() {}
}

Then accept the import assistance on the ArrayList import. Ta-daa. For weeks Alan was wondering why we kept on deleting his code... now we know it was just a magic trick. Fortunately you need a very specific combination of code structures and comments to exercise this bug so you shouldn't see this using 11 day to day.

2 comments:

Alan Davis said...

Gerard, you need to give Keimpe Bronkhorst some of the credit for identifying the simplified test case (without the wildlife). Alan

Gerard Davison said...

Noted, Keimpe does a Stirling job keeping the java model honest for us.