Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Compiler bug?



At 7:43 pm -0700 7/4/05, Rolf Howarth wrote:

I'm always hesitant to ascribe something to a compiler bug but I've got a problem which is driving me dotty.

I have a project which I've been developing with CodeWarrior. I'm now
putting together an ant script to do a clean build and package the
application for release. The ant script builds the application
without errors, but omits to output one or two inner classes of one
particular class! I get XX$55.class and XX$57.class but no $56! When
I run the code, not surprisingly, I get a ClassNotFoundError.

Aha! It WAS a compiler bug, http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4954586


The problem boils down to this. If you have an inner class which is in code that is never reached then the compiler won't output a .class file for that class but the outer class still refers to it and so throws a NoClassDefFoundError when you try to load it!

  private static final boolean DEBUG = false;

  if (DEBUG) {
     Object inner = new Object() { };
  }

-Rolf

--
Rolf Howarth, Square Box Systems Ltd, Stratford-upon-Avon UK.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.