It seems so obvious. I send various types of objects through an object stream. When they get to the other side, they are read as Object obj = in.readObject() : type Object. I can easily get the name of the original class type via obj.getClass().getName()
Now what I want is a very simple way of casting back to the original class type so that I can use overloaded handlers - i.e. one handler for each type that this application may receive. I've tried all day, but still can't find anything that works. Here's one thing I've tried.
try {
process2Input(obj.getClass().cast(Class.forName(rtm.getClass().getName())));
} catch (ClassNotFoundException e) {
}
As with other things, it still thinks it's Object class rather than its original class, which is given by getName()
Now what I want is a very simple way of casting back to the original class type so that I can use overloaded handlers - i.e. one handler for each type that this application may receive. I've tried all day, but still can't find anything that works. Here's one thing I've tried.
try {
process2Input(obj.getClass().cast(Class.forName(rtm.getClass().getName())));
} catch (ClassNotFoundException e) {
}
As with other things, it still thinks it's Object class rather than its original class, which is given by getName()