Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Spring normally uses a JDK dynamic proxy when a bean implements an interface, and a CGLIB subclass when it does not. Choose JDK proxying when the interface is the API callers need; choose class-based proxying when advice must cover concrete-class methods or callers require the concrete type. Proxy type matters for which methods callers can reach, which classes can be proxied, and whether configuration forces a particular strategy—not because the official guidance identifies a decisive performance winner.

What is the difference between JDK dynamic proxies and CGLIB?

Both are ways Spring AOP can place a proxy in front of a target object so calls entering through that proxy can receive advice. The difference is how the proxy is built: a JDK dynamic proxy presents interfaces, while CGLIB creates a runtime-generated subclass of the target class.

Question JDK dynamic proxy CGLIB proxy
How is it generated? A runtime proxy for interfaces implemented by the target. A runtime-generated subclass of the target class.
When does Spring choose it automatically? When the target implements at least one interface. When the target has no interface.
What methods can callers use through the proxy? Methods available through its exposed interfaces. Eligible methods on the subclassed target type, including concrete-class methods.
What is the main constraint? Callers must use the exposed interface contract. The target must be subclassable, and methods to advise must be eligible for overriding.
What setting can select it? Spring’s interface-oriented default behavior. proxy-target-class=true, or the absence of a target interface.
Is one clearly faster? No decisive advantage is documented. No decisive advantage is documented.

With a JDK proxy, the concrete implementation’s methods that are not part of an exposed interface are not part of the proxy’s interface surface. CGLIB can proxy eligible concrete methods because its generated proxy subclasses the target class. This distinction is often more important than the proxy’s name: callers interact with the proxy object, so its exposed type affects which method calls can enter the advice chain.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Should Spring use JDK dynamic proxies or CGLIB?

Start with the type and methods your callers actually need. If an interface fully describes the advised operations, JDK proxying is a natural fit; use CGLIB when the advised API is concrete-class-only, the target has no interface, or a concrete type is required at an injection boundary.

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter | 4Pack Type C Female to A Male Cable Converter for Apple Duo 17 16 15 14 Plus,iWatch Watch 12 11 10,iPad 9 8 Air,Airpods 5 4
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Prefer a JDK proxy when the interface is enough

An interface-oriented proxy keeps the dependency boundary explicit: callers depend on the contract rather than implementation-specific methods. If every operation that needs advice is declared on the interface and consumers can inject and call that interface, the automatic JDK choice is usually sufficient. Do not assume a JDK proxy will expose extra methods simply because the underlying implementation has them.

Prefer CGLIB when the concrete type matters

A class-based proxy is useful when a method requiring advice exists only on the concrete class, when there is no interface to proxy, or when an injection boundary requires the concrete type. Before selecting it, verify that the target class can be subclassed and that every method needing advice is visible and overridable. A class proxy is not a way around Java’s restrictions on subclassing or overriding.

Do not choose by performance alone

Spring’s ProxyFactoryBean reference describes little performance difference between CGLIB and dynamic proxies. The official comparison supplies no numeric benchmark that would justify a universal speed claim. Treat performance as workload- and environment-dependent; absent a controlled benchmark for the target JDK, JVM, Spring version, and workload, decide based on API shape and proxy constraints instead.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How does Spring choose a proxy automatically?

Spring’s default choice is interface-driven: at least one interface on the target leads to a JDK dynamic proxy; no target interface leads to a CGLIB subclass. This is the automatic behavior, not a rule that prevents configuration from selecting class-based proxying for an interface-backed target.

Rank #2
Sale
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter | USB C Dongle with 90W Max Power Delivery, 3×5Gbps USB A Data Ports, for MacBook, Dell, and More (Charger Not Included)
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
  1. Inspect the target’s interfaces. If it implements one or more interfaces, expect an interface proxy by default. If it implements none, expect CGLIB.
  2. Check the operations that need advice. Confirm they are available through the proxy type callers will use. For a JDK proxy, that means the exposed interface contract; for CGLIB, it means eligible methods on the subclassed type.
  3. Check injection and call sites. Determine whether consumers depend on an interface or require a concrete class, and whether they invoke only methods exposed by the proxy.
  4. Review proxy configuration. Look for settings that force class-based proxying, especially if the observed proxy differs from the automatic choice.

That sequence helps separate an expected proxy from a configuration surprise. For example, a bean implementing an interface can still be class-proxied if class-based proxying is enabled; conversely, an interface proxy can be inconvenient if callers rely on implementation-only methods.

What does proxy-target-class do?

Setting proxy-target-class=true requests class-based proxying with CGLIB, including for targets that have interfaces. Spring supports this choice through annotation and XML configuration; the relevant setting is a proxy strategy selection, not a fix for methods that cannot be overridden.

For annotation-based AOP, the setting can be written as @EnableAspectJAutoProxy(proxyTargetClass = true). XML configuration can use proxy-target-class="true". The exact configuration point depends on which proxy-producing facility your application uses, so inspect the active configuration rather than assuming the setting is present in one place.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

There is an important interaction: @EnableAspectJAutoProxy(proxyTargetClass = true), transaction auto-proxy configuration, and XML settings can participate in a unified auto-proxy creator. When those settings are combined, the strongest setting applies. As a result, changing one declaration may affect proxy behavior beyond the annotation or configuration block where you noticed it. If proxy type changes unexpectedly, search all relevant AOP and transaction configuration before changing the bean’s interfaces.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter | 85W Max PD, 2 USB 3.0 & 1 USBC Data Ports, SD/TF Card Reader, for Laptops/Mac and Other Type C Devices (Charger Not Included)
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Why is my bean a JDK proxy?

If the target implements at least one interface and class-based proxying is not being forced, a JDK dynamic proxy is Spring’s normal automatic choice. The bean can therefore behave as an interface proxy even though the implementation class itself is concrete.

  • Check the injection type. An interface dependency fits the JDK proxy’s exposed contract. A concrete-class dependency may not fit that proxy surface; if the concrete type is required, consider class-based proxying after checking subclass constraints.
  • Check the method declaration. If the method exists only on the implementation class, it is not exposed through the JDK proxy’s interface surface. Put the operation on the interface if it belongs in that contract, or use CGLIB if concrete-class proxying is appropriate.
  • Check for an explicit class-proxy setting. If a JDK proxy appears despite an expectation of CGLIB, review the configuration that applies to that bean and the other auto-proxy facilities involved.

Do not diagnose proxy type from the target class alone. The relevant question is what object and type the caller receives, and which methods are available through that proxy.

Why does self-invocation skip @Transactional, @Async, or other advice?

Spring AOP is proxy-based. A call that arrives from outside through the proxy can run advice, but a method on the target that calls another method on the same object through this does not pass through the proxy. The inner call therefore bypasses proxy advice, whether that advice is for transactions, asynchronous execution, caching, security, or another concern.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Changing from a JDK proxy to CGLIB does not change this call path: a same-object call still does not re-enter the proxy merely because the proxy is class-based. The practical remedies are to refactor so the advised operation is called through a separate bean/proxy boundary, or, where appropriate, use self-injection. Spring also provides AopContext.currentProxy() when the proxy is exposed, but this couples the class to Spring AOP and is discouraged. Prefer a design that avoids self-invocation when possible.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray | Data transfer & Fast charging for MacBook, iPhone 17/16/15, iPad, Samsung Galaxy, Apple Watch
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

What can prevent CGLIB from advising a method?

CGLIB works by subclassing and overriding eligible methods. A final class cannot be subclassed; a final method cannot be overridden; a private method is not overridable; and non-visible methods are excluded. If the required target class or method falls into one of these categories, forcing CGLIB does not make it adviseable.

  • Final target class: the generated subclass cannot extend it.
  • Final method: the subclass cannot override that method to intercept the call.
  • Private method: it cannot be overridden as a proxy method.
  • Non-visible method: it is outside the set of methods available for subclass-based interception.

If an advised operation is excluded, reconsider the method or class design, or use an interface-based proxy where its contract and call sites fit. The critical check is whether the particular method that needs advice can be intercepted by the chosen mechanism—not just whether the application starts successfully.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How should you troubleshoot a proxy mismatch?

Work from the failing call back toward proxy creation. This avoids changing configuration to solve a problem caused by an interface-only method surface, an ineligible CGLIB method, or self-invocation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Identify the expected advised call. Name the specific method and the advice that should run, such as transaction or asynchronous advice.
  2. Trace the call route. Establish whether the call enters through the Spring-managed proxy or is made internally through this. An internal self-call bypasses advice.
  3. Establish the proxy strategy. Check whether the target has interfaces and whether a setting forces CGLIB. Remember that a unified auto-proxy creator can make the strongest setting apply across participating configuration.
  4. Check the exposed API. For JDK proxying, verify the method is available on the relevant interface. For CGLIB, verify the target and method are subclass/override eligible.
  5. Check the dependency boundary. Make sure the caller injects and uses a type supported by the proxy strategy rather than relying on a concrete-only method through an interface proxy.
  6. Choose the smallest fitting change. Refactor the call boundary, adjust the interface contract, or select class-based proxying only if its constraints and application API justify it.

These checks distinguish three different failures that are often conflated: the call never crosses the proxy, the proxy does not expose the method, or the class-based proxy cannot override it. Each needs a different remedy.

Best Value
Sale
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display | 85W Max PD, 1 Powered USB-C 5Gbps & 2 Powered USB-A 3.0 5Gbps Data Ports, for MacBook Pro, MacBook Air, Dell and More (Black)
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Frequently Asked Questions

Why does a Spring bean look like a proxy in a debugger or test?

Spring AOP places a proxy in front of the target so calls through the managed object can be advised. The proxy’s visible type depends on whether Spring selected an interface proxy or a generated subclass.

Can I cast a JDK proxy to the implementation class to reach an extra method?

No: a JDK proxy exposes its interfaces, not implementation-only methods. Call such an operation through an interface that declares it, or consider class-based proxying if the concrete API is genuinely required and the target is eligible.

Are there official benchmark numbers proving one proxy type is faster?

The cited Spring guidance describes little performance difference but gives no numeric benchmark for this comparison. A meaningful speed conclusion would require measurements for the specific JDK, JVM, Spring version, and workload.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.