Java Reference
In-Depth Information
public static class Inner { ... }
The reflective model of Java programs is not the same as the language model. Reflection operates
at the level of the virtual machine, exposing many details of the translation of Java programs into
class files. Some of these details are mandated by the language specification, but others differ from
implementation to implementation. The mapping from Java programs into class files was
straightforward in early versions of the language, but it became more complex with the addition of
advanced language features that are not directly supported in the VM, such as nested classes,
covariant return types, generics, and enums.
Because of the complexity of the mapping from Java programs to class files, avoid using reflection
to instantiate inner classes. More generally, be aware that when using reflection on program
elements defined with advanced language features, the reflective view of the program may differ
from the source view. Avoid depending on details of the translation that are not mandated by the
language specification. The lesson for platform implementers is, once again, to provide clear and
precise diagnostics.
< Day Day Up >
 
 
Search WWH ::




Custom Search