A
andrewzzz
Hi guys,
I have a class("myplatform") which extends another("platform"). From a
main class I instanciate "myagent" but when I try to use any of the
methods inside Platform (the superclass of the class I just
instanciated) , I get a nullpointer error.
I checked the code many times and if I call the method directly from
the superclass it works correctly, (but I shouldn't do that really).
Somebody know why?
Here is simplified code of "platform" :
-----------------------------------------------------------------------------------------------------------------------------------------
package agentsLibrary;
public class Platform {
private String listaserver;
private static PathEl[] vettoreservers=null;
public Platform(String listaserver){
this.listaserver=listaserver;
//vettoreservers is then retrieved from an xml, I checked and is
correct!
}
synchronized public static PathEl[] getRemainingServers(){
return vettoreservers;
}
//...and other get methods like that...
}
-------------------------------------------------------------------------------------------------------------------------------------------
and code of MyPlatform (the subclass)
package test;
import agentsLibrary.Platform;
public class MyPlatform extends Platform{
private HashMap prodmap=null;
private ProductType pt=null;
private String nomefile;
public MyPlatform(String listaserver) {
super(listaserver);
this.prodmap=new HashMap();
nomefile="prodotti.xml";
}
public synchronized void loadInfo() {
//loads some info
}
synchronized public HashMap getProductsMap(){
return prodmap;
}
}
----------------------------------------------------------------
A main class creates an instance of myplatform , then tries to call
"synchronized public static PathEl[] getRemainingServers()" (PathEl[]
dpath=platf.getRemainingServers() from the superclass "Platform",
but get nullpointer!!
(note that if I check the content in platform and myplatform is correct
and not null!!!)
Thanks a lot javaboys!
I have a class("myplatform") which extends another("platform"). From a
main class I instanciate "myagent" but when I try to use any of the
methods inside Platform (the superclass of the class I just
instanciated) , I get a nullpointer error.
I checked the code many times and if I call the method directly from
the superclass it works correctly, (but I shouldn't do that really).
Somebody know why?
Here is simplified code of "platform" :
-----------------------------------------------------------------------------------------------------------------------------------------
package agentsLibrary;
public class Platform {
private String listaserver;
private static PathEl[] vettoreservers=null;
public Platform(String listaserver){
this.listaserver=listaserver;
//vettoreservers is then retrieved from an xml, I checked and is
correct!
}
synchronized public static PathEl[] getRemainingServers(){
return vettoreservers;
}
//...and other get methods like that...
}
-------------------------------------------------------------------------------------------------------------------------------------------
and code of MyPlatform (the subclass)
package test;
import agentsLibrary.Platform;
public class MyPlatform extends Platform{
private HashMap prodmap=null;
private ProductType pt=null;
private String nomefile;
public MyPlatform(String listaserver) {
super(listaserver);
this.prodmap=new HashMap();
nomefile="prodotti.xml";
}
public synchronized void loadInfo() {
//loads some info
}
synchronized public HashMap getProductsMap(){
return prodmap;
}
}
----------------------------------------------------------------
A main class creates an instance of myplatform , then tries to call
"synchronized public static PathEl[] getRemainingServers()" (PathEl[]
dpath=platf.getRemainingServers() from the superclass "Platform",
but get nullpointer!!
(note that if I check the content in platform and myplatform is correct
and not null!!!)
Thanks a lot javaboys!