getCurrentEngine();
if (debuggerEngine == null) {
logger.println("NetBeans: No debugging sessions was found.");
return;
}
JPDADebugger debugger = debuggerEngine.lookupFirst(null, JPDADebugger.class);
if (debugger == null) {
logger.println("NetBeans: Current debugger is not JPDA one.");
return;
}
if (!debugger.canFixClasses()) {
logger.println("NetBeans: The debugger does not support Fix action.");
return;
}
if (debugger.getState() == JPDADebugger.STATE_DISCONNECTED) {
logger.println("NetBeans: The debugger is not running");
return;
}
Map<String, byte[]> map = new HashMap<>();
EditorContext editorContext = DebuggerManager.
getDebuggerManager().lookupFirst(null, EditorContext.class);
String clazz = classname.replace('.', '/') + ".class"; //NOI18N
GradleClassPathProvider prv = project.getLookup().lookup(GradleClassPathProvider.class);
FileObject fo2 = prv.getBuildOutputClassPaths().findResource(clazz);
if (fo2 != null) {
try {
String basename = fo2.getName();
for (FileObject classfile : fo2.getParent().getChildren()) {
String basename2 = classfile.getName();
if (/*#220338*/!"class".equals(classfile.getExt()) || (!basename2.equals(basename) && !basename2.startsWith(basename + '$'))) {
continue;
}
String url = classToSourceURL(classfile, logger);
if (url != null) {
editorContext.updateTimeStamp(debugger, url);
}
map.put(classname + basename2.substring(basename.length()), classfile.asBytes());
}
} catch (IOException ex) {
NbGradleProject gradleProject = project.getLookup().lookup(NbGradleProject.class);
if (gradleProject != null) {
gradleProject.displayError("Unexpected error.", ex);
}
else {
throw new IllegalStateException("Unexpected error in an unexpected project type.", ex);
}
}
}
logger.println("NetBeans: classes to reload: " + map.keySet());
if (map.isEmpty()) {
logger.println("NetBeans: No class to reload");
return;
}
String error = null;
try {
debugger.fixClasses(map);
} catch (UnsupportedOperationException uoex) {
error = "The virtual machine does not support this operation: " + uoex.getLocalizedMessage();
} catch (NoClassDefFoundError ncdfex) {
error = "The bytes don't correspond to the class type (the names don't match): " + ncdfex.getLocalizedMessage();
} catch (VerifyError ver) {