Synthetic Class in Java

andHapp picture andHapp · Dec 30, 2008 · Viewed 53.8k times · Source

What is a synthetic class in Java? Why should it be used? How can I use it?

Answer

Andrew Newdigate picture Andrew Newdigate · Dec 30, 2008

Java has the ability to create classes at runtime. These classes are known as Synthetic Classes or Dynamic Proxies.

See http://java.sun.com/j2se/1.5.0/docs/guide/reflection/proxy.html for more information.

Other open-source libraries, such as CGLIB and ASM also allow you to generate synthetic classes, and are more powerful than the libraries provided with the JRE.

Synthetic classes are used by AOP (Aspect Oriented Programming) libraries such as Spring AOP and AspectJ, as well as ORM libraries such as Hibernate.