private void install(MirrorEventRequest request, Shadow.Kind kind, RequestContext context) { world.showMessage(IMessage.DEBUG, request.toString(), null, null); request.putProperty("for advice", advice); request.putProperty(SHADOW_KIND_PROPERTY_KEY, kind); world.vm.dispatch().addCallback(request, callback); if (OPTIMIZE_CFLOW && context.cflowCounterGuard != null) { // If guarded by a !cflow(...) pointcut, register this request so that the // cflowEntry advice will enable and disable it as the cflow pointcut is entered and left. List<MirrorEventRequest> guardedRequests = cflowGuardedRequests.get(context.cflowCounterGuard); if (guardedRequests == null) { guardedRequests = new ArrayList<MirrorEventRequest>(); cflowGuardedRequests.put(context.cflowCounterGuard, guardedRequests); } guardedRequests.add(request); } else { // Otherwise enable it unconditionally request.enable(); } }
private void installRequest(RequestContext context) { AdviceKind adviceKind = advice.getKind(); for (final Shadow.Kind kind : Shadow.toSet(context.kinds)) { switch (kind.bit) { case (Shadow.MethodExecutionBit): case (Shadow.MethodCallBit): // If there are no filters at all, it's much more efficient to create single request if (context.thisFilters.isEmpty()) { if (adviceKind == AdviceKind.Before || adviceKind.isCflow()) { addFiltersAndInstall( manager.createMethodMirrorHandlerRequest(), context.thisFilters, kind, context); } if (adviceKind.isAfter()) { addFiltersAndInstall( manager.createMethodMirrorHandlerRequest(), context.thisFilters, kind, context); } if (adviceKind == AdviceKind.Around) { addFiltersAndInstall( manager.createMethodMirrorHandlerRequest(), context.thisFilters, kind, context); } } else { installMethodRequests(kind, context); } break; case (Shadow.ConstructorExecutionBit): case (Shadow.ConstructorCallBit): if (adviceKind == AdviceKind.Before || adviceKind.isCflow()) { addFiltersAndInstall( manager.createConstructorMirrorHandlerRequest(), context.thisFilters, kind, context); } if (adviceKind.isAfter()) { addFiltersAndInstall( manager.createConstructorMirrorHandlerRequest(), context.thisFilters, kind, context); } if (adviceKind == AdviceKind.Around) { addFiltersAndInstall( manager.createConstructorMirrorHandlerRequest(), context.thisFilters, kind, context); } break; case (Shadow.FieldSetBit): case (Shadow.FieldGetBit): installFieldRequests(kind, context); break; case Shadow.SynchronizationLockBit: case Shadow.SynchronizationUnlockBit: installSynchronizationRequests(kind, context); break; case Shadow.AdviceExecutionBit: case Shadow.InitializationBit: case Shadow.PreInitializationBit: case Shadow.ExceptionHandlerBit: world.showMessage(IMessage.WARNING, "Unsupported pointcut kind: " + kind, null, null); break; } } }