Proxies created by the AOP framework reuse array instances when passing arguments to an invocation handler so that temporary objects do not need to be created. This however implies that that proxies need to be synchronized (this is handled by the code generator). In a multi-threaded application this can be a performance issue. Note that the proxy code is synchronized on a proxy instance so multiple proxies of the same object can be used concurrently without blocking threads.
Note that when primitive objects are passed to or returned from a proxy method they need to be wrapped with object types like Integer. This is the only scenario that requires allocation of temporary objects. Apart from wrapping primitives the AOP framework does not need to allocate any objects after initialization.
Due to the limitations of Java ME type system, the AOP framework is unable to distinguish primitive types from wrappers. This needs to be taken into account when overloading methods. For example, the following method signatures cannot be distinguished by the framework:
void method(int i, float f, double d); void method(Integer i, Float f, Double d);
The generated proxy classes (*__Proxy.class
and *__ProxyClass.class) can noticeably
increase the size of your application. If every byte counts for
you, using the AOP framework may not be the best choice.