Dynamic proxy and reflection mechanism in Java

Source: Internet
Author: User

The basic principle of object-oriented encapsulation, inheritance, polymorphism, polymorphic mechanism in Java, the expression of variable polymorphism, method polymorphism, which refers to the object belongs to the different classes, and call different class methods; For object methods, there are function overloads, and the signature of functions in Java is determined by the function name + parameter method. Cannot be determined only by a different return value.

Reflective reflect

The runtime gets various properties of the class type, domain, method, and so on.

A class is one that has instances that correspond to other different

(Calculatorimpl) Class.forName ("Calculatorimpl"). newinstance ();

Newinstance () to do the type conversion after the result is obtained.

Cglib bytecode enhancement, "extending Java classes and implementing Java interfaces at runtime", adds that the Java Dynamic Agent mechanism requires the interface to be implemented, while the Cglib targets those classes that do not implement interfaces by inheriting these classes, becoming subclasses, overwriting some methods, So Cglib is not working on the final class.

The byte code Generation Library is the high level API to generate and transform JAVA byte code. It is used by AOP, testing, data access frameworks to generate dynamic proxy objects and intercept field access

"Hibernate Uses cglib to generate proxies for persistent classes.

Dynamic proxy and reflection mechanism in Java

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.