@Override public Class<?> afterDefineClass(Class<?> result, IClass type) throws Exception { cache.put(type.getDescription(), new SoftReference<>(type)); return result; }
protected String getMethodCacheKey (String name, IClass... parameterTypes) { StringBuilder keySb = new StringBuilder(name); if(parameterTypes != null) { for(IClass type : parameterTypes) { keySb.append(type.getDescription()); } } return keySb.toString(); }
private String getDescription(IClass root, int dim) { StringBuilder nameKey = new StringBuilder(); while (dim-- > 0) { nameKey.append('['); } if (root.isPrimitive()) { nameKey.append(root.getDescription()); } else { nameKey.append(root.getDescription()); } return nameKey.toString(); }
/** * * @param elementType * @param dim */ public ArrayClass(IClass elementType, int dim, ASMSupportClassLoader classLoader) { super(classLoader); version = elementType.getVersion(); mod = elementType.getModifiers(); superClass = classLoader.getType(Object.class); interfaces = new IClass[]{classLoader.getType(Cloneable.class), classLoader.getType(Serializable.class)}; this.elementType = elementType; this.dim = dim; StringBuilder descsb = new StringBuilder(); int tmpDim = dim; while(tmpDim>0){ descsb.append("["); tmpDim--; } descsb.append(elementType.getDescription()); desc = descsb.toString(); name = desc; }
@Override public void execute(ClassExecuteContext context) { if(value != null && !Modifiers.isStatic(modifiers)) { throw new ASMSupportException("The initial value '" + value + "' of field '" + name + "' is invalided, cause by the field is not static, and the initial value only support static field."); } if(value != null && value instanceof Boolean) { value = (Boolean) value ? 1 : 0; } context.getClassVisitor().visitField( fe.getModifiers(), name, fe.getType().getDescription(), null, value).visitEnd(); }