Buggy code:
public void bindResultColumns ( TableDescriptor targetTableDescriptor , FromVTI targetVTI , ResultColumnList targetColumnList , DMLStatementNode statement , FromList fromListParam ) throws StandardException { } private void buildRCL ( ) throws StandardException { } private void deferredBindExpressions ( FromList fromListParam ) throws StandardException { subqueryList = ( ( SubqueryList ) ( getNodeFactory ( ) . getNode ( SUBQUERY_LIST , getContextManager ( ) ) ) ) ; aggregateVector = new Vector ( ) ; if ( ( joinClause ) != null ) { FromList fromList = ( ( FromList ) ( getNodeFactory ( ) . getNode ( FROM_LIST , getNodeFactory ( ) . doJoinOrderOptimization ( ) , getContextManager ( ) ) ) ) ; fromList . addElement ( ( ( FromTable ) ( leftResultSet ) ) ) ; fromList . addElement ( ( ( FromTable ) ( rightResultSet ) ) ) ; fromListParam . insertElementAt ( rightResultSet , 0 ) ; fromListParam . insertElementAt ( leftResultSet , 0 ) ; joinClause = joinClause . bindExpression ( fromListParam , subqueryList , aggregateVector ) ; try { joinClause = joinClause . bindExpression ( fromList , subqueryList , aggregateVector ) ; } catch ( StandardException se ) { if ( se . getSQLState ( ) . equals ( LANG_COLUMN_NOT_FOUND ) ) throw StandardException . newException ( LANG_DB2_ON_CLAUSE_INVALID ) ; throw se ; } if ( ( subqueryList . size ( ) ) > 0 ) throw StandardException . newException ( LANG_DB2_ON_CLAUSE_INVALID ) ; if ( ( aggregateVector . size ( ) ) > 0 ) { throw StandardException . newException ( LANG_NO_AGGREGATES_IN_ON_CLAUSE ) ; } fromListParam . removeElementAt ( 0 ) ; fromListParam . removeElementAt ( 0 ) ; } else if ( ( usingClause ) != null ) { joinClause = ( ( AndNode ) ( getNodeFactory ( ) . getNode ( AND_NODE , null , null , getContextManager ( ) ) ) ) ; AndNode currAnd = ( ( AndNode ) ( joinClause ) ) ; ValueNode trueNode = ( ( ValueNode ) ( getNodeFactory ( ) . getNode ( BOOLEAN_CONSTANT_NODE , Boolean . TRUE , getContextManager ( ) ) ) ) ; int usingSize = usingClause . size ( ) ; for ( int index = 0 ; index < usingSize ; index ++ ) { BinaryComparisonOperatorNode equalsNode ; ColumnReference leftCR ; ColumnReference rightCR ; ResultColumn rc = ( ( ResultColumn ) ( usingClause . elementAt ( index ) ) ) ; if ( ( currAnd . getLeftOperand ( ) ) != null ) { currAnd . setRightOperand ( ( ( AndNode ) ( getNodeFactory ( ) . getNode ( AND_NODE , null , null , getContextManager ( ) ) ) ) ) ; currAnd = ( ( AndNode ) ( currAnd . getRightOperand ( ) ) ) ; } fromListParam . insertElementAt ( leftResultSet , 0 ) ; leftCR = ( ( ColumnReference ) ( getNodeFactory ( ) . getNode ( COLUMN_REFERENCE , rc . getName ( ) , ( ( FromTable ) ( leftResultSet ) ) . getTableName ( ) , getContextManager ( ) ) ) ) ; leftCR = ( ( ColumnReference ) ( leftCR . bindExpression ( fromListParam , subqueryList , aggregateVector ) ) ) ; fromListParam . removeElementAt ( 0 ) ; fromListParam . insertElementAt ( rightResultSet , 0 ) ; rightCR = ( ( ColumnReference ) ( getNodeFactory ( ) . getNode ( COLUMN_REFERENCE , rc . getName ( ) , ( ( FromTable ) ( rightResultSet ) ) . getTableName ( ) , getContextManager ( ) ) ) ) ; rightCR = ( ( ColumnReference ) ( rightCR . bindExpression ( fromListParam , subqueryList , aggregateVector ) ) ) ; fromListParam . removeElementAt ( 0 ) ; equalsNode = ( ( BinaryComparisonOperatorNode ) ( getNodeFactory ( ) . getNode ( BINARY_EQUALS_OPERATOR_NODE , leftCR , rightCR , getContextManager ( ) ) ) ) ; equalsNode . bindComparisonOperator ( ) ; currAnd . setLeftOperand ( equalsNode ) ; currAnd . setRightOperand ( trueNode ) ; currAnd . postBindFixup ( ) ; } } if ( ( joinClause ) != null ) { <START_BUG> if ( joinClause . isParameterNode ( ) ) { <END_BUG> joinClause . setType ( new org . apache . derby . iapi . types . DataTypeDescriptor ( TypeId . BOOLEAN_ID , true ) ) ; } TypeId joinTypeId = joinClause . getTypeId ( ) ; if ( ! ( joinTypeId . systemBuiltIn ( ) ) ) { joinClause = joinClause . genSQLJavaSQLTree ( ) ; } if ( ! ( joinClause . getTypeServices ( ) . getTypeId ( ) . equals ( BOOLEAN_ID ) ) ) { throw StandardException . newException ( LANG_NON_BOOLEAN_JOIN_CLAUSE , joinClause . getTypeServices ( ) . getTypeId ( ) . getSQLTypeName ( ) ) ; } } } public ResultSetNode preprocess ( int numTables , GroupByList gbl , FromList fromList ) throws StandardException { } void projectResultColumns ( ) throws StandardException { } public void normExpressions ( ) throws StandardException { } public void pushExpressions ( PredicateList outerPredicateList ) throws StandardException { } protected void pushExpressionsToLeft ( PredicateList outerPredicateList ) throws StandardException { } private void pushExpressionsToRight ( PredicateList outerPredicateList ) throws StandardException { } private void grabJoinPredicates ( PredicateList outerPredicateList ) throws StandardException { } public FromList flatten ( ResultColumnList rcl , PredicateList outerPList , SubqueryList sql , GroupByList gbl ) throws StandardException { } public boolean LOJ_reorderable ( int numTables ) throws StandardException { } public FromTable transformOuterJoins ( ValueNode predicateTree , int numTables ) throws StandardException { } public void generate ( ActivationClassBuilder acb , MethodBuilder mb ) throws StandardException { } public void generateCore ( ActivationClassBuilder acb , MethodBuilder mb , int joinType ) throws StandardException { } protected void generateCore ( ActivationClassBuilder acb , MethodBuilder mb , int joinType , ValueNode joinClause , SubqueryList subquerys ) throws StandardException { } private int getJoinArguments ( ActivationClassBuilder acb , MethodBuilder mb , ValueNode joinClause ) throws StandardException { } protected void oneRowRightSide ( ActivationClassBuilder acb , MethodBuilder mb ) throws StandardException { }

Fix:
if ( joinClause . requiresTypeFromContext ( ) ) {