/** @see com.puppycrawl.tools.checkstyle.bcel.IObjectSetVisitor */ public void visitObject(Object aJavaClass) { final JavaClass javaClass = (JavaClass) aJavaClass; final String className = javaClass.getClassName(); final JavaClass[] superClasses = javaClass.getSuperClasses(); final Method[] methods = javaClass.getMethods(); // Check all methods for (int i = 0; i < methods.length; i++) { final Method method = methods[i]; // Check that the method is a possible match if (!method.isPrivate() && method.isStatic()) { // Go through all their superclasses for (int j = 0; j < superClasses.length; j++) { final JavaClass superClass = superClasses[j]; final String superClassName = superClass.getClassName(); final Method[] superClassMethods = superClass.getMethods(); // Go through the methods of the superclasses for (int k = 0; k < superClassMethods.length; k++) { final Method superClassMethod = superClassMethods[k]; if (superClassMethod.getName().equals(method.getName()) && !ignore(className, method)) { Type[] methodTypes = method.getArgumentTypes(); Type[] superTypes = superClassMethod.getArgumentTypes(); if (methodTypes.length == superTypes.length) { boolean match = true; for (int arg = 0; arg < methodTypes.length; arg++) { if (!methodTypes[arg].equals(superTypes[arg])) { match = false; } } // Same method parameters if (match) { log(javaClass, 0, "hidden.static.method", new Object[] {method, superClassName}); } } } } } } } }
private void importMethod(DbJVClass dbClaz, Method method) throws DbException { if (dbClaz == null) { return; } String methodName = method.getName(); boolean isConstructor = "<init>".equals(methodName); boolean isInitBlock = "<clinit>".equals(methodName); DbOOAbstractMethod oper = null; if (isInitBlock) { new DbJVInitBlock(dbClaz); } else if (isConstructor) { DbJVConstructor constr = new DbJVConstructor(dbClaz); importExceptions(constr, method); oper = constr; } else { // create method and return type DbJVMethod meth = new DbJVMethod(dbClaz); Type type = method.getReturnType(); meth.setReturnType(toAdt(type)); meth.setTypeUse(toTypeUse(type)); // set method modifiers meth.setAbstract(method.isAbstract()); meth.setFinal(method.isFinal()); meth.setNative(method.isNative()); meth.setStatic(method.isStatic()); meth.setStrictfp(method.isStrictfp()); meth.setSynchronized(method.isSynchronized()); // method.isTransient() // method.isVolatile() importExceptions(meth, method); oper = meth; } // set name and visibility if (oper != null) { oper.setName(methodName); oper.setVisibility(toVisibility(method)); // create parameters Type[] args = method.getArgumentTypes(); for (Type arg : args) { DbJVParameter param = new DbJVParameter(oper); param.setType(toAdt(arg)); param.setTypeUse(toTypeUse(arg)); } // end for } // end if } // end importMethod()
/** * Creates a new {@link GeneratorAdapter}. * * @param access access flags of the adapted method. * @param method the adapted method. * @param mv the method visitor to which this adapter delegates calls. */ public GeneratorAdapter(final int access, final Method method, final MethodVisitor mv) { super(access, method.getDescriptor(), mv); this.access = access; this.returnType = method.getReturnType(); this.argumentTypes = method.getArgumentTypes(); }