jacodb icon indicating copy to clipboard operation
jacodb copied to clipboard

Bug with local variables creation

Open DaniilStepanov opened this issue 2 years ago • 3 comments

Because of this condition instructions like 0=1 are possible. It is wrong behavior. Possible fix: add additional condition: if ((oldVar.typeName == expr.typeName && oldVar !is JcRawConstant) || (expr is JcRawNullConstant && !oldVar.typeName.isPrimitive)) {

Failing test:

class InvokeMethodWithException {

    class A {
        fun lol(a: Int): Int {
            return 888/a
        }
    }

    fun box():String {
        val method = A::class.java.getMethod("lol", Int::class.java)
        var failed = false
        try {
            method.invoke(null, 0)
        }
        catch(e: Exception) {
            failed = true
        }

        return if (!failed) "fail" else "OK"
    }

}

DaniilStepanov avatar Sep 05 '23 08:09 DaniilStepanov

@DaniilStepanov Could you please check this test . This test is green at the moment

lehvolk avatar Sep 05 '23 13:09 lehvolk

yes, it fixed

DaniilStepanov avatar Sep 05 '23 15:09 DaniilStepanov

Try this test:

fun box(): String {
    var x = ""
    run { x = "OK" }
    return x
}

DaniilStepanov avatar Sep 06 '23 12:09 DaniilStepanov