You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by "tkobayas (via GitHub)" <gi...@apache.org> on 2026/10/13 03:05:37 UTC
[I] Align Java annotation and DRL declaration metadata precedence between classic and executable models [incubator-kie]
tkobayas opened a new issue, #7185:
URL: https://github.com/apache/incubator-kie/issues/7185
# Description
## Summary
An empty DRL `declare` block for an existing Java class resets its Java annotation settings in the classic compiler, while the executable model retains them. Without the declaration, both models honor those settings.
Investigated during [PR #7176](https://github.com/apache/incubator-kie/pull/7176), this issue tracks the broader precedence policy separately from that PR's dynamic fact listener fixes.
## Observed behavior
| Java class setting | Classic compiler with an empty DRL declaration | Executable model with an empty DRL declaration |
|---|---|---|
| `@Role(EVENT)` | Reverts to `FACT` | Retains `EVENT` |
| `@Expires("10s")` | No explicit expiration offset | Retains 10 seconds |
| `@Timestamp("start")` | No timestamp attribute configured | Retains `start` |
| `@Duration("length")` | No duration attribute configured | Retains `length` |
| `@PropertyChangeSupport` | Disabled | Remains enabled |
| `@ClassReactive` [1] | Reverts to property reactive | Remains class reactive |
| `@PropertyReactive` [2] | Disabled | Remains enabled |
[1] `PropertySpecificOption.ALWAYS` (default). [2] `PropertySpecificOption.ALLOWED`.
An unrelated DRL annotation such as `@typesafe(true)` produces the same differences. The expiration row describes explicit metadata; expiration can also be inferred from rule constraints.
Tested on commit `b70bdb8527523b9a1046545ec457e38fd753c2a9` from PR #7176, using OpenJDK 21 and Maven 3.9.16, before [Toni's proposed fix](https://github.com/Thebas/incubator-kie/pull/1). These results were not reproduced against published 7.74.1.Final artifacts.
## Reproduction
Use this existing Java class:
```java
package org.example;
import org.kie.api.definition.type.*;
@Role(Role.Type.EVENT)
@Expires("10s")
@Timestamp("start")
@Duration("length")
@ClassReactive
public class EventFact {
public long getStart() { return 0L; }
public long getLength() { return 0L; }
}
```
Build this DRL using `KieHelper.build()` and `KieHelper.build(ExecutableModelProject.class)`:
```drl
import org.example.EventFact;
declare EventFact
end
rule "Match event"
when
EventFact()
then
end
```
Inspect `((InternalKnowledgeBase) base).getTypeDeclaration(EventFact.class)`:
```text
classic: role=FACT expires=-1 timestamp=null duration=null propertyReactive=true
executable: role=EVENT expires=10000 timestamp=start duration=length propertyReactive=false
```
Remove the declaration: both models produce the executable-model values above. For a JavaBeans-compatible fact with `@PropertyChangeSupport`, the empty declaration also prevents listener registration and setter-triggered reevaluation in classic, while executable retains them.
## Proposed behavior and scope
Preserve Java settings when the corresponding DRL annotation is omitted, and give explicit DRL settings documented precedence. Distinguish omission from an explicit reset or disable operation where supported. This is a proposed policy requiring agreement and compatibility assessment.
Classic processes the DRL declaration without first importing Java annotations; executable runtime metadata reads Java annotations before applying model metadata. Toni's fix addresses `@PropertyChangeSupport` and can also preserve `@Expires`; recheck those rows after integration. PR #7176 should proceed with its focused fix and regression test independently of the remaining differences.
Acceptance criteria:
- Agree on and document precedence, explicit overrides, and compatibility exceptions.
- Test both models with no declaration, an empty declaration, unrelated metadata, and explicit overrides for the annotations above.
- Align remaining differences and verify relevant runtime behavior.
The Drools 10.2.x [Rule Language Reference](https://kie.apache.org/docs/10.2.x/drools/drools/language-reference/index.html) describes adding metadata to existing types and using an empty declaration before extending a Java type. The [rule engine guide](https://kie.apache.org/docs/10.2.x/drools/drools/rule-engine/index.html) documents property-change settings in Java or DRL. These sections do not specify whether omitted DRL annotations preserve or clear Java metadata.
--
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: commits-unsubscribe@kie.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [I] Align Java annotation and DRL declaration metadata precedence between classic and executable models [incubator-kie]
Posted by "tkobayas (via GitHub)" <gi...@apache.org>.
tkobayas closed issue #7185: Align Java annotation and DRL declaration metadata precedence between classic and executable models
URL: https://github.com/apache/incubator-kie/issues/7185
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [I] Align Java annotation and DRL declaration metadata precedence between classic and executable models [incubator-kie]
Posted by "tkobayas (via GitHub)" <gi...@apache.org>.
tkobayas commented on issue #7185:
URL: https://github.com/apache/incubator-kie/issues/7185#issuecomment-6435692655
Fixed by https://github.com/apache/incubator-kie/pull/7186
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [I] Align Java annotation and DRL declaration metadata precedence between classic and executable models [incubator-kie]
Posted by "tkobayas (via GitHub)" <gi...@apache.org>.
tkobayas commented on issue #7185:
URL: https://github.com/apache/incubator-kie/issues/7185#issuecomment-6435689286
Docs issue : https://github.com/apache/incubator-kie/issues/7212
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org