/** * @return the (finally) built up Java class object. */ public JavaClass getJavaClass() { final int[] interfaces = getInterfaces(); final Field[] fields = getFields(); final Method[] methods = getMethods(); Attribute[] attributes = null; if (annotation_vec.isEmpty()) { attributes = getAttributes(); } else { // TODO: Sometime later, trash any attributes called 'RuntimeVisibleAnnotations' or 'RuntimeInvisibleAnnotations' final Attribute[] annAttributes = AnnotationEntryGen.getAnnotationAttributes(cp, getAnnotationEntries()); attributes = new Attribute[attribute_vec.size()+annAttributes.length]; attribute_vec.toArray(attributes); System.arraycopy(annAttributes,0,attributes,attribute_vec.size(),annAttributes.length); } // Must be last since the above calls may still add something to it final ConstantPool _cp = this.cp.getFinalConstantPool(); return new JavaClass(class_name_index, superclass_name_index, file_name, major, minor, super.getAccessFlags(), _cp, interfaces, fields, methods, attributes); }
/** * @return the (finally) built up Java class object. */ public JavaClass getJavaClass() { int[] interfaces = getInterfaces(); Field[] fields = getFields(); Method[] methods = getMethods(); Attribute[] attributes = getAttributes(); // Must be last since the above calls may still add something to it ConstantPool cp = this.cp.getFinalConstantPool(); return new JavaClass(class_name_index, superclass_name_index, file_name, major, minor, access_flags, cp, interfaces, fields, methods, attributes); }
private byte[] getBytesFromClass(final String className) throws ClassNotFoundException, IOException { final JavaClass clazz = getTestClass(className); final ConstantPoolGen cp = new ConstantPoolGen(clazz.getConstantPool()); final Method[] methods = clazz.getMethods(); for (int i = 0; i < methods.length; i++) { final Method method = methods[i]; if (!method.isNative() && !method.isAbstract()) { methods[i] = injection(clazz, method, cp, findFirstStringLocalVariableOffset(method)); } } clazz.setConstantPool(cp.getFinalConstantPool()); return clazz.getBytes(); }