本文整理汇总了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;
}
示例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);
}
示例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();
}
示例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();
}
}
}
}
示例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);
}
}
示例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;
}
示例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();
}
示例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();
}
示例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);
}
}
示例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();
}
}
}
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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);
}