private static boolean isCloseable(Exprent exp) {
    if (exp instanceof InvocationExprent) {
      InvocationExprent invocExp = (InvocationExprent)exp;
      if (invocExp.getName().equals("close") && invocExp.getStringDescriptor().equals("()V")) {
        if (invocExp.getInstance() != null && invocExp.getInstance() instanceof VarExprent) {
          return DecompilerContext.getStructContext().instanceOf(invocExp.getClassname(), "java/lang/AutoCloseable");
        }
      }
    }

    return false;
  }
Processes try catch statements to turns them into try-with-resources statements wherever possible.
Including the entire classpath is generally needed for this to work as it needs to know which classes implement AutoCloseable.

@author ForgeFlower devs, SuperCoder79
src/org/jetbrains/java/decompiler/modules/decompiler/TryWithResourcesProcessor.java