Re: Concurrency-interest Digest, Vol 146, Issue 19

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Concurrency-interest Digest, Vol 146, Issue 19

Valentin Kovalenko
> @JCStressTest
class ArrayLength {
    Object arr;

    @Actor
    public void actor1() {
        arr = new int[1];
    }

    @Actor
    public void actor2(I_Result r) {
        Object a = arr;
        if (a != null) {
          r.r1 = ((int[])a).length;
        } else {
          r.r1 = -1;
        }
    }
}

Would you say the result (r1) = (0) is plausible? In other words, do we expect
the arraylength to act like a field (thus allowing 0), or act like a metadata
(thus disallowing 0)?

Alexey,
this is actually covered in JLS 17.4.5. Happens-before Order: "The semantics of operations other than inter-thread actions, such as reads of array lengths (§10.7), executions of checked casts (§5.5§15.16), and invocations of virtual methods (§15.12), are not directly affected by data races."

_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://cs.oswego.edu/mailman/listinfo/concurrency-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Concurrency-interest Digest, Vol 146, Issue 19

Valentin Kovalenko
Sorry, the full quote is: "The semantics of operations other than inter-thread actions, such as reads of array lengths (§10.7), executions of checked casts (§5.5§15.16), and invocations of virtual methods (§15.12), are not directly affected by data races. Therefore, a data race cannot cause incorrect behavior such as returning the wrong length for an array."

On Tue, Mar 28, 2017 at 3:44 PM, Valentin Kovalenko <[hidden email]> wrote:
> @JCStressTest
class ArrayLength {
    Object arr;

    @Actor
    public void actor1() {
        arr = new int[1];
    }

    @Actor
    public void actor2(I_Result r) {
        Object a = arr;
        if (a != null) {
          r.r1 = ((int[])a).length;
        } else {
          r.r1 = -1;
        }
    }
}

Would you say the result (r1) = (0) is plausible? In other words, do we expect
the arraylength to act like a field (thus allowing 0), or act like a metadata
(thus disallowing 0)?

Alexey,
this is actually covered in JLS 17.4.5. Happens-before Order: "The semantics of operations other than inter-thread actions, such as reads of array lengths (§10.7), executions of checked casts (§5.5§15.16), and invocations of virtual methods (§15.12), are not directly affected by data races."


_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://cs.oswego.edu/mailman/listinfo/concurrency-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Concurrency-interest Digest, Vol 146, Issue 19

Viktor Klang
In reply to this post by Valentin Kovalenko
"directly affected" ;-)

--
Cheers,

On Mar 28, 2017 2:47 PM, "Valentin Kovalenko" <[hidden email]> wrote:
> @JCStressTest
class ArrayLength {
    Object arr;

    @Actor
    public void actor1() {
        arr = new int[1];
    }

    @Actor
    public void actor2(I_Result r) {
        Object a = arr;
        if (a != null) {
          r.r1 = ((int[])a).length;
        } else {
          r.r1 = -1;
        }
    }
}

Would you say the result (r1) = (0) is plausible? In other words, do we expect
the arraylength to act like a field (thus allowing 0), or act like a metadata
(thus disallowing 0)?

Alexey,
this is actually covered in JLS 17.4.5. Happens-before Order: "The semantics of operations other than inter-thread actions, such as reads of array lengths (§10.7), executions of checked casts (§5.5§15.16), and invocations of virtual methods (§15.12), are not directly affected by data races."

_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://cs.oswego.edu/mailman/listinfo/concurrency-interest



_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://cs.oswego.edu/mailman/listinfo/concurrency-interest
Loading...