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


Java ObjectType类代码示例

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


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

示例1: createStream

import org.apache.bcel.generic.ObjectType; //导入依赖的package包/类
public Stream createStream(Location location, ObjectType type, ConstantPoolGen cpg,
                           RepositoryLookupFailureCallback lookupFailureCallback) {

	Instruction ins = location.getHandle().getInstruction();

	try {
		if (ins instanceof InvokeInstruction) {
			if (!Hierarchy.isSubtype(type, baseClassType))
				return null;

			Stream stream = new Stream(location, type.getClassName(), baseClassType.getClassName())
			        .setIsOpenOnCreation(true)
			        .setIgnoreImplicitExceptions(true);
			if (bugType != null)
				stream.setInteresting(bugType);

			return stream;
		}
	} catch (ClassNotFoundException e) {
		lookupFailureCallback.reportMissingClass(e);
	}

	return null;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:25,代码来源:AnyMethodReturnValueStreamFactory.java

示例2: createStream

import org.apache.bcel.generic.ObjectType; //导入依赖的package包/类
public Stream createStream(Location location, ObjectType type, ConstantPoolGen cpg,
                           RepositoryLookupFailureCallback lookupFailureCallback) {

	Instruction ins = location.getHandle().getInstruction();
	if (ins.getOpcode() != Constants.GETSTATIC)
		return null;

	GETSTATIC getstatic = (GETSTATIC) ins;
	if (!className.equals(getstatic.getClassName(cpg))
	        || !fieldName.equals(getstatic.getName(cpg))
	        || !fieldSig.equals(getstatic.getSignature(cpg)))
		return null;

	return new Stream(location, type.getClassName(), streamBaseClass)
	        .setIgnoreImplicitExceptions(true)
	        .setIsOpenOnCreation(true);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:18,代码来源:StaticFieldLoadStreamFactory.java

示例3: toString

import org.apache.bcel.generic.ObjectType; //导入依赖的package包/类
public String toString() {
	StringBuffer buf = new StringBuffer();
	buf.append('{');
	boolean first = true;
	for (ThrownExceptionIterator i = iterator(); i.hasNext();) {
		ObjectType type = i.next();
		if (first)
			first = false;
		else
			buf.append(',');
		boolean implicit = !i.isExplicit();
		if (implicit) buf.append('[');
		buf.append(type.toString());
		if (implicit) buf.append(']');
	}
	buf.append('}');
	return buf.toString();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:19,代码来源:ExceptionSet.java

示例4: transfer

import org.apache.bcel.generic.ObjectType; //导入依赖的package包/类
public void transfer(BasicBlock basicBlock, InstructionHandle end, BlockType start, BlockType result)
		throws DataflowAnalysisException {
	result.copyFrom(start);

	if (start.isValid()) {
		if (basicBlock.isExceptionHandler()) {
			CodeExceptionGen exceptionGen = basicBlock.getExceptionGen();
			ObjectType catchType = exceptionGen.getCatchType();
			if (catchType == null) {
				// Probably a finally block, or a synchronized block
				// exception-compensation catch block.
				result.pushFinally();
			} else {
				// Catch type was explicitly specified:
				// this is probably a programmer-written catch block
				result.pushCatch();
			}
		}
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:21,代码来源:BlockTypeAnalysis.java

示例5: visitCHECKCAST

import org.apache.bcel.generic.ObjectType; //导入依赖的package包/类
@Override
public void visitCHECKCAST(CHECKCAST obj) {
    // cast to a safe object type
    ObjectType objectType = obj.getLoadClassType(cpg);
    if (objectType == null) {
        return;
    }

    String objectTypeSignature = objectType.getSignature();

    if(!taintConfig.isClassTaintSafe(objectTypeSignature)) {
        return;
    }

    try {
        getFrame().popValue();
        pushSafe();
    }
    catch (DataflowAnalysisException ex) {
        throw new InvalidBytecodeException("empty stack for checkcast", ex);
    }
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:23,代码来源:TaintFrameModelingVisitor.java

示例6: isIllegalFinalType

import org.apache.bcel.generic.ObjectType; //导入依赖的package包/类
private static boolean isIllegalFinalType(Type type, ClassContext classContext) {
    if (type instanceof ObjectType) {
        try {
            String className = ((ObjectType) type).getClassName();
            if (className.startsWith("java.")) {
                // Types in java.lang are final for security reasons.
                return false;
            }
            JavaClass cls = classContext.getAnalysisContext().lookupClass(className);
            return cls.isFinal() && !cls.isEnum();
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }
    return false;
}
 
开发者ID:palantir,项目名称:antipatterns,代码行数:17,代码来源:FinalSignatureDetector.java

示例7: createHelperMethodForDotClassCalls

import org.apache.bcel.generic.ObjectType; //导入依赖的package包/类
/**
 * Creates a method class$(String) which is used
 * during SomeClass.class instruction
 *
 * @param generatedClassName the instance class name
 */
protected void createHelperMethodForDotClassCalls(String generatedClassName) {
    InstructionList il = new InstructionList();
    MethodGen method = new MethodGen(Constants.ACC_STATIC, new ObjectType("java.lang.Class"), new Type[]{Type.STRING}, new String[]{"arg0"}, "class$", generatedClassName, il, constantsPool);
    InstructionHandle ih0 = il.append(InstructionFactory.createLoad(Type.OBJECT, 0));
    il.append(factory.createInvoke("java.lang.Class", "forName", new ObjectType("java.lang.Class"), new Type[]{Type.STRING}, Constants.INVOKESTATIC));
    InstructionHandle ih4 = il.append(InstructionFactory.createReturn(Type.OBJECT));
    InstructionHandle ih5 = il.append(InstructionFactory.createStore(Type.OBJECT, 1));
    il.append(factory.createNew("java.lang.NoClassDefFoundError"));
    il.append(InstructionConstants.DUP);
    il.append(InstructionFactory.createLoad(Type.OBJECT, 1));
    il.append(factory.createInvoke("java.lang.Throwable", "getMessage", Type.STRING, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
    il.append(factory.createInvoke("java.lang.NoClassDefFoundError", "<init>", Type.VOID, new Type[]{Type.STRING}, Constants.INVOKESPECIAL));
    il.append(InstructionConstants.ATHROW);
    method.addExceptionHandler(ih0, ih4, ih5, new ObjectType("java.lang.ClassNotFoundException"));
    method.setMaxStack();
    method.setMaxLocals();
    classGen.addMethod(method.getMethod());
    il.dispose();
}
 
开发者ID:paul-hammant,项目名称:JRemoting,代码行数:26,代码来源:BcelStubGenerator.java

示例8: generateEqualsMethod

import org.apache.bcel.generic.ObjectType; //导入依赖的package包/类
private void generateEqualsMethod(String generatedClassName) {

        /* public boolean equals(Object o) {
         *   return stubHelper.isEquals(this,o);
         * }
         */

        InstructionList il = new InstructionList();
        MethodGen method = new MethodGen(Constants.ACC_PUBLIC, Type.BOOLEAN, new Type[]{Type.OBJECT}, new String[]{"arg0"}, "equals", generatedClassName, il, constantsPool);

        il.append(InstructionFactory.createLoad(Type.OBJECT, 0));

        il.append(factory.createFieldAccess(generatedClassName, "stubHelper", new ObjectType("org.codehaus.jremoting.client.StubHelper"), Constants.GETFIELD));
        il.append(InstructionFactory.createLoad(Type.OBJECT, 0));
        il.append(InstructionFactory.createLoad(Type.OBJECT, 1));

        il.append(factory.createInvoke("org.codehaus.jremoting.client.StubHelper", "isEquals", Type.BOOLEAN, new Type[]{Type.OBJECT, Type.OBJECT}, Constants.INVOKEINTERFACE));
        il.append(InstructionFactory.createReturn(Type.INT));
        method.setMaxStack();
        method.setMaxLocals();
        classGen.addMethod(method.getMethod());
        il.dispose();
    }
 
开发者ID:paul-hammant,项目名称:JRemoting,代码行数:24,代码来源:BcelStubGenerator.java

示例9: getBCELType

import org.apache.bcel.generic.ObjectType; //导入依赖的package包/类
/**
 * Method getBCELType.
 * Maps the java datatype and the BCEL datatype
 *
 * @param clazz the class
 * @return Type the type
 */
protected Type getBCELType(Class clazz) {

    if (clazz.isPrimitive()) {
        return getBCELPrimitiveType(clazz.getName());
    } else if (!clazz.isArray()) {
        return new ObjectType(clazz.getName());
    } else {
        String className = clazz.getName();
        int index = className.lastIndexOf('[');
        int arrayDepth = className.indexOf('[') - className.lastIndexOf('[') + 1;
        if (className.charAt(index + 1) == 'L') {
            return new ArrayType(new ObjectType(clazz.getComponentType().getName()), arrayDepth);
        }

        return new ArrayType(getBCELPrimitiveType(className.substring(arrayDepth)), arrayDepth);
    }

}
 
开发者ID:paul-hammant,项目名称:JRemoting,代码行数:26,代码来源:BcelStubGenerator.java

示例10: transfer

import org.apache.bcel.generic.ObjectType; //导入依赖的package包/类
public void transfer(BasicBlock basicBlock, @CheckForNull InstructionHandle end, BlockType start, BlockType result)
        throws DataflowAnalysisException {
    result.copyFrom(start);

    if (start.isValid()) {
        if (basicBlock.isExceptionHandler()) {
            CodeExceptionGen exceptionGen = basicBlock.getExceptionGen();
            ObjectType catchType = exceptionGen.getCatchType();
            if (catchType == null) {
                // Probably a finally block, or a synchronized block
                // exception-compensation catch block.
                result.pushFinally();
            } else {
                // Catch type was explicitly specified:
                // this is probably a programmer-written catch block
                result.pushCatch();
            }
        }
    }
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:21,代码来源:BlockTypeAnalysis.java

示例11: createStream

import org.apache.bcel.generic.ObjectType; //导入依赖的package包/类
public Stream createStream(Location location, ObjectType type, ConstantPoolGen cpg,
        RepositoryLookupFailureCallback lookupFailureCallback) {

    Instruction ins = location.getHandle().getInstruction();

    try {
        if (ins instanceof InvokeInstruction) {
            if (!Hierarchy.isSubtype(type, baseClassType))
                return null;

            Stream stream = new Stream(location, type.getClassName(), baseClassType.getClassName()).setIsOpenOnCreation(true)
                    .setIgnoreImplicitExceptions(true);
            if (bugType != null)
                stream.setInteresting(bugType);

            return stream;
        }
    } catch (ClassNotFoundException e) {
        lookupFailureCallback.reportMissingClass(e);
    }

    return null;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:24,代码来源:AnyMethodReturnValueStreamFactory.java

示例12: getParameterObligationTypes

import org.apache.bcel.generic.ObjectType; //导入依赖的package包/类
/**
 * Get array of Obligation types corresponding to the parameters of the
 * given method.
 * 
 * @param xmethod
 *            a method
 * @return array of Obligation types for each of the method's parameters; a
 *         null element means the corresponding parameter is not an
 *         Obligation type
 */
public Obligation[] getParameterObligationTypes(XMethod xmethod) {
    Type[] paramTypes = Type.getArgumentTypes(xmethod.getSignature());
    Obligation[] result = new Obligation[paramTypes.length];
    for (int i = 0; i < paramTypes.length; i++) {
        if (!(paramTypes[i] instanceof ObjectType)) {
            continue;
        }
        try {
            result[i] = getObligationByType((ObjectType) paramTypes[i]);
        } catch (ClassNotFoundException e) {
            Global.getAnalysisCache().getErrorLogger().reportMissingClass(e);
        }
    }
    return result;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:26,代码来源:ObligationFactory.java

示例13: addFindMethod

import org.apache.bcel.generic.ObjectType; //导入依赖的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

示例14: getInstance

import org.apache.bcel.generic.ObjectType; //导入依赖的package包/类
public static ObjectType getInstance(@DottedClassName String s) {
    if (FindBugs.DEBUG && s.startsWith("[")) {
        throw new IllegalArgumentException("Cannot create an ObjectType to represent an array type: " + s);
    }
    if (s.endsWith(";"))
        throw new IllegalArgumentException(s);
    if (s.indexOf("/") >= 0) {
        s = s.replace('/', '.');
    }

    Map<String, ObjectType> map = instance.get();
    ObjectType result = map.get(s);
    if (result != null)
        return result;
    result = ObjectType.getInstance(s);
    map.put(s, result);
    return result;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:19,代码来源:ObjectTypeFactory.java

示例15: isSubtype

import org.apache.bcel.generic.ObjectType; //导入依赖的package包/类
/**
 * Determine whether or not a given ObjectType is a subtype of another.
 * Throws ClassNotFoundException if the question cannot be answered
 * definitively due to a missing class.
 *
 * @param type
 *            a ReferenceType
 * @param possibleSupertype
 *            another Reference type
 * @return true if <code>type</code> is a subtype of
 *         <code>possibleSupertype</code>, false if not
 * @throws ClassNotFoundException
 *             if a missing class prevents a definitive answer
 */
public boolean isSubtype(ObjectType type, ObjectType possibleSupertype) throws ClassNotFoundException {
    if (DEBUG_QUERIES) {
        System.out.println("isSubtype: check " + type + " subtype of " + possibleSupertype);
    }

    if (type.equals(possibleSupertype)) {
        if (DEBUG_QUERIES) {
            System.out.println("  ==> yes, types are same");
        }
        return true;
    }
    ClassDescriptor typeClassDescriptor = DescriptorFactory.getClassDescriptor(type);
    ClassDescriptor possibleSuperclassClassDescriptor = DescriptorFactory.getClassDescriptor(possibleSupertype);

    return isSubtype(typeClassDescriptor, possibleSuperclassClassDescriptor);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:31,代码来源:Subtypes2.java


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