public static boolean canAccess(@Nonnull TypeProto type, @Nonnull Method virtualMethod, boolean checkPackagePrivate, boolean checkProtected, boolean checkClass) { if (checkPackagePrivate && MethodUtil.isPackagePrivate(virtualMethod)) { String otherPackage = TypeUtils.getPackage(virtualMethod.getDefiningClass()); String thisPackage = TypeUtils.getPackage(type.getType()); if (!otherPackage.equals(thisPackage)) { return false; } } if (checkProtected && (virtualMethod.getAccessFlags() & AccessFlags.PROTECTED.getValue()) != 0) { if (!TypeProtoUtils.extendsFrom(type, virtualMethod.getDefiningClass())) { return false; } } if (checkClass) { ClassPath classPath = type.getClassPath(); ClassDef methodClassDef = classPath.getClassDef(virtualMethod.getDefiningClass()); if (!TypeUtils.canAccessClass(type.getType(), methodClassDef)) { return false; } } return true; } }
public static boolean canAccess(@Nonnull TypeProto type, @Nonnull Method virtualMethod, boolean checkPackagePrivate, boolean checkProtected, boolean checkClass) { if (checkPackagePrivate && MethodUtil.isPackagePrivate(virtualMethod)) { String otherPackage = TypeUtils.getPackage(virtualMethod.getDefiningClass()); String thisPackage = TypeUtils.getPackage(type.getType()); if (!otherPackage.equals(thisPackage)) { return false; } } if (checkProtected && (virtualMethod.getAccessFlags() & AccessFlags.PROTECTED.getValue()) != 0) { if (!TypeProtoUtils.extendsFrom(type, virtualMethod.getDefiningClass())) { return false; } } if (checkClass) { ClassPath classPath = type.getClassPath(); ClassDef methodClassDef = classPath.getClassDef(virtualMethod.getDefiningClass()); if (!TypeUtils.canAccessClass(type.getType(), methodClassDef)) { return false; } } return true; } }