Buggy code:
private ClassMetaData getMetaDataInternal ( Class < ? > cls , ClassLoader envLoader , boolean mustExist ) { } public ClassMetaData getMetaData ( String alias , ClassLoader envLoader , boolean mustExist ) { } private ClassMetaData throwNoRegisteredAlias ( String alias ) { } public String getClosestAliasName ( String alias ) { } public Collection < String > getAliasNames ( ) { } private final Collection < String > getAliasNamesInternal ( ) { } private ClassMetaData getMetaDataInternal ( Class < ? > cls , ClassLoader envLoader ) { } private static String toModeString ( int mode ) { } protected void prepareMapping ( ClassMetaData meta ) { } private void resolve ( ClassMetaData meta ) { } private List < ClassMetaData > resolveMeta ( ClassMetaData meta ) { } private void loadMapping ( ClassMetaData meta ) { } private void preMapping ( ClassMetaData meta ) { } private boolean resolveMapping ( ClassMetaData meta ) { } private List < ClassMetaData > processBuffer ( ClassMetaData meta , List < ClassMetaData > buffer , int mode ) { } public ClassMetaData [ ] getMetaDatas ( ) { } private ClassMetaData [ ] getMetaDatasInternal ( ) { } public ClassMetaData getCachedMetaData ( Class < ? > cls ) { } public ClassMetaData addMetaData ( Class < ? > cls ) { } public ClassMetaData addMetaData ( Class < ? > cls , int access ) { } public ClassMetaData addMetaData ( Class < ? > cls , int access , boolean ignoreTransient ) { } private ClassMetaData metasPutInternal ( Class < ? > cls , ClassMetaData meta ) { } protected ClassMetaData newClassMetaData ( Class < ? > type ) { } protected ClassMetaData [ ] newClassMetaDataArray ( int length ) { } protected FieldMetaData newFieldMetaData ( String name , Class < ? > type , ClassMetaData owner ) { } protected FieldMetaData [ ] newFieldMetaDataArray ( int length ) { } protected XMLMetaData [ ] newXMLClassMetaDataArray ( int length ) { } protected ClassMetaData newEmbeddedClassMetaData ( ValueMetaData owner ) { } protected ValueMetaData newValueMetaData ( FieldMetaData owner ) { } protected Order newOrder ( FieldMetaData owner , String name , boolean asc ) { } public FieldMetaData getOrderByField ( ClassMetaData meta , String orderBy ) { } protected Order newValueOrder ( FieldMetaData owner , boolean asc ) { } protected Order newRelatedFieldOrder ( FieldMetaData owner , FieldMetaData rel , boolean asc ) { } protected Order [ ] newOrderArray ( int size ) { } public boolean removeMetaData ( ClassMetaData meta ) { } public boolean removeMetaData ( Class < ? > cls ) { } private boolean removeMetaDataInternal ( Class < ? > cls ) { } void addDeclaredInterfaceImpl ( ClassMetaData meta , Class < ? > iface ) { } private void addDeclaredInterfaceImplInternal ( ClassMetaData meta , Class < ? > iface ) { } void setInterfaceImpl ( ClassMetaData meta , Class < ? > impl ) { } private void setInterfaceImplInternal ( ClassMetaData meta , Class < ? > impl ) { } InterfaceImplGenerator getImplGenerator ( ) { } public ClassMetaData getMetaData ( Object oid , ClassLoader envLoader , boolean mustExist ) { } private void resolveIdentityClass ( Object oid ) { } public ClassMetaData [ ] getImplementorMetaDatas ( Class < ? > cls , ClassLoader envLoader , boolean mustExist ) { } private ClassMetaData [ ] getImplementorMetaDatasInternal ( Collection < Class < ? > > classes , ClassLoader envLoader , boolean mustExist ) { Collection < ClassMetaData > mapped = new ArrayList < ClassMetaData > ( classes . size ( ) ) ; ClassMetaData meta = null ; for ( Class < ? > c : classes ) { meta = getMetaData ( c , envLoader , true ) ; if ( ( meta . isMapped ( ) ) || ( ( meta . getMappedPCSubclassMetaDatas ( ) . length ) > 0 ) ) { mapped . add ( meta ) ; } } <START_BUG> return mapped . toArray ( new ClassMetaData [ ] { } ) ; <END_BUG> } public NonPersistentMetaData getPersistenceAware ( Class < ? > cls ) { } public NonPersistentMetaData [ ] getPersistenceAwares ( ) { } private NonPersistentMetaData [ ] getPersistenceAwaresInternal ( ) { } public NonPersistentMetaData addPersistenceAware ( Class < ? > cls ) { } private NonPersistentMetaData addPersistenceAwareInternal ( Class < ? > cls ) { } public boolean removePersistenceAware ( Class < ? > cls ) { } public NonPersistentMetaData getNonMappedInterface ( Class < ? > iface ) { } public NonPersistentMetaData [ ] getNonMappedInterfaces ( ) { } private NonPersistentMetaData [ ] getNonMappedInterfacesInternal ( ) { } public NonPersistentMetaData addNonMappedInterface ( Class < ? > iface ) { } private NonPersistentMetaData addNonMappedInterfaceInternal ( Class < ? > iface ) { } public boolean removeNonMappedInterface ( Class < ? > iface ) { } public void clear ( ) { } private void clearInternal ( ) { } public Set < String > getPersistentTypeNames ( boolean devpath , ClassLoader envLoader ) { } private Set < String > getPersistentTypeNamesInternal ( boolean devpath , ClassLoader envLoader ) { } public Collection < Class < ? > > loadPersistentTypes ( boolean devpath , ClassLoader envLoader ) { } public Collection < Class < ? > > loadPersistentTypes ( boolean devpath , ClassLoader envLoader , boolean mustExist ) { } private Collection < Class < ? > > loadPersistentTypesInternal ( boolean devpath , ClassLoader envLoader , boolean mustExist ) { } private Class < ? > classForName ( String name , ClassLoader loader ) { } Collection < Class < ? > > getPCSubclasses ( Class < ? > cls ) { } public void register ( Class < ? > cls ) { } private void loadRegisteredClassMetaData ( ClassLoader envLoader ) { } Class < ? > [ ] processRegisteredClasses ( ClassLoader envLoader ) { } private void processRegisteredClass ( Class < ? > cls ) { }

Fix:
return mapped . toArray ( new ClassMetaData [ mapped . size ( ) ] ) ;