Package org.apache.bcel.classfile

Examples of org.apache.bcel.classfile.Method


     * @param sig method signature
     * @return <code>true</code> if method was present, <code>false</code> if not
     */
    public boolean deleteMethod(String name, String sig) {
        ClassGen cg = getClassGen();
        Method method = cg.containsMethod(name, sig);
        if (method == null) {
            return false;
        } else {
            cg.removeMethod(method);
            m_isModified = true;
View Full Code Here


            Method[] cmethods = cjc.getMethods();
            if (tmethods.length != cmethods.length) {
                return false;
            }
            for (int i = 0; i < tmethods.length; i++) {
                Method tmethod = tmethods[i];
                Method cmethod = cmethods[i];
                if (!equalFieldOrMethods(tmethod, cmethod) ||
                    !equalMethods(tmethod, cmethod)) {
                    return false;
                }
            }
View Full Code Here

    Method[] expected_methods = expected.getMethods();
    Method[] obtained_methods = obtained.getMethods();
    int i=0;
    int k=0;
    for(i=0;i< expected_methods.length;i++) {
      Method expectedm = expected_methods[i];
      Method obtainedm;
      for(k=i;k < obtained_methods.length; k++) {
        obtainedm = obtained_methods[k];
        if (obtainedm.getSignature().equals(expectedm.getSignature())) {
          obtained_methods[k]=obtained_methods[i];
          obtained_methods[i]=null;
          //System.out.println(expectedm.getCode().toString(true));
          assertEquals("MethodCode is different", expectedm.getCode().toString(false), obtainedm.getCode().toString(false));
          break;
        }
      }
      if (k==obtained_methods.length) {
        fail("Method "+expectedm.getSignature()+ " not found in obtained");       
View Full Code Here

        InstructionHandle handle = null;
        Instruction inst = null;

        GETSTATIC getStatic = null;

        Method m = null;

        try {
            il = mg.getInstructionList();
            handle = il.getStart();
            if (level_enters == SIMPLEENTER) {
View Full Code Here

            }
            for (int i = 0; i < methods.length; i++) {
                if (!(methods[i].isAbstract() || methods[i].isNative())) {
                    MethodGen mg =
                        new MethodGen(methods[i], source.getClassName(), cp);
                    Method stripped = trans.speedup(methods[i], mg, cp);
                    if (stripped != null)
                        cg.replaceMethod(methods[i], stripped);
                }
            }
            trans.done();
View Full Code Here

     */
    public static SourceLineAnnotation forFirstLineOfMethod(MethodDescriptor methodDescriptor) {
        SourceLineAnnotation result = null;

        try {
            Method m = Global.getAnalysisCache().getMethodAnalysis(Method.class, methodDescriptor);
            XClass xclass = Global.getAnalysisCache().getClassAnalysis(XClass.class, methodDescriptor.getClassDescriptor());
            LineNumberTable lnt = m.getLineNumberTable();
            String sourceFile = xclass.getSource();
            if (sourceFile != null && lnt != null) {
                int firstLine = Integer.MAX_VALUE;
                int bytecode = 0;
                LineNumber[] entries = lnt.getLineNumberTable();
View Full Code Here

    public static SourceLineAnnotation fromVisitedInstruction(MethodDescriptor methodDescriptor, int position) {
        try {
            IAnalysisCache analysisCache = Global.getAnalysisCache();
            JavaClass jclass = analysisCache.getClassAnalysis(JavaClass.class, methodDescriptor.getClassDescriptor());
            Method method = analysisCache.getMethodAnalysis(Method.class, methodDescriptor);
            return fromVisitedInstruction(jclass, method, position);
        } catch (CheckedAnalysisException e) {
            return createReallyUnknown(methodDescriptor.getClassDescriptor().toDottedClassName());
        }
    }
View Full Code Here

        try {
            JavaClass targetClass = AnalysisContext.currentAnalysisContext().lookupClass(className);
            targetMethod = Hierarchy.findMethod(targetClass, methodName, methodSig);
            if (targetMethod != null) {
                Method method = targetMethod.getMethod();
                if (method != null) {
                    code = method.getCode();
                }
            }

        } catch (ClassNotFoundException e) {
            AnalysisContext.reportMissingClass(e);
View Full Code Here

     *            the PreorderVisitor
     * @return the XMethod representing the method currently being visited
     */
    public static XMethod createXMethod(PreorderVisitor visitor) {
        JavaClass javaClass = visitor.getThisClass();
        Method method = visitor.getMethod();
        XMethod m = createXMethod(javaClass, method);
        return m;
    }
View Full Code Here

     * edu.umd.cs.findbugs.classfile.IAnalysisEngine#analyze(edu.umd.cs.findbugs
     * .classfile.IAnalysisCache, java.lang.Object)
     */
    @Override
    public MethodBytecodeSet analyze(IAnalysisCache analysisCache, MethodDescriptor descriptor) throws CheckedAnalysisException {
        Method method = analysisCache.getMethodAnalysis(Method.class, descriptor);
        Code code = method.getCode();
        if (code == null) {
            return null;
        }

        byte[] instructionList = code.getCode();
View Full Code Here

TOP

Related Classes of org.apache.bcel.classfile.Method

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.