log.trace("End nextTask(FINISHED), task="+task);
return;
}
}
ThreadTask threadTask = (ThreadTask) taskList.remove(0);
ClassLoadingTask loadTask = threadTask.getLoadTask();
if( trace )
log.trace("Begin nextTask("+taskList.size()+"), loadTask="+loadTask);
RepositoryClassLoader ucl3 = threadTask.ucl;
try
{
if( threadTask.t == null )
{
/* This is a task that has been reassigned back to the original
requesting thread ClassLoadingTask, so a new ThreadTask must
be scheduled.
*/
if( trace )
log.trace("Rescheduling threadTask="+threadTask);
scheduleTask(loadTask, ucl3, threadTask.order, true, trace);
}
else
{
if( trace )
log.trace("Running threadTask="+threadTask);
// Load the class using this thread
threadTask.run();
}
}
catch(Throwable e)
{
log.trace("Class loading Task Run failed with exception", e);
boolean retry = e instanceof ClassCircularityError
|| e.getClass().equals(LinkageError.class);
int numCCE = loadTask.incNumCCE();
if( retry && numCCE <= 10 )
{
log.info("Rescheduling failed Class loading Task");
/* Reschedule this task after all existing tasks to allow the
current load tasks which are conflicting to complete.
*/
try
{
// Reschedule and update the loadTask.threadTaskCount
scheduleTask(loadTask, ucl3, Integer.MAX_VALUE, true, trace);
}
catch(Throwable ex)
{
loadTask.setLoadError(ex);
log.error("Failed to reschedule task after LinkageError", ex);
}
if( trace )
log.trace("Post LinkageError state, loadTask="+loadTask);
}
else
{
loadTask.setLoadError(e);
log.error("Not resheduling failed loading task, loadTask="+loadTask, e);
}
}
finally
{
// We must release the loadLock acquired in beginLoadTask
if( threadTask.releaseInNextTask == true )
{
if( trace )
log.trace("Releasing loadLock and ownership of UCL: "+threadTask.ucl);
synchronized( registrationLock )
{
loadClassThreads.remove(threadTask.ucl);
}
synchronized( threadTask.ucl )
{
ucl3.release();
ucl3.notifyAll();
}
}
}
// If the ThreadTasks are complete mark the ClassLoadingTask finished
if( loadTask.threadTaskCount == 0 )
{
Class loadedClass = threadTask.getLoadedClass();
if( loadedClass != null )
{
ClassLoader loader = loadedClass.getClassLoader();
ClassLoader wrapper = repository.getWrappingClassLoader(loader);
if (wrapper != null)
loader=wrapper;
// Place the loaded class into the repositry cache
repository.cacheLoadedClass(threadTask.getClassname(),
loadedClass, loader);
}
/*
synchronized( loadTask )
{