in src/org/jetbrains/java/decompiler/main/rels/ClassWrapper.java [40:140]
public void init() {
DecompilerContext.setProperty(DecompilerContext.CURRENT_CLASS, classStruct);
DecompilerContext.setProperty(DecompilerContext.CURRENT_CLASS_WRAPPER, this);
DecompilerContext.setProperty(DecompilerContext.CURRENT_CLASS_NODE, DecompilerContext.getClassProcessor().getMapRootClasses().get(classStruct.qualifiedName));
DecompilerContext.getLogger().startClass(classStruct.qualifiedName);
boolean testMode = DecompilerContext.getOption(IFernflowerPreferences.UNIT_TEST_MODE);
CancellationManager cancellationManager = DecompilerContext.getCancellationManager();
for (StructMethod mt : classStruct.getMethods()) {
DecompilerContext.getLogger().startMethod(mt.getName() + " " + mt.getDescriptor());
MethodDescriptor md = MethodDescriptor.parseDescriptor(mt, null);
VarProcessor varProc = new VarProcessor(classStruct, mt, md);
DecompilerContext.startMethod(varProc);
VarNamesCollector vc = varProc.getVarNamesCollector();
CounterContainer counter = DecompilerContext.getCounterContainer();
RootStatement root = null;
boolean isError = false;
String customErrorMessage = null;
try {
cancellationManager.checkCanceled();
if (mt.containsCode()) {
if (testMode) {
root = MethodProcessorRunnable.codeToJava(classStruct, mt, md, varProc);
}
else {
DecompilerContext context = DecompilerContext.getCurrentContext();
try {
cancellationManager.startMethod(classStruct.qualifiedName, mt.getName());
MethodProcessorRunnable mtProc =
new MethodProcessorRunnable(classStruct, mt, md, varProc, DecompilerContext.getCurrentContext());
mtProc.run();
cancellationManager.checkCanceled();
root = mtProc.getResult();
}
finally {
DecompilerContext.setCurrentContext(context);
cancellationManager.finishMethod(classStruct.qualifiedName, mt.getName());
}
}
}
else {
int varIndex = 0;
if (!mt.hasModifier(CodeConstants.ACC_STATIC)) {
varProc.getThisVars().put(new VarVersion(0, 0), classStruct.qualifiedName);
varProc.setVarName(new VarVersion(0, 0), vc.getFreeName(0));
varIndex = 1;
}
for (int i = 0; i < md.params.length; i++) {
varProc.setVarName(new VarVersion(varIndex, 0), vc.getFreeName(varIndex));
varIndex += md.params[i].getStackSize();
}
}
}
catch (LimitContainer.LimitExceededDecompilerException e) {
String message =
"Method " + mt.getName() + " " + mt.getDescriptor() + " in class " + classStruct.qualifiedName + " couldn't be decompiled.";
DecompilerContext.getLogger().writeMessage(message, IFernflowerLogger.Severity.WARN);
isError = true;
customErrorMessage = e.getMessage();
}
catch (CancellationManager.TimeExceedException e) {
String message = "Processing time limit exceeded for method " + mt.getName() + ", execution interrupted.";
DecompilerContext.getLogger().writeMessage(message, IFernflowerLogger.Severity.ERROR);
isError = true;
}
catch (CancellationManager.CanceledException e) {
throw e;
}
catch (Throwable t) {
String message =
"Method " + mt.getName() + " " + mt.getDescriptor() + " in class " + classStruct.qualifiedName + " couldn't be decompiled.";
DecompilerContext.getLogger().writeMessage(message, IFernflowerLogger.Severity.WARN, t);
isError = true;
}
MethodWrapper methodWrapper = new MethodWrapper(root, varProc, mt, counter);
methodWrapper.decompiledWithErrors = isError;
methodWrapper.decompiledWithErrorsMessage = customErrorMessage;
methods.addWithKey(methodWrapper, InterpreterUtil.makeUniqueKey(mt.getName(), mt.getDescriptor()));
if (!isError) {
// rename vars so that no one has the same name as a field
VarNamesCollector namesCollector = new VarNamesCollector();
classStruct.getFields().forEach(f -> namesCollector.addName(f.getName()));
varProc.refreshVarNames(namesCollector);
applyParameterNames(mt, md, varProc); // if parameter names are present and should be used
applyDebugInfo(mt, varProc, methodWrapper); // if debug information is present and should be used
}
DecompilerContext.getLogger().endMethod();
}
DecompilerContext.getLogger().endClass();
}