I have a situation similar to the following:
// In some library code
public class A
{
private class B
{
Object value;
}
}
// In my code
Object o;
// o is initialized to an instance of B somehow
// ...
B bInstance = (B) o;
How would I go about casting an Object to type B given that the type of B is inaccessible?
To explain in more detail, A is not part of my code base. It's part of a library. I have access to an object that I know is of type B, but I can't cast it (in an IDE, for example) because the type information is not visible. It's a compilation error. The situation is very restrictive. I think it might be possible to achieve this using reflection, but I'm afraid I don't have a lot of experience using that particular paradigm. Is there any way around this? I appreciate any input the community would offer.