Buggy code:
public class HiveFuncHolder extends AbstractFuncHolder { static final Logger logger = org . slf4j . LoggerFactory . getLogger ( FunctionImplementationRegistry . class ) ; private MajorType [ ] argTypes ; private ObjectInspector returnOI ; private MajorType returnType ; private Class < ? extends GenericUDF > genericUdfClazz ; private boolean isGenericUDF = true ; private Class < ? extends UDF > udfClazz = null ; private String udfName = "" ; private boolean isRandom ; public HiveFuncHolder ( Class < ? extends GenericUDF > genericUdfClazz , MajorType [ ] argTypes , ObjectInspector returnOI , MajorType returnType , boolean isRandom ) { } public HiveFuncHolder ( String udfName , Class < ? extends UDF > udfClazz , MajorType [ ] argTypes , ObjectInspector returnOI , MajorType returnType , boolean isRandom ) { } public MajorType getReturnType ( ) { } public boolean isAggregating ( ) { } public boolean isRandom ( ) { } @ Override public MajorType getParmMajorType ( int i ) { } @ Override public int getParamCount ( ) { } @ Override public JVar [ ] renderStart ( ClassGenerator < ? > g , HoldingContainer [ ] inputVariables ) { } @ Override public HoldingContainer renderEnd ( ClassGenerator < ? > g , HoldingContainer [ ] inputVariables , JVar [ ] workspaceJVars ) { } private JInvocation getUDFInstance ( JCodeModel m ) { } @ Override public FunctionHolderExpression getExpr ( String name , List < LogicalExpression > args , ExpressionPosition pos ) { } private void generateSetup ( ClassGenerator < ? > g , JVar [ ] workspaceJVars ) { JCodeModel m = g . getModel ( ) ; JBlock sub = new JBlock ( true , true ) ; JVar oiArray = sub . decl ( m . _ref ( ObjectInspector [ ] . class ) , "argOIs" , JExpr . newArray ( m . _ref ( ObjectInspector . class ) , argTypes . length ) ) ; JClass oih = m . directClass ( ObjectInspectorHelper . class . getCanonicalName ( ) ) ; JClass mt = m . directClass ( MinorType . class . getCanonicalName ( ) ) ; JClass mode = m . directClass ( DataMode . class . getCanonicalName ( ) ) ; for ( int i = 0 ; i < ( argTypes . length ) ; i ++ ) { sub . assign ( oiArray . component ( JExpr . lit ( i ) ) , oih . staticInvoke ( "getDrillObjectInspector" ) . arg ( mode . staticInvoke ( "valueOf" ) . arg ( JExpr . lit ( argTypes [ i ] . getMode ( ) . getNumber ( ) ) ) ) . arg ( mt . staticInvoke ( "valueOf" ) . arg ( JExpr . lit ( argTypes [ i ] . getMinorType ( ) . getNumber ( ) ) ) ) ) ; } sub . assign ( workspaceJVars [ 2 ] , JExpr . newArray ( m . _ref ( DrillDeferredObject . class ) , argTypes . length ) ) ; for ( int i = 0 ; i < ( argTypes . length ) ; i ++ ) { sub . assign ( workspaceJVars [ 2 ] . component ( JExpr . lit ( i ) ) , JExpr . _new ( m . directClass ( DrillDeferredObject . class . getCanonicalName ( ) ) ) ) ; } sub . assign ( workspaceJVars [ 3 ] , JExpr . newArray ( m . _ref ( DrillDeferredObject . class ) , argTypes . length ) ) ; sub . assign ( workspaceJVars [ 1 ] , getUDFInstance ( m ) ) ; JTryBlock udfInitTry = sub . _try ( ) ; udfInitTry . body ( ) . assign ( workspaceJVars [ 0 ] , workspaceJVars [ 1 ] . invoke ( "initialize" ) . arg ( oiArray ) ) ; JCatchBlock udfInitCatch = udfInitTry . _catch ( m . directClass ( Exception . class . getCanonicalName ( ) ) ) ; JVar exVar = udfInitCatch . param ( "ex" ) ; udfInitCatch . body ( ) . _throw ( JExpr . _new ( m . directClass ( RuntimeException . class . getCanonicalName ( ) ) ) . arg ( JExpr . lit ( String . format ( "Failed<seq2seq4repair_space>to<seq2seq4repair_space>initialize<seq2seq4repair_space>GenericUDF" ) ) ) . arg ( exVar ) ) ; <START_BUG> sub . add ( ObjectInspectorHelper . initReturnValueHolder ( m , workspaceJVars [ 4 ] , returnOI , returnType . getMinorType ( ) ) ) ; <END_BUG> JBlock setup = g . getBlock ( SETUP ) ; setup . directStatement ( String . format ( "//**<seq2seq4repair_space>start<seq2seq4repair_space>%s<seq2seq4repair_space>for<seq2seq4repair_space>function<seq2seq4repair_space>%s<seq2seq4repair_space>**//<seq2seq4repair_space>" , SETUP . name ( ) , ( ( genericUdfClazz . getName ( ) ) + ( ! ( isGenericUDF ) ? ( "(" + ( udfName ) ) + ")" : "" ) ) ) ) ; setup . add ( sub ) ; setup . directStatement ( String . format ( "//**<seq2seq4repair_space>end<seq2seq4repair_space>%s<seq2seq4repair_space>for<seq2seq4repair_space>function<seq2seq4repair_space>%s<seq2seq4repair_space>**//<seq2seq4repair_space>" , SETUP . name ( ) , ( ( genericUdfClazz . getName ( ) ) + ( ! ( isGenericUDF ) ? ( "(" + ( udfName ) ) + ")" : "" ) ) ) ) ; } private HoldingContainer generateEval ( ClassGenerator < ? > g , HoldingContainer [ ] inputVariables , JVar [ ] workspaceJVars ) { } }

Fix:
sub . add ( ObjectInspectorHelper . initReturnValueHolder ( g , m , workspaceJVars [ 4 ] , returnOI , returnType . getMinorType ( ) ) ) ;