/** * Clears the registry (use only in tests!). */ public static void clear() { if (!Debug.isUnitTest()) throw new IllegalStateException("Must only be called in unit tests"); if (registry instanceof LocalActorRegistry) ((LocalActorRegistry) registry).clear(); else throw new UnsupportedOperationException(); } }
@SuppressWarnings("WeakerAccess") public boolean shouldInstrument(String className) { if (className != null) { className = className.replace('.', '/'); if (className.startsWith("co/paralleluniverse/fibers/instrument/") && !Debug.isUnitTest()) return false; if (className.equals(Classes.FIBER_CLASS_NAME) || className.startsWith(Classes.FIBER_CLASS_NAME + '$')) return false; if (className.equals(Classes.STACK_NAME)) return false; if (className.startsWith("org/objectweb/asm/") || className.startsWith("co/paralleluniverse/asm/")) return false; if (className.startsWith("org/gradle/")) return false; if (className.startsWith("org/netbeans/lib/")) return false; if (className.startsWith("java/lang/") || (!allowJdkInstrumentation && MethodDatabase.isJDK(className))) return false; if (isExcluded(className)) return false; } return true; }
@SuppressWarnings("CallToThreadDumpStack") public static void exit(int code, Throwable t, String filename) { final Strand currentStrand = Strand.currentStrand(); if (flightRecorder != null) { flightRecorder.record(1, "DEBUG EXIT REQUEST ON STRAND " + currentStrand + ": " + Arrays.toString(currentStrand.getStackTrace())); if (t != null) flightRecorder.record(1, "CAUSED BY " + t + ": " + Arrays.toString(currentStrand.getStackTrace())); flightRecorder.stop(); } if (requestShutdown.compareAndSet(false, true)) { System.err.println("DEBUG EXIT REQUEST ON STRAND " + currentStrand + (currentStrand.isFiber() ? " (THREAD " + Thread.currentThread() + ")" : "") + ": SHUTTING DOWN THE JVM."); Thread.dumpStack(); if (t != null) { System.err.println("CAUSED BY " + t); t.printStackTrace(); } dumpRecorder(filename); if (!isUnitTest()) // Calling System.exit() in gradle unit tests breaks gradle System.exit(code); } }
if (!ok) { final String str = "Uninstrumented whole methods ('**') or single calls ('!!') detected: " + stackTrace; if (Debug.isUnitTest()) throw new VerifyInstrumentationException(str); System.err.println("WARNING: " + str);