Fix NestHost length computation
Fixes #5987
PiperOrigin-RevId: 212658573
diff --git a/third_party/ijar/classfile.cc b/third_party/ijar/classfile.cc
index b77e769..7c03f51 100644
--- a/third_party/ijar/classfile.cc
+++ b/third_party/ijar/classfile.cc
@@ -1201,7 +1201,7 @@
}
void Write(u1 *&p) {
- WriteProlog(p, -1);
+ WriteProlog(p, 2);
put_u2be(p, host_class_index_->slot());
}
diff --git a/third_party/ijar/test/ijar_test.sh b/third_party/ijar/test/ijar_test.sh
index 703ac90..20b1d64 100755
--- a/third_party/ijar/test/ijar_test.sh
+++ b/third_party/ijar/test/ijar_test.sh
@@ -521,9 +521,14 @@
function test_nestmates_attribute() {
# Check that Java 11 NestMates attributes are preserved
$IJAR $NESTMATES_JAR $NESTMATES_IJAR || fail "ijar failed"
+
$JAVAP -classpath $NESTMATES_IJAR -v NestTest >& $TEST_log \
|| fail "javap failed"
expect_log "NestMembers" "NestMembers not preserved!"
+
+ $JAVAP -classpath $NESTMATES_IJAR -v 'NestTest$P' >& $TEST_log \
+ || fail "javap failed"
+ expect_log "NestHost" "NestHost not preserved!"
}
function test_source_debug_extension_attribute() {