Review request:Updated JDK-8004728 Implement core reflection API for parameter reflection
Peter Levart
peter.levart at gmail.com
Thu Dec 20 06:47:00 UTC 2012
On 12/20/2012 06:33 AM, Eric McCorkle wrote:
> On 12/19/12 18:47, Peter Levart wrote:
>> >Hi Eric,
>> >
>> >in Executable.java:
>> >
>> > 292 private Parameter[] privateGetParameters() {
>> > 293 if (null != parameters)
>> > 294 return parameters.get();
>> >
>> >
>> >If/when SoftReference is cleared,privateGetParameters will be returning
>> >null forever. Also Executable objects are already SoftReferenced from
>> >the Class. Do we need another level of SoftReferencing?
> I'd say not. I'll take that bit out.
>
Hi again, Eric,
To be exact: only 'root' Executable objects are SoftReferenced from the
Class. The copies that are exposed to user are not referenced at all (by
reflection library). So as long as internal JDK code is not calling any
new Parameter returning methods on 'root' Executable instances, they
will never materialize any Parameter objects. The user only has to be
aware that the Executable instance he/she has got hold on has a direct
reference to any Parameter instances and vice versa. There is already a
precedent for that: annotations are directly referenced from
Field/Method/Constructor and they may have direct references to various
Class instances.
Although the specification does not specify it, a nice addition to the
API would be the following method on Executable:
Parameter getParameter(String parameterName);
...since parameter names are unique, aren't they? Parameter instances
would have to be cached in a Map though.
Regards, Peter
More information about the core-libs-dev
mailing list