Buggy code:
public class ForeignKey extends Constraint { public static final int ACTION_NONE = 1 ; public static final int ACTION_RESTRICT = 2 ; public static final int ACTION_CASCADE = 3 ; public static final int ACTION_NULL = 4 ; public static final int ACTION_DEFAULT = 5 ; private static Localizer _loc = Localizer . forPackage ( ForeignKey . class ) ; private String _pkTableName = null ; private String _pkSchemaName = null ; private String _pkColumnName = null ; private int _seq = 0 ; private LinkedMap _joins = null ; private LinkedMap _joinsPK = null ; private LinkedMap _consts = null ; public LinkedMap _constsPK = null ; private int _delAction = ForeignKey . ACTION_NONE ; private int _upAction = ForeignKey . ACTION_NONE ; private int _index = 0 ; private Column [ ] _locals = null ; private Column [ ] _pks = null ; private Object [ ] _constVals = null ; private Column [ ] _constCols = null ; private Object [ ] _constValsPK = null ; private Column [ ] _constColsPK = null ; private Table _pkTable = null ; private Boolean _autoAssign = null ; public static int getAction ( String name ) { } public static String getActionName ( int action ) { } public ForeignKey ( ) { } public ForeignKey ( String name , Table table ) { } public boolean isLogical ( ) { } public boolean isPrimaryKeyAutoAssigned ( ) { } private boolean isPrimaryKeyAutoAssigned ( List seen ) { if ( ( _autoAssign ) != null ) return _autoAssign . booleanValue ( ) ; Column [ ] cols = getPrimaryKeyColumns ( ) ; if ( ( cols . length ) == 0 ) { _autoAssign = Boolean . FALSE ; return false ; } for ( int i = 0 ; i < ( cols . length ) ; i ++ ) { if ( cols [ i ] . isAutoAssigned ( ) ) { _autoAssign = Boolean . TRUE ; return true ; } } ForeignKey [ ] fks = _pkTable . getForeignKeys ( ) ; seen . add ( this ) ; for ( int i = 0 ; i < ( cols . length ) ; i ++ ) { for ( int j = 0 ; j < ( fks . length ) ; j ++ ) { <START_BUG> if ( ( fks [ j ] . getPrimaryKeyColumn ( cols [ i ] ) ) == null ) <END_BUG> continue ; if ( ( ! ( seen . contains ( fks [ j ] ) ) ) && ( fks [ j ] . isPrimaryKeyAutoAssigned ( seen ) ) ) { _autoAssign = Boolean . TRUE ; return true ; } } } _autoAssign = Boolean . FALSE ; return false ; } public String getPrimaryKeyTableName ( ) { } public void setPrimaryKeyTableName ( String pkTableName ) { } public String getPrimaryKeySchemaName ( ) { } public void setPrimaryKeySchemaName ( String pkSchemaName ) { } public String getPrimaryKeyColumnName ( ) { } public void setPrimaryKeyColumnName ( String pkColumnName ) { } public int getKeySequence ( ) { } public void setKeySequence ( int seq ) { } public int getDeleteAction ( ) { } public void setDeleteAction ( int action ) { } public int getUpdateAction ( ) { } public void setUpdateAction ( int action ) { } public int getIndex ( ) { } void setIndex ( int index ) { } public Column getPrimaryKeyColumn ( Column local ) { } public Column getColumn ( Column pk ) { } public Object getConstant ( Column local ) { } public Object getPrimaryKeyConstant ( Column pk ) { } public Column [ ] getColumns ( ) { } public Object [ ] getConstants ( ) { } public Object [ ] getPrimaryKeyConstants ( ) { } public boolean containsColumn ( Column col ) { } public boolean containsPrimaryKeyColumn ( Column col ) { } public boolean containsConstantColumn ( Column col ) { } public boolean containsConstantPrimaryKeyColumn ( Column col ) { } public Column [ ] getPrimaryKeyColumns ( ) { } public Column [ ] getConstantColumns ( ) { } public Column [ ] getConstantPrimaryKeyColumns ( ) { } public void setJoins ( Column [ ] cols , Column [ ] pkCols ) { } public void setConstantJoins ( Object [ ] consts , Column [ ] pkCols ) { } public void setConstantJoins ( Column [ ] cols , Object [ ] consts ) { } public void join ( Column local , Column toPK ) { } public void joinConstant ( Object val , Column toPK ) { } public void joinConstant ( Column col , Object val ) { } public boolean removeJoin ( Column col ) { } public Table getPrimaryKeyTable ( ) { } public void refColumns ( ) { } public void derefColumns ( ) { } public boolean equalsForeignKey ( ForeignKey fk ) { } public boolean columnsMatch ( Column [ ] fkCols , Column [ ] fkPKCols ) { } private static boolean match ( Column [ ] cols , Column [ ] fkCols ) { } private static boolean hasColumn ( Column [ ] cols , Column col ) { } private static boolean match ( Object [ ] vals , Object [ ] fkVals ) { } }

Fix:
if ( ! ( fks [ j ] . containsColumn ( cols [ i ] ) ) )