summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreshizhan <eshizhan@126.com>2021-01-29 12:34:08 +0800
committereshizhan <eshizhan@126.com>2021-01-29 12:34:08 +0800
commit5bccb19933b3eda51518d79ca52a06b89d304bf6 (patch)
treec6456844b635ebf4b644e5defef6259157289fa2
parent084c8e89b5d40bb739b7a6dee61a89452d679c1c (diff)
downloadjavassist-5bccb19933b3eda51518d79ca52a06b89d304bf6.tar.gz
javassist-5bccb19933b3eda51518d79ca52a06b89d304bf6.zip
add unit tests for LocalVariableAttribute.variableNameByIndex and MethodParametersAttribute.parameterName
-rw-r--r--src/main/javassist/bytecode/LocalVariableAttribute.java2
-rw-r--r--src/test/javassist/JvstTest4.java4
-rw-r--r--src/test/javassist/bytecode/BytecodeTest.java3
3 files changed, 8 insertions, 1 deletions
diff --git a/src/main/javassist/bytecode/LocalVariableAttribute.java b/src/main/javassist/bytecode/LocalVariableAttribute.java
index c1106be1..dcee7965 100644
--- a/src/main/javassist/bytecode/LocalVariableAttribute.java
+++ b/src/main/javassist/bytecode/LocalVariableAttribute.java
@@ -227,7 +227,7 @@ public class LocalVariableAttribute extends AttributeInfo {
public String variableNameByIndex(int index) {
for (int i = 0; i < tableLength(); i++) {
if (index(i) == index) {
- return getConstPool().getUtf8Info(nameIndex(i));
+ return variableName(i);
}
}
throw new ArrayIndexOutOfBoundsException();
diff --git a/src/test/javassist/JvstTest4.java b/src/test/javassist/JvstTest4.java
index d53148bd..259451b9 100644
--- a/src/test/javassist/JvstTest4.java
+++ b/src/test/javassist/JvstTest4.java
@@ -1019,11 +1019,15 @@ public class JvstTest4 extends JvstTestRoot {
assertEquals(2, attr.size());
assertEquals("i", cp.getUtf8Info(attr.name(0)));
assertEquals("s", cp.getUtf8Info(attr.name(1)));
+ assertEquals("i", attr.parameterName(0));
+ assertEquals("s", attr.parameterName(1));
attr = (MethodParametersAttribute)attr.copy(cp, null);
assertEquals(2, attr.size());
assertEquals("i", cp.getUtf8Info(attr.name(0)));
assertEquals("s", cp.getUtf8Info(attr.name(1)));
+ assertEquals("i", attr.parameterName(0));
+ assertEquals("s", attr.parameterName(1));
}
// JIRA JASSIST-220
diff --git a/src/test/javassist/bytecode/BytecodeTest.java b/src/test/javassist/bytecode/BytecodeTest.java
index 5ddf5d5b..7aef1cce 100644
--- a/src/test/javassist/bytecode/BytecodeTest.java
+++ b/src/test/javassist/bytecode/BytecodeTest.java
@@ -354,6 +354,9 @@ public class BytecodeTest extends TestCase {
assertEquals("I", ainfo2.descriptor(i));
}
print("**** end ***");
+
+ assertEquals("this", ainfo2.variableNameByIndex(0));
+ assertEquals("i", ainfo2.variableNameByIndex(1));
}
public void testAnnotations() throws Exception {