diff options
Diffstat (limited to 'src/lombok/core/AnnotationValues.java')
-rw-r--r-- | src/lombok/core/AnnotationValues.java | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/lombok/core/AnnotationValues.java b/src/lombok/core/AnnotationValues.java index 8c69ffc4..515079e6 100644 --- a/src/lombok/core/AnnotationValues.java +++ b/src/lombok/core/AnnotationValues.java @@ -77,8 +77,11 @@ public class AnnotationValues<A extends Annotation> { "No value supplied but " + method.getName() + " has no default either.", -1); } + private A cachedInstance = null; + @SuppressWarnings("unchecked") public A getInstance() throws AnnotationValueDecodeFail { + if ( cachedInstance != null ) return cachedInstance; InvocationHandler invocations = new InvocationHandler() { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { AnnotationValue v = values.get(method.getName()); @@ -134,7 +137,7 @@ public class AnnotationValues<A extends Annotation> { } }; - return (A) Proxy.newProxyInstance(type.getClassLoader(), new Class[] { type }, invocations); + return cachedInstance = (A) Proxy.newProxyInstance(type.getClassLoader(), new Class[] { type }, invocations); } private Object guessToType(Object guess, Class<?> expected, AnnotationValue v, int pos) { |