Having problems with a factory class, I pass in a human readable name that maps to a class that has a single constructor with a single argument, I get the following error:
java.lang.NoSuchMethodException: com.satgraf.evolution2.observers.VSIDSTemporalLocalityEvolutionObserver.<init>(com.satlib.evolution.ConcreteEvolutionGraph)
at java.lang.Class.getConstructor0(Class.java:2892)
at java.lang.Class.getConstructor(Class.java:1723)
at com.satlib.evolution.observers.EvolutionObserverFactory.getByName(EvolutionObserverFactory.java:84)
at com.satgraf.evolution2.UI.Evolution2GraphFrame.main(Evolution2GraphFrame.java:229)
These are the classes in question, I have about a dozen of these things in different projects, they all work without problem - including one that is almost identical, can't see why this one is failing:
public EvolutionObserver getByName(String name, EvolutionGraph graph){
if(classes.get(name) == null){
return null;
}
else{
try {
Constructor<? extends EvolutionObserver> con = classes.get(name).getConstructor(graph.getClass());
EvolutionObserver i = con.newInstance(graph);
observers.add(i);
return i;
}
catch (InvocationTargetException | InstantiationException | IllegalAccessException | NoSuchMethodException | IllegalArgumentException | SecurityException ex) {
Logger.getLogger(EvolutionObserverFactory.class.getName()).log(Level.SEVERE, null, ex);
return null;
}
}
}
The class being instantiated is:
public class VSIDSTemporalLocalityEvolutionObserver extends JPanel implements EvolutionObserver{
public VSIDSTemporalLocalityEvolutionObserver(EvolutionGraph graph){
...
}
...
}
The argument graph
is of type:
public class ConcreteEvolutionGraph extends ConcreteCommunityGraph implements EvolutionGraph{
...
}
Aucun commentaire:
Enregistrer un commentaire