Object getValue(ClassLoader cl, ClassPool cp, Method method) throws ClassNotFoundException { if (values == null) throw new ClassNotFoundException( "no array elements found: " + method.getName()); int size = values.length; Class clazz; if (type == null) { clazz = method.getReturnType().getComponentType(); if (clazz == null || size > 0) throw new ClassNotFoundException("broken array type: " + method.getName()); } else clazz = type.getType(cl); Object a = Array.newInstance(clazz, size); for (int i = 0; i < size; i++) Array.set(a, i, values[i].getValue(cl, cp, method)); return a; }
@Override Object getValue(ClassLoader cl, ClassPool cp, Method method) throws ClassNotFoundException { if (values == null) throw new ClassNotFoundException( "no array elements found: " + method.getName()); int size = values.length; Class<?> clazz; if (type == null) { clazz = method.getReturnType().getComponentType(); if (clazz == null || size > 0) throw new ClassNotFoundException("broken array type: " + method.getName()); } else clazz = type.getType(cl); Object a = Array.newInstance(clazz, size); for (int i = 0; i < size; i++) Array.set(a, i, values[i].getValue(cl, cp, method)); return a; }
return getDefault(name, method); else return mv.getValue(classLoader, pool, method);
try { if (mv != null) value = mv.getValue(classLoader, pool, methods[i]); if (value == null) value = getDefault(name, methods[i]);
try { if (mv != null) value = mv.getValue(classLoader, pool, methods[i]); if (value == null) value = getDefault(name, methods[i]);
private Object getDefault(String name, Method method) throws ClassNotFoundException, RuntimeException { String classname = annotation.getTypeName(); if (pool != null) { try { CtClass cc = pool.get(classname); ClassFile cf = cc.getClassFile2(); MethodInfo minfo = cf.getMethod(name); if (minfo != null) { AnnotationDefaultAttribute ainfo = (AnnotationDefaultAttribute) minfo.getAttribute(AnnotationDefaultAttribute.tag); if (ainfo != null) { MemberValue mv = ainfo.getDefaultValue(); return mv.getValue(classLoader, pool, method); } } } catch (NotFoundException e) { throw new RuntimeException("cannot find a class file: " + classname); } } throw new RuntimeException("no default value: " + classname + "." + name + "()"); }
/** * Executes a method invocation on a proxy instance. * The implementations of <code>toString()</code>, <code>equals()</code>, * and <code>hashCode()</code> are directly supplied by the * <code>AnnotationImpl</code>. The <code>annotationType()</code> method * is also available on the proxy instance. */ @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String name = method.getName(); if (Object.class == method.getDeclaringClass()) { if ("equals".equals(name)) { Object obj = args[0]; return Boolean.valueOf(checkEquals(obj)); } else if ("toString".equals(name)) return annotation.toString(); else if ("hashCode".equals(name)) return Integer.valueOf(hashCode()); } else if ("annotationType".equals(name) && method.getParameterTypes().length == 0) return getAnnotationType(); MemberValue mv = annotation.getMemberValue(name); if (mv == null) return getDefault(name, method); return mv.getValue(classLoader, pool, method); }
try { if (mv != null) value = mv.getValue(classLoader, pool, methods[i]); if (value == null) value = getDefault(name, methods[i]);
try { if (mv != null) value = mv.getValue(classLoader, pool, methods[i]); if (value == null) value = getDefault(name, methods[i]);
private Object getDefault(String name, Method method) throws ClassNotFoundException, RuntimeException { String classname = annotation.getTypeName(); if (pool != null) { try { CtClass cc = pool.get(classname); ClassFile cf = cc.getClassFile2(); MethodInfo minfo = cf.getMethod(name); if (minfo != null) { AnnotationDefaultAttribute ainfo = (AnnotationDefaultAttribute) minfo.getAttribute(AnnotationDefaultAttribute.tag); if (ainfo != null) { MemberValue mv = ainfo.getDefaultValue(); return mv.getValue(classLoader, pool, method); } } } catch (NotFoundException e) { throw new RuntimeException("cannot find a class file: " + classname); } } throw new RuntimeException("no default value: " + classname + "." + name + "()"); }
Object getValue(ClassLoader cl, ClassPool cp, Method method) throws ClassNotFoundException { if (values == null) throw new ClassNotFoundException( "no array elements found: " + method.getName()); int size = values.length; Class clazz; if (type == null) { clazz = method.getReturnType().getComponentType(); if (clazz == null || size > 0) throw new ClassNotFoundException("broken array type: " + method.getName()); } else clazz = type.getType(cl); Object a = Array.newInstance(clazz, size); for (int i = 0; i < size; i++) Array.set(a, i, values[i].getValue(cl, cp, method)); return a; }
Object getValue(ClassLoader cl, ClassPool cp, Method method) throws ClassNotFoundException { if (values == null) throw new ClassNotFoundException( "no array elements found: " + method.getName()); int size = values.length; Class clazz; if (type == null) { clazz = method.getReturnType().getComponentType(); if (clazz == null || size > 0) throw new ClassNotFoundException("broken array type: " + method.getName()); } else clazz = type.getType(cl); Object a = Array.newInstance(clazz, size); for (int i = 0; i < size; i++) Array.set(a, i, values[i].getValue(cl, cp, method)); return a; }
Object getValue(ClassLoader cl, ClassPool cp, Method method) throws ClassNotFoundException { if (values == null) throw new ClassNotFoundException( "no array elements found: " + method.getName()); int size = values.length; Class clazz; if (type == null) { clazz = method.getReturnType().getComponentType(); if (clazz == null || size > 0) throw new ClassNotFoundException("broken array type: " + method.getName()); } else clazz = type.getType(cl); Object a = Array.newInstance(clazz, size); for (int i = 0; i < size; i++) Array.set(a, i, values[i].getValue(cl, cp, method)); return a; }
Object getValue(ClassLoader cl, ClassPool cp, Method method) throws ClassNotFoundException { if (values == null) throw new ClassNotFoundException( "no array elements found: " + method.getName()); int size = values.length; Class clazz; if (type == null) { clazz = method.getReturnType().getComponentType(); if (clazz == null || size > 0) throw new ClassNotFoundException("broken array type: " + method.getName()); } else clazz = type.getType(cl); Object a = Array.newInstance(clazz, size); for (int i = 0; i < size; i++) Array.set(a, i, values[i].getValue(cl, cp, method)); return a; }
Object getValue(ClassLoader cl, ClassPool cp, Method method) throws ClassNotFoundException { if (values == null) throw new ClassNotFoundException( "no array elements found: " + method.getName()); int size = values.length; Class clazz; if (type == null) { clazz = method.getReturnType().getComponentType(); if (clazz == null || size > 0) throw new ClassNotFoundException("broken array type: " + method.getName()); } else clazz = type.getType(cl); Object a = Array.newInstance(clazz, size); for (int i = 0; i < size; i++) Array.set(a, i, values[i].getValue(cl, cp, method)); return a; }
return getDefault(name, method); else return mv.getValue(classLoader, pool, method);
private Object getDefault(String name, Method method) throws ClassNotFoundException, RuntimeException { String classname = annotation.getTypeName(); if (pool != null) { try { CtClass cc = pool.get(classname); ClassFile cf = cc.getClassFile2(); MethodInfo minfo = cf.getMethod(name); if (minfo != null) { AnnotationDefaultAttribute ainfo = (AnnotationDefaultAttribute) minfo.getAttribute(AnnotationDefaultAttribute.tag); if (ainfo != null) { MemberValue mv = ainfo.getDefaultValue(); return mv.getValue(classLoader, pool, method); } } } catch (NotFoundException e) { throw new RuntimeException("cannot find a class file: " + classname); } } throw new RuntimeException("no default value: " + classname + "." + name + "()"); }
private Object getDefault(String name, Method method) throws ClassNotFoundException, RuntimeException { String classname = annotation.getTypeName(); if (pool != null) { try { CtClass cc = pool.get(classname); ClassFile cf = cc.getClassFile2(); MethodInfo minfo = cf.getMethod(name); if (minfo != null) { AnnotationDefaultAttribute ainfo = (AnnotationDefaultAttribute) minfo.getAttribute(AnnotationDefaultAttribute.tag); if (ainfo != null) { MemberValue mv = ainfo.getDefaultValue(); return mv.getValue(classLoader, pool, method); } } } catch (NotFoundException e) { throw new RuntimeException("cannot find a class file: " + classname); } } throw new RuntimeException("no default value: " + classname + "." + name + "()"); }
private Object getDefault(String name, Method method) throws ClassNotFoundException, RuntimeException { String classname = annotation.getTypeName(); if (pool != null) { try { CtClass cc = pool.get(classname); ClassFile cf = cc.getClassFile2(); MethodInfo minfo = cf.getMethod(name); if (minfo != null) { AnnotationDefaultAttribute ainfo = (AnnotationDefaultAttribute) minfo.getAttribute(AnnotationDefaultAttribute.tag); if (ainfo != null) { MemberValue mv = ainfo.getDefaultValue(); return mv.getValue(classLoader, pool, method); } } } catch (NotFoundException e) { throw new RuntimeException("cannot find a class file: " + classname); } } throw new RuntimeException("no default value: " + classname + "." + name + "()"); }
private Object getDefault(String name, Method method) throws ClassNotFoundException, RuntimeException { String classname = annotation.getTypeName(); if (pool != null) { try { CtClass cc = pool.get(classname); ClassFile cf = cc.getClassFile2(); MethodInfo minfo = cf.getMethod(name); if (minfo != null) { AnnotationDefaultAttribute ainfo = (AnnotationDefaultAttribute) minfo.getAttribute(AnnotationDefaultAttribute.tag); if (ainfo != null) { MemberValue mv = ainfo.getDefaultValue(); return mv.getValue(classLoader, pool, method); } } } catch (NotFoundException e) { throw new RuntimeException("cannot find a class file: " + classname); } } throw new RuntimeException("no default value: " + classname + "." + name + "()"); }