-
Type:
Enhancement
-
Resolution: Unresolved
-
Priority:
P4
-
None
-
Affects Version/s: repo-babylon
-
Component/s: core-libs
The Java Language Specification declares what constitutes a constant expression (such expressions may be used in case labels of switch expressions).
We could add a static method to JavaExpression that accepts a Java operation and returns an Optional<Object> for the result of evaluation. An empty optional is returned of the operation does not model a constant expression.
This method can then be used when lowering switch expressions for bytecode generation, rather than currently use similar functionality that is internal. Further, that internal functional currently uses the Java code model interpreter. We should remove dependence on that and use a specific interpreter that only supports constant expressions.
We could add a static method to JavaExpression that accepts a Java operation and returns an Optional<Object> for the result of evaluation. An empty optional is returned of the operation does not model a constant expression.
This method can then be used when lowering switch expressions for bytecode generation, rather than currently use similar functionality that is internal. Further, that internal functional currently uses the Java code model interpreter. We should remove dependence on that and use a specific interpreter that only supports constant expressions.
- links to