Buggy code:
public class ServerDaemon { static final int maxThreads = Integer . parseInt ( DaemonConfig . getInstance ( ) . getMaxThreads ( ) ) ; static final SystemLog systemLog = SystemLog . getInstance ( ) ; static final JobLog jobLog = JobLog . getInstance ( ) ; static final JobsDB jobsDB = JobsDB . getInstance ( ) ; static final JobTaskCompletion jobTaskCompletion = JobTaskCompletion . getInstance ( ) ; static List < ServerDaemon . AdaptationTrainingThread > threads = new ArrayList < ServerDaemon . AdaptationTrainingThread > ( ) ; public static void main ( String [ ] args ) throws InterruptedException { } private static boolean CleanThreads ( List < ServerDaemon . AdaptationTrainingThread > threads ) { } private static void CheckForNotRunningJobs ( List < ServerDaemon . AdaptationTrainingThread > threads ) { } private static boolean JobRunning ( List < ServerDaemon . AdaptationTrainingThread > threads , int thisJobID ) { } private static void StartJob ( List < ServerDaemon . AdaptationTrainingThread > threads , int jobID ) { } private static int NumJobsRunning ( List < ServerDaemon . AdaptationTrainingThread > threads ) { } public static class AdaptationTrainingThread extends Thread { final int jobID ; boolean complete ; final String [ ] tasks = new String [ ] { "EnvironmentSetup" , "AllophoneExtractor" , "EHMMLabeller" , "LabelPauseDeleter" , "PhoneUnitLabelComputer" , "TranscriptionAligner" , "PhoneUnitFeatureComputer" , "PhoneLabelFeatureAligner" , "HMMVoiceDataPreparation" , "HMMVoiceConfigure" , "HMMVoiceMakeVoice" , "HMMVoiceMakeData" , "HMMVoiceCompiler" } ; public AdaptationTrainingThread ( int jobID ) { } @ Override public void run ( ) { String jobHex = Util . ConvertDecToHex ( jobID , 4 ) ; String speakerInitials = ServerDaemon . jobsDB . GetSpeakerInitials ( jobID , this . getClass ( ) . getSimpleName ( ) ) ; String voiceDir = DaemonConfig . getInstance ( ) . getVoiceDir ( ) ; String basePath = ( ( voiceDir + "//working//" ) + jobHex ) + "//" ; String workingDirectory = ( ( "ennz-" + speakerInitials ) + "-adapt-" ) + jobHex ; while ( ! ( complete ) ) { boolean errored = false ; LinkedHashMap < String , Object [ ] > taskStatus = ServerDaemon . jobTaskCompletion . GetJobStatus ( jobID ) ; Set < String > tasks = taskStatus . keySet ( ) ; for ( String task : tasks ) { int jobStatus ; try { jobStatus = ServerDaemon . jobTaskCompletion . GetJobTaskStatus ( jobID , task ) ; } catch ( SQLException e1 ) { errored = true ; break ; } switch ( jobStatus ) { case - 1 : ServerDaemon . jobLog . LogInformation ( jobID , this . getClass ( ) . getSimpleName ( ) , ( ( "Task<seq2seq4repair_space>" + task ) + "<seq2seq4repair_space>marked<seq2seq4repair_space>as<seq2seq4repair_space>errored.<seq2seq4repair_space>Attempting<seq2seq4repair_space>to<seq2seq4repair_space>start<seq2seq4repair_space>again" ) ) ; break ; case 1 : ServerDaemon . jobLog . LogInformation ( jobID , this . getClass ( ) . getSimpleName ( ) , ( ( "Task<seq2seq4repair_space>" + task ) + "<seq2seq4repair_space>marked<seq2seq4repair_space>as<seq2seq4repair_space>incomplete.<seq2seq4repair_space>Attempting<seq2seq4repair_space>to<seq2seq4repair_space>start<seq2seq4repair_space>again." ) ) ; break ; case 2 : continue ; } <START_BUG> String taskClass = "nz.ac.auckland.voice_adaptation.scheduler.tasks." + task ; <END_BUG> AdaptationTask adaptationTask ; try { adaptationTask = ( ( AdaptationTask ) ( Class . forName ( taskClass ) . newInstance ( ) ) ) ; adaptationTask . Initialise ( jobID , basePath , workingDirectory , speakerInitials ) ; ServerDaemon . jobTaskCompletion . MarkJobAsRunning ( jobID , task ) ; int status = adaptationTask . run ( ) ; if ( status == 0 ) { ServerDaemon . jobTaskCompletion . MarkJobAsComplete ( jobID , task ) ; } else { ServerDaemon . jobTaskCompletion . MarkJobAsErrored ( jobID , task ) ; throw new Exception ( ( "Task<seq2seq4repair_space>failed:<seq2seq4repair_space>" + task ) ) ; } } catch ( InstantiationException | IllegalAccessException | ClassNotFoundException | SQLException e ) { errored = true ; e . printStackTrace ( ) ; break ; } catch ( Exception e ) { errored = true ; ServerDaemon . systemLog . LogError ( ( ( ( "JobID:<seq2seq4repair_space>" + ( this . jobID ) ) + "<seq2seq4repair_space>-<seq2seq4repair_space>" ) + ( e . getMessage ( ) ) ) ) ; break ; } } if ( ! errored ) { complete = true ; ServerDaemon . jobsDB . MarkJobAsComplete ( jobID ) ; ServerDaemon . systemLog . LogInformation ( ( ( "Job<seq2seq4repair_space>" + ( jobID ) ) + "<seq2seq4repair_space>marked<seq2seq4repair_space>as<seq2seq4repair_space>complete." ) ) ; } else { ServerDaemon . jobsDB . MarkJobAsErrored ( jobID ) ; ServerDaemon . systemLog . LogInformation ( ( ( "Job<seq2seq4repair_space>" + ( jobID ) ) + "<seq2seq4repair_space>marked<seq2seq4repair_space>as<seq2seq4repair_space>errored." ) ) ; break ; } } } public int GetJobID ( ) { } } }

Fix:
String taskClass = "nz.ac.auckland.voice_adaptation.daemon.scheduler.tasks." + task ;