So i'm having an issue with the following design pattern I was hoping to get some help on. I keep getting a ClassNotFoundException on my interfaceFactory when I know that it is linked. The InterfaceFactory has been used by a python program in the sense shown below. I tried to implement it in java without much luck. its the java lines near the end that are giving me so much trouble. Any thoughts as to what might be going on?
Public class InterfaceFactory
{
public static Class<? extends Y> classR; //must be initialized in setup
public static Y newY(){ … }
}
In python, the statements
InterfaceFactory.classR = classT #classT not a constructor just the classname
classT.CONSTANT1 =….
classT.CONSTANT2=….
Where classT extends Y as it should. It isn’t a constructor or anything. Just the name of the class. I’m trying to use the 1 line of python code above in java. The implementation I tried was:
InterfaceFactory interfaceFactory = new InterfaceFactory(); //line1
interfaceFactory.classR = classT.class; //line2
classT.CONSTANT1=something;
it throws a ClassNotFoundException on line1.
Aucun commentaire:
Enregistrer un commentaire