Skip to content

Commit

Permalink
use Java 8 compatible way to get package name of class
Browse files Browse the repository at this point in the history
  • Loading branch information
jpstotz committed Jan 27, 2024
1 parent e3d0e4e commit d6f07d1
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ public class EcdResouceBundle {
public EcdResouceBundle(Class<?> messagesClass) {
ClassLoader classLoader = messagesClass.getClassLoader();
Locale targetLocale = Locale.getDefault();
String resourceBundleName = messagesClass.getPackageName() + ".messages";
// Java 8 workaround for messagesClass.getpackageName()
String messageClassName = messagesClass.getName();
String packageName = messageClassName.substring(0, messageClassName.lastIndexOf("."));
String resourceBundleName = packageName + ".messages";
this.resourceBundle = ResourceBundle.getBundle(resourceBundleName, targetLocale, classLoader);
}

Expand Down

0 comments on commit d6f07d1

Please sign in to comment.