RFR: 8064846: Lazy-init thread safety problems in core reflection
Martin Buchholz
martinrb at google.com
Fri Nov 14 21:38:10 UTC 2014
Hi Aleksey,
I've implemented your suggestions and regenerated the webrev.
On Fri, Nov 14, 2014 at 12:03 AM, Aleksey Shipilev
<aleksey.shipilev at oracle.com> wrote:
> Hi Martin,
>
> On 11/14/2014 03:03 AM, Martin Buchholz wrote:
>> I'd like you to do a code review.
>>
>> http://cr.openjdk.java.net/~martin/webrevs/openjdk9/core-reflection-volatile/
>> https://bugs.openjdk.java.net/browse/JDK-8064846
>
> Looks good and sane, thanks for taking care of it.
>
> Not a big fan of chained assignments though. It looks like you may reuse
> the same local variable "superinterfaces" here:
>
> 97 public Type[] getSuperInterfaces() {
> 98 Type[] superInterfaces = this.superInterfaces;
> 99 if (superInterfaces == null) { // lazily initialize super
> interfaces
> 100 // first, extract super interface subtree(s) from AST
> 101 TypeTree[] ts = getTree().getSuperInterfaces();
> 102 // create array to store reified subtree(s)
> 103 superInterfaces = new Type[ts.length];
> 104 // reify all subtrees
> 105 for (int i = 0; i < ts.length; i++) {
> 106 Reifier r = getReifier(); // obtain visitor
> 107 ts[i].accept(r);// reify subtree
> 108 // extract result from visitor and store it
> 109 superInterfaces[i] = r.getResult();
> 110 }
> 111 this.superInterfaces = superInterfaces;
> 112 }
> 113 return superInterfaces.clone(); // return cached result
> 114 }
>
>
> Thanks,
> -Aleksey.
>
>
More information about the core-libs-dev
mailing list