On Wed, Dec 19, 2012 at 5:47 PM, Peter Levart <[email protected]> wrote: > 279 public Parameter[] getParameters() { > 280 // TODO: This may eventually need to be guarded by security > 281 // mechanisms similar to those in Field, Method, etc. > 282 Parameter[] raw = privateGetParameters(); > 283 Parameter[] out = new Parameter[raw.length]; > 284 // Need to copy the cached array to prevent users from messing > 285 // with it > 286 for (int i = 0; i < raw.length; i++) { > 287 out[i] = new Parameter(raw[i]); > 288 } > 289 return out; > 290 } > > together with the copy constructor in Parameter.java: > > 48 Parameter(Parameter p) { > 49 this.name = p.name; > 50 this.modifiers = p.modifiers; > 51 this.executable = p.executable; > 52 this.index = p.index; > 53 } > > If I see right, then Parameter is an immutable object. You need not copy the > Parameter objects when copying the array. Just do a shallow copy with > Arrays.copy.
(off topic, sorry) A question that I've been wondering : why do JDK methods return arrays, instead of something like List? To avoid dependencies among JDK packages? Then how about an interface java.lang.Sequence<T>? It would be very useful for user applications as well. Zhong Yu
