This is the mail archive of the frysk@sourceware.org mailing list for the frysk project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: inner classes with fields names similar to outer class/method fields


Mark Wielaard wrote:
Hi,

The following bug cost me a while to track down. The fix is easy. But if
you are not expecting this then you might be puzzled about it for a long
time like I was.

testSyscallRunning(frysk.proc.TestSyscallRunning)java.lang.NullPointerException
   at frysk.proc.TestSyscallRunning$2.execute(TestRunner)

The problem was that under some versions of the fc6 compiler this method
was miscompiled (!), under f7 the compiler gets it right. The anonymous
inner class that extends TaskEvent tries to refer to the final task
field of the method it is in. But TaskEvent has a field called task
itself. The TaskEvent.task field is never initialized and so stays null.
By explicitly renaming the final field in the outer method and using
that name in the inner class the reference is always correct (under
either the fc6 or f7 compiler).
Mark,

Can you be more specific? Frysk's build system already has a check for what sounds like a very similar bug vis:

class foo {
{
  func1() {
    class Bar {}
 }
 func2() {
   class Bar {}
 }
}


Andrew



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]