Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#243 OpcodeStack reports constant value for long when it shouldn'

2.0.3
closed-invalid
nobody
detectors (11)
5
2014-06-19
2012-12-22
Dave Brosius
No

This method

private long fpCountChars(Collection<String> c)
{
long totLength = 0;
for (String s : c)
{
totLength += s.length();
}
return totLength;
}

reports that totLength at the bottom has a constant value of 0, which it does not.

patch fixes pushByLongMath in the case that parm1 and parm2 both don't have constants.

Discussion

  • Dave Brosius
    Dave Brosius
    2012-12-22

    • labels: --> detectors
     
  • Hi Dave,
    I haven't tried to reproduce, but I cannot see how the patch could fix the issue - "newValue.constValue = null;" is not changing anything , as after "Item newValue = new Item("J");" constValue is already set to null and not changed on related "if/else" branch. I'm overlooking something?

    Regards,
    Andrey

     
  • Dave Brosius
    Dave Brosius
    2013-01-01

    ah, drat, you are right. i got confused some how. i will delete the patch

    The problem is the lvValues object gets reset in mergeJumps, back to the what the register held before the totLength += s.length(); occurred, leaving totLength with a constant 0 in it. The mergeJump occurred at byteoffset 41 (GOTO)

    0: lconst_0
    1: lstore_2
    2: aload_1
    3: invokeinterface #13, 1 // InterfaceMethod java/util/Collection.iterator:()Ljava/util/Iterator;
    8: astore 4
    10: aload 4
    12: invokeinterface #10, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z
    17: ifeq 44
    20: aload 4
    22: invokeinterface #11, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
    27: checkcast #14 // class java/lang/String
    30: astore 5
    32: lload_2
    33: aload 5
    35: invokevirtual #15 // Method java/lang/String.length:()I
    38: i2l
    39: ladd
    40: lstore_2
    41: goto 10
    44: lload_2
    45: lreturn

     
  • Dave Brosius
    Dave Brosius
    2013-01-06

    on another note, it seems to me that pushByLocalStore needs to set the register number on it before setting llvalue because currently the reg number is -1

    ie

    @@ -3110,6 +3114,7 @@
    i.fieldLoadedFromRegister = -1;
    }
    }
    + it.registerNumber = register;
    setLVValue(register, it);
    }

    this doesn't fix the mergejumps problem however.

     
    • status: open --> closed-invalid
    • Group: --> 2.0.3