RFR: 8042906: Remove use of reflection in ORB

Chris Hegarty chris.hegarty at oracle.com
Mon May 12 12:45:59 UTC 2014


On 12/05/14 12:33, Mark Sheppard wrote:
> If I read the javdoc correctly neither computeIfAbsent nor putIfAbsent
> seem to match the
> previous semantics of the if statement?
>
> computeIfAbsent: "If the value for the specified key is present and
> non-null, attempts to compute a new mapping given the key and its
> current mapped value."

I think this is from computeIfPresent, rather than computeIfAbsent.

> or
> "If the specified key is not already associated with a value (or is
> mapped to |null|), attempts to compute its value using the given mapping
> function and enters it into this map unless |null|. "
> my interpretation is this is relevant if value if there exist a value
> and you want to update?

Remapping is computeIfPresent.

> putIfAbsent: "If the specified key is not already associated with a
> value (or is mapped to |null|) associates it with the given value and
> returns |null|, else returns the current value."
> in this case we can have null value returned

Yes, computeIfAbsent is not a swap in replacement here.

> previous semantics were if the PM doesn't exist then instantiate and
> cache it in the hashtable. return the PM - no null value returned

The return value will be whatever, null of otherwise, is returned from 
setupPresentationManager, which is exactly what computeIfAbsent does.

-Chris.

>
> maybe I'm misinterpreting the docs
>
> regards
> Mark
> On 12/05/2014 08:52, Seán Coffey wrote:
>> Good tip Alan/Chris.
>>
>> I'll make that change and push.
>>
>> Regards,
>> Sean.
>>
>> On 12 May 2014 07:17:04 GMT+01:00, Alan Bateman
>> <Alan.Bateman at oracle.com> wrote:
>>> On 11/05/2014 21:56, Seán Coffey wrote:
>>>> Now that JDK 8 is the official build bootstrap JDK for JDK 9, we can
>>>> remove use of reflection in ORB code to access the applet context.
>>>>
>>>> bug report : https://bugs.openjdk.java.net/browse/JDK-8042906
>>>> webrev : http://cr.openjdk.java.net/~coffeys/webrev.8042906/webrev/
>>> I agree with Chris that computeIfAbsent is best here, that was also the
>>>
>>> suggestion back in early April before the bootstrapping issue came up.
>>> In any case, it's good you are re-visiting this to clean it up.
>>>
>>> -Alan
>



More information about the core-libs-dev mailing list