class BadHexadecimalConversionDetector implements Detector {

    private static final String BAD_HEXA_CONVERSION_TYPE = "BAD_HEXA_CONVERSION";
    private BugReporter bugReporter;

    public BadHexadecimalConversionDetector(BugReporter bugReporter) {
        this.bugReporter = bugReporter;
    }

    @Override
    public void visitClassContext(ClassContext classContext) {<FILL_FUNCTION_BODY>}

    @Override
    public void report() {

    }
}

        JavaClass javaClass = classContext.getJavaClass();

        Method[] methodList = javaClass.getMethods();

        for (Method m : methodList) {
            MethodGen methodGen = classContext.getMethodGen(m);

            //To suspect that an invalid String representation is being build,
            //we identify the construction of a MessageDigest and
            //the use of a function that trim leading 0.
            boolean invokeMessageDigest = false;
            boolean invokeToHexString = false;

            ConstantPoolGen cpg = classContext.getConstantPoolGen();
            if (methodGen == null || methodGen.getInstructionList() == null) {
                continue; //No instruction .. nothing to do
            }
            for (Iterator itIns = methodGen.getInstructionList().iterator();itIns.hasNext();) {
                Instruction inst = ((InstructionHandle) itIns.next()).getInstruction();
//                    ByteCode.printOpCode(inst, cpg);

                if (inst instanceof INVOKEVIRTUAL) { //MessageDigest.digest is called
                    INVOKEVIRTUAL invoke = (INVOKEVIRTUAL) inst;
                    if ("java.security.MessageDigest".equals(invoke.getClassName(cpg)) && "digest".equals(invoke.getMethodName(cpg))) {
                        invokeMessageDigest = true;
                    }
                } else if (inst instanceof INVOKESTATIC && invokeMessageDigest) { //The conversion must occurs after the digest was created
                    INVOKESTATIC invoke = (INVOKESTATIC) inst;
                    if ("java.lang.Integer".equals(invoke.getClassName(cpg)) && "toHexString".equals(invoke.getMethodName(cpg))) {
                        invokeToHexString = true;
                    }
                }
            }

            if (invokeMessageDigest && invokeToHexString) {
                bugReporter.reportBug(new BugInstance(this, BAD_HEXA_CONVERSION_TYPE, Priorities.NORMAL_PRIORITY) //
                        .addClassAndMethod(javaClass, m));
            }
        }
    
<no_super_class>