if(!xClass.canCastTo(to))
throw new XRuntimeException("Can't cast %s to %s", xClass, to);
}
public static void checkAccess(XClass xClass, XField field) {
XClass xClass2 = field.getDeclaringClass();
if(xClass.getVirtualMachine()!=xClass2.getVirtualMachine()){
throw new XRuntimeException("%s has a diferent VM than %s", xClass, xClass2);
}
int modifier = xClass2.getModifier();
int fModifier = field.getModifier();
XClass checkClass1 = xClass;
while(checkClass1.getOuterClass()!=null){
checkClass1 = checkClass1.getOuterClass();
}
XClass checkClass2 = xClass2;
while(checkClass2.getOuterClass()!=null){
checkClass2 = checkClass2.getOuterClass();
}
boolean sameOuterClass = checkClass1==checkClass2;
if(XModifier.isPrivate(modifier) || XModifier.isPrivate(fModifier)){
if(!sameOuterClass){
throw new XRuntimeException("%s can't access %s", xClass, field);