static CloseGuard get() { Method getMethod; Method openMethod; Method warnIfOpenMethod; try { Class<?> closeGuardClass = Class.forName("dalvik.system.CloseGuard"); getMethod = closeGuardClass.getMethod("get"); openMethod = closeGuardClass.getMethod("open", String.class); warnIfOpenMethod = closeGuardClass.getMethod("warnIfOpen"); } catch (Exception ignored) { getMethod = null; openMethod = null; warnIfOpenMethod = null; } return new CloseGuard(getMethod, openMethod, warnIfOpenMethod); } }
static CloseGuard get() { Method getMethod; Method openMethod; Method warnIfOpenMethod; try { Class<?> closeGuardClass = Class.forName("dalvik.system.CloseGuard"); getMethod = closeGuardClass.getMethod("get"); openMethod = closeGuardClass.getMethod("open", String.class); warnIfOpenMethod = closeGuardClass.getMethod("warnIfOpen"); } catch (Exception ignored) { getMethod = null; openMethod = null; warnIfOpenMethod = null; } return new CloseGuard(getMethod, openMethod, warnIfOpenMethod); } }
static CloseGuard get() { Method getMethod; Method openMethod; Method warnIfOpenMethod; try { Class<?> closeGuardClass = Class.forName("dalvik.system.CloseGuard"); getMethod = closeGuardClass.getMethod("get"); openMethod = closeGuardClass.getMethod("open", String.class); warnIfOpenMethod = closeGuardClass.getMethod("warnIfOpen"); } catch (Exception ignored) { getMethod = null; openMethod = null; warnIfOpenMethod = null; } return new CloseGuard(getMethod, openMethod, warnIfOpenMethod); } }
@Override public Object getStackTraceForCloseable(String closer) { return closeGuard.createAndOpen(closer); }
@Override public Object getStackTraceForCloseable(String closer) { return closeGuard.createAndOpen(closer); }
@Override public void logCloseableLeak(String message, Object stackTrace) { boolean reported = closeGuard.warnIfOpen(stackTrace); if (!reported) { // Unable to report via CloseGuard. As a last-ditch effort, send it to the logger. log(WARN, message, null); } }
@Override public void logCloseableLeak(String message, Object stackTrace) { boolean reported = closeGuard.warnIfOpen(stackTrace); if (!reported) { // Unable to report via CloseGuard. As a last-ditch effort, send it to the logger. log(WARN, message, null); } }
@Override public Object getStackTraceForCloseable(String closer) { return closeGuard.createAndOpen(closer); }
@Override public void logCloseableLeak(String message, Object stackTrace) { boolean reported = closeGuard.warnIfOpen(stackTrace); if (!reported) { // Unable to report via CloseGuard. As a last-ditch effort, send it to the logger. log(WARN, message, null); } }
static CloseGuard get() { Method getMethod; Method openMethod; Method warnIfOpenMethod; try { Class<?> closeGuardClass = Class.forName("dalvik.system.CloseGuard"); getMethod = closeGuardClass.getMethod("get"); openMethod = closeGuardClass.getMethod("open", String.class); warnIfOpenMethod = closeGuardClass.getMethod("warnIfOpen"); } catch (Exception ignored) { getMethod = null; openMethod = null; warnIfOpenMethod = null; } return new CloseGuard(getMethod, openMethod, warnIfOpenMethod); } }
@Override public Object getStackTraceForCloseable(String closer) { return closeGuard.createAndOpen(closer); }
@Override public void logCloseableLeak(String message, Object stackTrace) { boolean reported = closeGuard.warnIfOpen(stackTrace); if (!reported) { // Unable to report via CloseGuard. As a last-ditch effort, send it to the logger. log(WARN, message, null); } }