tkobayas commented on code in PR #7216:
URL: https://github.com/apache/incubator-kie/pull/7216#discussion_r4374320834
##########
drools-compiler/src/main/java/org/drools/compiler/builder/impl/TypeDeclarationFactory.java:
##########
@@ -66,44 +65,26 @@ public TypeDeclaration processTypeDeclaration(
PackageRegistry pkgRegistry,
type = new TypeDeclaration( typeDescr.getTypeName() );
type.setResource( typeDescr.getResource() );
- // if is not new, search the already existing declaration and
- // compare them o see if they are at least compatibles
- // check whether it is necessary to build the class or not
Class<?> existingClass =
TypeDeclarationUtils.getExistingDeclarationClass( typeDescr, pkgRegistry );
type.setTypeClass( existingClass );
type.setNovel( existingClass == null );
type.setNature( existingClass == null ?
TypeDeclaration.Nature.DEFINITION : TypeDeclaration.Nature.DECLARATION );
-
- // Pre-populate from Java class annotations so that
finalizeConfigurator()
- // (which runs before wireFieldAccessors) sees the correct role,
expiration,
- // reactivity, and dynamic settings. DRL annotations applied next
will override.
- if ( existingClass != null ) {
- TypeDeclaration.processTypeAnnotations( type,
- new Annotated.ClassAdapter( existingClass ),
- context.getBuilderConfiguration().getOption(
PropertySpecificOption.KEY ) );
- }
}
- processTypeAnnotations(typeDescr, type);
- return type;
- }
-
- private void processTypeAnnotations( AbstractClassTypeDeclarationDescr
typeDescr, TypeDeclaration type ) {
try {
- processAnnotations( typeDescr, type );
+ processAnnotations( typeDescr, type,
context.getBuilderConfiguration().getOption( PropertySpecificOption.KEY ) );
} catch (Exception e) {
results.addBuilderResult(new TypeDeclarationError(typeDescr,
e.getMessage() ) );
}
+ return type;
}
- // Processes annotations from the DRL descriptor, overriding values
pre-populated from
- // Java class annotations in processTypeDeclaration(). Runs before
finalizeConfigurator(),
- // which needs @Role and @PropertyChangeSupport already set.
- public static void processAnnotations( AbstractClassTypeDeclarationDescr
typeDescr, TypeDeclaration type ) {
- Role role = getTypedAnnotation(typeDescr, Role.class);
- if (role != null) {
- type.setRole(role.value());
+ public static void processAnnotations( AbstractClassTypeDeclarationDescr
typeDescr, TypeDeclaration type, PropertySpecificOption propertySpecificOption
) {
+ Annotated annotated = toAnnotated(typeDescr);
+ if (type.getTypeClass() != null) {
+ annotated = Annotated.withFallback(annotated, new
Annotated.ClassAdapter(type.getTypeClass()));
}
+ TypeDeclaration.processTypeAnnotations( type, annotated,
propertySpecificOption );
TypeSafe typeSafe = getTypedAnnotation(typeDescr, TypeSafe.class);
if (typeSafe != null) {
Review Comment:
This is intentional. `@TypeSafe` is read-only from the DRL `@typesafe`,
never from the Java class, in both the classic and executable models (see the
note in `AlignAnnotationTest`).
I'll add a comment in processAnnotations() to make this explicit.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]