-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[incubator-kie-drools] ArithmeticException: Non-terminating decimal e… #6250
[incubator-kie-drools] ArithmeticException: Non-terminating decimal e… #6250
Conversation
…xpansion with non-executable model after jitting
GHA kogito-runtimes : Not related to this PR
|
In jitting, Note: Mvel (= before jitting) and executable-model use |
@@ -873,16 +875,20 @@ private void jitAritmeticOperation(Class<?> operationType, AritmeticOperator ope | |||
try { | |||
switch (operator) { | |||
case ADD: | |||
invoke(operationType.getMethod("add", operationType)); | |||
addMathContext(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @tkobayas , thanks for the PR.
IIUC:
- the
addMathContext()
method has some kind of hidden side effect - the
invoke(operationType.getMethod("subtract", operationType, MathContext.class));
need that side effect, to work. - this has to be replicated/duplicated for all the arithmetic operations
Would not be better to create a specific invoke
method, to be called for arithmetic operations, that
- execute
mv.visitFieldInsn(GETSTATIC, "java/math/MathContext", "DECIMAL128", "Ljava/math/MathContext;");
- execute
invoke(operationType.getMethod("multiply", operationType, MathContext.class));
(with name of operation received from parameter:)
e.g. (inside ClassGenerator)
protected final void invokeArithmeticaOperation(Class<?> operationType, String operation) throws NoSuchMethodException {
mv.visitFieldInsn(GETSTATIC, "java/math/MathContext", "DECIMAL128", "Ljava/math/MathContext;");
invoke(operationType.getMethod("operation", operationType, MathContext.class));
}
What do you think ? Does this make sense ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gitgabrio Thank you for the suggestion! Yes, it's better. I have refactored accordingly.
I also noticed that BigInteger needs to be handled differently. Updated with test cases.
- Add test for BigInteger
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx @tkobayas !
apache#6250) * [incubator-kie-drools] ArithmeticException: Non-terminating decimal expansion with non-executable model after jitting * - Refactor for invokeBigDecimalArithmeticOperation - Add test for BigInteger
…xpansion with non-executable model after jitting
Issue: