/** * Return all declared methods with the given name and parameter types. * Note that in bytecode, constructors are named <code><init></code> * and static initializers are named <code><clinit></code>. */ public BCMethod[] getDeclaredMethods(String name, Class[] paramTypes) { if (paramTypes == null) return getDeclaredMethods(name, (String[]) null); String[] paramNames = new String[paramTypes.length]; for (int i = 0; i < paramTypes.length; i++) paramNames[i] = paramTypes[i].getName(); return getDeclaredMethods(name, paramNames); }
/** * Return all declared methods with the given name and parameter types. * Note that in bytecode, constructors are named <code><init></code> * and static initializers are named <code><clinit></code>. */ public BCMethod[] getDeclaredMethods(String name, Class[] paramTypes) { if (paramTypes == null) return getDeclaredMethods(name, (String[]) null); String[] paramNames = new String[paramTypes.length]; for (int i = 0; i < paramTypes.length; i++) paramNames[i] = paramTypes[i].getName(); return getDeclaredMethods(name, paramNames); }
/** * Return all declared methods with the given name and parameter types. * Note that in bytecode, constructors are named <code><init></code> * and static initializers are named <code><clinit></code>. */ public BCMethod[] getDeclaredMethods(String name, BCClass[] paramTypes) { if (paramTypes == null) return getDeclaredMethods(name, (String[]) null); String[] paramNames = new String[paramTypes.length]; for (int i = 0; i < paramTypes.length; i++) paramNames[i] = paramTypes[i].getName(); return getDeclaredMethods(name, paramNames); }
/** * Return all declared methods with the given name and parameter types. * Note that in bytecode, constructors are named <code><init></code> * and static initializers are named <code><clinit></code>. */ public BCMethod[] getDeclaredMethods(String name, BCClass[] paramTypes) { if (paramTypes == null) return getDeclaredMethods(name, (String[]) null); String[] paramNames = new String[paramTypes.length]; for (int i = 0; i < paramTypes.length; i++) paramNames[i] = paramTypes[i].getName(); return getDeclaredMethods(name, paramNames); }
/** * Return all the declared methods with the given name, or an empty array * if none. * Note that in bytecode, constructors are named <code><init></code> * and static initializers are named <code><clinit></code>. */ public BCMethod[] getDeclaredMethods(String name) { Collection matches = new LinkedList(); BCMethod[] methods = getDeclaredMethods(); for (int i = 0; i < methods.length; i++) if (methods[i].getName().equals(name)) matches.add(methods[i]); return (BCMethod[]) matches.toArray(new BCMethod[matches.size()]); }
/** * Return the declared method with the given name, or null if none. * If multiple methods are declared with the given name, which is returned * is undefined. * Note that in bytecode, constructors are named <code><init></code> * and static initializers are named <code><clinit></code>. */ public BCMethod getDeclaredMethod(String name) { BCMethod[] methods = getDeclaredMethods(); for (int i = 0; i < methods.length; i++) if (methods[i].getName().equals(name)) return methods[i]; return null; }
/** * Return the declared method with the given name, or null if none. * If multiple methods are declared with the given name, which is returned * is undefined. * Note that in bytecode, constructors are named <code><init></code> * and static initializers are named <code><clinit></code>. */ public BCMethod getDeclaredMethod(String name) { BCMethod[] methods = getDeclaredMethods(); for (int i = 0; i < methods.length; i++) if (methods[i].getName().equals(name)) return methods[i]; return null; }
/** * Return all the declared methods with the given name, or an empty array * if none. * Note that in bytecode, constructors are named <code><init></code> * and static initializers are named <code><clinit></code>. */ public BCMethod[] getDeclaredMethods(String name) { Collection matches = new LinkedList(); BCMethod[] methods = getDeclaredMethods(); for (int i = 0; i < methods.length; i++) if (methods[i].getName().equals(name)) matches.add(methods[i]); return (BCMethod[]) matches.toArray(new BCMethod[matches.size()]); }
/** * Return the methods of this class, including those of all superclasses, * or an empty array if none. * The base version of methods that are overridden will be included, as * will all constructors and static initializers. * The methods will be ordered from those in the most-specific type up to * those in {@link Object}. */ public BCMethod[] getMethods() { Collection allMethods = new LinkedList(); BCMethod[] methods; for (BCClass type = this; type != null; type = type.getSuperclassBC()) { methods = type.getDeclaredMethods(); for (int i = 0; i < methods.length; i++) allMethods.add(methods[i]); } return (BCMethod[]) allMethods.toArray(new BCMethod[allMethods.size()]); }
/** * Return the methods of this class, including those of all superclasses, * or an empty array if none. * The base version of methods that are overridden will be included, as * will all constructors and static initializers. * The methods will be ordered from those in the most-specific type up to * those in {@link Object}. */ public BCMethod[] getMethods() { Collection allMethods = new LinkedList(); BCMethod[] methods; for (BCClass type = this; type != null; type = type.getSuperclassBC()) { methods = type.getDeclaredMethods(); for (int i = 0; i < methods.length; i++) allMethods.add(methods[i]); } return (BCMethod[]) allMethods.toArray(new BCMethod[allMethods.size()]); }
/** * Return all declared methods with the given name and parameter types. * Note that in bytecode, constructors are named <code><init></code> * and static initializers are named <code><clinit></code>. */ public BCMethod[] getDeclaredMethods(String name, String[] paramTypes) { if (paramTypes == null) paramTypes = new String[0]; BCMethod[] methods = getDeclaredMethods(); List matches = null; for (int i = 0; i < methods.length; i++) { if (methods[i].getName().equals(name) && paramsMatch(methods[i], paramTypes)) { if (matches == null) matches = new ArrayList(3); matches.add(methods[i]); } } if (matches == null) return new BCMethod[0]; return (BCMethod[]) matches.toArray(new BCMethod[matches.size()]); }
/** * Return all declared methods with the given name and parameter types. * Note that in bytecode, constructors are named <code><init></code> * and static initializers are named <code><clinit></code>. */ public BCMethod[] getDeclaredMethods(String name, String[] paramTypes) { if (paramTypes == null) paramTypes = new String[0]; BCMethod[] methods = getDeclaredMethods(); List matches = null; for (int i = 0; i < methods.length; i++) { if (methods[i].getName().equals(name) && paramsMatch(methods[i], paramTypes)) { if (matches == null) matches = new ArrayList(3); matches.add(methods[i]); } } if (matches == null) return new BCMethod[0]; return (BCMethod[]) matches.toArray(new BCMethod[matches.size()]); }
/** * Return the declared method with the given name and parameter types, * or null if none. If multiple methods are declared with the given name * and parameters, which is returned is undefined. * Note that in bytecode, constructors are named <code><init></code> * and static initializers are named <code><clinit></code>. */ public BCMethod getDeclaredMethod(String name, String[] paramTypes) { if (paramTypes == null) paramTypes = new String[0]; BCMethod[] methods = getDeclaredMethods(); for (int i = 0; i < methods.length; i++) { if (methods[i].getName().equals(name) && paramsMatch(methods[i], paramTypes)) return methods[i]; } return null; }
/** * Return the declared method with the given name and parameter types, * or null if none. If multiple methods are declared with the given name * and parameters, which is returned is undefined. * Note that in bytecode, constructors are named <code><init></code> * and static initializers are named <code><clinit></code>. */ public BCMethod getDeclaredMethod(String name, String[] paramTypes) { if (paramTypes == null) paramTypes = new String[0]; BCMethod[] methods = getDeclaredMethods(); for (int i = 0; i < methods.length; i++) { if (methods[i].getName().equals(name) && paramsMatch(methods[i], paramTypes)) return methods[i]; } return null; }
/** * Return the declared method with the given name and signature, * or null if none. * Note that in bytecode, constructors are named <code><init></code> * and static initializers are named <code><clinit></code>. */ public BCMethod getDeclaredMethod(String name, String returnType, String[] paramTypes) { if (paramTypes == null) paramTypes = new String[0]; BCMethod[] methods = getDeclaredMethods(); for (int i = 0; i < methods.length; i++) { if (methods[i].getName().equals(name) && methods[i].getReturnName().equals(_project.getNameCache(). getExternalForm(returnType, false)) && paramsMatch(methods[i], paramTypes)) return methods[i]; } return null; }
/** * Return the declared method with the given name and signature, * or null if none. * Note that in bytecode, constructors are named <code><init></code> * and static initializers are named <code><clinit></code>. */ public BCMethod getDeclaredMethod(String name, String returnType, String[] paramTypes) { if (paramTypes == null) paramTypes = new String[0]; BCMethod[] methods = getDeclaredMethods(); for (int i = 0; i < methods.length; i++) { if (methods[i].getName().equals(name) && methods[i].getReturnName().equals(_project.getNameCache(). getExternalForm(returnType, false)) && paramsMatch(methods[i], paramTypes)) return methods[i]; } return null; }
private void addSynchronization(BCClass bc) { BCMethod[] methods = bc.getDeclaredMethods(); for (int i = 0; i < methods.length; i++) { if (methods[i].isPublic() && _synchs.contains(methods[i].getName())) methods[i].setSynchronized(true); } // add synchronized isLoaded call. // public synchronized boolean isLoaded (int field) // { // return super.isLoaded (field); // } BCMethod method = bc.declareMethod("isLoaded", boolean.class, new Class[]{ int.class }); method.setSynchronized(true); Code code = method.getCode(true); code.aload().setThis(); code.iload().setParam(0); code.invokespecial().setMethod(AbstractPCData.class, "isLoaded", boolean.class, new Class[]{ int.class }); code.calculateMaxLocals(); code.calculateMaxStack(); code.ireturn(); }
private void addSynchronization(BCClass bc) { BCMethod[] methods = bc.getDeclaredMethods(); for (int i = 0; i < methods.length; i++) { if (methods[i].isPublic() && _synchs.contains(methods[i].getName())) methods[i].setSynchronized(true); } // add synchronized isLoaded call. // public synchronized boolean isLoaded (int field) // { // return super.isLoaded (field); // } BCMethod method = bc.declareMethod("isLoaded", boolean.class, new Class[]{ int.class }); method.setSynchronized(true); Code code = method.getCode(true); code.aload().setThis(); code.iload().setParam(0); code.invokespecial().setMethod(AbstractPCData.class, "isLoaded", boolean.class, new Class[]{ int.class }); code.calculateMaxLocals(); code.calculateMaxStack(); code.ireturn(); }
private void addSynchronization(BCClass bc) { BCMethod[] methods = bc.getDeclaredMethods(); for (int i = 0; i < methods.length; i++) { if (methods[i].isPublic() && _synchs.contains(methods[i].getName())) methods[i].setSynchronized(true); } // add synchronized isLoaded call. // public synchronized boolean isLoaded (int field) // { // return super.isLoaded (field); // } BCMethod method = bc.declareMethod("isLoaded", boolean.class, new Class[]{ int.class }); method.setSynchronized(true); Code code = method.getCode(true); code.aload().setThis(); code.iload().setParam(0); code.invokespecial().setMethod(AbstractPCData.class, "isLoaded", boolean.class, new Class[]{ int.class }); code.calculateMaxLocals(); code.calculateMaxStack(); code.ireturn(); }
public void acceptVisit(BCVisitor visit) { visit.enterBCClass(this); ConstantPool pool = null; try { pool = _state.getPool(); } catch (UnsupportedOperationException uoe) { } if (pool != null) pool.acceptVisit(visit); BCField[] fields = getDeclaredFields(); for (int i = 0; i < fields.length; i++) { visit.enterBCMember(fields[i]); fields[i].acceptVisit(visit); visit.exitBCMember(fields[i]); } BCMethod[] methods = getDeclaredMethods(); for (int i = 0; i < methods.length; i++) { visit.enterBCMember(methods[i]); methods[i].acceptVisit(visit); visit.exitBCMember(methods[i]); } visitAttributes(visit); visit.exitBCClass(this); }