@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("startupLogger") private static void logAgentDirsLockedException(File confDir, File lockFile, Map<String, String> properties) {
@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); }
@GuardedBy("mainThreadContext") @RequiresNonNull("auxThreadContexts") private boolean allowAnotherAuxThreadContextWithTraceEntries() { int unmergedCount = auxThreadContexts.size();
@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 void addMixin(ClassNode mixinClassNode) { List<FieldNode> fieldNodes = mixinClassNode.fields; for (FieldNode fieldNode : fieldNodes) { if (!Modifier.isTransient(fieldNode.access)) { // this is needed to avoid serialization issues (even if the new field is // serializable, this can still cause issues in a cluster if glowroot is not // deployed on all nodes) throw new IllegalStateException( "@Mixin fields must be marked transient: " + mixinClassNode.name); } fieldNode.accept(this); } List<MethodNode> methodNodes = mixinClassNode.methods; for (MethodNode mn : methodNodes) { if (mn.name.equals("<init>")) { continue; } String[] exceptions = Iterables.toArray(mn.exceptions, String.class); MethodVisitor mv = cw.visitMethod(mn.access, mn.name, mn.desc, mn.signature, exceptions); mn.accept(new MethodRemapper(mv, new SimpleRemapper(mixinClassNode.name, type.getInternalName()))); } }
@RequiresNonNull("methodMetaInternalName") private void generateMethodMetaConstructor(ClassWriter cw) { MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>",
@RequiresNonNull("methodMetaInternalName") private void addOnBeforeMethod(ClassWriter cw) { MethodVisitor mv = visitOnBeforeMethod(cw, "Lorg/glowroot/agent/plugin/api/TraceEntry;");
@RequiresNonNull({"threadContextHolderLocal", "threadContextLocal"}) private void loadOptionalThreadContext(String nestingGroup, String suppressionKey, Object... stack) { loadMaybeNullThreadContext(stack); Label label = new Label(); visitJumpInsn(IFNONNULL, label); loadLocal(threadContextHolderLocal); if (nestingGroup.isEmpty()) { mv.visitLdcInsn(0); } else { mv.visitLdcInsn(getNestingGroupId(nestingGroup)); } if (suppressionKey.isEmpty()) { mv.visitLdcInsn(0); } else { mv.visitLdcInsn(getSuppressionKeyId(suppressionKey)); } visitMethodInsn(INVOKESTATIC, bytecodeType.getInternalName(), "createOptionalThreadContext", "(" + fastThreadContextThreadLocalHolderType.getDescriptor() + "II)" + threadContextPlusType.getDescriptor(), false); storeLocal(threadContextLocal); visitLabel(label); visitImplicitFrame(stack); loadLocal(threadContextLocal); }
@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); }