Bug in attribute writing
Brian Goetz
brian.goetz at oracle.com
Thu May 18 14:32:58 UTC 2023
I just noticed that in BoundAttribute.BoundUnknownAttribute:
private void checkWriteSupported(Function<ConstantPool,
Boolean> condition) {
if (!condition.apply(classReader))
throw new UnsupportedOperationException("Write of
unknown attribute " + attributeName() + " not supported to alien
constant pool");
}
we should at least be checking the option "support unknown attributes"
before we say OK.
Overall, I am not sure we have a fully consistent story for unsupported
attributes here. The basic problem with attributes for which we don't
have an AttributeMapper is that we can't be sure about validity. We
don't know where the CP indexes are (though if we are sharing CPs, this
is OK), and we don't know what other data might be off.
(We also have a bigger problem with the type annotations attributes,
which are known to have all sorts of non-CP offsets (nth bound of mth
type variable, nth exception, indexes into code array, etc) which could
easily but thrown off by transformation and there is no practical way to
detect whether the original RVTA is still valid.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/classfile-api-dev/attachments/20230518/44ff41d9/attachment-0001.htm>
More information about the classfile-api-dev
mailing list