[Bluej-discuss] debugging in inner classes

Jan Derriks j.derriks+bluej-discuss at hva.nl
Fri Oct 20 16:54:52 BST 2006


There is a workaround: make a reference attribute in the inner class to
point to the outer object.
The outer reference value can be set from a constructor or using an extra
method.
I could not find a direct way of inspecting the outer internals with BlueJ
either.

Example:
/**
 * Class Hello:
 *
 * Hello-world program to demonstrate BlueJ.
 */
class Hello
{
    int foomain=2020;
    
    public void go()
    {
        System.out.println("Hello, world");
        new Inner(this).do2();
        
    }

    public static void main(String[] args)
    {
        Hello hi = new Hello();
        hi.go();
    }
    
    class Inner {
      int aaa=3;
      Hello outer;
      
      Inner (Hello h) { // could be a separate method instead of contructor
          outer = h;
      }
      void do2(){
          aaa = aaa + 1; // set a breakpoint here and view 'outer'
      }
    }        
}

--
Jan Derriks
Instituut voor Informatica, Hogeschool van Amsterdam


> -----Original Message-----
> From: bluej-discuss-bounces at bluej.org 
> [mailto:bluej-discuss-bounces at bluej.org] On Behalf Of Stephen Bloch
> Sent: woensdag 18 oktober 2006 20:56
> To: bluej-discuss at bluej.org
> Subject: [Bluej-discuss] debugging in inner classes
> 
> 
> I set a breakpoint in an inner class (say, an event handler, so I can 
> tell whether the event was actually triggered), run the program, and 
> it stops at the desired line.  Code on this line can see and even 
> modify instance variables of the "outer" class, but I can't see those 
> instance variables in the debugger window.  Or is there a way that I 
> just haven't spotted?
> -- 
> 							Stephen Bloch
> 							Math/CS Dept
>  
> Adelphi University
>  
> sbloch at adelphi.edu _______________________________________________
> mailing list bluej-discuss at bluej.org
> To unsubscribe or change your preferences, go to 
> http://lists.bluej.org/mailman/listinfo/bluej-discuss
> 



More information about the bluej-discuss mailing list