tkobayas commented on PR #7270:
URL: https://github.com/apache/incubator-kie/pull/7270#issuecomment-6680843139

   @eatmoreduck Thank you for the PR!
   
   I agree with Copilot's point. The generated model carries only the 
annotation name as written in the DRL, so at runtime `TypeDeclarationUtil` has 
no way to tell whether `ClassReactive` means 
`org.kie.api.definition.type.ClassReactive` or an imported 
`com.acme.ClassReactive`. Matching case-insensitively at runtime therefore 
misclassifies a custom annotation whose simple name collides with a built-in. 
Before this PR, such an annotation was (correctly) kept as custom metadata.
   
   The resolved identity is already available at codegen time: 
`DeclaredTypeRegistrationPhase` runs `AnnotationNormalizer` before 
`POJOGenerator`, so `AnnotationDescr.getFullyQualifiedName()` is populated. I'd 
suggest:
   
   - In `POJOGenerator.processTypeMetadata()`, when the resolved FQN is a 
built-in (`org.kie.api.definition.type.Role`, `Expires`, ...), emit its 
canonical name (`role`, `expires`, ...). Otherwise keep emitting 
`ann.getName()` as today, so custom metadata keys don't change.
   - Drop the case-insensitive mapping in 
`TypeDeclarationUtil.canonicalAnnotationName()`.
   - Add a regression test with an imported custom annotation whose simple name 
collides with a built-in (e.g. `ClassReactive`), checking that property 
reactivity is unchanged and the custom metadata is kept.
   
   The trade-off is that kjars built before the fix keep the current behavior 
until they are rebuilt. Since the capitalized annotations are already ignored 
there today, that is not a regression.


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