MVEL2在Android抛出异常 [英] MVEL2 on android throws exception
问题描述
有没有任何人有MVEL2经验,在Android上?
Did anyone has experience with MVEL2 on android?
我已经尝试了同样的code用一个简单的java程序,稍后机器人:
i've tried out the same code with a simple java program and later on android:
在Android上执行以下抛出异常:
The following exception is thrown when executed on android:
E/AndroidRuntime(30793): java.lang.ExceptionInInitializerError
我试图从MVEL网站的例子:
I tried the example from the mvel website:
String template = "Hello, my name is @{name.toUpperCase()}";
Map vars = new HashMap();
vars.put("name", "Michael");
System.out.println(TemplateRuntime.eval(template, vars));
如果世界上没有其他解决方案,任何人都可以提出一个模板引擎,采用Android工程 并支持迭代?
If theres no solution could anyone suggest a template engine which works with android and supports iteration?
推荐答案
MVEL2试图串系统java.version属性初始化解析器时,前3个字符,和Android下的版本为0。这会导致一堆异常最终导致的ExceptionInInitializerError。
MVEL2 tries to substring the first 3 characters of the system java.version property when initializing the parser, and under Android the version is 0. That causes a bunch of exceptions which eventually cause the ExceptionInInitializerError.
如果您想强制java.version属性,你可以简单地自行设置:
If you want to force the java.version property, you can simply set it yourself:
System.setProperty("java.version", "1.6");
我不知道是什么样的奇怪的副作用,这可能会导致为Android,但至少它得到了MVEL解析器和运行而没有抛出异常!
I have no idea what kind of odd side effects this may cause for Android, but at least it gets the MVEL parser up and running without throwing exceptions!
这篇关于MVEL2在Android抛出异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!