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

Consider method handles #3

Open
lukaseder opened this issue Oct 28, 2013 · 2 comments
Open

Consider method handles #3

lukaseder opened this issue Oct 28, 2013 · 2 comments

Comments

@lukaseder
Copy link
Member

See also:
https://code.google.com/p/joor/issues/detail?id=19

@lukaseder lukaseder modified the milestone: Version 0.9.5 Dec 22, 2014
@iirekm
Copy link
Contributor

iirekm commented Feb 20, 2015

There are problems with this approach:

  • won't work in Java 6 (there are still projects that have to support it) and Android (I guess that current joor should work there without problems)
  • the biggest cost about reflection is finding method by name and calling setAccessible(true), after that it's almost as fast as regular method calls, if performance is a problem, we may consider caching of accessible() objects some day, MethodHandles also have a quite big lookup cost, so no real gain

MethodHandles may also provide automatic resolution of 'similar' methods, but it works only for methods which are visible from current code. If someone wants to call visible 'similar' methods in everyday programming then should rather consider dynamic languages like Groovy (they can use invokedynamic and MethodHandles).

@lukaseder
Copy link
Member Author

won't work in Java 6 (there are still projects that have to support it) and Android (I guess that current joor should work there without problems)

We can catch NoSuchMethodError or NoClassDefFoundError in a static initialiser and see whether this feature is accessible or not. If it isn't, there's still the possibility to implement stuff with pre-Java-7 API.

MethodHandles also have a quite big lookup cost, so no real gain

Probably true

If someone wants to call visible 'similar' methods in everyday programming then should rather consider dynamic languages like Groovy

That's correct. The use-cases of jOOR are limited. We designed it mostely for integration testing. Certainly, actual method handle support is low-prio. I'll fix tags accordingly.

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