String name = method.getName();
MemberValue mv = annotation.getMemberValue(name);
if (mv == null)
- return getDefault(name);
+ return getDefault(name, method);
else
- return mv.getValue(classLoader, pool);
+ return mv.getValue(classLoader, pool, method);
}
- private Object getDefault(String name)
+ private Object getDefault(String name, Method method)
throws ClassNotFoundException, RuntimeException
{
String classname = annotation.getTypeName();
minfo.getAttribute(AnnotationDefaultAttribute.tag);
if (ainfo != null) {
MemberValue mv = ainfo.getDefaultValue();
- return mv.getValue(classLoader, pool);
+ return mv.getValue(classLoader, pool, method);
}
}
}
import javassist.ClassPool;
import javassist.bytecode.ConstPool;
import java.io.IOException;
+import java.lang.reflect.Method;
/**
* Nested annotation.
value = a;
}
- Object getValue(ClassLoader cl, ClassPool cp)
+ Object getValue(ClassLoader cl, ClassPool cp, Method m)
throws ClassNotFoundException
{
return AnnotationImpl.make(cl, getType(cl), cp, value);
import javassist.bytecode.ConstPool;
import java.io.IOException;
import java.lang.reflect.Array;
+import java.lang.reflect.Method;
/**
* Array member.
values = null;
}
- Object getValue(ClassLoader cl, ClassPool cp) throws ClassNotFoundException {
- if (type == null || values == null)
- throw new ClassNotFoundException("no array elements specified");
+ 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;
- Object a = Array.newInstance(type.getType(cl), size);
+ 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));
+ Array.set(a, i, values[i].getValue(cl, cp, method));
return a;
}
import javassist.ClassPool;
import javassist.bytecode.ConstPool;
import java.io.IOException;
+import java.lang.reflect.Method;
/**
* Boolean constant value.
setValue(false);
}
- Object getValue(ClassLoader cl, ClassPool cp) {
+ Object getValue(ClassLoader cl, ClassPool cp, Method m) {
return new Boolean(getValue());
}
import javassist.ClassPool;
import javassist.bytecode.ConstPool;
import java.io.IOException;
+import java.lang.reflect.Method;
/**
* Byte constant value.
setValue((byte)0);
}
- Object getValue(ClassLoader cl, ClassPool cp) {
+ Object getValue(ClassLoader cl, ClassPool cp, Method m) {
return new Byte(getValue());
}
import javassist.ClassPool;
import javassist.bytecode.ConstPool;
import java.io.IOException;
+import java.lang.reflect.Method;
/**
* Char constant value.
setValue('\0');
}
- Object getValue(ClassLoader cl, ClassPool cp) {
+ Object getValue(ClassLoader cl, ClassPool cp, Method m) {
return new Character(getValue());
}
import javassist.bytecode.ConstPool;
import javassist.bytecode.Descriptor;
import java.io.IOException;
+import java.lang.reflect.Method;
/**
* Class value.
setValue("java.lang.Class");
}
- Object getValue(ClassLoader cl, ClassPool cp)
+ Object getValue(ClassLoader cl, ClassPool cp, Method m)
throws ClassNotFoundException
{
return loadClass(cl, getValue());
import javassist.ClassPool;
import javassist.bytecode.ConstPool;
import java.io.IOException;
+import java.lang.reflect.Method;
/**
* Double floating-point number constant value.
*
* @author <a href="mailto:bill@jboss.org">Bill Burke</a>
* @author Shigeru Chiba
- * @version $Revision: 1.6 $
+ * @version $Revision: 1.7 $
*/
public class DoubleMemberValue extends MemberValue {
int valueIndex;
setValue(0.0);
}
- Object getValue(ClassLoader cl, ClassPool cp) {
+ Object getValue(ClassLoader cl, ClassPool cp, Method m) {
return new Double(getValue());
}
package javassist.bytecode.annotation;
import java.io.IOException;
+import java.lang.reflect.Method;
import javassist.ClassPool;
import javassist.bytecode.ConstPool;
typeIndex = valueIndex = 0;
}
- Object getValue(ClassLoader cl, ClassPool cp)
+ Object getValue(ClassLoader cl, ClassPool cp, Method m)
throws ClassNotFoundException
{
try {
import javassist.ClassPool;
import javassist.bytecode.ConstPool;
import java.io.IOException;
+import java.lang.reflect.Method;
/**
* Floating-point number constant value.
*
* @author <a href="mailto:bill@jboss.org">Bill Burke</a>
* @author Shigeru Chiba
- * @version $Revision: 1.6 $
+ * @version $Revision: 1.7 $
*/
public class FloatMemberValue extends MemberValue {
int valueIndex;
setValue(0.0F);
}
- Object getValue(ClassLoader cl, ClassPool cp) {
+ Object getValue(ClassLoader cl, ClassPool cp, Method m) {
return new Float(getValue());
}
import javassist.ClassPool;
import javassist.bytecode.ConstPool;
import java.io.IOException;
+import java.lang.reflect.Method;
/**
* Integer constant value.
setValue(0);
}
- Object getValue(ClassLoader cl, ClassPool cp) {
+ Object getValue(ClassLoader cl, ClassPool cp, Method m) {
return new Integer(getValue());
}
import javassist.ClassPool;
import javassist.bytecode.ConstPool;
import java.io.IOException;
+import java.lang.reflect.Method;
/**
* Long integer constant value.
setValue(0L);
}
- Object getValue(ClassLoader cl, ClassPool cp) {
+ Object getValue(ClassLoader cl, ClassPool cp, Method m) {
return new Long(getValue());
}
import javassist.ClassPool;
import javassist.bytecode.ConstPool;
import java.io.IOException;
+import java.lang.reflect.Method;
/**
* The value of a member declared in an annotation.
* Returns the value. If the value type is a primitive type, the
* returned value is boxed.
*/
- abstract Object getValue(ClassLoader cl, ClassPool cp)
+ abstract Object getValue(ClassLoader cl, ClassPool cp, Method m)
throws ClassNotFoundException;
abstract Class getType(ClassLoader cl) throws ClassNotFoundException;
import javassist.ClassPool;
import javassist.bytecode.ConstPool;
import java.io.IOException;
+import java.lang.reflect.Method;
/**
* Short integer constant value.
setValue((short)0);
}
- Object getValue(ClassLoader cl, ClassPool cp) {
+ Object getValue(ClassLoader cl, ClassPool cp, Method m) {
return new Short(getValue());
}
import javassist.ClassPool;
import javassist.bytecode.ConstPool;
import java.io.IOException;
+import java.lang.reflect.Method;
/**
* String constant value.
setValue("");
}
- Object getValue(ClassLoader cl, ClassPool cp) {
+ Object getValue(ClassLoader cl, ClassPool cp, Method m) {
return getValue();
}