A Java library for runtime proxies and compile-time generated static proxies. It started in 2015 as an internal AOP-style utility and has quietly stayed useful ever since — currently tracking JDK 26 and Maven 4.

Two ways to wrap a method call

Runtime — DynamicProxyBuilder

A fluent API around JDK dynamic proxies:

java
Service proxy = DynamicProxyBuilder
    .createBuilder(Service.class, new ServiceImpl())
    .addIPreAction((original, method, args) -> {
      // before every invocation
    })
    .addIPostAction((original, method, args) -> {
      // after every invocation
    })
    .addSecurityRule(() -> currentUserCanCall())
    .addMetrics()
    .build();

You get pre/post hooks, security gates, logging, Dropwizard metrics and virtual proxy strategies without writing a single InvocationHandler.

Compile-time — annotation processor

Annotate your interface, the processor emits a static proxy class at build time. Zero reflection at runtime, full type-safety, JIT-friendly. You get the proxy behaviour with the performance characteristics of hand-written code.

xml
<plugin>
  <artifactId>maven-compiler-plugin</artifactId>
  <configuration>
    <annotationProcessorPaths>
      <path>
        <groupId>com.svenruppert</groupId>
        <artifactId>proxybuilder</artifactId>
        <version>00.11.01</version>
      </path>
    </annotationProcessorPaths>
  </configuration>
</plugin>

When to reach for it

Security wrappers — declarative “is the current user allowed to call this method” without an AOP framework ✅ Method-level metrics — counter / timer / histogram per method call without modifying the implementation ✅ Lazy initialisation — virtual proxies that defer construction until first use ✅ Tracing / debugging — pre/post hooks for ad-hoc instrumentation

❌ When you’re already in a Spring or Quarkus stack — use their AOP layers ❌ When you need cross-cutting concerns across non-interface classes — JDK proxies only wrap interfaces

Modules

  • proxybuilder-annotations — annotations-only JAR (tiny, on consumer compile path)
  • proxybuilder — implementation: runtime utilities + annotation processor
  • proxybuilder-testusage — runnable usage examples and integration tests

License is EUPL-1.2. Maven coordinates on the project site.