use of org.hotswap.agent.javassist.CtClass in project HotswapAgent by HotswapProjects.
the class MultiType method getAllMultiInterfaces.
private Map getAllMultiInterfaces(MultiType type) {
Map map = new HashMap();
Iterator iter = type.interfaces.values().iterator();
while (iter.hasNext()) {
CtClass intf = (CtClass) iter.next();
map.put(intf.getName(), intf);
getAllInterfaces(intf, map);
}
return map;
}
use of org.hotswap.agent.javassist.CtClass in project HotswapAgent by HotswapProjects.
the class Type method getDeclaredInterfaces.
Map getDeclaredInterfaces(CtClass clazz, Map map) {
if (map == null)
map = new HashMap();
if (clazz.isInterface())
map.put(clazz.getName(), clazz);
CtClass[] interfaces;
try {
interfaces = clazz.getInterfaces();
} catch (NotFoundException e) {
throw new RuntimeException(e);
}
for (int i = 0; i < interfaces.length; i++) {
CtClass intf = interfaces[i];
map.put(intf.getName(), intf);
getDeclaredInterfaces(intf, map);
}
return map;
}
use of org.hotswap.agent.javassist.CtClass in project HotswapAgent by HotswapProjects.
the class Type method getAllInterfaces.
Map getAllInterfaces(CtClass clazz, Map map) {
if (map == null)
map = new HashMap();
if (clazz.isInterface())
map.put(clazz.getName(), clazz);
do {
try {
CtClass[] interfaces = clazz.getInterfaces();
for (int i = 0; i < interfaces.length; i++) {
CtClass intf = interfaces[i];
map.put(intf.getName(), intf);
getAllInterfaces(intf, map);
}
clazz = clazz.getSuperclass();
} catch (NotFoundException e) {
throw new RuntimeException(e);
}
} while (clazz != null);
return map;
}
use of org.hotswap.agent.javassist.CtClass in project HotswapAgent by HotswapProjects.
the class Type method findCommonInterfaces.
Map findCommonInterfaces(Map typeMap, Map alterMap) {
Iterator i = alterMap.keySet().iterator();
while (i.hasNext()) {
if (!typeMap.containsKey(i.next()))
i.remove();
}
// Reduce to subinterfaces
// This does not need to be recursive since we make a copy,
// and that copy contains all super types for the whole hierarchy
i = new ArrayList(alterMap.values()).iterator();
while (i.hasNext()) {
CtClass intf = (CtClass) i.next();
CtClass[] interfaces;
try {
interfaces = intf.getInterfaces();
} catch (NotFoundException e) {
throw new RuntimeException(e);
}
for (int c = 0; c < interfaces.length; c++) alterMap.remove(interfaces[c].getName());
}
return alterMap;
}
use of org.hotswap.agent.javassist.CtClass in project HotswapAgent by HotswapProjects.
the class Annotation method createMemberValue.
/**
* Makes an instance of <code>MemberValue</code>.
*
* @param cp the constant pool table.
* @param type the type of the member.
* @return the member value
* @throws NotFoundException when the type is not found
*/
public static MemberValue createMemberValue(ConstPool cp, CtClass type) throws NotFoundException {
if (type == CtClass.booleanType)
return new BooleanMemberValue(cp);
else if (type == CtClass.byteType)
return new ByteMemberValue(cp);
else if (type == CtClass.charType)
return new CharMemberValue(cp);
else if (type == CtClass.shortType)
return new ShortMemberValue(cp);
else if (type == CtClass.intType)
return new IntegerMemberValue(cp);
else if (type == CtClass.longType)
return new LongMemberValue(cp);
else if (type == CtClass.floatType)
return new FloatMemberValue(cp);
else if (type == CtClass.doubleType)
return new DoubleMemberValue(cp);
else if (type.getName().equals("java.lang.Class"))
return new ClassMemberValue(cp);
else if (type.getName().equals("java.lang.String"))
return new StringMemberValue(cp);
else if (type.isArray()) {
CtClass arrayType = type.getComponentType();
MemberValue member = createMemberValue(cp, arrayType);
return new ArrayMemberValue(member, cp);
} else if (type.isInterface()) {
Annotation info = new Annotation(cp, type);
return new AnnotationMemberValue(info, cp);
} else {
// treat as enum. I know this is not typed,
// but JBoss has an Annotation Compiler for JDK 1.4
// and I want it to work with that. - Bill Burke
EnumMemberValue emv = new EnumMemberValue(cp);
emv.setType(type.getName());
return emv;
}
}
Aggregations