From 3997b2ed31c535a0c70ca0881bf527374f73f875 Mon Sep 17 00:00:00 2001 From: BJ Hargrave Date: Fri, 9 Jun 2023 09:23:35 -0400 Subject: [PATCH] classfile: Properly handle unnamed MethodParameter A method parameter may not have a name. Fixes https://github.com/bndtools/bnd/issues/5689 Signed-off-by: BJ Hargrave --- .../src/aQute/bnd/classfile/MethodParametersAttribute.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/biz.aQute.bnd.util/src/aQute/bnd/classfile/MethodParametersAttribute.java b/biz.aQute.bnd.util/src/aQute/bnd/classfile/MethodParametersAttribute.java index 6742711e00..c91a919a71 100644 --- a/biz.aQute.bnd.util/src/aQute/bnd/classfile/MethodParametersAttribute.java +++ b/biz.aQute.bnd.util/src/aQute/bnd/classfile/MethodParametersAttribute.java @@ -71,11 +71,12 @@ public String toString() { static MethodParameter read(DataInput in, ConstantPool constant_pool) throws IOException { int name_index = in.readUnsignedShort(); int access_flags = in.readUnsignedShort(); - return new MethodParameter(constant_pool.utf8(name_index), access_flags); + String name = (name_index == 0) ? null : constant_pool.utf8(name_index); + return new MethodParameter(name, access_flags); } void write(DataOutput out, ConstantPool constant_pool) throws IOException { - int name_index = constant_pool.utf8Info(name); + int name_index = (name == null) ? 0 : constant_pool.utf8Info(name); out.writeShort(name_index); out.writeShort(access_flags); }