Here you can find the source of newInstanceWithDefaults(Class
public static <T extends Annotation> T newInstanceWithDefaults(Class<T> annotationType)
//package com.java2s; /******************************************************************************* * Copyright (c) 2012 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ import java.lang.annotation.Annotation; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; public class Main { public static <T extends Annotation> T newInstanceWithDefaults(Class<T> annotationType) { Object proxy = Proxy.newProxyInstance(annotationType.getClassLoader(), new Class<?>[] { annotationType }, new InvocationHandler() { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { return method.getDefaultValue(); }//from w w w. ja va2 s. com }); return annotationType.cast(proxy); } }