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

add functions for getting the parameter names of method #357

Merged
merged 2 commits into from Jan 30, 2021

Conversation

eshizhan
Copy link
Contributor

  1. Add function in LocalVariableAttribute.java for getting correct local variable name by given index. The variableName method has some ambiguities for get the parameter names of method, see How to get method parameter names with javassist? #14 , Obtained incorrect original parameter name of method by MethodInfo API #16 , how to get the methd parameter name? #131 . The local_variable_table may appear in any order, so variableName method give incorrect value.
  2. Add function in MethodParametersAttribute.java for getting parameter names.

public String variableNameByIndex(int index) {
for (int i = 0; i < tableLength(); i++) {
if (index(i) == index) {
return getConstPool().getUtf8Info(nameIndex(i));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had better use variableName(i)

Copy link
Contributor

@NingZhang-e NingZhang-e left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add unit tests.

* @param i the position of the parameter.
*/
public String parameterName(int i) {
return getConstPool().getUtf8Info(name(i));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add unit tests for the changes.

@eshizhan
Copy link
Contributor Author

@NingZhang-e Thanks for review, I added unit tests.

@chibash chibash merged commit fc728c4 into jboss-javassist:master Jan 30, 2021
chibash added a commit that referenced this pull request Jan 30, 2021
odl-github pushed a commit to opendaylight/odlparent that referenced this pull request Jan 7, 2022
odl-github pushed a commit to opendaylight/odlparent that referenced this pull request Jan 7, 2022
jboss-javassist/javassist#305
jboss-javassist/javassist#328
jboss-javassist/javassist#339
jboss-javassist/javassist#350
jboss-javassist/javassist#357
jboss-javassist/javassist#363

Change-Id: I29963013cf637731fe1064425b9d2e80d63bd9d3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 0df0ba3)
odl-github pushed a commit to opendaylight/odlparent that referenced this pull request Jan 7, 2022
jboss-javassist/javassist#305
jboss-javassist/javassist#328
jboss-javassist/javassist#339
jboss-javassist/javassist#350
jboss-javassist/javassist#357
jboss-javassist/javassist#363

Change-Id: I29963013cf637731fe1064425b9d2e80d63bd9d3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 0df0ba3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants