-
Notifications
You must be signed in to change notification settings - Fork 62
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
Allow duplicate method names in JVM verification #884
Conversation
Fixes #212. Previously `crucible_jvm_verify` and related commands would fail to verify methods whose names were not unique. However, JVM allows multiple methods to coexist in the same class as long as their types are distinct. This change now allows users to optionally add a type descriptor to a method name to specify a particular method with a given name. For example "foo(L)V" indicates method "foo" with a long argument and void result type.
If you print the loaded module, does it display the names with these selectors? |
I didn't touch the printing code for |
Thanks! I think this feature would be quite helpful. |
EDIT: Here's the output of printing the module
As you can see, it does list all the similarly-named methods separately, but it shows the types in pretty-printed form instead of the descriptor encoding. |
I think some extra information would be nice to add to printed |
These are referred to by the name "<init>", which is what they are called in the JVM class file. Like other methods, they can be used with type descriptors to disambiguate when constructors are defined at multiple types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a good improvement to me. It would definitely be good to have some method to discover the appropriate descriptor names other than from the ambiguity error message.
#884 redid jvm method verification so that it would only perform method resolution (where it searches superclasses to find the given method name) a single time. However, subsequent method lookups were using the original class name instead of the name of the superclass where the method was found. This caused method handle lookups to fail in examples (like ecdsa) where methods were defined in superclasses. This commit fixes that bug.
#884 redid jvm method verification so that it would only perform method resolution (where it searches superclasses to find the given method name) a single time. However, subsequent method lookups were using the original class name instead of the name of the superclass where the method was found. This caused method handle lookups to fail in examples (like ecdsa) where methods were defined in superclasses. This commit fixes that bug.
This patch adds new functionality to
crucible_jvm_verify
where if the class you're working with contains multiple methods with the same name, you can select the one you want by appending a type descriptor string to the method name. For example"foo(II)Z"
chooses a method namedfoo
with two integer arguments and a boolean result. Type descriptors are optional if the base name is unambiguous. In case a method name is ambiguous, the error message prints all the valid type descriptors that could be used to disambiguate.Fixes #212.