Consider the DirectMethodHandle$Holder
class. (It is one of the classes returned by Class.forName("java.lang.invoke.DirectMethodHandle").getDeclaredClasses()
, which is documented to return member classes.)
The following assertion fails under JDK 19:
assert Class.forName("java.lang.invoke.DirectMethodHandle$Holder").isMemberClass();
Why? Which rule of section 8.5 does it violate?
Like some of the commenters, I am coming to the conclusion that this is a very weird bug. For example, using some javax.annotation.processing
and some javax.lang.model.*
classes, the following assertion does not fail:
assert NestingKind.MEMBER == ((TypeElement)processingEnvironment.getElementUtils().getTypeElement("java.lang.invoke.DirectMethodHandle.Holder")).getNestingKind();
So the outputs of the mechanisms underpinning the compiler do not agree with the outputs of the reflection machinery. I've filed a bug against the JDK.
Aucun commentaire:
Enregistrer un commentaire