Buggy code:
public class ModelMetrics extends Keyed < ModelMetrics > { final Key _modelKey ; final Key _frameKey ; final ModelCategory _model_category ; final long _model_checksum ; final long _frame_checksum ; transient Model _model ; transient Frame _frame ; public double _mse ; public ModelMetrics ( Model model , Frame frame , double mse ) { } public ModelMetrics ( Model model , Frame frame ) { } public Model model ( ) { } public Frame frame ( ) { } public ConfusionMatrix cm ( ) { } public float [ ] hr ( ) { } public AUCData auc ( ) { } public static TwoDimTable calcVarImp ( VarImp vi ) { } public static TwoDimTable calcVarImp ( final float [ ] rel_imp , String [ ] coef_names ) { } public static TwoDimTable calcVarImp ( final double [ ] rel_imp , String [ ] coef_names ) { } public static TwoDimTable calcVarImp ( final double [ ] rel_imp , String [ ] coef_names , String table_header , String [ ] col_headers ) { if ( rel_imp == null ) return null ; if ( coef_names == null ) { coef_names = new String [ rel_imp . length ] ; for ( int i = 0 ; i < ( coef_names . length ) ; i ++ ) coef_names [ i ] = "C" + ( String . valueOf ( ( i + 1 ) ) ) ; } assert ( rel_imp . length ) == ( coef_names . length ) ; Integer [ ] sorted_idx = new Integer [ rel_imp . length ] ; for ( int i = 0 ; i < ( sorted_idx . length ) ; i ++ ) sorted_idx [ i ] = i ; Arrays . sort ( sorted_idx , new Comparator < Integer > ( ) { public int compare ( Integer idx1 , Integer idx2 ) { return Double . compare ( ( - ( rel_imp [ idx1 ] ) ) , ( - ( rel_imp [ idx2 ] ) ) ) ; } } ) ; double total = 0 ; double max = rel_imp [ sorted_idx [ 0 ] ] ; <START_BUG> String [ ] sorted_names = new String [ coef_names . length ] ; <END_BUG> double [ ] [ ] sorted_imp = new double [ rel_imp . length ] [ 3 ] ; int j = 0 ; for ( int i : sorted_idx ) { total += rel_imp [ i ] ; sorted_names [ j ] = coef_names [ i ] ; sorted_imp [ j ] [ 0 ] = rel_imp [ i ] ; sorted_imp [ ( j ++ ) ] [ 1 ] = ( rel_imp [ i ] ) // max ; } j = 0 ; for ( int i : sorted_idx ) sorted_imp [ ( j ++ ) ] [ 2 ] = ( rel_imp [ i ] ) // total ; String [ ] col_types = new String [ 3 ] ; String [ ] col_formats = new String [ 3 ] ; Arrays . fill ( col_types , "double" ) ; Arrays . fill ( col_formats , "%5f" ) ; return new TwoDimTable ( table_header , sorted_names , col_headers , col_types , col_formats , "Variable" , new String [ rel_imp . length ] [ ] , sorted_imp ) ; } private static Key < ModelMetrics > buildKey ( Key model_key , long model_checksum , Key frame_key , long frame_checksum ) { } private static Key < ModelMetrics > buildKey ( Model model , Frame frame ) { } public boolean isForModel ( Model m ) { } public boolean isForFrame ( Frame f ) { } public static ModelMetrics getFromDKV ( Model model , Frame frame ) { } @ Override protected long checksum_impl ( ) { } public static abstract class MetricBuilder extends Iced { public double _sumsqe ; public transient float [ ] _work ; public long _count ; public abstract float [ ] perRow ( float [ ] ds , float [ ] yact , Model m ) { } public void reduce ( ModelMetrics . MetricBuilder mb ) { } public void postGlobal ( ) { } public abstract ModelMetrics makeModelMetrics ( Model m , Frame f , double sigma ) { } } }

Fix:
String [ ] sorted_names = new String [ rel_imp . length ] ;