Buggy code:
public class NamingContext implements EventContext { private static final RuntimePermission SET_ACTIVE_NAMING_STORE = new RuntimePermission ( "org.jboss.as.naming.SET_ACTIVE_NAMING_STORE" ) ; private static volatile NamingStore ACTIVE_NAMING_STORE = new InMemoryNamingStore ( ) ; public static void setActiveNamingStore ( final NamingStore namingStore ) { } private static final String PACKAGE_PREFIXES = "org.jboss.as.naming.interfaces" ; public static void initializeNamingManager ( ) { } private final NamingStore namingStore ; private final Name prefix ; private final Hashtable environment ; public NamingContext ( final Hashtable environment ) { } public NamingContext ( final Name prefix , final Hashtable environment ) throws NamingException { } public NamingContext ( final Name prefix , final NamingStore namingStore , final Hashtable environment ) { } public NamingContext ( final NamingStore namingStore , final Hashtable environment ) { } public Object lookup ( final Name name ) throws NamingException { } public Object lookup ( final String name ) throws NamingException { } public Object lookup ( final String name , boolean dereference ) throws NamingException { } public Object lookup ( final Name name , boolean dereference ) throws NamingException { } public void bind ( final Name name , Object object ) throws NamingException { } public void bind ( final String name , final Object obj ) throws NamingException { } public void rebind ( final Name name , Object object ) throws NamingException { } public void rebind ( final String name , final Object object ) throws NamingException { } public void unbind ( final Name name ) throws NamingException { } public void unbind ( final String name ) throws NamingException { } public void rename ( final Name oldName , final Name newName ) throws NamingException { } public void rename ( final String oldName , final String newName ) throws NamingException { } public NamingEnumeration < NameClassPair > list ( final Name name ) throws NamingException { } public NamingEnumeration < NameClassPair > list ( final String name ) throws NamingException { } public NamingEnumeration < Binding > listBindings ( final Name name ) throws NamingException { } public NamingEnumeration < Binding > listBindings ( final String name ) throws NamingException { } public void destroySubcontext ( final Name name ) throws NamingException { } public void destroySubcontext ( String name ) throws NamingException { } public Context createSubcontext ( Name name ) throws NamingException { } public Context createSubcontext ( String name ) throws NamingException { } public Object lookupLink ( Name name ) throws NamingException { } public Object lookupLink ( String name ) throws NamingException { } public NameParser getNameParser ( Name name ) throws NamingException { } public NameParser getNameParser ( String name ) throws NamingException { } public Name composeName ( Name name , Name prefix ) throws NamingException { } public String composeName ( String name , String prefix ) throws NamingException { } public Object addToEnvironment ( String propName , Object propVal ) throws NamingException { } public Object removeFromEnvironment ( String propName ) throws NamingException { } public Hashtable < ? , ? > getEnvironment ( ) throws NamingException { } public void close ( ) throws NamingException { } public String getNameInNamespace ( ) throws NamingException { } public void addNamingListener ( final Name target , final int scope , final NamingListener listener ) throws NamingException { } public void addNamingListener ( final String target , final int scope , final NamingListener listener ) throws NamingException { } public void removeNamingListener ( final NamingListener listener ) throws NamingException { } public boolean targetMustExist ( ) throws NamingException { } private Name parseName ( final String name ) throws NamingException { } private Name getAbsoluteName ( final Name name ) throws NamingException { } private Object getObjectInstance ( final Object object , final Name name , final Hashtable < ? , ? > environment ) throws NamingException { try { final ObjectFactoryBuilder factoryBuilder = ObjectFactoryBuilder . INSTANCE ; final ObjectFactory objectFactory = factoryBuilder . createObjectFactory ( object , environment ) ; <START_BUG> return objectFactory == null ? null : objectFactory . getObjectInstance ( object , name , this , environment ) ; <END_BUG> } catch ( NamingException e ) { throw e ; } catch ( Throwable t ) { throw NamingMessages . MESSAGES . cannotDeferenceObject ( t ) ; } } private Object resolveLink ( Object result , boolean dereference ) throws NamingException { } private void check ( Name name , Action ... actions ) throws NamingException { } Name getPrefix ( ) { } NamingStore getNamingStore ( ) { } WritableNamingStore getWritableNamingStore ( ) { } }

Fix:
return objectFactory . getObjectInstance ( object , name , this , environment ) ;