Skip to content

Java: Add Argument.getParameter() #5188

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Marcono1234
Copy link
Contributor

Adds the following predicates:

  • Argument.getParameter()
  • Argument.getVarargsParameter()
  • Callable.getVarargsParameter()

Argument.getParameter() is probably the most useful one of them, but I added the other ones for completeness.
However, I am not sure how useful they actually are which is why I have marked this pull request as Draft for now.

@github-actions github-actions bot added the Java label Feb 16, 2021
@aschackmull
Copy link
Contributor

I'm slightly hesitant about these. It's useful to have a little bit of ad-hoc argument-parameter matching (and that's already present on Parameter), but since this sort of thing is mostly useful for data flow things then you'll quickly start to want support for a lot of additional things that aren't as straight-forward: namely, Instance argument to instance parameter matching and virtual dispatch.

@Marcono1234
Copy link
Contributor Author

Marcono1234 commented May 29, 2021

Hmm, ok I guess you are right, the functionality of most of the proposed predicates can be achieved by using the predicates of Parameter.

However, what do you think about adding the following then:

  • For Parameter: getAnExplicitVarargsArgument(), getAnImplicitVarargsArgument()
    Parameter.getAnArgument() does not include varargs arguments.
  • Callable.getVarargsParameter()

At least for the use case I am thinking of, I am mainly interested in the type of a parameter, and what argument is used for it (e.g. primitive array as varargs element). Or can / should the dataflow library be used for this?

@aschackmull
Copy link
Contributor

Or can / should the dataflow library be used for this?

No, I think you are right that the ad-hoc argument-to-parameter matching is quite sufficient for something like this, and yes, I think it makes sense to add those predicates for completeness (Parameter.getAnExplicitVarargsArgument() and Parameter.getAnImplicitVarargsArgument() in particular, and Callable.getVarargsParameter() seems fine to add as well).

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

Successfully merging this pull request may close these issues.

2 participants