Home > Java > javaTutorial > body text

Java Reflection Tutorial

黄舟
Release: 2017-02-07 10:39:26
Original
1274 people have browsed it

The Java reflection mechanism allows us to check the information of classes, interfaces, variables and methods at runtime (Runtime) outside of compile time. Reflection also allows us to instantiate objects at runtime, call methods, and obtain the value of variables by calling get/set methods.

The Java reflection mechanism is powerful and very practical. For example, you can use reflection to map Java objects to database tables, as Butterfly Persistence does, or map a statement in a script to a database table at runtime. The corresponding object calls the method, just like Butterfly Container (Translator's Note: Framework written by the original author) does when parsing its configuration script.


There are already countless Java reflection guides on the Internet. However, most of the guides, including the reflection guide published by Sun, only introduce some reflections. its surface content and its potential.

In this series of articles, we will understand the Java reflection mechanism more deeply than other guides. It will explain the basic principles of the Java reflection mechanism, including how to use arrays, annotations, generics and dynamic proxies. There are implementations of dynamic loading of classes and overloading of classes. It will also show you how to implement some more unique functions, such as reading all get/set methods from a class, or accessing private variables and private methods of a class. This series of guides will also address some non-reflection related but confusing issues, such as which generic information is valid at runtime. Some people claim that all generic information disappears at runtime. In fact, this is not true. It's not right.

What is described in this series of articles is the Java 6 version of the reflection mechanism. Please click to read the original text for details.

1 Java Reflection Tutorial
2 Java Reflection Guide
3 Java Reflection: Classes
4 Java Reflection: Constructor
5 Java Reflection: Variable
6 Java Reflection: Method
7 Java Reflection: Getters and Setters
8 Java Reflection: Private variables and private methods
9 Java Reflection: Annotations
10 Java Reflection: Generics
11 Java Reflection: Array
12 Java Reflection: Dynamic Proxy
13 Java Reflection: Dynamic Class Loading and Overloading

The above is the content of the Java Reflection tutorial. For more related content, please pay attention to the PHP Chinese website (www.php .cn)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!