Buggy code:
private boolean skipEnhance ( BCMethod method ) { } private void addAccessors ( ) throws NoSuchMethodException { } private void addSubclassSetMethod ( FieldMetaData fmd ) throws NoSuchMethodException { } private boolean setVisibilityToSuperMethod ( BCMethod method ) { } private void addSubclassGetMethod ( FieldMetaData fmd ) { } private void addGetMethod ( int index , FieldMetaData fmd ) throws NoSuchMethodException { } private void addSetMethod ( int index , FieldMetaData fmd ) throws NoSuchMethodException { } private void addAttachDetachCode ( ) throws NoSuchMethodException { } private void addDetachedStateMethods ( boolean impl ) { } private void getfield ( Code code , BCClass declarer , String attrName ) { } private void putfield ( Code code , BCClass declarer , String attrName , Class fieldType ) { } private String toBackingFieldName ( String name ) { } private String fromBackingFieldName ( String name ) { } private void addDetachExternalize ( boolean parentDetachable , boolean detachedState ) throws NoSuchMethodException { } private void addReadExternal ( boolean parentDetachable , boolean detachedState ) throws NoSuchMethodException { } private void addReadUnmanaged ( Collection unmgd , boolean parentDetachable ) throws NoSuchMethodException { } private void readExternal ( Code code , String fieldName , Class type , FieldMetaData fmd ) throws NoSuchMethodException { } private void addWriteExternal ( boolean parentDetachable , boolean detachedState ) throws NoSuchMethodException { } private void addWriteUnmanaged ( Collection unmgd , boolean parentDetachable ) throws NoSuchMethodException { } private void writeExternal ( Code code , String fieldName , Class type , FieldMetaData fmd ) throws NoSuchMethodException { } private void addGetManagedValueCode ( Code code , FieldMetaData fmd ) throws NoSuchMethodException { } private void addGetManagedValueCode ( Code code , FieldMetaData fmd , boolean fromSameClass ) throws NoSuchMethodException { } private void addSetManagedValueCode ( Code code , FieldMetaData fmd ) throws NoSuchMethodException { } private int getAccessorParameterOffset ( ) { } private Instruction loadManagedInstance ( Code code , boolean forStatic ) { } private BCMethod createGetMethod ( FieldMetaData fmd ) { } private BCMethod createSetMethod ( FieldMetaData fmd ) { } private void addGetEnhancementContractVersionMethod ( ) { } public Class getType ( ClassMetaData meta ) { } private static void transferCodeAttributes ( BCMethod from , BCMethod to ) { } public static void main ( String [ ] args ) throws IOException { } public static boolean run ( OpenJPAConfiguration conf , String [ ] args , Options opts ) throws IOException { } public static boolean run ( OpenJPAConfiguration conf , String [ ] args , PCEnhancer . Flags flags , MetaDataRepository repos , BytecodeWriter writer , ClassLoader loader ) throws IOException { if ( loader == null ) loader = conf . getClassResolverInstance ( ) . getClassLoader ( PCEnhancer . class , null ) ; if ( flags . tmpClassLoader ) loader = ( ( ClassLoader ) ( AccessController . doPrivileged ( J2DoPrivHelper . newTemporaryClassLoaderAction ( loader ) ) ) ) ; if ( repos == null ) { repos = conf . newMetaDataRepositoryInstance ( ) ; repos . setSourceMode ( MODE_META ) ; } Log log = conf . getLog ( LOG_TOOL ) ; Collection classes ; if ( ( args . length ) == 0 ) { log . info ( PCEnhancer . _loc . get ( "running-all-classes" ) ) ; classes = repos . getPersistentTypeNames ( true , loader ) ; if ( classes == null ) { log . warn ( PCEnhancer . _loc . get ( "no-class-to-enhance" ) ) ; return false ; } } else { ClassArgParser cap = conf . getMetaDataRepositoryInstance ( ) . getMetaDataFactory ( ) . newClassArgParser ( ) ; cap . setClassLoader ( loader ) ; classes = new HashSet ( ) ; for ( int i = 0 ; i < ( args . length ) ; i ++ ) classes . addAll ( Arrays . asList ( cap . parseTypes ( args [ i ] ) ) ) ; } Project project = new Project ( ) ; BCClass bc ; PCEnhancer enhancer ; int status ; for ( Iterator itr = classes . iterator ( ) ; itr . hasNext ( ) ; ) { Object o = itr . next ( ) ; if ( log . isTraceEnabled ( ) ) log . trace ( PCEnhancer . _loc . get ( "enhance-running" , o ) ) ; if ( o instanceof String ) <START_BUG> bc = project . loadClass ( ( ( String ) ( o ) ) ) ; <END_BUG> else bc = project . loadClass ( ( ( Class ) ( o ) ) ) ; enhancer = new PCEnhancer ( conf , bc , repos , loader ) ; if ( writer != null ) enhancer . setBytecodeWriter ( writer ) ; enhancer . setDirectory ( flags . directory ) ; enhancer . setAddDefaultConstructor ( flags . addDefaultConstructor ) ; status = enhancer . run ( ) ; if ( status == ( PCEnhancer . ENHANCE_NONE ) ) { if ( log . isTraceEnabled ( ) ) log . trace ( PCEnhancer . _loc . get ( "enhance-norun" ) ) ; } else if ( status == ( PCEnhancer . ENHANCE_INTERFACE ) ) { if ( log . isTraceEnabled ( ) ) log . trace ( PCEnhancer . _loc . get ( "enhance-interface" ) ) ; } else if ( status == ( PCEnhancer . ENHANCE_AWARE ) ) { if ( log . isTraceEnabled ( ) ) log . trace ( PCEnhancer . _loc . get ( "enhance-aware" ) ) ; enhancer . record ( ) ; } else enhancer . record ( ) ; project . clear ( ) ; } return true ; } public static class Flags { public File directory = null ; public boolean addDefaultConstructor = true ; public boolean tmpClassLoader = true ; public boolean enforcePropertyRestrictions = false ; } public static interface AuxiliaryEnhancer { public void run ( BCClass bc , ClassMetaData meta ) { } public boolean skipEnhance ( BCMethod m ) { } } }

Fix:
bc = project . loadClass ( ( ( String ) ( o ) ) , loader ) ;