Hi Manuel,
On 14/02/2023 9:14 pm, Manuel Álvarez Álvarez wrote:
Dear all,
When dealing with enclosed classes, frameworks like bytebuddy use the
EnclosingMethod attribute in order to discover generic type argument
bounds. When retransforming a class, the JvmtiClassFileReconstituter.cpp
omits the enclosing attributes (they are available in the
java.lang.Class object) so the bytes received by the transformer are
missing the attribute potentially causing issues downstream.
Are there any strong reasons why these attributes are not written by the
JvmtiClassFileReconstituter?
I can't find anything specific about why this is missing, just a general
note in the JVMTI spec for retransformClasses that some attributes may
be missing:
"The initial class file bytes represent the bytes passed to
ClassLoader.defineClass or RedefineClasses (before any transformations
were applied), however they may not exactly match them. The constant
pool may differ in ways described in GetConstantPool. Constant pool
indices in the bytecodes of methods will correspond. Some attributes may
not be present."
I suspect the omission is simply because this is not an attribute that
the VM uses in any way.
Others may have more insight.
Cheers,
David
Kind regards and thank you in advance,
Manuel.