Process to add some default methods to javax.naming.Context?

Vincent Ryan vincent.x.ryan at
Fri Oct 14 14:20:21 UTC 2016

Hello Laird,

The problem of having to cast the result of Context.lookup <> can be solved using an existing method:
    InitialContext.doLookup <>

Although it might not suit all uses because no JNDI environment properties are passed to the InitialContext
constructor that gets created within the method.

> On 13 Oct 2016, at 18:14, Laird Nelson <ljnelson at> wrote:
> Hello; I am new to this mailing list and its conventions; if I misstep I am
> happy to be pointed in the right direction.  I was directed here by Mark
> Reinhold.
> Disclaimer in case it matters: I work for Oracle.
> I have long wanted there to be methods in javax.naming.Context like the
> following:
> // typed from memory off the cuff
> default <T> T lookup(final String name, final Class<T> type) {
>  return type.cast(this.lookup(name));
> }
> // do similar things for other lookup* methods here
> What would be the steps I would next need to take to help with this?
> Thanks in advance for help, time and guidance,
> Best,
> Laird
> --

More information about the core-libs-dev mailing list