Program: 150275
Project: 150275
Buggy source:
/** 
 * Repackage the arguments passed as an array of jvalue into an array of Object, used by the JNI functions CallStatic<type>MethodA
 * @param mth the target VM_Method
 * @param argAddress an address into the C space for the array of jvalue unions;  each element is 2-word and holds the argument of the appropriate type
 * @return an Object array holding the arguments wrapped at Objects
 */
static Object[] packageParameterFromJValue(VM_Method targetMethod,VM_Address argAddress){
  VM_TypeReference[] argTypes=targetMethod.getParameterTypes();
  int argCount=argTypes.length;
  Object[] argObjectArray=new Object[argCount];
  VM_JNIEnvironment env=VM_Thread.getCurrentThread().getJNIEnv();
  for (int i=0; i < argCount; i++) {
    VM_Address addr=argAddress.add(BYTES_IN_DOUBLE * i);
    VM_Word hiword=VM_Magic.getMemoryWord(addr);
    VM_Word loword;
    if (VM.BuildFor32Addr) {
      loword=VM_Magic.getMemoryWord(addr.add(BYTES_IN_ADDRESS));
    }
    if (argTypes[i].isFloatType()) {
      if (VM.BuildFor32Addr) {
        argObjectArray[i]=VM_Reflection.wrapFloat(Float.intBitsToFloat(hiword.toInt()));
      }
 else {
        VM._assert(false);
      }
    }
 else     if (argTypes[i].isDoubleType()) {
      if (VM.BuildFor32Addr) {
        long doubleBits=(((long)hiword.toInt()) << BITS_IN_INT) | (loword.toInt() & 0xFFFFFFFFL);
        argObjectArray[i]=VM_Reflection.wrapDouble(Double.longBitsToDouble(doubleBits));
      }
 else {
        argObjectArray[i]=VM_Reflection.wrapDouble(Double.longBitsToDouble(hiword.toLong()));
      }
    }
 else     if (argTypes[i].isLongType()) {
      if (VM.BuildFor32Addr) {
        long longValue=(((long)hiword.toInt()) << BITS_IN_INT) | (loword.toInt() & 0xFFFFFFFFL);
        argObjectArray[i]=VM_Reflection.wrapLong(longValue);
      }
 else {
        argObjectArray[i]=VM_Reflection.wrapLong(hiword.toLong());
      }
    }
 else     if (argTypes[i].isBooleanType()) {
      if (VM.BuildFor32Addr) {
        argObjectArray[i]=VM_Reflection.wrapBoolean((hiword.toInt() & 0xFF000000) >>> 24);
      }
 else {
        VM._assert(false);
      }
    }
 else     if (argTypes[i].isByteType()) {
      if (VM.BuildFor32Addr) {
        argObjectArray[i]=VM_Reflection.wrapByte((byte)((hiword.toInt() & 0xFF000000) >>> 24));
      }
 else {
        VM._assert(false);
      }
    }
 else     if (argTypes[i].isCharType()) {
      if (VM.BuildFor32Addr) {
        argObjectArray[i]=VM_Reflection.wrapChar((char)((hiword.toInt() & 0xFFFF0000) >>> 16));
      }
 else {
        VM._assert(false);
      }
    }
 else     if (argTypes[i].isShortType()) {
      if (VM.BuildFor32Addr) {
        argObjectArray[i]=VM_Reflection.wrapShort((short)((hiword.toInt() & 0xFFFF0000) >>> 16));
      }
 else {
        VM._assert(false);
      }
    }
 else     if (argTypes[i].isReferenceType()) {
      if (VM.BuildFor32Addr) {
        argObjectArray[i]=env.getJNIRef(hiword.toInt());
      }
 else {
        VM._assert(false);
      }
    }
 else     if (argTypes[i].isIntType()) {
      if (VM.BuildFor32Addr) {
        argObjectArray[i]=VM_Reflection.wrapInt(hiword.toInt());
      }
 else {
        VM._assert(false);
      }
    }
 else {
      return null;
    }
  }
  return argObjectArray;
}

Fixed version (ground truth):
/** 
 * Repackage the arguments passed as an array of jvalue into an array of Object, used by the JNI functions CallStatic<type>MethodA
 * @param mth the target VM_Method
 * @param argAddress an address into the C space for the array of jvalue unions;  each element is 2-word and holds the argument of the appropriate type
 * @return an Object array holding the arguments wrapped at Objects
 */
static Object[] packageParameterFromJValue(VM_Method targetMethod,VM_Address argAddress){
  VM_TypeReference[] argTypes=targetMethod.getParameterTypes();
  int argCount=argTypes.length;
  Object[] argObjectArray=new Object[argCount];
  VM_JNIEnvironment env=VM_Thread.getCurrentThread().getJNIEnv();
  for (int i=0; i < argCount; i++) {
    VM_Address addr=argAddress.add(BYTES_IN_DOUBLE * i);
    VM_Word hiword=VM_Magic.getMemoryWord(addr);
    VM_Word loword;
    if (VM.BuildFor32Addr) {
      loword=VM_Magic.getMemoryWord(addr.add(BYTES_IN_ADDRESS));
    }
    if (argTypes[i].isFloatType()) {
      if (VM.BuildFor32Addr) {
        argObjectArray[i]=VM_Reflection.wrapFloat(Float.intBitsToFloat(hiword.toInt()));
      }
 else {
        argObjectArray[i]=VM_Reflection.wrapFloat(Float.intBitsToFloat((int)((hiword.toLong() & 0xFFFFFFFF00000000L) >>> 32)));
      }
    }
 else     if (argTypes[i].isDoubleType()) {
      if (VM.BuildFor32Addr) {
        long doubleBits=(((long)hiword.toInt()) << BITS_IN_INT) | (loword.toInt() & 0xFFFFFFFFL);
        argObjectArray[i]=VM_Reflection.wrapDouble(Double.longBitsToDouble(doubleBits));
      }
 else {
        argObjectArray[i]=VM_Reflection.wrapDouble(Double.longBitsToDouble(hiword.toLong()));
      }
    }
 else     if (argTypes[i].isLongType()) {
      if (VM.BuildFor32Addr) {
        long longValue=(((long)hiword.toInt()) << BITS_IN_INT) | (loword.toInt() & 0xFFFFFFFFL);
        argObjectArray[i]=VM_Reflection.wrapLong(longValue);
      }
 else {
        argObjectArray[i]=VM_Reflection.wrapLong(hiword.toLong());
      }
    }
 else     if (argTypes[i].isBooleanType()) {
      if (VM.BuildFor32Addr) {
        argObjectArray[i]=VM_Reflection.wrapBoolean((hiword.toInt() & 0xFF000000) >>> 24);
      }
 else {
        argObjectArray[i]=VM_Reflection.wrapBoolean((int)((hiword.toLong() & 0xFF00000000000000L) >>> 56));
      }
    }
 else     if (argTypes[i].isByteType()) {
      if (VM.BuildFor32Addr) {
        argObjectArray[i]=VM_Reflection.wrapByte((byte)((hiword.toInt() & 0xFF000000) >>> 24));
      }
 else {
        argObjectArray[i]=VM_Reflection.wrapByte((byte)((hiword.toLong() & 0xFF00000000000000L) >>> 56));
      }
    }
 else     if (argTypes[i].isCharType()) {
      if (VM.BuildFor32Addr) {
        argObjectArray[i]=VM_Reflection.wrapChar((char)((hiword.toInt() & 0xFFFF0000) >>> 16));
      }
 else {
        argObjectArray[i]=VM_Reflection.wrapChar((char)((hiword.toLong() & 0xFFFF000000000000L) >>> 48));
      }
    }
 else     if (argTypes[i].isShortType()) {
      if (VM.BuildFor32Addr) {
        argObjectArray[i]=VM_Reflection.wrapShort((short)((hiword.toInt() & 0xFFFF0000) >>> 16));
      }
 else {
        argObjectArray[i]=VM_Reflection.wrapShort((short)((hiword.toLong() & 0xFFFF000000000000L) >>> 48));
      }
    }
 else     if (argTypes[i].isReferenceType()) {
      argObjectArray[i]=env.getJNIRef(hiword.toInt());
    }
 else     if (argTypes[i].isIntType()) {
      argObjectArray[i]=VM_Reflection.wrapInt(hiword.toInt());
    }
 else {
      return null;
    }
  }
  return argObjectArray;
}