Program: 150205
Project: 150205
Buggy source:
/** 
 * Common code shared by invokeWithJValue, invokeWithVarArg and invokeWithDotDotVarArg
 * @param obj the object instance 
 * @param methodID a VM_MemberReference id
 * @param argAddress a raw address for the argument array
 * @param expectReturnType the return type for checking purpose
 * @param skip4Args This flag is received from the JNI function and passed directly to VM_Reflection.invoke().   It is true if the actual method is to be invoked, which could be from the superclass. It is false if the method from the real class of the object  is to be invoked, which may not be the actual method specified by methodID
 * @param isVarArg  This flag describes whether the array of parameters is in var arg format orjvalue format
 * @return an object that may be the return object or a wrapper for the primitive return value 
 */
public static Object packageAndInvoke(Object obj,int methodID,VM_Address argAddress,VM_TypeReference expectReturnType,boolean skip4Args,int argtype) throws Exception {
  VM_Method targetMethod=VM_MemberReference.getMemberRef(methodID).asMethodReference().resolve();
  VM_TypeReference returnType=targetMethod.getReturnType();
  if (expectReturnType == null) {
    if (!returnType.isReferenceType())     throw new Exception("String_Node_Str" + returnType);
  }
 else {
    if (returnType != expectReturnType)     throw new Exception("String_Node_Str" + expectReturnType + "String_Node_Str"+ returnType);
  }
  Object[] argObjectArray;
switch (argtype) {
case SVR4_DOTARG:
    argObjectArray=packageParameterFromDotArgSVR4(targetMethod,argAddress,skip4Args);
  break;
case JVALUE_ARG:
argObjectArray=packageParameterFromJValue(targetMethod,argAddress);
break;
case SVR4_VARARG:
argObjectArray=packageParameterFromVarArgSVR4(targetMethod,argAddress);
break;
case SVR4_VARARG:
argObjectArray=packageParameterFromVarArg(targetMethod,argAddress);
break;
case AIX_VARARG:
argObjectArray=packageParameterFromVarArg(targetMethod,argAddress);
break;
default :
argObjectArray=null;
if (VM.VerifyAssertions) VM._assert(VM.NOT_REACHED);
}
Object returnObj=VM_Reflection.invoke(targetMethod,obj,argObjectArray,skip4Args);
return returnObj;
}

Fixed version (ground truth):
/** 
 * Common code shared by invokeWithJValue, invokeWithVarArg and invokeWithDotDotVarArg
 * @param obj the object instance 
 * @param methodID a VM_MemberReference id
 * @param argAddress a raw address for the argument array
 * @param expectReturnType the return type for checking purpose
 * @param skip4Args This flag is received from the JNI function and passed directly to VM_Reflection.invoke().   It is true if the actual method is to be invoked, which could be from the superclass. It is false if the method from the real class of the object  is to be invoked, which may not be the actual method specified by methodID
 * @param isVarArg  This flag describes whether the array of parameters is in var arg format orjvalue format
 * @return an object that may be the return object or a wrapper for the primitive return value 
 */
public static Object packageAndInvoke(Object obj,int methodID,VM_Address argAddress,VM_TypeReference expectReturnType,boolean skip4Args,int argtype) throws Exception {
  VM_Method targetMethod=VM_MemberReference.getMemberRef(methodID).asMethodReference().resolve();
  VM_TypeReference returnType=targetMethod.getReturnType();
  if (expectReturnType == null) {
    if (!returnType.isReferenceType())     throw new Exception("String_Node_Str" + returnType);
  }
 else {
    if (returnType != expectReturnType)     throw new Exception("String_Node_Str" + expectReturnType + "String_Node_Str"+ returnType);
  }
  Object[] argObjectArray;
switch (argtype) {
case SVR4_DOTARG:
    argObjectArray=packageParameterFromDotArgSVR4(targetMethod,argAddress,skip4Args);
  break;
case JVALUE_ARG:
argObjectArray=packageParameterFromJValue(targetMethod,argAddress);
break;
case SVR4_VARARG:
argObjectArray=packageParameterFromVarArgSVR4(targetMethod,argAddress);
break;
case SVR4_DOTARG:
case SVR4_VARARG:
argObjectArray=packageParameterFromVarArg(targetMethod,argAddress);
break;
case OSX_DOTARG:
argObjectArray=packageParameterFromVarArg(targetMethod,argAddress);
break;
case AIX_VARARG:
argObjectArray=packageParameterFromVarArg(targetMethod,argAddress);
break;
default :
argObjectArray=null;
if (VM.VerifyAssertions) VM._assert(VM.NOT_REACHED);
}
Object returnObj=VM_Reflection.invoke(targetMethod,obj,argObjectArray,skip4Args);
return returnObj;
}