/** * Adds a Code attribute. * * <p> * The added attribute must share the same constant pool table as this * <code>method_info</code> structure. */ public void setCodeAttribute(CodeAttribute cattr) { removeCodeAttribute(); if (attribute == null) attribute = new ArrayList(); attribute.add(cattr); }
/** * Adds a Code attribute. * * <p> * The added attribute must share the same constant pool table as this * <code>method_info</code> structure. */ public void setCodeAttribute(CodeAttribute cattr) { removeCodeAttribute(); if (attribute == null) attribute = new ArrayList<AttributeInfo>(); attribute.add(cattr); }
/** * Adds a Code attribute. * * <p> * The added attribute must share the same constant pool table as this * <code>method_info</code> structure. */ public void setCodeAttribute(CodeAttribute cattr) { removeCodeAttribute(); if (attribute == null) attribute = new ArrayList(); attribute.add(cattr); }
/** * Adds a Code attribute. * * <p> * The added attribute must share the same constant pool table as this * <code>method_info</code> structure. */ public void setCodeAttribute(CodeAttribute cattr) { removeCodeAttribute(); if (attribute == null) attribute = new ArrayList(); attribute.add(cattr); }
/** * Adds a Code attribute. * * <p> * The added attribute must share the same constant pool table as this * <code>method_info</code> structure. */ public void setCodeAttribute(CodeAttribute cattr) { removeCodeAttribute(); if (attribute == null) attribute = new ArrayList(); attribute.add(cattr); }
/** * Adds a Code attribute. * * <p> * The added attribute must share the same constant pool table as this * <code>method_info</code> structure. */ public void setCodeAttribute(CodeAttribute cattr) { removeCodeAttribute(); if (attribute == null) attribute = new LinkedList(); attribute.add(cattr); }
/** * Adds a Code attribute. * * <p> * The added attribute must share the same constant pool table as this * <code>method_info</code> structure. */ public void setCodeAttribute(CodeAttribute cattr) { removeCodeAttribute(); if (attribute == null) attribute = new ArrayList(); attribute.add(cattr); }
/** * if no parameters are given, a return-type will be defined, otherwise not! * * @param cls class to add the method to * @param field field properties (type) * @param name * @param body method body * @param parameter (optional) method call argument types */ static void addMethod(CtClass cls, CtClass returnType, String name, String body, CtClass... parameter) { try { CtMethod ctMethod = CtNewMethod.make(returnType, name, parameter, EMPTY_CTCLASS_ARR, body, cls); if (cls.isInterface()) { ctMethod.setModifiers(ctMethod.getModifiers() | AccessFlag.ABSTRACT); /* * without removing the "code attribute" on interfaces we get the following error: * "java.lang.ClassFormatError: Code attribute in native or abstract methods in class file Test" * */ ctMethod.getMethodInfo().removeCodeAttribute(); } cls.addMethod(ctMethod); } catch (Exception e) { ManagedException.forward(e); } } }