Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Needs for tracing return event for 'void' methods only #192

Closed
yburkouski opened this issue Jan 24, 2016 · 6 comments
Closed

Needs for tracing return event for 'void' methods only #192

yburkouski opened this issue Jan 24, 2016 · 6 comments

Comments

@yburkouski
Copy link

With a 'location = @location(Kind.RETURN)' and '@return AnyType ret' I can trigger and get return from any methods except of constructors () and with 'void' return signature.
I suggest to use for this case a variant with '@return java.lang.Void ret' cause there is only 1 alternate: using '@location(Kind.RETURN)' without '@return' (it catches return method event for constructors and 'void' methods), but in this case it's impossible to get method return value. AnyType is not suitable for catching it because it would be impossible to tell 'void' from 'null' return.
I'm using this app for testing: https://github.com/yburkouski/Btrace-Test-App

@jbachorik
Copy link
Collaborator

Could you clarify the request? Do you want to trace only 'void' returns or all returns, including 'void'?

@yburkouski
Copy link
Author

only void methods: methods that has been declared like void m(){...} + constructors

cause right now there is possible to trace all methods including 'void' (without Return annotation), and any non void methods (with Return annotation), but there is impossible to trace only void return methods.

@jbachorik
Copy link
Collaborator

There is a proposed solution in https://github.com/jbachorik/btrace/tree/anytype-void-return branch.

In order to trace only void returning methods you will need to declare the @Return parameter to be of java.lang.Void type -

@OnMethod(clazz = "cls", method = "mthd", location = @Location(Kind.RETURN))
public static void dotrace(@Return Void dummy) {
...
}

Please, verify whether this resolves your problems.

@jbachorik jbachorik added this to the 1.3.5 milestone Mar 3, 2016
@jbachorik
Copy link
Collaborator

@yburkouski Are you fine with the proposed solution?

@yburkouski
Copy link
Author

@jbachorik sorry for delay, I will test it tomorrow.

@yburkouski
Copy link
Author

@jbachorik works as expected. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants