Java Reflection Tutorials

Source: Internet
Author: User

reprinted from concurrent Programming network –ifeve.com

The Java reflection mechanism allows us to check the information of classes, interfaces, variables, and methods at run time (runtime) outside of the compile period (Compile time). Reflection also allows us to instantiate an object at run time, invoke a method, and get the value of a variable by calling the Get/set method.

The Java reflection mechanism is powerful and functional. For example, you can use a reflection mechanism to map a Java object to a database table, as butterfly persistence (a framework written by the original author), or a statement in a script that maps to the corresponding object invocation method at run time, like Butterfly Container (Translator Note: The framework written by the original author) is done when parsing its configuration script.

There are a plethora of Java reflection guides already on the Internet, but most of the guidelines, including the reflection guidelines released by Sun, only introduce some of the reflective surface content and its potential.

In this series of articles, we will understand the Java reflection mechanism more deeply than other guidelines, and it will explain how the basic principles of the Java Reflection mechanism include the use of arrays, annotations, generics, and dynamic loading of classes and the implementation of overloads of classes. It also shows you how to implement some features that are more characteristic, such as reading all the Get/set methods from a class, or accessing private variables of a class and private methods. This series of guides also explains some of the non-reflection-related but confusing issues, such as which generic information is valid at run time, and some people claim that all generic information disappears during runtime, but this is not true.

The article in this series describes the reflection mechanism in Java version 6.

    1. Java Reflection Tutorials
    2. Java Reflection (i): Java Reflection Guide
    3. Java Reflection (ii): Classes
    4. Java Reflection (iii): constructors
    5. Java Reflection (iv): variables
    6. Java Reflection (V): Methods
    7. Java Reflection (vi): Getters and Setters
    8. Java Reflection (vii): Private variables and private methods
    9. Java Reflection (eight): annotations
    10. Java Reflection (ix): generics
    11. Java Reflection (10): Arrays
    12. Java Reflection (11): Dynamic Proxy
    13. Java Reflection (12): Dynamic class loading and overloading

Original address Author: Jakob Jenkov Translator: Yevenhai ([email protected]) proofreading: Fang Fei

Java Reflection Tutorials

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.