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

forbidden apis does not detect signature polymorphic methods #105

Closed
rmuir opened this issue Jun 15, 2016 · 3 comments
Closed

forbidden apis does not detect signature polymorphic methods #105

rmuir opened this issue Jun 15, 2016 · 3 comments
Assignees
Milestone

Comments

@rmuir
Copy link
Member

rmuir commented Jun 15, 2016

I want to ban MethodHandle.invoke() for some reasons (e.g. its lenient in tests, slow in production, but has a too easy sounding name). If someone wants to do the same thing, they can be explicit they want that.

But forbidden apis never detects violations, because they won't match a "wildcard" signature for these methods (since any parameters can be pushed on stack as-is). Instead it ignores all uses of this method.

A method is signature polymorphic if all of the following are true:
    It is declared in the java.lang.invoke.MethodHandle class.
    It takes a single variable arity parameter (§8.4.1) whose declared type is Object[].
    It has a return type of Object.
    It is native.
@rmuir rmuir added the bug label Jun 15, 2016
@uschindler uschindler self-assigned this Jun 15, 2016
@uschindler
Copy link
Member

uschindler commented Jun 15, 2016

This is similar to the problems with bridge methods. There are 2 possibilities:

  • Allow just method names like field names with wildcards. But this is still not easy to solve, because the current algorithm checks the whole signature (always) and just collects all possible signatures beforehand while parsing the signatures file. The lookup is done by a map, so needs more refactoring. See also: Add support for glob pattern combined with methods/fields #88
  • It might be better to detect those polymorphic signatures directly. I can check for the polymorpic annotation somehow.

I will look into both options. I am about to release 2.2, so this would be a good opportunity.

@uschindler
Copy link
Member

I opened PR #106 using the second approach. All informative description is there.

uschindler added a commit that referenced this issue Jun 19, 2016
Add support for signature polymorphic methods
@uschindler
Copy link
Member

I committed the PR.

@uschindler uschindler added this to the 2.2 milestone Jun 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants