fixed NPE reported by Paul King, getPackage() might return null...

I can't believe it's so difficult to extract the package name of a class...
This commit is contained in:
Lars Kühne 2003-01-31 06:11:23 +00:00
parent d963b8bfc2
commit 635444ddb2
1 changed files with 4 additions and 2 deletions

View File

@ -56,8 +56,10 @@ public class PackageHtmlCheck extends AbstractFileSetCheck
dispatcher.fireFileStarted(path);
if (!packageHtml.exists()) {
LocalizedMessage[] errors = new LocalizedMessage[1];
final String bundle =
this.getClass().getPackage().getName() + ".messages";
final String className = getClass().getName();
final int pkgEndIndex = className.lastIndexOf('.');
final String pkgName = className.substring(0, pkgEndIndex);
final String bundle = pkgName + ".messages";
errors[0] = new LocalizedMessage(
0, bundle, "javadoc.packageHtml", null);
getMessageDispatcher().fireErrors(path, errors);