// Make sure that the type being rebound is in fact an interface.
if (targetClass.isInterface() == null) {
throw error(logger, name + " must be an interface");
}
AbstractResource resource;
try {
resource = ResourceFactory.getBundle(targetClass, locale);
} catch (MissingResourceException e) {
throw error(
logger,
"Localization failed; there must be at least one properties file accessible through the classpath in package '"
+ packageName
+ "' whose base name is '"
+ ResourceFactory.getResourceName(targetClass) + "'");
} catch (IllegalArgumentException e) {
// A bad key can generate an illegal argument exception.
throw error(logger, e.getMessage());
}
// generated implementations for interface X will be named X_, X_en,
// X_en_CA, etc.
String realLocale = "_";
if (resource.getLocale() != null) {
realLocale += resource.getLocale();
}
// Use _ rather than "." in class name, cannot use $
String resourceName = targetClass.getName().replace('.', '_');
String className = resourceName + realLocale;
PrintWriter pw = context.tryCreate(logger, packageName, className);