Process for adding default method to javax.naming.Context?

Alan Bateman Alan.Bateman at oracle.com
Fri Aug 20 10:12:52 UTC 2021


On 19/08/2021 15:32, Laird Nelson wrote:
> :
>
> To recap in brief: being able to do:
>
>    Frob frob = someNamingContext.lookup("frob", Frob.class);
>
> would be very convenient, e.g. via something like:
>
>    // Proposed new default method in javax.naming.Context
>    default <T> T lookup(Name name, Class<T> type) {
>      return type.cast(lookup(name)); // just delegate to the existing
> lookup() method
>    }
>
> Should I simply file an RFE in https://bugs.openjdk.java.net/ or should I
> first further discuss the idea here?
>
> The contribution guide (https://openjdk.java.net/contribute/) seemed to
> suggest starting with a discussion on the list when an RFE doesn't already
> exist, but to be honest there's not much more to the idea than this at the
> moment.
Yes, it's best to start a discussion here. We can create a JBS issues as 
needed.

I think you are asking for an overload that specifies a class literal as 
a type token to avoid an explicit cast at the use-sites. Is this to 
improve usages within Helidon or are there enterprise libs that expose 
JNDI Context objects that would be used by a wider set of users?

-Alan




More information about the core-libs-dev mailing list