Method m = OgnlRuntime.getWriteMethod(context.getCurrentType() != null ?
context.getCurrentType() : target.getClass(),
_methodName, _children != null ? _children.length : -1);
if (m == null)
{
throw new UnsupportedCompilationException("Unable to determine setter method generation for " + _methodName);
}
String post = "";
String result = "." + m.getName() + "(";
if (m.getReturnType() != void.class && m.getReturnType().isPrimitive()
&& (_parent == null || !ASTTest.class.isInstance(_parent)))
{
Class wrapper = OgnlRuntime.getPrimitiveWrapperClass(m.getReturnType());
ExpressionCompiler.addCastString(context, "new " + wrapper.getName() + "(");
post = ")";
_getterClass = wrapper;
}
boolean varArgs = OgnlRuntime.isJdk15() && m.isVarArgs();
if (varArgs)
{
throw new UnsupportedCompilationException("Javassist does not currently support varargs method calls");
}
try {
/* if (lastChild(context) && m.getParameterTypes().length > 0 && _children.length <= 0)
throw new UnsupportedCompilationException("Unable to determine setter method generation for " + m); */
if ((_children != null) && (_children.length > 0))
{
Class[] parms = m.getParameterTypes();
String prevCast = (String)context.remove(ExpressionCompiler.PRE_CAST);
for(int i = 0; i < _children.length; i++)
{
if (i > 0)
{
result += ", ";
}
Class prevType = context.getCurrentType();
context.setCurrentObject(context.getRoot());
context.setCurrentType(context.getRoot() != null ? context.getRoot().getClass() : null);
context.setCurrentAccessor(null);
context.setPreviousType(null);
Object value = _children[i].getValue(context, context.getRoot());
String parmString = _children[i].toSetSourceString(context, context.getRoot());
if (context.getCurrentType() == Void.TYPE || context.getCurrentType() == void.class)
throw new UnsupportedCompilationException("Method argument can't be a void type.");
if (parmString == null || parmString.trim().length() < 1)
{
if (ASTProperty.class.isInstance(_children[i]) || ASTMethod.class.isInstance(_children[i])
|| ASTStaticMethod.class.isInstance(_children[i]) || ASTChain.class.isInstance(_children[i]))
throw new UnsupportedCompilationException("ASTMethod setter child returned null from a sub property expression.");
parmString = "null";
}
// to undo type setting of constants when used as method parameters