ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan.Mate...@rzf.fin-nrw.de
Subject AW: AW: custom task calls classes with logging = NPE
Date Mon, 30 Aug 2004 12:30:12 GMT
> Perhaps you are familiar with the tutorial on writing your 
> own task? I followed it and then based
> my development on that. In the tutorial, the first example 
> puts this method in the task:
> 
>     private Project project;
> 
>     public void setProject(Project proj) {
>         project = proj;
>     }
> 
> It disappears in the next version of the example (with no 
> explanation, 


After that I extended oata.Task, which earns that method from
oata.ProjectComponent.


> or maybe I just misssed that bit) and if you leave it in like that (as I
did), 
> you're gonna start having NPE coming out your ears.

You are hiding the project variable:

PC has a protected variable with public getter+setter.
Your class has a private variable and a public setter.

That results that YourTask.setProject() will set the private member
and the inherited YourTask.getProject() will return the inherited
protected member - which never will be set ...


Jan

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message