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


Java Code类代码示例

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


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

示例1: visit

import org.apache.bcel.classfile.Code; //导入依赖的package包/类
public void visit(Code obj) {
	sawSuperFinalize = false;
	super.visit(obj);
	if (!getMethodName().equals("finalize")
	        || !getMethodSig().equals("()V"))
		return;
	String overridesFinalizeIn
	        = Lookup.findSuperImplementor(getDottedClassName(),
	                "finalize",
	                "()V",
	                bugReporter);
	boolean superHasNoFinalizer = overridesFinalizeIn.equals("java.lang.Object");
	// System.out.println("superclass: " + superclassName);
	if (obj.getCode().length == 1) {
		if (superHasNoFinalizer)
			bugReporter.reportBug(new BugInstance(this, "FI_EMPTY", NORMAL_PRIORITY).addClassAndMethod(this));
		else
			bugReporter.reportBug(new BugInstance(this, "FI_NULLIFY_SUPER", NORMAL_PRIORITY)
			        .addClassAndMethod(this)
			        .addClass(overridesFinalizeIn));
	} else if (obj.getCode().length == 5 && sawSuperFinalize)
		bugReporter.reportBug(new BugInstance(this, "FI_USELESS", NORMAL_PRIORITY).addClassAndMethod(this));
	else if (!sawSuperFinalize && !superHasNoFinalizer)
		bugReporter.reportBug(new BugInstance(this, "FI_MISSING_SUPER_CALL", NORMAL_PRIORITY).addClassAndMethod(this)
		        .addClass(overridesFinalizeIn));
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:27,代码来源:FindFinalizeInvocations.java

示例2: visit

import org.apache.bcel.classfile.Code; //导入依赖的package包/类
public void visit(Code obj) {
	instanceCreated = false;
	instanceCreatedWarningGiven = false;
	if (!getMethodName().equals("<clinit>")) return;
	super.visit(obj);
	requires.remove(getDottedClassName());
	if (getDottedClassName().equals("java.lang.System")) {
		requires.add("java.io.FileInputStream");
		requires.add("java.io.FileOutputStream");
		requires.add("java.io.BufferedInputStream");
		requires.add("java.io.BufferedOutputStream");
		requires.add("java.io.PrintStream");
	}
	if (!requires.isEmpty()) {
		classRequires.put(getDottedClassName(), requires);
		requires = new TreeSet<String>();
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:19,代码来源:InitializationChain.java

示例3: analyze

import org.apache.bcel.classfile.Code; //导入依赖的package包/类
protected BitSet analyze(Method method) {
 final BitSet result = new BitSet();

 Code code = method.getCode();
 if (code != null) {
  byte[] instructionList = code.getCode();

  // Create a callback to put the opcodes of the method's
  // bytecode instructions into the BitSet.
  BytecodeScanner.Callback callback = new BytecodeScanner.Callback() {
   public void handleInstruction(int opcode, int index) {
    result.set(opcode, true);
   }
  };

  // Scan the method.
  BytecodeScanner scanner = new BytecodeScanner();
  scanner.scan(instructionList, callback);
 }

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

示例4: visitCode

import org.apache.bcel.classfile.Code; //导入依赖的package包/类
/**
 * @see org.apache.bcel.classfile.Visitor#visitCode
 */
public void visitCode(Code aCode)
{   
    for (Iterator iter = mVisitors.iterator(); iter.hasNext();) {
        IDeepVisitor visitor = (IDeepVisitor) iter.next();
        Visitor v = visitor.getClassFileVisitor();
        aCode.accept(v);
    }
    
    // perform a deep visit
    final byte[] code = aCode.getCode();
    final InstructionList list = new InstructionList(code);
    final Iterator it = list.iterator();
    for (Iterator iter = list.iterator(); iter.hasNext();) {
        InstructionHandle instruction = (InstructionHandle) iter.next();
        visitInstructionHandle(instruction);
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:21,代码来源:VisitorSet.java

示例5: handleCodeFragment

import org.apache.bcel.classfile.Code; //导入依赖的package包/类
/** Handles a single code fragment. */
private void handleCodeFragment(List<String> resultList,
		ConstantPoolGen cpg, Code code) {
	for (Instruction i : new InstructionList(code.getCode())
			.getInstructions()) {
		if (i instanceof NEW) {
			NEW newInstruction = (NEW) i;
			ObjectType ot = newInstruction.getLoadClassType(cpg);

			if (ot == null) { // ot is primitive type
				continue;
			}

			String newClassName = ot.getClassName();
			if (!resultList.contains(newClassName)
					&& !isBlacklisted(newClassName)) {
				resultList.add(newClassName);
			}
		}
	}
}
 
开发者ID:vimaier,项目名称:conqat,代码行数:22,代码来源:CreationListBuilder.java

示例6: visit

import org.apache.bcel.classfile.Code; //导入依赖的package包/类
@Override
public void visit(Code obj) {

    count_aload_1 = 0;
    previousOpcode = -1;
    previousPreviousOpcode = -1;
    data.nullTested.clear();
    seenInvokeStatic = false;
    seenMonitorEnter = getMethod().isSynchronized();
    data.staticFieldsReadInThisMethod.clear();
    super.visit(obj);
    if (getMethodName().equals("<init>") && count_aload_1 > 1
            && (getClassName().indexOf('$') >= 0 || getClassName().indexOf('+') >= 0)) {
        data.needsOuterObjectInConstructor.add(getDottedClassName());
        // System.out.println(betterClassName +
        // " needs outer object in constructor");
    }
    bugAccumulator.reportAccumulatedBugs();
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:20,代码来源:UnreadFields.java

示例7: getSurroundingTryBlock

import org.apache.bcel.classfile.Code; //导入依赖的package包/类
public static @CheckForNull
CodeException getSurroundingTryBlock(ConstantPool constantPool, Code code, @CheckForNull String vmNameOfExceptionClass, int pc) {
    int size = Integer.MAX_VALUE;
    if (code.getExceptionTable() == null)
        return null;
    CodeException result = null;
    for (CodeException catchBlock : code.getExceptionTable()) {
        if (vmNameOfExceptionClass != null) {
            Constant catchType = constantPool.getConstant(catchBlock.getCatchType());
            if (catchType == null || catchType instanceof ConstantClass
                    && !((ConstantClass) catchType).getBytes(constantPool).equals(vmNameOfExceptionClass))
                continue;
        }
        int startPC = catchBlock.getStartPC();
        int endPC = catchBlock.getEndPC();
        if (pc >= startPC && pc <= endPC) {
            int thisSize = endPC - startPC;
            if (size > thisSize) {
                size = thisSize;
                result = catchBlock;
            }
        }
    }
    return result;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:26,代码来源:Util.java

示例8: visit

import org.apache.bcel.classfile.Code; //导入依赖的package包/类
@Override
public void visit(Code m) {
    applicableApplications = new HashSet<TypeQualifierValue<?>>();
    XMethod xMethod = getXMethod();

    // Find the direct annotations on this method
    updateApplicableAnnotations(xMethod);

    // Find direct annotations on called methods and loaded fields
    super.visit(m);

    if (applicableApplications.size() > 0) {
        qualifiers.setDirectlyRelevantTypeQualifiers(getMethodDescriptor(), new ArrayList<TypeQualifierValue<?>>(
                applicableApplications));
    }
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:17,代码来源:NoteDirectlyRelevantTypeQualifiers.java

示例9: getSourceAnnotationForClass

import org.apache.bcel.classfile.Code; //导入依赖的package包/类
/**
 * @param className
 * @return
 */
static SourceLineAnnotation getSourceAnnotationForClass(String className, String sourceFileName) {

    int lastLine = -1;
    int firstLine = Integer.MAX_VALUE;

    try {
        JavaClass targetClass = AnalysisContext.currentAnalysisContext().lookupClass(className);
        for (Method m : targetClass.getMethods()) {
            Code c = m.getCode();
            if (c != null) {
                LineNumberTable table = c.getLineNumberTable();
                if (table != null)
                    for (LineNumber line : table.getLineNumberTable()) {
                        lastLine = Math.max(lastLine, line.getLineNumber());
                        firstLine = Math.min(firstLine, line.getLineNumber());
                    }
            }
        }
    } catch (ClassNotFoundException e) {
        AnalysisContext.reportMissingClass(e);
    }
    if (firstLine < Integer.MAX_VALUE)
        return new SourceLineAnnotation(className, sourceFileName, firstLine, lastLine, -1, -1);
    return SourceLineAnnotation.createUnknown(className, sourceFileName);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:30,代码来源:SourceLineAnnotation.java

示例10: visit

import org.apache.bcel.classfile.Code; //导入依赖的package包/类
@Override
public void visit(Code obj) {
    sawWait = false;
    sawAwait = false;
    waitHasTimeout = false;
    sawNotify = false;
    earliestJump = 9999999;
    super.visit(obj);
    if ((sawWait || sawAwait) && waitAt < earliestJump) {
        String bugType = sawWait ? "WA_NOT_IN_LOOP" : "WA_AWAIT_NOT_IN_LOOP";
        bugReporter.reportBug(new BugInstance(this, bugType, waitHasTimeout ? LOW_PRIORITY : NORMAL_PRIORITY)
                .addClassAndMethod(this).addSourceLine(this, waitAt));
    }
    if (sawNotify)
        bugReporter.reportBug(new BugInstance(this, "NO_NOTIFY_NOT_NOTIFYALL", LOW_PRIORITY).addClassAndMethod(this)
                .addSourceLine(this, notifyPC));
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:18,代码来源:WaitInLoop.java

示例11: visit

import org.apache.bcel.classfile.Code; //导入依赖的package包/类
@Override
public void visit(Code obj) {
    if (!directChildOfTestCase && (getMethodName().equals("setUp") || getMethodName().equals("tearDown"))
            && !getMethod().isPrivate() && getMethodSig().equals("()V")) {
        sawSuperCall = false;
        super.visit(obj);
        if (sawSuperCall)
            return;
        JavaClass we = Lookup.findSuperImplementor(getThisClass(), getMethodName(), "()V", bugReporter);
        if (we != null && !we.getClassName().equals("junit.framework.TestCase")) {
            // OK, got a bug
            int offset = 0;
            if (getMethodName().equals("tearDown"))
                offset = obj.getCode().length - 1;
            Method superMethod = Lookup.findImplementation(we, getMethodName(), "()V");
            Code superCode = superMethod.getCode();
            if (superCode != null && superCode.getCode().length > 3)
                bugReporter.reportBug(new BugInstance(this, getMethodName().equals("setUp") ? "IJU_SETUP_NO_SUPER"
                        : "IJU_TEARDOWN_NO_SUPER", NORMAL_PRIORITY).addClassAndMethod(this).addMethod(we, superMethod)
                        .describe(MethodAnnotation.METHOD_OVERRIDDEN).addSourceLine(this, offset));
        }
    }
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:24,代码来源:InvalidJUnitTest.java

示例12: visit

import org.apache.bcel.classfile.Code; //导入依赖的package包/类
@Override
public void visit(Code obj) {
    found.clear();
    // Solution to sourceforge bug 1765925; returning null is the
    // convention used by java.io.File.listFiles()
    if (getMethodName().equals("listFiles")) {
        return;
    }
    String returnType = getMethodSig().substring(getMethodSig().indexOf(")") + 1);
    if (returnType.startsWith("[")) {
        nullOnTOS = false;
        super.visit(obj);
        if (!found.isEmpty()) {
            BugInstance bug = new BugInstance(this, "PZLA_PREFER_ZERO_LENGTH_ARRAYS", LOW_PRIORITY).addClassAndMethod(this);
            for (SourceLineAnnotation s : found)
                bug.add(s);
            bugReporter.reportBug(bug);
            found.clear();
        }
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:22,代码来源:PreferZeroLengthArrays.java

示例13: analyze

import org.apache.bcel.classfile.Code; //导入依赖的package包/类
public UnpackedCode analyze(IAnalysisCache analysisCache, MethodDescriptor descriptor) throws CheckedAnalysisException {
    Method method = getMethod(analysisCache, descriptor);
    Code code = method.getCode();
    if (code == null)
        return null;

    byte[] instructionList = code.getCode();

    // Create callback
    UnpackedBytecodeCallback callback = new UnpackedBytecodeCallback(instructionList.length);

    // Scan the method.
    BytecodeScanner scanner = new BytecodeScanner();
    scanner.scan(instructionList, callback);

    return callback.getUnpackedCode();

}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:19,代码来源:UnpackedCodeFactory.java

示例14: visit

import org.apache.bcel.classfile.Code; //导入依赖的package包/类
@Override
public void visit(Code obj) {
    if (DEBUG)
        System.out.printf("%nVisiting %s%n", getMethodDescriptor());
    reachable = false;
    lastPC = 0;
    biggestJumpTarget = -1;
    found.clear();
    switchHdlr = new SwitchHandler();
    clearAllDeadStores();
    deadStore = null;
    priority = NORMAL_PRIORITY;
    fallthroughDistance = 1000;
    enumType = null;
    super.visit(obj);
    enumType = null;
    if (!found.isEmpty()) {
        if (found.size() >= 4 && priority == NORMAL_PRIORITY)
            priority = LOW_PRIORITY;
        for (SourceLineAnnotation s : found)
            bugAccumulator.accumulateBug(new BugInstance(this, "SF_SWITCH_FALLTHROUGH", priority).addClassAndMethod(this), s);
    }

    bugAccumulator.reportAccumulatedBugs();
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:26,代码来源:SwitchFallthrough.java

示例15: visit

import org.apache.bcel.classfile.Code; //导入依赖的package包/类
@Override
public void visit(Code obj) {
    sawSuperFinalize = false;
    super.visit(obj);
    bugAccumulator.reportAccumulatedBugs();
    if (!getMethodName().equals("finalize") || !getMethodSig().equals("()V"))
        return;
    String overridesFinalizeIn = Lookup.findSuperImplementor(getDottedClassName(), "finalize", "()V", bugReporter);
    boolean superHasNoFinalizer = overridesFinalizeIn.equals("java.lang.Object");
    // System.out.println("superclass: " + superclassName);
    if (obj.getCode().length == 1) {
        if (superHasNoFinalizer) {
            if (!getMethod().isFinal())
                bugReporter.reportBug(new BugInstance(this, "FI_EMPTY", NORMAL_PRIORITY).addClassAndMethod(this));
        } else
            bugReporter.reportBug(new BugInstance(this, "FI_NULLIFY_SUPER", NORMAL_PRIORITY).addClassAndMethod(this)
                    .addClass(overridesFinalizeIn));
    } else if (obj.getCode().length == 5 && sawSuperFinalize)
        bugReporter.reportBug(new BugInstance(this, "FI_USELESS", NORMAL_PRIORITY).addClassAndMethod(this));
    else if (!sawSuperFinalize && !superHasNoFinalizer)
        bugReporter.reportBug(new BugInstance(this, "FI_MISSING_SUPER_CALL", NORMAL_PRIORITY).addClassAndMethod(this)
                .addClass(overridesFinalizeIn));
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:24,代码来源:FindFinalizeInvocations.java


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