Don't attempt to load camelCased version of the package name.

It's unlikely that a package would have a camelCased name and an attempt to load a class with wrong case is causing NoClassDefFoundError instead of ClassNotFoundException on non case-sensitive file systems.
This commit is contained in:
Igor Motov 2011-04-21 11:37:22 -04:00 committed by kimchy
parent db04649271
commit 4c295a28d5
1 changed files with 2 additions and 7 deletions

View File

@ -213,20 +213,15 @@ public class ImmutableSettings implements Settings {
try {
return (Class<? extends T>) getClassLoader().loadClass(fullClassName);
} catch (ClassNotFoundException e1) {
fullClassName = prefixPackage + toCamelCase(sValue) + "." + Strings.capitalize(toCamelCase(sValue)) + suffixClassName;
try {
return (Class<? extends T>) getClassLoader().loadClass(fullClassName);
} catch (ClassNotFoundException e2) {
fullClassName = prefixPackage + toCamelCase(sValue).toLowerCase() + "." + Strings.capitalize(toCamelCase(sValue)) + suffixClassName;
try {
return (Class<? extends T>) getClassLoader().loadClass(fullClassName);
} catch (ClassNotFoundException e3) {
} catch (ClassNotFoundException e2) {
throw new NoClassSettingsException("Failed to load class setting [" + setting + "] with value [" + sValue + "]", e);
}
}
}
}
}
@Override public String[] getAsArray(String settingPrefix) throws SettingsException {
return getAsArray(settingPrefix, Strings.EMPTY_ARRAY);