diff --git a/pmd-java/src/main/resources/category/java/codestyle.xml b/pmd-java/src/main/resources/category/java/codestyle.xml
index 8421462853..9643356624 100644
--- a/pmd-java/src/main/resources/category/java/codestyle.xml
+++ b/pmd-java/src/main/resources/category/java/codestyle.xml
@@ -1359,8 +1359,9 @@ Detects when a class or interface does not have a package definition.
3
- //ClassOrInterfaceDeclaration[count(preceding::PackageDeclaration) = 0]
+ /CompilationUnit[not(./PackageDeclaration)]/TypeDeclaration[1]
+