RFR: 8064846: Lazy-init thread safety problems in core reflection
Aleksey Shipilev
aleksey.shipilev at oracle.com
Fri Nov 14 08:03:41 UTC 2014
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