kandi background
Explore Kits

dexposed | dexposed enable 'god' mode for single android application. | Aspect Oriented library

 by   alibaba Java Version: Current License: No License

 by   alibaba Java Version: Current License: No License

Download this library from

kandi X-RAY | dexposed Summary

dexposed is a Java library typically used in Programming Style, Aspect Oriented applications. dexposed has no vulnerabilities and it has medium support. However dexposed has 8 bugs and it build file is not available. You can download it from GitHub.
Dexposed is a powerful yet non-invasive runtime AOP (Aspect-oriented Programming) framework for Android app development, based on the work of open-source Xposed framework project. The AOP of Dexposed is implemented purely non-invasive, without any annotation processor, weaver or bytecode rewriter. The integration is as simple as loading a small JNI library in just one line of code at the initialization phase of your app. Not only the code of your app, but also the code of Android framework that running in your app process can be hooked. This feature is extremely useful in Android development as we developers heavily rely on the fragmented old versions of Android platform (SDK). Together with dynamic class loading, a small piece of compiled Java AOP code can be loaded into the running app, effectively altering the behavior of the target app without restart.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • dexposed has a medium active ecosystem.
  • It has 4365 star(s) with 1064 fork(s). There are 400 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 21 open issues and 53 have been closed. On average issues are closed in 171 days. There are no pull requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of dexposed is current.
dexposed Support
Best in #Aspect Oriented
Average in #Aspect Oriented
dexposed Support
Best in #Aspect Oriented
Average in #Aspect Oriented

quality kandi Quality

  • dexposed has 8 bugs (1 blocker, 0 critical, 3 major, 4 minor) and 190 code smells.
dexposed Quality
Best in #Aspect Oriented
Average in #Aspect Oriented
dexposed Quality
Best in #Aspect Oriented
Average in #Aspect Oriented

securitySecurity

  • dexposed has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • dexposed code analysis shows 0 unresolved vulnerabilities.
  • There are 6 security hotspots that need review.
dexposed Security
Best in #Aspect Oriented
Average in #Aspect Oriented
dexposed Security
Best in #Aspect Oriented
Average in #Aspect Oriented

license License

  • dexposed does not have a standard license declared.
  • Check the repository for any license declaration and review the terms closely.
  • Without a license, all rights are reserved, and you cannot use the library in your applications.
dexposed License
Best in #Aspect Oriented
Average in #Aspect Oriented
dexposed License
Best in #Aspect Oriented
Average in #Aspect Oriented

buildReuse

  • dexposed releases are not available. You will need to build from source code and install.
  • dexposed has no build file. You will be need to create the build yourself to build the component from source.
  • Installation instructions are not available. Examples and code snippets are available.
  • dexposed saves you 1031 person hours of effort in developing the same functionality from scratch.
  • It has 2340 lines of code, 203 functions and 31 files.
  • It has medium code complexity. Code complexity directly impacts maintainability of the code.
dexposed Reuse
Best in #Aspect Oriented
Average in #Aspect Oriented
dexposed Reuse
Best in #Aspect Oriented
Average in #Aspect Oriented
Top functions reviewed by kandi - BETA

kandi has reviewed dexposed and discovered the below as its top functions. This is intended to give you an instant insight into dexposed implemented functionality, and help decide if they suit your requirements.

  • Handle the given method invocation .
  • Load all callbacks for the given apk file .
  • Checks to see if the product is on the CPU
  • Implementation of the hook
  • Finds an exact method for a given class .
  • Open the patch apk button .
  • Transforms a class name into a canonical class name .
  • Sort by priority .
  • Removes the specified element from the list .
  • Callback method .

dexposed Key Features

dexposed enable 'god' mode for single android application.

Integration

copy iconCopydownload iconDownload
	dependencies {
	    compile 'com.taobao.android:dexposed:0.1.1@aar'
	}

Basic usage

copy iconCopydownload iconDownload
        // Target class, method with parameter types, followed by the hook callback (XC_MethodHook).
		DexposedBridge.findAndHookMethod(Activity.class, "onCreate", Bundle.class, new XC_MethodHook() {
        
            // To be invoked before Activity.onCreate().
			@Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
				// "thisObject" keeps the reference to the instance of target class.
				Activity instance = (Activity) param.thisObject;
        
				// The array args include all the parameters.
				Bundle bundle = (Bundle) param.args[0];
				Intent intent = new Intent();
				// XposedHelpers provide useful utility methods.
				XposedHelpers.setObjectField(param.thisObject, "mIntent", intent);
		
				// Calling setResult() will bypass the original method body use the result as method return value directly.
				if (bundle.containsKey("return"))
					param.setResult(null);
			}
					
			// To be invoked after Activity.onCreate()
			@Override protected void afterHookedMethod(MethodHookParam param) throws Throwable {
		        XposedHelpers.callMethod(param.thisObject, "sampleMethod", 2);
			}
		});

Community Discussions

Trending Discussions on Aspect Oriented
  • @Recover method not intercepted by Spring AOP advice
  • I get java.lang.ClassNotFoundException: org.springframework.web.context.WebApplicationContext at Tomcat webb app
  • Is it Possible to add PostSharp for dynamic compilation using c# compiler
  • Check User Authorization with Aspect Oriented Programming in Asp.Net Core 3.1 Web Api
  • Install AspectJ Eclipse
Trending Discussions on Aspect Oriented

QUESTION

@Recover method not intercepted by Spring AOP advice

Asked 2021-Jun-08 at 03:45

While writing code using Spring/Java and Aspect oriented programing, I'm facing an issue. In the service class, I have the retry method using @Retryable and a recovery method using @Recover.

Each of these 2 methods are attached to Aspects. The Retryable method - "triggerJob" inside TestProcessService is attached to these methods in TestAspect class - beforeTestTriggerJobsAdvice, afterTestTriggerJobsAdvice, onErrorTestTriggerJobsAdvice. They all are working fine and getting triggered at the right time.

PROBLEM STATEMENT: The Recovery method - "recover" inside TestProcessService is attached to these methods in TestAspect class - beforeRecoveryTestJobsAdvice, onErrorRecoveryTestTriggerJobsAdvice, and afterRecoveryTestTriggerJobsAdvice.

BUT NONE OF THESE ASPECT METHODS ARE GETTING CALLED once the code reached the recover method inside TestProcessService.

Here is the code:

SCHEDULER CLASS (triggers the methods inside TEST_MyProcessService class at regular interval)

@Slf4j
@Component
public class TEST_ScheduledProcessPoller {

    private final TEST_MyProcessService MyProcessService;
    private final MyServicesConfiguration MyServicesConfiguration;

    public TEST_ScheduledProcessPoller(TEST_MyProcessService MyProcessService,
                                  MyServicesConfiguration MyServicesConfiguration) {
        this.MyProcessService = MyProcessService;
        this.MyServicesConfiguration = MyServicesConfiguration;
    }

    @Scheduled(cron = "0 0/2 * * * *")
    public void scheduleTaskWithFixedDelay() {
        try {
            log.info("scheduleTaskWithFixedDelay");
            this.triggerMyJobs(true);
        } catch (Exception e) {
            log.error(e.getMessage());
        }
    }

    protected void triggerMyJobs(boolean isDaily) throws Exception {
        log.info("triggerMyJobs");
        MyServiceType serviceType = this.MyServicesConfiguration.getMy();
        this.MyProcessService.triggerJob(serviceType, isDaily, 1L);
    }
}

SERVICE CLASS:

@Slf4j
@Service
public class TEST_MyProcessService {

    @Retryable(maxAttemptsExpression = "${api.retry.limit}", backoff = @Backoff(delayExpression = "${api.retry.max-interval}"))
    public void triggerJob(MyServiceType MyServiceType, boolean isDaily, long eventId) {
        // Some code here that can throw exceptions.
        log.info("triggerJob");
        throw new RuntimeException("triggerJob");
    }

    @Recover
    public void recover(MyServiceType MyServiceType, boolean isDaily, long eventId) {
        log.info("recover");
        // Some code here that can throw exceptions.
        throw new RuntimeException();
    }
}

ASPECT CLASS:

@Component
@Slf4j
public class TEST_MyAspect {

    @Pointcut("execution(* packgName.otherProj.services.TEST_MyProcessService.triggerJob(..))")
    public void MyTriggerJobs() {
    }

    @Pointcut("execution(* packgName.otherProj.services.TEST_MyProcessService.recover(..))")
    public void MyRecoverJobs() {
    }

    @Before("MyTriggerJobs()")
    public void beforeMyTriggerJobsAdvice(JoinPoint joinPoint) {
        log.info("log beforeMyTriggerJobsAdvice");
    }

    @AfterReturning("MyTriggerJobs()")
    public void afterMyTriggerJobsAdvice(JoinPoint joinPoint) {
        log.info("log afterMyTriggerJobsAdvice");
    }

    @AfterThrowing(value = "MyTriggerJobs()", throwing = "error")
    public void onErrorMyTriggerJobsAdvice(JoinPoint joinPoint, Throwable error) {
        log.info("log onErrorMyTriggerJobsAdvice");
    }

    @Before("MyRecoverJobs()")
    public void beforeMyRecoverJobsAdvice(JoinPoint joinPoint) {
        log.info("log beforeMyRecoverJobsAdvice");
    }

    @AfterThrowing(value = "MyRecoverJobs()", throwing = "error")
    public void onErrorRecoveryMyTriggerJobsAdvice(JoinPoint joinPoint, Throwable error) {
        log.info("log onErrorRecoveryMyTriggerJobsAdvice");
    }


    @AfterReturning("MyRecoverJobs()")
    public void afterRecoveryMyTriggerJobsAdvice(JoinPoint joinPoint) {
        log.info("log afterRecoveryMyTriggerJobsAdvice");
    }
}

LOG output:

2021-06-02 20:56:00.016  INFO [,60b7f0602b2ecb0deefc04d6840b6274,eefc04d6840b6274,true] 92605 --- [   scheduling-1] c.c.p.r.c.TEST_ScheduledProcessPoller    : scheduleTaskWithFixedDelay
2021-06-02 20:56:00.016  INFO [,60b7f0602b2ecb0deefc04d6840b6274,eefc04d6840b6274,true] 92605 --- [   scheduling-1] c.c.p.r.c.TEST_ScheduledProcessPoller    : triggerBdaJobs
2021-06-02 20:56:00.051  INFO [,60b7f0602b2ecb0deefc04d6840b6274,eefc04d6840b6274,true] 92605 --- [   scheduling-1] c.c.p.r.component.aspect.TEST_BdaAspect  : log beforeBdaTriggerJobsAdvice
2021-06-02 20:56:00.060  INFO [,60b7f0602b2ecb0deefc04d6840b6274,eefc04d6840b6274,true] 92605 --- [   scheduling-1] c.c.p.r.services.TEST_BdaProcessService  : triggerJob
2021-06-02 20:56:00.061  INFO [,60b7f0602b2ecb0deefc04d6840b6274,eefc04d6840b6274,true] 92605 --- [   scheduling-1] c.c.p.r.component.aspect.TEST_BdaAspect  : log onErrorBdaTriggerJobsAdvice
2021-06-02 20:56:05.065  INFO [,60b7f0602b2ecb0deefc04d6840b6274,eefc04d6840b6274,true] 92605 --- [   scheduling-1] c.c.p.r.component.aspect.TEST_BdaAspect  : log beforeBdaTriggerJobsAdvice
2021-06-02 20:56:05.066  INFO [,60b7f0602b2ecb0deefc04d6840b6274,eefc04d6840b6274,true] 92605 --- [   scheduling-1] c.c.p.r.services.TEST_BdaProcessService  : triggerJob
2021-06-02 20:56:05.066  INFO [,60b7f0602b2ecb0deefc04d6840b6274,eefc04d6840b6274,true] 92605 --- [   scheduling-1] c.c.p.r.component.aspect.TEST_BdaAspect  : log onErrorBdaTriggerJobsAdvice
2021-06-02 20:56:10.070  INFO [,60b7f0602b2ecb0deefc04d6840b6274,eefc04d6840b6274,true] 92605 --- [   scheduling-1] c.c.p.r.component.aspect.TEST_BdaAspect  : log beforeBdaTriggerJobsAdvice
2021-06-02 20:56:10.070  INFO [,60b7f0602b2ecb0deefc04d6840b6274,eefc04d6840b6274,true] 92605 --- [   scheduling-1] c.c.p.r.services.TEST_BdaProcessService  : triggerJob
2021-06-02 20:56:10.070  INFO [,60b7f0602b2ecb0deefc04d6840b6274,eefc04d6840b6274,true] 92605 --- [   scheduling-1] c.c.p.r.component.aspect.TEST_BdaAspect  : log onErrorBdaTriggerJobsAdvice
2021-06-02 20:56:10.070  INFO [,60b7f0602b2ecb0deefc04d6840b6274,eefc04d6840b6274,true] 92605 --- [   scheduling-1] c.c.p.r.services.TEST_BdaProcessService  : recover
2021-06-02 20:56:10.070 ERROR [,60b7f0602b2ecb0deefc04d6840b6274,eefc04d6840b6274,true] 92605 --- [   scheduling-1] c.c.p.r.c.TEST_ScheduledProcessPoller    : null

ANSWER

Answered 2021-Jun-08 at 03:45

I am not a Spring user, but interested in all things AOP, both AspectJ and Spring AOP. I liked your little puzzle. Thanks to your MCVE, I was able to reproduce the issue and debug into it. This is a perfect example for why an MCVE is so much superior to simply posting a bunch of code snippets. So thanks for that, please keep up this way of asking questions.

When looking at the situation in a debugger, you see that while the aspect is proceeding into triggerJob, at some point we are in method AnnotationAwareRetryOperationsInterceptor.invoke and there we have the following code:

@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
    MethodInterceptor delegate = getDelegate(invocation.getThis(), invocation.getMethod());
    if (delegate != null) {
        return delegate.invoke(invocation);
    }
    else {
        return invocation.proceed();
    }
}

At this point Spring makes a choice to construct the delegate which later will be used for calling recover. It is constructed with target object invocation.getThis(), which points to the original object, i.e. a TEST_BdaProcessService instance. At this point, the code could simply use invocation.getProxy() instead, which would point to the AOP proxy, i.e. a TEST_BdaProcessService$$EnhancerBySpringCGLIB$$2f8076ac instance. The problem is that the target object reference is passed through to the point where recover gets called, and the corresponding recoverer instance at that point only knows the target object, having no clue of the corresponding proxy object anymore.

When I experimentally assigned the proxy to the delegate as a target, your advice method was invoked.

So we are talking about a Spring limitation here. Whether that was a deliberate choice in order to avoid any other related problems or simply an oversight, I have no idea.

enter image description here


Update: I created Spring Retry issue #244 on your behalf. You want to subscribe to it, so you can find out if/when it is going to be fixed.

Update 2: The issue has been fixed, is merged into the main branch and is probably going to be part of the upcoming 1.3.2 version, whenever that one might be released. For now, you can just clone Spring Retry, build by yourself and use the snapshot. I retested against your MCVE, the aspect now kicks in as expected for the recover method.

Source https://stackoverflow.com/questions/67810277

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install dexposed

You can download it from GitHub.
You can use dexposed like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the dexposed component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

Support

Dexposed support all dalvik runtime arm architecture devices from Android 2.3 to 4.4 (no include 3.0). The stability has been proved in our long term product practice. Follow is support status.

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

Explore Related Topics

Share this Page

share link
Consider Popular Aspect Oriented Libraries
Compare Aspect Oriented Libraries with Highest Support
Compare Aspect Oriented Libraries with Highest Quality
Compare Aspect Oriented Libraries with Highest Security
Compare Aspect Oriented Libraries with Permissive License
Compare Aspect Oriented Libraries with Highest Reuse
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.