You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
version: 2.4.4.Final
Not quite sure if the issue already been fixed or not in the later versions, haven't try yet
ERROR Error: incomplete statement: (possible use of reserved keyword as identifier)
The code that can reproduce the issue
public class Test {
private static String LEVEL1 = "level1Key";
private static String LEVEL2 = "level2Key";
private static String NON_ASCII = "[^\\x00-\\x7F]";
public static void main(String[] args) {
String expression = "'value : ' + (level1Key.level2Key)";
Map<String, Object> context = new HashMap<>();
Map<String, Object> secondLayerMap = new HashMap<>();
List<Object> list = new ArrayList<>();
list.add("content1");
list.add("content2");
secondLayerMap.put(LEVEL2, list);
context.put(LEVEL1, secondLayerMap);
// I believe there's still some other pre-handling that can be applied
// but in my project, exclude those non-ASCII is already enough
// expression = expression.replaceAll(NON_ASCII, " ");
Object result = null;
try {
result = MVEL.eval(expression, context);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(result);
}
}
When I debug the issue, I found the NBSP charater is the root cause. The ASCII code of NBSP is 160. Within the implementation of MVEL, the NBSP won't be recognized as a whitespace character(so here an alternative way is to enhance the method about determine whether one character is whitespace or not), and lead to the cursor not moved correctly. Further it will lead to the issue. And finally the NPE throw out seems doesn't make sense as well as the error message: possible use of reserved keyword as identifier
Of course, I can use replaceAll to solve this issue, and currently it can fulfill my requirements, but it can be great if we can have a "fix" for this, maybe add some more generic pre-handling to avoid the similar issues. For example, do some replacement for those non-printable Unicode and control charaters....
The text was updated successfully, but these errors were encountered:
version: 2.4.4.Final
Not quite sure if the issue already been fixed or not in the later versions, haven't try yet
ERROR
Error: incomplete statement: (possible use of reserved keyword as identifier)
The code that can reproduce the issue
When I debug the issue, I found the NBSP charater is the root cause. The ASCII code of NBSP is 160. Within the implementation of MVEL, the NBSP won't be recognized as a whitespace character(so here an alternative way is to enhance the method about determine whether one character is whitespace or not), and lead to the cursor not moved correctly. Further it will lead to the issue. And finally the NPE throw out seems doesn't make sense as well as the error message: possible use of reserved keyword as identifier
Of course, I can use replaceAll to solve this issue, and currently it can fulfill my requirements, but it can be great if we can have a "fix" for this, maybe add some more generic pre-handling to avoid the similar issues. For example, do some replacement for those non-printable Unicode and control charaters....
The text was updated successfully, but these errors were encountered: