private static void scanForFinalModifiers(Class<?> clazz) throws FinalModifierException
{
LOGGER.debug(Constants.LOG_ENTRY, "scanForFinalModifiers", new Object[] { clazz });
if (isFinal(clazz.getModifiers())) {
throw new FinalModifierException(clazz);
}
List<String> finalMethods = new ArrayList<String>();
// we don't want to check for final methods on java.* or javax.* Class
// also, clazz can never be null here (we will always hit
// java.lang.Object first)
while (!clazz.getName().startsWith("java.") && !clazz.getName().startsWith("javax.")) {
for (Method m : clazz.getDeclaredMethods()) {
//Static finals are ok, because we won't be overriding them :)
if (isFinal(m.getModifiers()) && !Modifier.isStatic(m.getModifiers())) {
finalMethods.add(m.toGenericString());
}
}
clazz = clazz.getSuperclass();
}
if (!finalMethods.isEmpty()) {
String methodList = finalMethods.toString();
methodList = methodList.substring(1, methodList.length() - 1);
throw new FinalModifierException(clazz, methodList);
}
LOGGER.debug(Constants.LOG_EXIT, "scanForFinalModifiers");
}