JDIDebugPlugin.getUniqueIdentifier(),
DebugException.TARGET_REQUEST_FAILED,
"At least one target failed to drop to frame after successful hot code replace.", null); //$NON-NLS-1$
Iterator<JDIDebugTarget> iter = targets.iterator();
while (iter.hasNext()) {
JDIDebugTarget target = iter.next();
if (!target.isAvailable()) {
deregisterTarget(target);
continue;
}
// Make a local copy of the resources/names to swap so we can filter
// unloaded types on a per-target basis.
List<IResource> resourcesToReplace = new ArrayList<IResource>(resources);
List<String> qualifiedNamesToReplace = new ArrayList<String>(qualifiedNames);
filterUnloadedTypes(target, resourcesToReplace,
qualifiedNamesToReplace);
if (qualifiedNamesToReplace.isEmpty()) {
// If none of the changed types are loaded, do nothing.
continue;
}
List<IThread> poppedThreads = new ArrayList<IThread>();
target.setIsPerformingHotCodeReplace(true);
try {
boolean framesPopped = false;
if (target.canPopFrames()) {
// JDK 1.4 drop to frame support:
// JDK 1.4 spec is faulty around methods that have
// been rendered obsolete after class redefinition.
// Thus, pop the frames that contain affected methods
// *before* the class redefinition to avoid problems.
try {
attemptPopFrames(target, resourcesToReplace,
qualifiedNamesToReplace, poppedThreads);
framesPopped = true; // No exception occurred
} catch (DebugException de) {
if (shouldLogHCRException(de)) {
ms.merge(de.getStatus());
}
}
}
target.removeOutOfSynchTypes(qualifiedNamesToReplace);
if (target.supportsJDKHotCodeReplace()) {
redefineTypesJDK(target, resourcesToReplace,
qualifiedNamesToReplace);
} else if (target.supportsJ9HotCodeReplace()) {
redefineTypesJ9(target, qualifiedNamesToReplace);
}
if (containsObsoleteMethods(target)) {
fireObsoleteMethods(target);
}
try {
if (target.canPopFrames() && framesPopped) {
// Second half of JDK 1.4 drop to frame support:
// All affected frames have been popped and the classes
// have been reloaded. Step into the first changed
// frame of each affected thread.
// must re-set 'is doing HCR' to be able to step
target.setIsPerformingHotCodeReplace(false);
attemptStepIn(poppedThreads);
} else {
// J9 drop to frame support:
// After redefining classes, drop to frame
attemptDropToFrame(target, resourcesToReplace,
qualifiedNamesToReplace);
}
} catch (DebugException de) {
if (shouldLogHCRException(de)) {
ms.merge(de.getStatus());
}
}
fireHCRSucceeded(target);
} catch (DebugException de) {
// target update failed
fireHCRFailed(target, de);
}
// also re-set 'is doing HCR' here in case HCR failed
target.setIsPerformingHotCodeReplace(false);
target.fireChangeEvent(DebugEvent.CONTENT);
}
if (!ms.isOK()) {
JDIDebugPlugin.log(ms);
}
fDeltaCache.clear();