Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#76 Instantiate class as argument in static initialiser block

closed-fixed
nobody
Exceptions (14)
5
2008-02-17
2008-01-31
Anonymous
No

Hi,

Green is a great tool and I've been using it a good bit, however, I have stumbled over the following you will probably want to fix.

If you instantiate a class as a argument, in a method call inside a class static initialiser, Green suffers from a NullPointerException. The following illustrates the problem.

public class TestStatic {
static {
VerySimple vs = new VerySimple();
TestToCall ttc = new TestToCall();
ttc.callMe(new VerySimple()); // Will cause NPE
ttc.callMe(vs); // Will not cause NPE
}
public TestStatic() {
// TODO Auto-generated constructor stub
}
}

public class TestToCall {
public String callMe(VerySimple imple)
{
return "OK";
}
}

public class VerySimple {

}

I've spent a bit of time narrowing this down, so I am pretty sure that this is the specific circumstance in which the problem occurs. If you need any more information, I'd be delighted to help.

Regards,

OOK

Discussion

  • Gene Wang
    Gene Wang
    2008-02-17

    Logged In: YES
    user_id=1520789
    Originator: NO

    First of all, thank you for narrowing this down for us. This issue did have to do with the class instantiation inside the method call; because it invoked one of our relationship recognizers. However, Green did not handle relationships coming from initializer blocks properly. This issue has been corrected and will be in the next release.

     
  • Gene Wang
    Gene Wang
    2008-02-17

    • status: open --> closed-fixed