Package org.apache.bcel.classfile

Examples of org.apache.bcel.classfile.Method


      JavaClass jc = Repository.lookupClass(myOwner.getClassName());
      Method[] methods = jc.getMethods();
      if (method_no >= methods.length){
        throw new InvalidMethodException("METHOD DOES NOT EXIST!");
      }
      Method method = methods[method_no];
      code = method.getCode();
     
      // No Code? Nothing to verify!
      if ( method.isAbstract() || method.isNative() ){ // IF mg HAS NO CODE (static constraint of Pass 2)
        return VerificationResult.VR_OK;
      }

      // TODO:
      // We want a very sophisticated code examination here with good explanations
      // on where to look for an illegal instruction or such.
      // Only after that we should try to build an InstructionList and throw an
      // AssertionViolatedException if after our examination InstructionList building
      // still fails.
      // That examination should be implemented in a byte-oriented way, i.e. look for
      // an instruction, make sure its validity, count its length, find the next
      // instruction and so on.
      try{
        instructionList = new InstructionList(method.getCode().getCode());
      }
      catch(RuntimeException re){
        return new VerificationResult(VerificationResult.VERIFIED_REJECTED, "Bad bytecode in the code array of the Code attribute of method '"+method+"'.");
      }
     
View Full Code Here


        // Find all obviously locked call sites
        Set<CallSite> obviouslyLockedSites = new HashSet<CallSite>();
        for (Iterator<CallSite> i = selfCalls.callSiteIterator(); i.hasNext();) {
            CallSite callSite = i.next();
            Method method = callSite.getMethod();
            Location location = callSite.getLocation();
            InstructionHandle handle = location.getHandle();

            // Only instance method calls qualify as candidates for
            // "obviously locked"
View Full Code Here

      String name = ((ConstantUtf8) cp.getConstant(obj.getNameIndex())).getBytes();
      if (! name.equals("Code")){
        throw new ClassConstraintException("The Code attribute '"+tostring(obj)+"' is not correctly named 'Code' but '"+name+"'.");
      }

      Method m = null; // satisfy compiler
      if (!(carrier.predecessor() instanceof Method)){
        addMessage("Code attribute '"+tostring(obj)+"' is not declared in a method_info structure but in '"+carrier.predecessor()+"'. Ignored.");
        return;
      }
      else{
View Full Code Here

            return;
        }

        // Hopefully we can find the conflicted value in a local variable
        if (locationWhereDoomedValueIsObserved != null) {
            Method method = Global.getAnalysisCache().getMethodAnalysis(Method.class, xMethod.getMethodDescriptor());

            LocalVariableAnnotation localVariable = ValueNumberSourceInfo.findLocalAnnotationFromValueNumber(method,
                    locationWhereDoomedValueIsObserved, vn, vnaFrame);
            if (localVariable != null && !localVariable.equals(warning.getPrimaryLocalVariableAnnotation())) {
                localVariable.setDescription(localVariable.isSignificant() ? "LOCAL_VARIABLE_VALUE_DOOMED_NAMED"
View Full Code Here

            SourceSinkInfo sourceSinkInfo) {
        MethodDescriptor methodDescriptor = xMethod.getMethodDescriptor();
        switch (sourceSinkInfo.getType()) {
        case PARAMETER:
            try {
                Method method = Global.getAnalysisCache().getMethodAnalysis(Method.class, methodDescriptor);
                LocalVariableAnnotation lva = LocalVariableAnnotation.getParameterLocalVariableAnnotation(method,
                        sourceSinkInfo.getLocal());
                lva.setDescription(lva.isSignificant() ? LocalVariableAnnotation.PARAMETER_VALUE_SOURCE_NAMED_ROLE
                        : LocalVariableAnnotation.PARAMETER_VALUE_SOURCE_ROLE);
View Full Code Here

            super("Jump info for opcode stack", JumpInfo.class);
        }

        @Override
        public @CheckForNull JumpInfo analyze(IAnalysisCache analysisCache, MethodDescriptor descriptor) throws CheckedAnalysisException {
            Method method = analysisCache.getMethodAnalysis(Method.class, descriptor);
            JavaClass jclass = getJavaClass(analysisCache, descriptor.getClassDescriptor());
            Code code = method.getCode();
            if (code == null) {
                return null;
            }

            JumpStackComputation branchAnalysis = new JumpStackComputation(descriptor);
View Full Code Here

            throw new UnsupportedOperationException("StaticConstant type not expected");
        }
    }

    private void pushByLocalObjectLoad(DismantleBytecode dbc, int register) {
        Method m = dbc.getMethod();
        LocalVariableTable lvt = m.getLocalVariableTable();
        if (lvt != null) {
            LocalVariable lv = LVTHelper.getLocalVariableAtPC(lvt, register, dbc.getPC());
            if (lv != null) {
                String signature = lv.getSignature();
                pushByLocalLoad(signature, register);
View Full Code Here

    static  private  @CheckForNull JumpInfoFromStackMap getFromStackMap(IAnalysisCache analysisCache, MethodDescriptor descriptor)  {
        if (frame_type_field == null) {
            return null;
        }

        Method method;
        try {
            method = analysisCache.getMethodAnalysis(Method.class, descriptor);
        } catch (CheckedAnalysisException e1) {
            analysisCache.getErrorLogger().logError("Unable to get method for " + descriptor, e1);
            return null;
        }

        Code code = method.getCode();
        if (code == null) {
            return null;
        }
        StackMapTable stackMapTable = getStackMapTable(code);
        if (stackMapTable == null) {
View Full Code Here

            map.put(xMethod, m);
        }
        List<? extends XMethod> xmethodsInCallOrder = classInfo.getXMethodsInCallOrder();
        List<Method> methodsInCallOrder = new ArrayList<Method>(xmethodsInCallOrder.size());
        for (XMethod x : xmethodsInCallOrder) {
            Method m = map.get(x);
            if (m != null) {
                methodsInCallOrder.add(m);
            }
        }
        return methodsInCallOrder;
View Full Code Here

            while (true) {
                c = c.getSuperClass();
                if (c == null) {
                    return null;
                }
                Method m = findImplementation(c, name, signature);
                if (m != null) {
                    return c;
                }
            }
        } catch (ClassNotFoundException e) {
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.