当前位置: 首页>>代码示例>>Java>>正文


Java ReferenceType类代码示例

本文整理汇总了Java中org.apache.bcel.generic.ReferenceType的典型用法代码示例。如果您正苦于以下问题:Java ReferenceType类的具体用法?Java ReferenceType怎么用?Java ReferenceType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ReferenceType类属于org.apache.bcel.generic包,在下文中一共展示了ReferenceType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mergeReferenceTypes

import org.apache.bcel.generic.ReferenceType; //导入依赖的package包/类
@Override
protected ReferenceType mergeReferenceTypes(ReferenceType aRef, ReferenceType bRef) throws DataflowAnalysisException {
    byte aType = aRef.getType();
    byte bType = bRef.getType();

    if (isExtendedStringType(aType) || isExtendedStringType(bType)) {
        // If both types are the same extended String type,
        // then the same type is returned. Otherwise, extended
        // types are downgraded to plain java.lang.String,
        // and a standard merge is applied.
        if (aType == bType) {
            return aRef;
        }

        if (isExtendedStringType(aType)) {
            aRef = Type.STRING;
        }
        if (isExtendedStringType(bType)) {
            bRef = Type.STRING;
        }
    }

    return super.mergeReferenceTypes(aRef, bRef);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:25,代码来源:FindRefComparison.java

示例2: getActions

import org.apache.bcel.generic.ReferenceType; //导入依赖的package包/类
public void getActions(ReferenceType receiverType, String methodName, String signature, boolean isStatic,
            Collection<ObligationPolicyDatabaseAction> actionList) {
        if (DEBUG) {
            System.out.println("Lookup for " + receiverType + "," + methodName + "," + signature + "," + isStatic + ": ");
        }
        for (ObligationPolicyDatabaseEntry entry : entryList) {

            boolean matched = entry.getActions(receiverType, methodName, signature, isStatic, actionList);

            if (DEBUG) {
                if (matched) 
                    System.out.println(" Entry " + entry + "  ==> MATCH");
//                else
//                    System.out.println("  ==> no match");                                
            }
        }
        if (DEBUG) {
            System.out.println("  ** Resulting action list: " + actionList);
        }
    }
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:21,代码来源:ObligationPolicyDatabase.java

示例3: getTypeParameters

import org.apache.bcel.generic.ReferenceType; //导入依赖的package包/类
/**
 * Parse a bytecode signature that has 1 or more (possibly generic) types
 * and return a list of the Types.
 * 
 * @param signature
 *            bytecode signature e.g. e.g.
 *            <code>Ljava/util/ArrayList&lt;Ljava/lang/String;&gt;;Ljava/util/ArrayList&lt;TT;&gt;;Ljava/util/ArrayList&lt;*&gt;;</code>
 */
public static final @CheckForNull
List<ReferenceType> getTypeParameters(String signature) {
    GenericSignatureParser parser = new GenericSignatureParser("(" + signature + ")V");
    List<ReferenceType> types = new ArrayList<ReferenceType>();

    Iterator<String> iter = parser.parameterSignatureIterator();
    while (iter.hasNext()) {
        String parameterString = iter.next();
        ReferenceType t = (ReferenceType) getType(parameterString);
        if (t == null)
            return null;
        types.add(t);
    }
    return types;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:24,代码来源:GenericUtilities.java

示例4: isSubtype

import org.apache.bcel.generic.ReferenceType; //导入依赖的package包/类
/**
 * Determine if one reference type is a subtype of another.
 * 
 * @param t
 *            a reference type
 * @param possibleSupertype
 *            the possible supertype
 * @return true if t is a subtype of possibleSupertype, false if not
 */
public static boolean isSubtype(ReferenceType t, ReferenceType possibleSupertype) throws ClassNotFoundException {
    if (true) {
        return Global.getAnalysisCache().getDatabase(Subtypes2.class).isSubtype(t, possibleSupertype);
    } else {
        Map<ReferenceType, Boolean> subtypes = subtypeCache.get(possibleSupertype);
        if (subtypes == null) {
            subtypes = new HashMap<ReferenceType, Boolean>();
            subtypeCache.put(possibleSupertype, subtypes);
        }
        Boolean result = subtypes.get(t);
        if (result == null) {
            result = Boolean.valueOf(t.isAssignmentCompatibleWith(possibleSupertype));
            subtypes.put(t, result);
        }
        return result;
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:27,代码来源:Hierarchy.java

示例5: addFindMethod

import org.apache.bcel.generic.ReferenceType; //导入依赖的package包/类
protected void addFindMethod(ParsedMethod m) {
    GeneratedMethod gm = new GeneratedMethod(m);
    InstructionList il = gm.start();

    writeMethodPreamble(gm, il);
    il.append(new PUSH(_cp, (ObjectType) gm.getReturnType()));

    m.getArguments()[0].pushAsObject(il);

    il.append(_factory.createInvoke(EM_TYPE, "find", Type.OBJECT,
        new Type[] { Type.CLASS, Type.OBJECT }, Constants.INVOKEINTERFACE));

    il.append(_factory.createCheckCast(((ReferenceType) gm.getReturnType())));
    il.append(InstructionFactory.createReturn(gm.getReturnType()));

    gm.done();
}
 
开发者ID:abassouk,项目名称:autodao,代码行数:18,代码来源:DAOAnalysis.java

示例6: getTypeParameters

import org.apache.bcel.generic.ReferenceType; //导入依赖的package包/类
/**
 * Parse a bytecode signature that has 1 or more (possibly generic) types
 * and return a list of the Types.
 *
 * @param signature
 *            bytecode signature e.g. e.g.
 *            <code>Ljava/util/ArrayList&lt;Ljava/lang/String;&gt;;Ljava/util/ArrayList&lt;TT;&gt;;Ljava/util/ArrayList&lt;*&gt;;</code>
 */
public static final @CheckForNull
List<ReferenceType> getTypeParameters(String signature) {
    GenericSignatureParser parser = new GenericSignatureParser("(" + signature + ")V");
    List<ReferenceType> types = new ArrayList<ReferenceType>();

    Iterator<String> iter = parser.parameterSignatureIterator();
    while (iter.hasNext()) {
        String parameterString = iter.next();
        ReferenceType t = (ReferenceType) getType(parameterString);
        if (t == null)
            return null;
        types.add(t);
    }
    return types;
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:24,代码来源:GenericUtilities.java

示例7: addPassThruMethod

import org.apache.bcel.generic.ReferenceType; //导入依赖的package包/类
protected void addPassThruMethod(ParsedMethod m) {
    GeneratedMethod gm = new GeneratedMethod(m);
    InstructionList il = gm.start();
    Type returnType = gm.getReturnType();

    boolean hasArg = m.getArgumentLength() > 0;

    writeMethodPreamble(gm, il);
    if (hasArg)
        il.append(InstructionFactory.createLoad(Type.OBJECT, 1));
    il.append(_factory.createInvoke(EM_TYPE, m.getMethod().getName(),
        returnType == Type.VOID ? Type.VOID : Type.OBJECT,
        hasArg ? new Type[] { Type.OBJECT } : Type.NO_ARGS,
        Constants.INVOKEINTERFACE));

    if (returnType != Type.VOID) {
        il.append(_factory.createCheckCast(((ReferenceType) returnType)));
    }
    il.append(InstructionFactory.createReturn(returnType));

    gm.done();
}
 
开发者ID:abassouk,项目名称:autodao,代码行数:23,代码来源:DAOAnalysis.java

示例8: mergeTypes

import org.apache.bcel.generic.ReferenceType; //导入依赖的package包/类
public Type mergeTypes(Type a, Type b) throws DataflowAnalysisException {
	byte aType = a.getType(), bType = b.getType();

	if (aType == T_TOP)			// Top is the identity element
		return b;
	else if (bType == T_TOP)	// Top is the identity element
		return a;
	else if (aType == T_BOTTOM || bType == T_BOTTOM)	// Bottom meet anything is bottom
		return BottomType.instance();
	else if (isReferenceType(aType) && isReferenceType(bType)) {	// Two object types!
		// Handle the Null type, which serves as a special "top"
		// value for reference types.
		if (aType == T_NULL)
			return b;
		else if (bType == T_NULL)
			return a;

		ReferenceType aRef = (ReferenceType) a;
		ReferenceType bRef = (ReferenceType) b;
		return mergeReferenceTypes(aRef, bRef);
	} else if (isReferenceType(aType) || isReferenceType(bType))	// Object meet non-object is bottom
		return BottomType.instance();
	else if (aType == bType)	// Same non-object type?
		return a;
	else if (isIntegerType(aType) && isIntegerType(bType)) // Two different integer types - use T_INT
		return Type.INT;
	else						// Default - types are incompatible
		return BottomType.instance();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:30,代码来源:StandardTypeMerger.java

示例9: mergeReferenceTypes

import org.apache.bcel.generic.ReferenceType; //导入依赖的package包/类
/**
 * Default implementation of merging reference types.
 * This just returns the first common superclass, which is compliant
 * with the JVM Spec.  Subclasses may override this method
 * in order to implement extended type rules.
 *
 * @param aRef a ReferenceType
 * @param bRef a ReferenceType
 * @return the merged Type
 */
protected Type mergeReferenceTypes(ReferenceType aRef, ReferenceType bRef) throws DataflowAnalysisException {
	// Two concrete object types.
	// According to the JVM spec, 2nd edition, 4.9.2,
	// the result of merging types is the "first common superclass".
	// Interfaces are NOT considered!
	// This will use the Repository to look up classes.
	try {
		// Special case: ExceptionObjectTypes.
		// We want to preserve the ExceptionSets associated,
		// in order to track the exact set of exceptions
		if (isObjectType(aRef.getType()) && isObjectType(bRef.getType()) &&
		        (aRef.getType() == T_EXCEPTION || bRef.getType() == T_EXCEPTION)) {
			ExceptionSet union = exceptionSetFactory.createExceptionSet();

			updateExceptionSet(union, (ObjectType) aRef);
			updateExceptionSet(union, (ObjectType) bRef);

			return ExceptionObjectType.fromExceptionSet(union);
		}

		return aRef.getFirstCommonSuperclass(bRef);
	} catch (ClassNotFoundException e) {
		lookupFailureCallback.reportMissingClass(e);
		throw new DataflowAnalysisException("Repository lookup failure: " + e.toString(), e);
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:37,代码来源:StandardTypeMerger.java

示例10: getCommonSupertype

import org.apache.bcel.generic.ReferenceType; //导入依赖的package包/类
/**
 * Get the least (lowest in the lattice) common supertype
 * of the exceptions in the set.  Returns the special TOP
 * type if the set is empty.
 */
public Type getCommonSupertype() throws ClassNotFoundException {
	if (commonSupertype != null)
		return commonSupertype;

	if (isEmpty()) {
		// This probably means that we're looking at an
		// infeasible exception path.
		return TypeFrame.getTopType();
	}

	// Compute first common superclass
	ThrownExceptionIterator i = iterator();
	ReferenceType result = i.next();
	while (i.hasNext()) {
		result = result.getFirstCommonSuperclass(i.next());
		if (result == null) {
			// This should only happen if the class hierarchy
			// is incomplete.  We'll just be conservative.
			result = Type.THROWABLE;
			break;
		}
	}

	// Cache and return the result
	commonSupertype = result;
	return result;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:33,代码来源:ExceptionSet.java

示例11: findMethod

import org.apache.bcel.generic.ReferenceType; //导入依赖的package包/类
public Method findMethod(InvokeInstruction ins) {
      String name = ins.getMethodName(cpg);
      String sig = ins.getSignature(cpg);
      ReferenceType cls = ins.getReferenceType(cpg);

      String s = (cls instanceof ObjectType) ? ((ObjectType) cls).getClassName() : "java.lang.Object";

      JavaClass cl = lookupClass(s);

      if (cl == null) {
          System.out.println("findMethodClass: could not find class " + s);
          return null;
      }

      while (cl != null) {
          Method[] methods = cl.getMethods();
          for (int i = 0; i < methods.length; i++) {
              if (methods[i].getName().equals(name)
                  && methods[i].getSignature().equals(sig)) {
                  return methods[i];
              }
          }
          try {
cl = cl.getSuperClass();
   } catch (ClassNotFoundException e) {
System.out.println("findMethod: could not find class " + cl.getSuperclassName());
       return null;
   }
      }
      System.out.println("findMethod: could not find method " + name + sig);
      return null;
  }
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:33,代码来源:Cashmerec.java

示例12: findMethodClass

import org.apache.bcel.generic.ReferenceType; //导入依赖的package包/类
public JavaClass findMethodClass(InvokeInstruction ins) {
      String name = ins.getMethodName(cpg);
      String sig = ins.getSignature(cpg);
      ReferenceType cls = ins.getReferenceType(cpg);

      String s = (cls instanceof ObjectType) ? ((ObjectType) cls).getClassName() : "java.lang.Object";

      JavaClass cl = lookupClass(s);

      if (cl == null) {
          System.out.println("findMethodClass: could not find class " + s);
          return null;
      }

      while (cl != null) {
          Method[] methods = cl.getMethods();
          for (int i = 0; i < methods.length; i++) {
                  if (methods[i].getName().equals(name)
              	    && methods[i].getSignature().equals(sig)) {
                  return cl;
              }
          }
          try {
cl = cl.getSuperClass();
   } catch (ClassNotFoundException e) {
System.out.println("findMethodClass: could not find class " + cl.getSuperclassName());
       return null;
   }
      }
      System.out.println("findMethodClass: could not find method " + name + sig);
      return null;
  }
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:33,代码来源:Cashmerec.java

示例13: findMethodClass

import org.apache.bcel.generic.ReferenceType; //导入依赖的package包/类
private JavaClass findMethodClass(InvokeInstruction ins, ConstantPoolGen cpg) {
      String name = ins.getMethodName(cpg);
      String sig = ins.getSignature(cpg);
      ReferenceType cls = ins.getReferenceType(cpg);

      String className = (cls instanceof ObjectType) ? ((ObjectType) cls).getClassName() : "java.lang.Object";

      JavaClass cl = lookupClass(className);

      if (cl == null) {
          return null;
      }

      while (cl != null) {
          Method[] methods = cl.getMethods();
          for (int i = 0; i < methods.length; i++) {
                  if (methods[i].getName().equals(name)
                  && methods[i].getSignature().equals(sig)) {
                  return cl;
              }
          }
          try {
cl = cl.getSuperClass();
   } catch (ClassNotFoundException e) {
System.out.println("findMethodClass: could not find class " + cl.getSuperclassName());
       return null;
   }
      }
      return null;
  }
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:31,代码来源:SpawningMethod.java

示例14: isNonEscapingConstructor

import org.apache.bcel.generic.ReferenceType; //导入依赖的package包/类
boolean isNonEscapingConstructor(INVOKESPECIAL invoker) {
    ReferenceType cls = invoker.getReferenceType(methodGen.getConstantPool());

    String className = (cls instanceof ObjectType) ? ((ObjectType) cls).getClassName() : "java.lang.Object";

    JavaClass javaClass;
    try {
        javaClass = Repository.lookupClass(className);
    } catch(ClassNotFoundException e) {
        return false;
    }
    return nonEscapingConstructor(javaClass, invoker.getSignature(methodGen.getConstantPool()));
}
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:14,代码来源:LoadAwareBasicBlock.java

示例15: check_reflection

import org.apache.bcel.generic.ReferenceType; //导入依赖的package包/类
private int check_reflection(MethodGen mgen, ConstantPoolGen cpgen) {
	int cnt = 0;

	InstructionList ilist = mgen.getInstructionList();
	if (ilist == null || ilist.size() == 0)
		return cnt;

	for (Instruction instr : ilist.getInstructions()) {
		// go through all instructions and look for invokes
		if (instr instanceof InvokeInstruction) {
			InvokeInstruction invoke = (InvokeInstruction) instr;
			ReferenceType rtype = invoke.getReferenceType(cpgen);

			if (rtype instanceof ObjectType) {
				String cname = ((ObjectType) rtype).getClassName();
				String mname = invoke.getName(cpgen);

				// we look for exact match
				if (cname.equals("java.lang.reflect.Method") && mname.equals("invoke")) {
					// Util.log(rtype.toString());
					cnt++;
				}
			} else {
				// reference type can be ArrayType or UninitializedObjectType
			}
		}
	}

	return cnt;
}
 
开发者ID:USC-NSL,项目名称:SIF,代码行数:31,代码来源:ClassFileScanner.java


注:本文中的org.apache.bcel.generic.ReferenceType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。