From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18896 invoked by alias); 2 Jul 2007 12:32:00 -0000 Received: (qmail 18889 invoked by uid 22791); 2 Jul 2007 12:32:00 -0000 X-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_05,DK_POLICY_SIGNSOME,FORGED_RCVD_HELO X-Spam-Check-By: sourceware.org Received: from wildebeest.demon.nl (HELO gnu.wildebeest.org) (83.160.170.119) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 02 Jul 2007 12:31:55 +0000 Received: from dijkstra.wildebeest.org ([192.168.1.29]) by gnu.wildebeest.org with esmtp (Exim 4.43) id 1I5L6g-00041x-26 for frysk@sources.redhat.com; Mon, 02 Jul 2007 14:34:18 +0200 Subject: inner classes with fields names similar to outer class/method fields From: Mark Wielaard To: frysk Content-Type: text/plain Date: Mon, 02 Jul 2007 12:32:00 -0000 Message-Id: <1183379510.3622.17.camel@dijkstra.wildebeest.org> Mime-Version: 1.0 X-Mailer: Evolution 2.8.3 (2.8.3-2.fc6) Content-Transfer-Encoding: 7bit X-Spam-Score: -4.4 (----) X-IsSubscribed: yes Mailing-List: contact frysk-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: frysk-owner@sourceware.org X-SW-Source: 2007-q3/txt/msg00000.txt.bz2 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). 2007-06-02 Mark Wielaard * TestSyscallRunning.java (testSyscallRunning): Rename final task field to proc_task. There should be a warning in the compiler to complain if such a confusing name clash is detected. Cheers, Mark diff -u -r1.12 TestSyscallRunning.java --- frysk/proc/TestSyscallRunning.java 17 Apr 2007 19:45:09 -0000 1.12 +++ frysk/proc/TestSyscallRunning.java 2 Jul 2007 12:16:10 -0000 @@ -103,10 +103,10 @@ // Get the port that will be listened on. int port = Integer.decode(in.readLine()).intValue(); - final Task task = proc.getMainTask(); + final Task proc_task = proc.getMainTask(); - final SyscallObserver syso = new SyscallObserver("accept", task, false); - task.requestAddSyscallObserver(syso); + final SyscallObserver syso = new SyscallObserver("accept", proc_task, false ); + proc_task.requestAddSyscallObserver(syso); // Make sure the observer is properly installed. while (! syso.isAdded()) @@ -122,15 +122,15 @@ // Now unblock and then attach another observer. // Do all this on the eventloop so properly serialize calls. - final SyscallObserver syso2 = new SyscallObserver("accept", task, true); + final SyscallObserver syso2 = new SyscallObserver("accept", proc_task, true ); Manager.eventLoop.add(new TaskEvent() { public void execute () { // Continue running (inside syscall), // while attaching another syscall observer - task.requestUnblock(syso); - task.requestAddSyscallObserver(syso2); + proc_task.requestUnblock(syso); + proc_task.requestAddSyscallObserver(syso2); } });