mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-22 20:14:43 +02:00
7190750: (pack200) the java unpacker produces non spec. compliant classfile with lambda classfiles
Reviewed-by: jrose
This commit is contained in:
parent
3be453e452
commit
d07131ac67
1 changed files with 21 additions and 0 deletions
|
@ -207,6 +207,22 @@ class ClassWriter {
|
||||||
m);
|
m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void reorderBSMandICS(Attribute.Holder h) {
|
||||||
|
Attribute bsmAttr = h.getAttribute(Package.attrBootstrapMethodsEmpty);
|
||||||
|
if (bsmAttr == null) return;
|
||||||
|
|
||||||
|
Attribute icsAttr = h.getAttribute(Package.attrInnerClassesEmpty);
|
||||||
|
if (icsAttr == null) return;
|
||||||
|
|
||||||
|
int bsmidx = h.attributes.indexOf(bsmAttr);
|
||||||
|
int icsidx = h.attributes.indexOf(icsAttr);
|
||||||
|
if (bsmidx > icsidx) {
|
||||||
|
h.attributes.remove(bsmAttr);
|
||||||
|
h.attributes.add(icsidx, bsmAttr);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// handy buffer for collecting attrs
|
// handy buffer for collecting attrs
|
||||||
ByteArrayOutputStream buf = new ByteArrayOutputStream();
|
ByteArrayOutputStream buf = new ByteArrayOutputStream();
|
||||||
DataOutputStream bufOut = new DataOutputStream(buf);
|
DataOutputStream bufOut = new DataOutputStream(buf);
|
||||||
|
@ -216,6 +232,11 @@ class ClassWriter {
|
||||||
writeShort(0); // attribute size
|
writeShort(0); // attribute size
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// there may be cases if an InnerClass attribute is explicit, then the
|
||||||
|
// ordering could be wrong, fix the ordering before we write it out.
|
||||||
|
if (h instanceof Package.Class)
|
||||||
|
reorderBSMandICS(h);
|
||||||
|
|
||||||
writeShort(h.attributes.size());
|
writeShort(h.attributes.size());
|
||||||
for (Attribute a : h.attributes) {
|
for (Attribute a : h.attributes) {
|
||||||
a.finishRefs(cpIndex);
|
a.finishRefs(cpIndex);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue