I am using JDT Core for a project and a problem is getting in the way.
The project is about collect some information from source code. A part of that requires that I resolve constant values and the API provides that. It works well for primitive values, but doesn't for wrappers.
For example, give following code using JDT:
node.resolveConstantExpressionValue();
It works very well with this code:
private static final int MY_CONST = 123;
But doesn't work with follow:
private static final Integer MY_CONST = 123;
I debugged for while and I found the logic that converts the value if it is an int (primitive) in following line:
https://github.com/eclipse/eclipse.jdt.core/blob/d6fdfb48c98dc3f94509f41f07432086fff67206/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/Constant.java#L197
So my questions are:
- The Integer wrapper (or others) wouldn't have the same behavior and converts the value as well as done with primitives?
- Is there some other concept that I miss and explain this behavior?
- Is there some change that I could made to solve it?
Thank you!
[Updated on: Fri, 24 July 2020 10:53] by Moderator