aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/javassist/bytecode
diff options
context:
space:
mode:
authorwuwen <wuwen.55@aliyun.com>2023-10-08 16:31:26 +0800
committerwuwen <wuwen.55@aliyun.com>2023-11-03 15:04:16 +0800
commit784a7c1ef9996d166aedcd4aacd1fa12016dde7f (patch)
treecab713641bdaebdf50b2e74428d3ca0a42b3aa2a /src/main/javassist/bytecode
parent700be6f6f9546e8af049b1a763ce27f1fde5955d (diff)
downloadjavassist-784a7c1ef9996d166aedcd4aacd1fa12016dde7f.tar.gz
javassist-784a7c1ef9996d166aedcd4aacd1fa12016dde7f.zip
fixes GitHub Issue 462 (Internal class issues in the Java 21)
Diffstat (limited to 'src/main/javassist/bytecode')
-rw-r--r--src/main/javassist/bytecode/MethodParametersAttribute.java9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/main/javassist/bytecode/MethodParametersAttribute.java b/src/main/javassist/bytecode/MethodParametersAttribute.java
index b9c252a9..f78f6c72 100644
--- a/src/main/javassist/bytecode/MethodParametersAttribute.java
+++ b/src/main/javassist/bytecode/MethodParametersAttribute.java
@@ -32,7 +32,8 @@ public class MethodParametersAttribute extends AttributeInfo {
byte[] data = new byte[names.length * 4 + 1];
data[0] = (byte)names.length;
for (int i = 0; i < names.length; i++) {
- ByteArray.write16bit(cp.addUtf8Info(names[i]), data, i * 4 + 1);
+ String name = names[i];
+ ByteArray.write16bit(name == null ? 0 : cp.addUtf8Info(name), data, i * 4 + 1);
ByteArray.write16bit(flags[i], data, i * 4 + 3);
}
@@ -61,7 +62,8 @@ public class MethodParametersAttribute extends AttributeInfo {
* @param i the position of the parameter.
*/
public String parameterName(int i) {
- return getConstPool().getUtf8Info(name(i));
+ int index = name(i);
+ return index == 0 ? null : getConstPool().getUtf8Info(index);
}
/**
@@ -87,7 +89,8 @@ public class MethodParametersAttribute extends AttributeInfo {
String[] names = new String[s];
int[] flags = new int[s];
for (int i = 0; i < s; i++) {
- names[i] = cp.getUtf8Info(name(i));
+ int index = name(i);
+ names[i] = index == 0 ? null : cp.getUtf8Info(index);
flags[i] = accessFlags(i);
}