HHH-18505 fix npe occurring while processing module descriptor

Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
Gavin King 2024-08-20 13:08:37 +02:00
parent 46bb5011b5
commit 656f592895
1 changed files with 6 additions and 1 deletions

View File

@ -367,7 +367,7 @@ public class HibernateProcessor extends AbstractProcessor {
try { try {
if ( !included( element ) if ( !included( element )
|| hasAnnotation( element, Constants.EXCLUDE ) || hasAnnotation( element, Constants.EXCLUDE )
|| hasAnnotation( context.getElementUtils().getPackageOf(element), Constants.EXCLUDE ) ) { || hasPackageAnnotation( element, Constants.EXCLUDE ) ) {
// skip it completely // skip it completely
} }
else if ( isEntityOrEmbeddable( element ) ) { else if ( isEntityOrEmbeddable( element ) ) {
@ -420,6 +420,11 @@ public class HibernateProcessor extends AbstractProcessor {
} }
} }
private boolean hasPackageAnnotation(Element element, String annotation) {
final PackageElement pack = context.getElementUtils().getPackageOf( element ); // null for module descriptor
return pack != null && hasAnnotation( pack, annotation );
}
private void createMetaModelClasses() { private void createMetaModelClasses() {
for ( Metamodel aux : context.getMetaAuxiliaries() ) { for ( Metamodel aux : context.getMetaAuxiliaries() ) {