Buggy code:
public boolean getCreateSubclass ( ) { } public void setCreateSubclass ( boolean subclass ) { } public boolean getEnforcePropertyRestrictions ( ) { } public void setEnforcePropertyRestrictions ( boolean fail ) { } public File getDirectory ( ) { } public void setDirectory ( File dir ) { } public BytecodeWriter getBytecodeWriter ( ) { } public void setBytecodeWriter ( BytecodeWriter writer ) { } public int run ( ) { } private void configureBCs ( ) { } public void record ( ) throws IOException { } private void record ( BCClass bc ) throws IOException { } private void validateProperties ( ) { } private void registerBackingFieldInfo ( FieldMetaData fmd , BCMethod method , BCField field ) { } private void addAttributeTranslation ( ) { } private static String getSetterName ( FieldMetaData fmd ) { } private static String getGetterName ( FieldMetaData fmd ) { } static BCField getReturnedField ( BCMethod meth ) { } static BCField getAssignedField ( BCMethod meth ) { } private static BCField findField ( BCMethod meth , Instruction template , boolean findAccessed ) { } private void addViolation ( String key , Object [ ] args , boolean fatal ) { } private void processViolations ( ) { } private void replaceAndValidateFieldAccess ( ) throws NoSuchMethodException { } private void replaceAndValidateFieldAccess ( Code code , Instruction ins , boolean get , Instruction stat ) throws NoSuchMethodException { } private void addNotifyAccess ( Code code , FieldMetaData fmd ) { } private void addNotifyMutation ( Code code , FieldMetaData fmd , int val , int param ) throws NoSuchMethodException { } private boolean isBackingFieldOfAnotherProperty ( String name , Code code ) { } private ClassMetaData getPersistenceCapableOwner ( String fieldName , Class owner ) { } private void addPCMethods ( ) throws NoSuchMethodException { } private void addClearFieldsMethod ( ) throws NoSuchMethodException { } private void addNewInstanceMethod ( boolean oid ) { } private void addManagedFieldCountMethod ( ) { } private void addProvideFieldsMethods ( ) throws NoSuchMethodException { } private void addReplaceFieldsMethods ( ) throws NoSuchMethodException { } private void addCopyFieldsMethod ( ) throws NoSuchMethodException { } private int beginSwitchMethod ( String name , Code code ) { } private void addMultipleFieldsMethodVersion ( BCMethod single ) { } private void addStockMethods ( ) throws NoSuchMethodException { } private void translateFromStateManagerMethod ( Method m , boolean isDirtyCheckMethod ) { } private void addGetVersionMethod ( ) throws NoSuchMethodException { } private Class toPrimitiveWrapper ( FieldMetaData fmd ) { } private void addReplaceStateManagerMethod ( ) { } private void addNoOpApplicationIdentityMethods ( ) { } private void addCopyKeyFieldsToObjectIdMethod ( boolean fieldManager ) throws NoSuchMethodException { } private void addExtractObjectIdFieldValueCode ( Code code , FieldMetaData pk ) { } private void addCopyKeyFieldsFromObjectIdMethod ( boolean fieldManager ) throws NoSuchMethodException { } private Boolean usesClassStringIdConstructor ( ) { } private Class unwrapSingleFieldIdentity ( FieldMetaData fmd ) { } private Method getReflectionGetterMethod ( Class type , Class argType ) throws NoSuchMethodException { } private Method getFieldSupplierMethod ( Class type ) throws NoSuchMethodException { } private Method getFieldConsumerMethod ( Class type ) throws NoSuchMethodException { } private void addNewObjectIdInstanceMethod ( boolean obj ) throws NoSuchMethodException { } private Method getStateManagerMethod ( Class type , String prefix , boolean get , boolean curValue ) throws NoSuchMethodException { } private Method getMethod ( Class owner , Class type , String prefix , boolean get , boolean haspc , boolean curValue ) throws NoSuchMethodException { } private Instruction throwException ( Code code , Class type ) { } private void enhanceClass ( ) { } private void addFields ( ) { } private void addStaticInitializer ( ) { Code code = getOrCreateClassInitCode ( true ) ; if ( ( _meta . getPCSuperclass ( ) ) != null ) { if ( getCreateSubclass ( ) ) { <START_BUG> code . constant ( ) . setValue ( _meta . getFields ( ) . length ) ; <END_BUG> code . putstatic ( ) . setField ( PCEnhancer . INHERIT , int . class ) ; } else { code . invokestatic ( ) . setMethod ( getType ( _meta . getPCSuperclassMetaData ( ) ) . getName ( ) , ( ( PCEnhancer . PRE ) + "GetManagedFieldCount" ) , int . class . getName ( ) , null ) ; code . putstatic ( ) . setField ( PCEnhancer . INHERIT , int . class ) ; } code . classconstant ( ) . setClass ( getType ( _meta . getPCSuperclassMetaData ( ) ) ) ; code . putstatic ( ) . setField ( PCEnhancer . SUPER , Class . class ) ; } FieldMetaData [ ] fmds = _meta . getDeclaredFields ( ) ; code . constant ( ) . setValue ( fmds . length ) ; code . anewarray ( ) . setType ( String . class ) ; for ( int i = 0 ; i < ( fmds . length ) ; i ++ ) { code . dup ( ) ; code . constant ( ) . setValue ( i ) ; code . constant ( ) . setValue ( fmds [ i ] . getName ( ) ) ; code . aastore ( ) ; } code . putstatic ( ) . setField ( ( ( PCEnhancer . PRE ) + "FieldNames" ) , String [ ] . class ) ; code . constant ( ) . setValue ( fmds . length ) ; code . anewarray ( ) . setType ( Class . class ) ; for ( int i = 0 ; i < ( fmds . length ) ; i ++ ) { code . dup ( ) ; code . constant ( ) . setValue ( i ) ; code . classconstant ( ) . setClass ( fmds [ i ] . getDeclaredType ( ) ) ; code . aastore ( ) ; } code . putstatic ( ) . setField ( ( ( PCEnhancer . PRE ) + "FieldTypes" ) , Class [ ] . class ) ;

Fix:
code . constant ( ) . setValue ( 0 ) ;