Buggy code:
class GetMapValue extends AbstractVal { private final Val _map ; private final Val _key ; private final String _alias ; private ClassMetaData _meta = null ; private Class _cast = null ; public GetMapValue ( Val map , Val key , String alias ) { } public ClassMetaData getMetaData ( ) { } public void setMetaData ( ClassMetaData meta ) { } public boolean isVariable ( ) { } public Class getType ( ) { } public void setImplicitType ( Class type ) { } public ExpState initialize ( Select sel , ExpContext ctx , int flags ) { } private static class GetMapValueExpState extends ExpState { public final ExpState mapState ; public final ExpState keyState ; public GetMapValueExpState ( Joins joins , ExpState mapState , ExpState keyState ) { } } public Object toDataStoreValue ( Select sel , ExpContext ctx , ExpState state , Object val ) { } public void select ( Select sel , ExpContext ctx , ExpState state , boolean pks ) { } public void selectColumns ( Select sel , ExpContext ctx , ExpState state , boolean pks ) { } public void groupBy ( Select sel , ExpContext ctx , ExpState state ) { } public void orderBy ( Select sel , ExpContext ctx , ExpState state , boolean asc ) { } private SQLBuffer newSQLBuffer ( Select sel , ExpContext ctx , ExpState state ) { } public Object load ( ExpContext ctx , ExpState state , Result res ) throws SQLException { } public void calculateValue ( Select sel , ExpContext ctx , ExpState state , Val other , ExpState otherState ) { } public int length ( Select sel , ExpContext ctx , ExpState state ) { } public void appendTo ( Select sel , ExpContext ctx , ExpState state , SQLBuffer sql , int index ) { if ( ! ( ( _map ) instanceof PCPath ) ) throw new UnsupportedOperationException ( ) ; if ( ! ( ( _key ) instanceof Const ) ) throw new UnsupportedOperationException ( ) ; GetMapValue . GetMapValueExpState gstate = ( ( GetMapValue . GetMapValueExpState ) ( state ) ) ; PCPath map = ( ( PCPath ) ( _map ) ) ; Object key = ( ( Const ) ( _key ) ) . getValue ( ctx , gstate . keyState ) ; FieldMapping field = map . getFieldMapping ( gstate . mapState ) ; if ( ! ( ( field . getStrategy ( ) ) instanceof LRSMapFieldStrategy ) ) throw new UnsupportedOperationException ( ) ; LRSMapFieldStrategy strat = ( ( LRSMapFieldStrategy ) ( field . getStrategy ( ) ) ) ; ClassMapping [ ] clss = strat . getIndependentValueMappings ( true ) ; if ( ( clss != null ) && ( ( clss . length ) > 1 ) ) throw RelationStrategies . unjoinable ( field ) ; <START_BUG> ClassMapping cls = ( ( clss . length ) == 0 ) ? null : clss [ 0 ] ; <END_BUG> ForeignKey fk = strat . getJoinForeignKey ( cls ) ; sql . append ( "(SELECT<seq2seq4repair_space>" ) ; Column [ ] values = field . getElementMapping ( ) . getColumns ( ) ; for ( int i = 0 ; i < ( values . length ) ; i ++ ) { if ( i > 0 ) sql . append ( ",<seq2seq4repair_space>" ) ; sql . append ( values [ i ] . getTable ( ) ) . append ( "." ) . append ( values [ i ] ) ; } sql . append ( "<seq2seq4repair_space>FROM<seq2seq4repair_space>" ) . append ( values [ 0 ] . getTable ( ) ) ; sql . append ( "<seq2seq4repair_space>WHERE<seq2seq4repair_space>" ) ; ContainerFieldStrategy . appendUnaliasedJoin ( sql , sel , null , ctx . store . getDBDictionary ( ) , field , fk ) ; sql . append ( "<seq2seq4repair_space>AND<seq2seq4repair_space>" ) ; key = strat . toKeyDataStoreValue ( key , ctx . store ) ; Column [ ] cols = strat . getKeyColumns ( cls ) ; Object [ ] vals = ( ( cols . length ) == 1 ) ? null : ( ( Object [ ] ) ( key ) ) ; for ( int i = 0 ; i < ( cols . length ) ; i ++ ) { sql . append ( cols [ i ] . getTable ( ) ) . append ( "." ) . append ( cols [ i ] ) ; if ( vals == null ) sql . append ( ( key == null ? "<seq2seq4repair_space>IS<seq2seq4repair_space>" : "<seq2seq4repair_space>=<seq2seq4repair_space>" ) ) . appendValue ( key , cols [ i ] ) ; else sql . append ( ( ( vals [ i ] ) == null ? "<seq2seq4repair_space>IS<seq2seq4repair_space>" : "<seq2seq4repair_space>=<seq2seq4repair_space>" ) ) . appendValue ( vals [ i ] , cols [ i ] ) ; } sql . append ( ")" ) ; } }

Fix:
ClassMapping cls = ( ( clss == null ) || ( ( clss . length ) == 0 ) ) ? null : clss [ 0 ] ;