Java examples for Reflection:Class
Is class assignable to another class
//package com.java2s; public class Main { public static boolean hasAccess(final String callerClass, Class... clazz) {/*from ww w .jav a 2s. c o m*/ final Class<?> caller = getClassByString(callerClass); if (caller == null) return false; for (final Class c : clazz) { if (c.isAssignableFrom(caller)) return true; } return false; } private static Class<?> getClassByString(final String className) { if (className == null) return null; try { return Class.forName(className); } catch (ClassNotFoundException e) { e.printStackTrace(); } return null; } }