I need to instantiate a function passed as a string, and i wrote a wrapper for a "Function" object that let me execute the function after it's defined.
The wrapper uses the JavaAssist library, using object and method as fields of the wrapper object and a method that let me use the function outside the wrapper class.
My troubles are about the function body syntax, i have a lot of
java.lang.VerifyError: (class: MyClass, method: myMethod signature: (*my signature, unimportant *) Expecting to find *a primitive type* on stack
related to casts on the fly, for example
Double c = (double) intVariable;
which I solved (not really good solution, but it is working) avoiding those casting and always instantiating variables of the defined type
Double c = new Double( (String) intVariable.toString() );
Now I have another problem, and it's driving me crazy: this is the content of the string
Double t2 = new Double ( (String) parametri.get("pigreco").toString() );
Double t3 = new Double ( (String) (new Integer(2)).toString() );";
Double mysum = t2;
mysum+= t3;
return my sum;
t2.getClass() and t3.getClass() return java.lang.Double but mysum is the concatenation of t2 and t3, not the arithmetic sum... how come is it possible?