@RequiresNonNull("player") private Notification updateNotification(@Nullable Bitmap bitmap) { Notification notification = createNotification(player, bitmap); notificationManager.notify(notificationId, notification); return notification; }
@RequiresNonNull("player") protected EventTime generateEventTime( Timeline timeline, int windowIndex, @Nullable MediaPeriodId mediaPeriodId) {
@GuardedBy("mainThreadContext") @RequiresNonNull("auxThreadContexts") private Iterable<ThreadContextImpl> getUnmergedAuxThreadContext() { if (unmergeableAuxThreadContexts == null) { if (unmergedLimitExceededAuxThreadContexts == null) { return auxThreadContexts; } else { return Iterables.concat(auxThreadContexts, unmergedLimitExceededAuxThreadContexts); } } else if (unmergedLimitExceededAuxThreadContexts == null) { return Iterables.concat(unmergeableAuxThreadContexts, auxThreadContexts); } else { return Iterables.concat(unmergeableAuxThreadContexts, auxThreadContexts, unmergedLimitExceededAuxThreadContexts); } }
@RequiresNonNull("threadAllocatedBytes") private long getAllocatedBytesInternal() { long allocatedBytes = threadAllocatedBytes.getThreadAllocatedBytesSafely(threadId); if (startingAllocatedBytes != -1 && allocatedBytes != -1) { return allocatedBytes - startingAllocatedBytes; } else { return -1; } } }
@RequiresNonNull("type") private MethodVisitor visitMethodWithAdvice(MethodVisitor mv, int access, String name, String descriptor, List<Advice> matchingAdvisors) { // FIXME remove superseded advisors return newWeavingMethodVisitor(access, name, descriptor, matchingAdvisors, mv); }
@RequiresNonNull("methodMetaInternalName") private void generateMethodMetaGetter(ClassWriter cw, String fieldName, String methodName) { MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, methodName, "()Lorg/glowroot/agent/bytecode/api/MessageTemplate;", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, methodMetaInternalName, fieldName, "Lorg/glowroot/agent/bytecode/api/MessageTemplate;"); mv.visitInsn(ARETURN); mv.visitMaxs(0, 0); mv.visitEnd(); }
@RequiresNonNull("type") private WeavingMethodVisitor newWeavingMethodVisitor(int access, String name, String descriptor, List<Advice> matchingAdvisors, MethodVisitor mv) { Integer methodMetaUniqueNum = collectMetasAtMethod(matchingAdvisors, name, descriptor); usedAdvisors.addAll(matchingAdvisors); return new WeavingMethodVisitor(mv, frames, access, name, descriptor, type, matchingAdvisors, metaHolderInternalName, methodMetaUniqueNum, loader == null); }
@RequiresNonNull({"type", "metaHolderInternalName"}) private void handleMetaHolders() { if (loader == null) { initializeBoostrapMetaHolders(); } else { try { generateMetaHolder(); } catch (Exception e) { // this will terminate weaving and get logged by WeavingClassFileTransformer throw new RuntimeException(e); } } }
@RequiresNonNull({"metaHolderInternalName", "methodMetaGroupUniqueNum"}) private void loadMethodMeta(AdviceParameter parameter) { Type methodMetaFieldType = parameter.type(); String methodMetaFieldName = "glowroot$method$meta$" + methodMetaGroupUniqueNum + '$' + methodMetaFieldType.getInternalName().replace('/', '$'); if (bootstrapClassLoader) { int index = BootstrapMetaHolders.reserveMethodMetaHolderIndex(metaHolderInternalName, methodMetaFieldName); push(index); visitMethodInsn(INVOKESTATIC, bytecodeType.getInternalName(), "getMethodMeta", "(I)Ljava/lang/Object;", false); mv.visitTypeInsn(CHECKCAST, methodMetaFieldType.getInternalName()); } else { visitFieldInsn(GETSTATIC, metaHolderInternalName, methodMetaFieldName, methodMetaFieldType.getDescriptor()); } }
@RequiresNonNull("metaHolderInternalName") private void loadClassMeta(AdviceParameter parameter) { Type classMetaFieldType = parameter.type(); String classMetaFieldName = "glowroot$class$meta$" + classMetaFieldType.getInternalName().replace('/', '$'); if (bootstrapClassLoader) { int index = BootstrapMetaHolders.reserveClassMetaHolderIndex(metaHolderInternalName, classMetaFieldName); push(index); visitMethodInsn(INVOKESTATIC, bytecodeType.getInternalName(), "getClassMeta", "(I)Ljava/lang/Object;", false); mv.visitTypeInsn(CHECKCAST, classMetaFieldType.getInternalName()); } else { visitFieldInsn(GETSTATIC, metaHolderInternalName, classMetaFieldName, classMetaFieldType.getDescriptor()); } }
@RequiresNonNull("threadContextLocal") private void checkSuppressibleUsingKey(String suppressibleUsingKey, Label otherEnabledFactorsDisabledEnd) { loadLocal(threadContextLocal); visitMethodInsn(INVOKEINTERFACE, threadContextPlusType.getInternalName(), "getCurrentSuppressionKeyId", "()I", true); int suppressionKeyId = getSuppressionKeyId(suppressibleUsingKey); mv.visitLdcInsn(suppressionKeyId); visitJumpInsn(IF_ICMPEQ, otherEnabledFactorsDisabledEnd); }
@RequiresNonNull("owner") private ImmutableInstrumentationConfig.Builder startBuilder() { Type type = Type.getObjectType(owner); Type[] argumentTypes = Type.getArgumentTypes(descriptor); ImmutableInstrumentationConfig.Builder builder = ImmutableInstrumentationConfig.builder() .className(type.getClassName()) .methodName(methodName); for (Type argumentType : argumentTypes) { builder.addMethodParameterTypes(argumentType.getClassName()); } return builder; } }
@RequiresNonNull("threadContextLocal") private void updateSuppressionKeyId(int prevSuppressionKeyIdLocal, String suppressionKey) { loadLocal(threadContextLocal); visitMethodInsn(INVOKEINTERFACE, threadContextPlusType.getInternalName(), "getCurrentSuppressionKeyId", "()I", true); storeLocal(prevSuppressionKeyIdLocal); int suppressionKeyId = getSuppressionKeyId(suppressionKey); loadLocal(threadContextLocal); mv.visitLdcInsn(suppressionKeyId); visitMethodInsn(INVOKEINTERFACE, threadContextPlusType.getInternalName(), "setCurrentSuppressionKeyId", "(I)V", true); }
@RequiresNonNull("type") private MethodVisitor visitInitWithMixins(int access, String name, String descriptor, @Nullable String signature, String /*@Nullable*/ [] exceptions, List<Advice> matchingAdvisors) { MethodVisitor mv = cw.visitMethod(access, name, descriptor, signature, exceptions); mv = new InitMixins(mv, access, name, descriptor, mixinTypes, type); for (Advice advice : matchingAdvisors) { if (!advice.pointcut().timerName().isEmpty()) { logger.warn("cannot add timer to <clinit> or <init> methods at this time"); break; } } return newWeavingMethodVisitor(access, name, descriptor, matchingAdvisors, mv); }
@RequiresNonNull("threadContextLocal") private void checkAndUpdateNestingGroupId(int prevNestingGroupIdLocal, String nestingGroup, Label otherEnabledFactorsDisabledEnd) { loadLocal(threadContextLocal); visitMethodInsn(INVOKEINTERFACE, threadContextPlusType.getInternalName(), "getCurrentNestingGroupId", "()I", true); dup(); storeLocal(prevNestingGroupIdLocal); int nestingGroupId = getNestingGroupId(nestingGroup); mv.visitLdcInsn(nestingGroupId); visitJumpInsn(IF_ICMPEQ, otherEnabledFactorsDisabledEnd); loadLocal(threadContextLocal); mv.visitLdcInsn(nestingGroupId); visitMethodInsn(INVOKEINTERFACE, threadContextPlusType.getInternalName(), "setCurrentNestingGroupId", "(I)V", true); }
@RequiresNonNull("asyncTimer") private void stopAsync() { long endTick = ticker.read(); if (extendedTimer == null) { endQueryData(endTick); } else { stopSync(endTick); } asyncTimer.end(endTick); }
@RequiresNonNull("asyncTimer") private void stopAsync() { long endTick = ticker.read(); if (extendedTimer == null) { endQueryData(endTick); // it is not helpful to capture stack trace at end of async trace entry since it is // ended by a different thread (and by not capturing, it reduces thread safety // needs) } else { stopSync(endTick); } asyncTimer.end(endTick); }
@GuardedBy("mainThreadContext") @RequiresNonNull({"alreadyMergedAuxThreadTimers", "alreadyMergedAuxThreadStats", "alreadyMergedAuxQueries", "alreadyMergedAuxServiceCalls"}) private void mergeAux(ThreadContextImpl mergeableAuxThreadContext) { alreadyMergedAuxThreadTimers.mergeRootTimer(mergeableAuxThreadContext.getRootTimer()); alreadyMergedAuxThreadStats.mergeThreadStats(mergeableAuxThreadContext.getThreadStats()); mergeableAuxThreadContext.mergeQueriesInto(alreadyMergedAuxQueries); mergeableAuxThreadContext.mergeServiceCallsInto(alreadyMergedAuxServiceCalls); }
@RequiresNonNull({"threadContextHolderLocal", "threadContextLocal"}) private void loadMaybeNullThreadContext(Object... stack) { loadLocal(threadContextHolderLocal); Label label = new Label(); visitJumpInsn(IFNONNULL, label); visitMethodInsn(INVOKESTATIC, bytecodeType.getInternalName(), "getCurrentThreadContextHolder", "()" + fastThreadContextThreadLocalHolderType.getDescriptor(), false); storeLocal(threadContextHolderLocal); visitLabel(label); visitImplicitFrame(stack); loadLocal(threadContextHolderLocal); visitMethodInsn(INVOKEVIRTUAL, fastThreadContextThreadLocalHolderType.getInternalName(), "get", "()" + threadContextPlusType.getDescriptor(), false); dup(); storeLocal(threadContextLocal); }
@RequiresNonNull("startupLogger") private static void start(Directories directories, Map<String, String> properties, @Nullable Instrumentation instrumentation, @Nullable PreCheckClassFileTransformer preCheckClassFileTransformer) throws Exception { String version = Version.getVersion(MainEntryPoint.class); startupLogger.info("Glowroot version: {}", version); startupLogger.info("Java version: {}", getJavaVersion()); startupLogger.info("Java args: {}", getJvmArgs()); glowrootAgentInit = createGlowrootAgentInit(directories, properties, instrumentation); glowrootAgentInit.init(directories.getPluginsDir(), directories.getConfDirs(), directories.getLogDir(), directories.getTmpDir(), directories.getGlowrootJarFile(), properties, instrumentation, preCheckClassFileTransformer, version, checkNotNull(directories.getAgentDirLockCloseable())); }