@@ -0,0 +1,1715 @@
+import java.util.Map;%0Aimport java.util.concurrent.ConcurrentHashMap;%0Aimport java.util.concurrent.atomic.AtomicBoolean;%0A%0Aimport com.sun.btrace.annotations.BTrace;%0Aimport com.sun.btrace.annotations.OnMethod;%0Aimport com.sun.btrace.annotations.Self;%0A%0Aimport static com.sun.btrace.BTraceUtils.Collections.size;%0Aimport static com.sun.btrace.BTraceUtils.identityHashCode;%0Aimport static com.sun.btrace.BTraceUtils.jstackStr;%0Aimport static com.sun.btrace.BTraceUtils.println;%0A%0A/**%0A * Traces unclosed Jar files%0A */%0A@BTrace(unsafe = true)%0Apublic class JarFileTracer %7B%0A%09private static Map%3CInteger, String%3E openFiles = new ConcurrentHashMap%3C%3E();%0A%09private static AtomicBoolean buildRunning = new AtomicBoolean(false);%0A%0A%09@OnMethod(%0A%09%09%09clazz = %22java.util.jar.JarFile%22,%0A%09%09%09method = %22%3Cinit%3E%22)%0A%09public static void onGetInputStream(@Self Object thisObject) %7B%0A%09%09openFiles.put(identityHashCode(thisObject), jstackStr());%0A%09%7D%0A%0A%09@OnMethod(%0A%09%09%09clazz = %22java.util.jar.JarFile%22,%0A%09%09%09method = %22close%22)%0A%09public static void onClose(@Self Object thisObject) %7B%0A%09%09openFiles.remove(identityHashCode(thisObject));%0A%09%7D%0A%0A%09@OnMethod(clazz = %22+org.gradle.BuildListener%22,%0A%09%09%09method = %22buildStarted%22)%0A%09public static void buildStarted() %7B%0A%09%09buildRunning.set(true);%0A%09%7D%0A%0A%09@OnMethod(clazz = %22+org.gradle.BuildListener%22,%0A%09%09%09method = %22buildFinished%22)%0A%09public static void buildFinished() %7B%0A%09%09if (buildRunning.compareAndSet(true, false)) %7B%0A%09%09%09println(%22--------------------------------------------------%22);%0A%09%09%09if (size(openFiles) %3E 0) %7B%0A%09%09%09%09for (String stackTrace : openFiles.values()) %7B%0A%09%09%09%09%09println(stackTrace);%0A%09%09%09%09%09println();%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%09else %7B%0A%09%09%09%09println(%22No unclosed streams.%22);%0A%09%09%09%7D%0A%09%09%09println(%22--------------------------------------------------%22);%0A%09%09%7D%0A%09%7D%0A%7D%0A

Add probe for tracing open Jar files