Buggy code:
public class MetaDataRepository implements Serializable , PCRegistry . RegisterClassListener , Configurable , Closeable , MetaDataModes { public static final int VALIDATE_NONE = 0 ; public static final int VALIDATE_META = 1 ; public static final int VALIDATE_MAPPING = 2 ; public static final int VALIDATE_UNENHANCED = 4 ; public static final int VALIDATE_RUNTIME = 8 ; protected static final Class [ ] EMPTY_CLASSES = new Class [ 0 ] ; protected static final NonPersistentMetaData [ ] EMPTY_NON_PERSISTENT = new NonPersistentMetaData [ 0 ] ; protected final ClassMetaData [ ] EMPTY_METAS ; protected final FieldMetaData [ ] EMPTY_FIELDS ; protected final Order [ ] EMPTY_ORDERS ; private static final Localizer _loc = Localizer . forPackage ( MetaDataRepository . class ) ; private SequenceMetaData _sysSeq = null ; private final Map _metas = new HashMap ( ) ; private final Map _oids = Collections . synchronizedMap ( new HashMap ( ) ) ; private final Map _impls = Collections . synchronizedMap ( new HashMap ( ) ) ; private final Map _ifaces = Collections . synchronizedMap ( new HashMap ( ) ) ; private final Map _queries = new HashMap ( ) ; private final Map _seqs = new HashMap ( ) ; private final Map _aliases = Collections . synchronizedMap ( new HashMap ( ) ) ; private final Map _pawares = Collections . synchronizedMap ( new HashMap ( ) ) ; private final Map _nonMapped = Collections . synchronizedMap ( new HashMap ( ) ) ; private final Map _subs = Collections . synchronizedMap ( new HashMap ( ) ) ; protected final XMLMetaData [ ] EMPTY_XMLMETAS ; private final Map _xmlmetas = new HashMap ( ) ; private transient OpenJPAConfiguration _conf = null ; private transient Log _log = null ; private transient InterfaceImplGenerator _implGen = null ; private transient MetaDataFactory _factory = null ; private int _resMode = ( MODE_META ) | ( MODE_MAPPING ) ; private int _sourceMode = ( ( MODE_META ) | ( MODE_MAPPING ) ) | ( MODE_QUERY ) ; private int _validate = ( MetaDataRepository . VALIDATE_META ) | ( MetaDataRepository . VALIDATE_UNENHANCED ) ; private final Collection _registered = new ArrayList ( ) ; private final SortedSet _resolving = new TreeSet ( new MetaDataInheritanceComparator ( ) ) ; private final SortedSet _mapping = new TreeSet ( new MetaDataInheritanceComparator ( ) ) ; private final List _errs = new LinkedList ( ) ; private ListenerList _listeners = new LifecycleEventManager . ListenerList ( 3 ) ; public MetaDataRepository ( ) { } public OpenJPAConfiguration getConfiguration ( ) { } public Log getLog ( ) { } public MetaDataFactory getMetaDataFactory ( ) { } public void setMetaDataFactory ( MetaDataFactory factory ) { } public int getValidate ( ) { } public void setValidate ( int validate ) { } public void setValidate ( int validate , boolean on ) { } public int getResolve ( ) { } public void setResolve ( int mode ) { } public void setResolve ( int mode , boolean on ) { } public int getSourceMode ( ) { } public void setSourceMode ( int mode ) { } public void setSourceMode ( int mode , boolean on ) { } public synchronized ClassMetaData getMetaData ( Class cls , ClassLoader envLoader , boolean mustExist ) { if ( ( cls != null ) && ( DynamicPersistenceCapable . class . isAssignableFrom ( cls ) ) ) cls = cls . getSuperclass ( ) ; ClassMetaData meta = getMetaDataInternal ( cls , envLoader ) ; if ( ( meta == null ) && mustExist ) { <START_BUG> if ( ( cls != null ) && ( ! ( ImplHelper . isManagedType ( cls ) ) ) ) <END_BUG> throw new org . apache . openjpa . util . MetaDataException ( MetaDataRepository . _loc . get ( "no-meta-notpc" , cls ) ) . setFatal ( false ) ; Set pcNames = getPersistentTypeNames ( false , envLoader ) ; if ( ( pcNames != null ) && ( ( pcNames . size ( ) ) > 0 ) ) throw new org . apache . openjpa . util . MetaDataException ( MetaDataRepository . _loc . get ( "no-meta-types" , cls , pcNames ) ) ; throw new org . apache . openjpa . util . MetaDataException ( MetaDataRepository . _loc . get ( "no-meta" , cls ) ) ; } resolve ( meta ) ; return meta ; } public ClassMetaData getMetaData ( String alias , ClassLoader envLoader , boolean mustExist ) { } 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 resolveMeta ( ClassMetaData meta ) { } private void loadMapping ( ClassMetaData meta ) { } private void preMapping ( ClassMetaData meta ) { } private boolean resolveMapping ( ClassMetaData meta ) { } private List processBuffer ( ClassMetaData meta , SortedSet buffer , int mode ) { } public synchronized ClassMetaData [ ] getMetaDatas ( ) { } public ClassMetaData getCachedMetaData ( Class cls ) { } public ClassMetaData addMetaData ( Class cls ) { } public ClassMetaData addMetaData ( Class cls , int access ) { } 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 ) { } protected Order newValueOrder ( FieldMetaData owner , boolean asc ) { } protected Order newRelatedFieldOrder ( FieldMetaData owner , FieldMetaData rel , boolean asc ) { }

Fix:
if ( ( cls != null ) && ( ! ( ImplHelper . isManagedType ( _conf , cls ) ) ) )