Skip to content

Commit

Permalink
Handle synthetic method parameters entries that don't have names
Browse files Browse the repository at this point in the history
> If the value of the name_index item is zero, then this parameters element indicates a formal parameter with no name.

https://docs.oracle.com/javase/specs/jvms/se20/html/jvms-4.html#jvms-4.7.24

PiperOrigin-RevId: 530621691
Change-Id: I7ff5bea7a5203f10c62fde42ff10818f8c94cd9e
  • Loading branch information
cushon authored and copybara-github committed May 9, 2023
1 parent 09e3a81 commit 3954a18
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions third_party/ijar/classfile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,8 @@ struct MethodParametersAttribute : Attribute {
u1 parameters_count = get_u1(p);
for (int ii = 0; ii < parameters_count; ++ii) {
MethodParameter* parameter = new MethodParameter;
parameter->name_ = constant(get_u2be(p));
int name_id = get_u2be(p);
parameter->name_ = name_id == 0 ? NULL : constant(name_id);
parameter->access_flags_ = get_u2be(p);
attr->parameters_.push_back(parameter);
}
Expand All @@ -1203,7 +1204,7 @@ struct MethodParametersAttribute : Attribute {
u1 *payload_start = p - 4;
put_u1(p, parameters_.size());
for (MethodParameter* parameter : parameters_) {
put_u2be(p, parameter->name_->slot());
put_u2be(p, parameter->name_ == NULL ? 0 : parameter->name_->slot());
put_u2be(p, parameter->access_flags_);
}
put_u4be(payload_start, p - 4 - payload_start); // backpatch length
Expand Down

1 comment on commit 3954a18

@olamy
Copy link

@olamy olamy commented on 3954a18 Oct 7, 2023

Choose a reason for hiding this comment

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

Would it be possible to have this backported to 6.x branch?
It does affect jar produced by jdk21 compilation.

Please sign in to comment.