@Override public void visit(JavaClass obj) { String superclassName = obj.getSuperclassName(); isSynthetic = "java.rmi.server.RemoteStub".equals(superclassName); Attribute[] attributes = obj.getAttributes(); if (attributes != null) { for (Attribute a : attributes) { if (a instanceof Synthetic) { isSynthetic = true; } } } }
public static boolean classHasParameter(JavaClass obj) { for (Attribute a : obj.getAttributes()) { if (a instanceof Signature) { String sig = ((Signature) a).getSignature(); return sig.charAt(0) == '<'; } } return false; }
public static boolean isSynthetic(JavaClass j) { if (j.isSynthetic()) { return true; } for(Attribute a : j.getAttributes()) { if (a instanceof Synthetic) { return true; } } return false; } public static boolean isSynthetic(FieldGenOrMethodGen m) {
fout.write(LCBREOL); for (Attribute a : c.getAttributes()) { if (a.getTag() == org.apache.bcel.Const.ATTR_CODE) { for (Attribute ca : ((Code) a).getAttributes()) {
/** * Determine the outer class of obj. * * @param obj * @return JavaClass for outer class, or null if obj is not an outer class * @throws ClassNotFoundException */ @CheckForNull public static JavaClass getOuterClass(JavaClass obj) throws ClassNotFoundException { for (Attribute a : obj.getAttributes()) { if (a instanceof InnerClasses) { for (InnerClass ic : ((InnerClasses) a).getInnerClasses()) { if (obj.getClassNameIndex() == ic.getInnerClassIndex()) { // System.out.println("Outer class is " + // ic.getOuterClassIndex()); ConstantClass oc = (ConstantClass) obj.getConstantPool().getConstant(ic.getOuterClassIndex()); String ocName = oc.getBytes(obj.getConstantPool()); return Repository.lookupClass(ocName); } } } } return null; }
constantPool.accept(this); Field[] fields = obj.getFields(); Attribute[] attributes = obj.getAttributes(); for (Field field : fields) { doVisitField(field);
private Signature getSignature(JavaClass clazz) { for (Attribute attribute : clazz.getAttributes()) { if (attribute instanceof Signature) { return (Signature) attribute; } } return null; }
@Nullable private BootstrapMethods getBootstrapAttribute(JavaClass clz) { for (Attribute att : clz.getAttributes()) { if (att instanceof BootstrapMethods) { return (BootstrapMethods) att; } } return null; }
@Nullable private Attribute getBootstrapAttribute(JavaClass clz) { for (Attribute att : clz.getAttributes()) { if ("BootstrapMethods".equals(att.getName())) { return att; } } return null; }
public static boolean classHasParameter(JavaClass obj) { for (Attribute a : obj.getAttributes()) { if (a instanceof Signature) { String sig = ((Signature) a).getSignature(); return sig.charAt(0) == '<'; } } return false; }
public static boolean isSynthetic(JavaClass j) { if (j.isSynthetic()) { return true; } for(Attribute a : j.getAttributes()) { if (a instanceof Synthetic) { return true; } } return false; } public static boolean isSynthetic(FieldGenOrMethodGen m) {
/** * @return Annotations on the class * @since 6.0 */ public AnnotationEntry[] getAnnotationEntries() { if (annotations == null) { annotations = AnnotationEntry.createAnnotationEntries(getAttributes()); } return annotations; }
@Override public void visit(JavaClass obj) { String superclassName = obj.getSuperclassName(); isSynthetic = "java.rmi.server.RemoteStub".equals(superclassName); Attribute[] attributes = obj.getAttributes(); if (attributes != null) { for (Attribute a : attributes) { if (a instanceof Synthetic) { isSynthetic = true; } } } }
private void writeMainHTML( final AttributeHTML attribute_html ) throws IOException { try (PrintWriter file = new PrintWriter(new FileOutputStream(dir + class_name + ".html"))) { file.println("<HTML>\n" + "<HEAD><TITLE>Documentation for " + class_name + "</TITLE>" + "</HEAD>\n" + "<FRAMESET BORDER=1 cols=\"30%,*\">\n" + "<FRAMESET BORDER=1 rows=\"80%,*\">\n" + "<FRAME NAME=\"ConstantPool\" SRC=\"" + class_name + "_cp.html" + "\"\n MARGINWIDTH=\"0\" " + "MARGINHEIGHT=\"0\" FRAMEBORDER=\"1\" SCROLLING=\"AUTO\">\n" + "<FRAME NAME=\"Attributes\" SRC=\"" + class_name + "_attributes.html" + "\"\n MARGINWIDTH=\"0\" " + "MARGINHEIGHT=\"0\" FRAMEBORDER=\"1\" SCROLLING=\"AUTO\">\n" + "</FRAMESET>\n" + "<FRAMESET BORDER=1 rows=\"80%,*\">\n" + "<FRAME NAME=\"Code\" SRC=\"" + class_name + "_code.html\"\n MARGINWIDTH=0 " + "MARGINHEIGHT=0 FRAMEBORDER=1 SCROLLING=\"AUTO\">\n" + "<FRAME NAME=\"Methods\" SRC=\"" + class_name + "_methods.html\"\n MARGINWIDTH=0 " + "MARGINHEIGHT=0 FRAMEBORDER=1 SCROLLING=\"AUTO\">\n" + "</FRAMESET></FRAMESET></HTML>"); } final Attribute[] attributes = java_class.getAttributes(); for (int i = 0; i < attributes.length; i++) { attribute_html.writeAttribute(attributes[i], "class" + i); } } }
@Nullable private BootstrapMethod getBootstrapMethod(int bootstrapIndex) { for (Attribute a : cls.getAttributes()) { if ("BootstrapMethods".equals(a.getName())) { if (a instanceof BootstrapMethods) { BootstrapMethods bma = (BootstrapMethods) a; BootstrapMethod[] methods = bma.getBootstrapMethods(); if (bootstrapIndex >= methods.length) { return null; } return methods[bootstrapIndex]; } throw new RuntimeException("Incompatible bcel version, the bcel that is in use, is too old and doesn't have attribute 'BootstrapMethods'"); } } return null; }
protected Attribute[] findAttribute(final String name, final JavaClass clazz) { final Attribute[] all = clazz.getAttributes(); final List<Attribute> chosenAttrsList = new ArrayList<>(); for (final Attribute element : all) { if (verbose) { System.err.println("Attribute: " + element.getName()); } if (element.getName().equals(name)) { chosenAttrsList.add(element); } } return chosenAttrsList.toArray(new Attribute[] {}); }
public void visitJavaClass(JavaClass clazz) { stack.push(clazz); clazz.accept(visitor); Field[] fields = clazz.getFields(); for(int i=0; i < fields.length; i++) fields[i].accept(this); Method[] methods = clazz.getMethods(); for(int i=0; i < methods.length; i++) methods[i].accept(this); Attribute[] attributes = clazz.getAttributes(); for(int i=0; i < attributes.length; i++) attributes[i].accept(this); clazz.getConstantPool().accept(this); stack.pop(); }
@Override public void visitJavaClass(final JavaClass _clazz) { stack.push(_clazz); _clazz.accept(visitor); final Field[] fields = _clazz.getFields(); for (final Field field : fields) { field.accept(this); } final Method[] methods = _clazz.getMethods(); for (final Method method : methods) { method.accept(this); } final Attribute[] attributes = _clazz.getAttributes(); for (final Attribute attribute : attributes) { attribute.accept(this); } _clazz.getConstantPool().accept(this); stack.pop(); }
/** * Determine the outer class of obj. * * @param obj * @return JavaClass for outer class, or null if obj is not an outer class * @throws ClassNotFoundException */ @CheckForNull public static JavaClass getOuterClass(JavaClass obj) throws ClassNotFoundException { for (Attribute a : obj.getAttributes()) { if (a instanceof InnerClasses) { for (InnerClass ic : ((InnerClasses) a).getInnerClasses()) { if (obj.getClassNameIndex() == ic.getInnerClassIndex()) { // System.out.println("Outer class is " + // ic.getOuterClassIndex()); ConstantClass oc = (ConstantClass) obj.getConstantPool().getConstant(ic.getOuterClassIndex()); String ocName = oc.getBytes(obj.getConstantPool()); return Repository.lookupClass(ocName); } } } } return null; }
/** * Initialize with existing class. * @param clazz JavaClass object (e.g. read from file) */ public ClassGen(JavaClass clazz) { class_name_index = clazz.getClassNameIndex(); superclass_name_index = clazz.getSuperclassNameIndex(); class_name = clazz.getClassName(); super_class_name = clazz.getSuperclassName(); file_name = clazz.getSourceFileName(); access_flags = clazz.getAccessFlags(); cp = new ConstantPoolGen(clazz.getConstantPool()); major = clazz.getMajor(); minor = clazz.getMinor(); Attribute[] attributes = clazz.getAttributes(); Method[] methods = clazz.getMethods(); Field[] fields = clazz.getFields(); String[] interfaces = clazz.getInterfaceNames(); for(int i=0; i < interfaces.length; i++) addInterface(interfaces[i]); for(int i=0; i < attributes.length; i++) addAttribute(attributes[i]); for(int i=0; i < methods.length; i++) addMethod(methods[i]); for(int i=0; i < fields.length; i++) addField(fields[i]); }