@Override public int getDimension() { if(!reallyClass.isArray()){ throw new ASMSupportException("The class " + getName() + " is not array"); } return type.getDimensions(); }
@Override public IClass getType(Class<?> javaClass) { String desc = Type.getDescriptor(javaClass); Reference<IClass> ref = cache.get(desc); IClass type = ref == null ? null : ref.get(); if (type == null) { if (AnyException.class.equals(javaClass)) { type = new AnyException(this); } else if (javaClass.isArray()) { type = getArrayType( ClassUtils.getRootComponentType(javaClass), Type .getType(javaClass).getDimensions()); } else { type = new ProductClass(javaClass, this); } cache.put(desc, new WeakReference<>(type)); } return type; }
/** * Create static block of class. * * @param block */ public MethodBuilder createStaticBlock(KernelStaticBlockBody block){ if(productClass.existStaticInitBlock()) { throw new IllegalArgumentException("The static block(<clinit>) has already exist, call modifyMethod to change it."); } return createStaticBlockInternal(block); }
for(Field gv : getFields()){ if(gv.getName().equals(name)){ found.add(gv); IClass objectType = getClassHolder().getType(Object.class); while(fieldOwner != null && !fieldOwner.equals(objectType)) { try {
ProductClass.this.addClinitMethod(meta); } else if (name.equals(ASConstants.INIT)) { ProductClass.this.addConstructor(meta); } else if (Modifiers.isBridge(access)){ ProductClass.this.getBridgeMethod().add(meta); } else { ProductClass.this.addDeclaredMethod(meta);
@Override public void initialized(ClassExecuteContext context) { InputStream is = classLoader.getResourceAsStream(productClass.getName()); try { LOG.print("Start modify class : " + productClass.getReallyClass());
public final void modifyMethod(String name, Class<?>[] argClasses, KernelModifiedMethodBody mb){ Class<?> clazz = productClass.getReallyClass(); if(argClasses == null){ argClasses = new Class<?>[0];
ASMSupportClassLoader classLoader = ProductClass.this.getClassHolder(); InputStream in = classLoader.getResourceAsStream(reallyClass.getName().replace('.', '/') + ".class"); if (in != null) {
@Override public void execute(ClassExecuteContext classExecuteContext) { for (FieldBuilder ifc : fields) { ifc.execute(classExecuteContext); } for (MethodBuilder imc : methods) { imc.execute(classExecuteContext); } for (MethodBuilder imc : methodModifiers) { imc.execute(classExecuteContext); } if(LOG.isPrintEnabled()){ LOG.print("End modify class : " + productClass.getReallyClass()); } }
@Override protected boolean doGenerate(GeneratorContext context, ProgramBlock<? extends KernelProgramBlock> block, LocVar encoder, IClass type, Param value) { JSONPool jsonPool = context.getJsonPool(); if(type instanceof ProductClass) { if(jsonPool.getOrRegister(((ProductClass)type).getReallyClass()) != null) { FieldVar pool = block.this_().field("jsonPool"); pool.call("getOrRegister", block.val(type)).call("parse", encoder, value); return true; } } return false; }
@Override public IClass getType(String possible) { String desc = ClassUtils.getDescription(possible); Reference<IClass> ref = cache.get(desc); IClass type = ref == null ? null : ref.get(); if (type == null) { if ("E".equals(desc)) { type = new AnyException(this); } else { Class<?> reflexClazz = ClassUtils.primitiveToClass(desc); if (reflexClazz == null) { try { reflexClazz = loadClass(ClassUtils.getClassname(possible)); } catch (ClassNotFoundException e) { throw new ASMSupportException(e); } } if (reflexClazz.isArray()) { type = getArrayType( ClassUtils.getRootComponentType(reflexClazz), Type .getType(reflexClazz).getDimensions()); } else { type = new ProductClass(reflexClazz, this); } } cache.put(desc, new WeakReference<>(type)); } return type; }