Aktuelle Änderungen Printable View Änderungen Bearbeiten
HygienicMacros > SyntacticSugar > TabbedBrowsing > ProperTailCall > Recursion > MercurialVsGit > VirtualMachine > LargeScaleApps > CodeGeneration > LanguageFights > LispGenerators > DesignPatterns > PatternsInSoftwareEngineering > VersionControl > MultiThreading > ConcurrentProgramming > JavaReflectionClear TrailJava language reflection provides a very versatile way of dynamically linking program components. It allows your program to create and manipulate objects of any classes (subject to security restrictions) without the need to hardcode the target classes ahead of time. These features make reflection especially useful for creating libraries that work with objects in very general ways. For example, reflection is often used in frameworks that persist objects to databases, XML, or other external formats.
A more serious drawback for many applications is that using reflection can obscure what's actually going on inside your code. Programmers expect to see the logic of a program in the source code, and techniques such as reflection that bypass the source code can create maintenance problems. Reflection code is also more complex than the corresponding direct code, as can be seen in the code samples from the performance comparisons. The best ways to deal with these issues are to use reflection sparingly -- only in the places where it really adds useful flexibility -- and document its use within the target classes.
but as long as you cache the lookups, reflection is very fast. What is slow is doing things like looking up a method on a class or looking up an instance member. We do all these lookups once and then cache the results.