void (String message, Throwable t) { try { Class<?> logger = loadClass("com.intellij.openapi.diagnostic.Logger"); MethodHandles.Lookup lookup = MethodHandles.lookup(); Object instance = lookup.findStatic(logger, "getInstance", MethodType.methodType(logger, Class.class)).invoke(getClass()); lookup.findVirtual(logger, "error", MethodType.methodType(void.class, String.class, Throwable.class)) .bindTo(instance) .invokeExact(message, t); } catch (Throwable tt) { t.addSuppressed(tt); System.err.println(getClass().getName() + ": " + message); t.printStackTrace(System.err); } }