eatmoreduck opened a new pull request, #7270:
URL: https://github.com/apache/incubator-kie/pull/7270

   **Thank you for submitting this pull request**
   
   **NOTE!:** Target branch is `main`.
   
   **Issue**:
   
   * 
[apache/incubator-kie#7252](https://github.com/apache/incubator-kie/issues/7252)
   
   **Referenced Pull Requests**: _(none)_
   
   ---
   
   ## What
   
   A `declare` block redeclaring an existing Java class silently ignored the 
**capitalized (Java-name) spelling** of the built-in type annotations in the 
executable model: with a class carrying `@Role(Role.Type.EVENT)` / 
`@Expires("10s")` and a DRL `declare MyEvent @Role(FACT) @Expires(5s) end`, the 
executable model kept `EVENT`/`10000` (the Java class values) while the classic 
compiler honored the DRL override. Measured on `STANDARD_FROM_DRL` and 
`PATTERN_DSL`; lowercase `@role`/`@expires` work in both.
   
   ## Root cause
   
   The generated model registers type annotations under the name as written in 
the DRL (`POJOGenerator.processTypeMetadata` → `addAnnotation(ann.getName())`), 
and `TypeDeclarationUtil.wireMetaTypeAnnotations` matches that key against a 
lowercase-only switch: `"Role"` matches no case and fails the 
`KNOWN_ANNOTATIONS` check, so `@Role(FACT)` is classified as a *custom* 
annotation and lands in the `ClassDefinition` raw metadata instead of 
configuring the `TypeDeclaration` — with no error and no warning.
   
   ## Fix
   
   `wireMetaTypeAnnotations` canonicalizes the key before matching:
   
   - An **unqualified** name maps to its built-in case-insensitively: `Role` → 
`role`, `PropertyReactive` → `propertyReactive`.
   - A **qualified** name maps only when it is a built-in's own FQN 
(`org.kie.api.definition.type.Role` → `role`); any other qualified annotation 
keeps its name and still lands in custom metadata, unchanged.
   - Custom annotations keep their original spelling in `ClassDefinition` 
metadata (the raw key is preserved for that path).
   
   ## Tests
   
   `AlignAnnotationTest` (the executable-model/classic alignment suite from 
#7185) gains capitalized `@Role(FACT)` / `@Expires(5s)` override cases — **red 
on `main`** for the executable-model run types, green after the fix. Verified 
locally:
   
   ```
   mvn -pl drools-model/drools-model-codegen -am test 
-Dtest='AlignAnnotationTest'
   → Tests run: 36, Failures: 0
   mvn -pl drools-model/drools-model-compiler -am test
   → BUILD SUCCESS (102 tests in the touched module, upstream modules green)
   ```
   
   <details>
   <summary>How to replicate the CI locally</summary>
   
   `mvn -pl drools-model/drools-model-codegen -am test 
-Dtest='AlignAnnotationTest' -Dsurefire.failIfNoSpecifiedTests=false`
   </details>
   


-- 
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]

Reply via email to