org.apache.bcel.classfile.Method Java Examples

The following examples show how to use org.apache.bcel.classfile.Method. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BadlyOverriddenAdapter.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void visit(JavaClass obj) {
    try {
        methodMap.clear();
        badOverrideMap.clear();
        JavaClass superClass = obj.getSuperClass();
        if (superClass == null) {
            return;
        }
        String packageName = superClass.getPackageName();
        String className = superClass.getClassName();

        // A more generic way to add Adapters would be nice here
        isAdapter = ((className.endsWith("Adapter")) && ("java.awt.event".equals(packageName) || "javax.swing.event".equals(packageName)))
                || (("DefaultHandler".equals(className) && ("org.xml.sax.helpers".equals(packageName))));
        if (isAdapter) {
            Method[] methods = superClass.getMethods();
            for (Method method1 : methods) {
                methodMap.put(method1.getName(), method1.getSignature());
            }
        }
    } catch (ClassNotFoundException cnfe) {
        bugReporter.reportMissingClass(cnfe);
    }
}
 
Example #2
Source File: Subtypes2.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static boolean isJSP(JavaClass javaClass) {
    @DottedClassName
    String className = javaClass.getClassName();
    if (className.endsWith("_jsp") || className.endsWith("_tag")) {
        return true;
    }
    for (Method m : javaClass.getMethods()) {
        if (m.getName().startsWith("_jsp")) {
            return true;
        }
    }

    for (Field f : javaClass.getFields()) {
        if (f.getName().startsWith("_jsp")) {
            return true;
        }
    }
    return Subtypes2.instanceOf(className, "javax.servlet.jsp.JspPage")
            || Subtypes2.instanceOf(className, "org.apache.jasper.runtime.HttpJspBase")
            || Subtypes2.instanceOf(className, "javax.servlet.jsp.tagext.SimpleTagSupport")
            || Subtypes2.instanceOf(className, " org.apache.jasper.runtime.JspSourceDependent");
}
 
Example #3
Source File: JdkGenericDumpTestCase.java    From commons-bcel with Apache License 2.0 6 votes vote down vote up
private void testJar(final File file) throws Exception {
    System.out.println(file);
    try (JarFile jar = new JarFile(file)) {
        final Enumeration<JarEntry> en = jar.entries();
        while (en.hasMoreElements()) {
            final JarEntry jarEntry = en.nextElement();
            final String name = jarEntry.getName();
            if (name.endsWith(".class")) {
                // System.out.println("- " + name);
                try (InputStream inputStream = jar.getInputStream(jarEntry)) {
                    final ClassParser classParser = new ClassParser(inputStream, name);
                    final JavaClass javaClass = classParser.parse();
                    for (final Method method : javaClass.getMethods()) {
                        compare(name, method);
                    }
                }
            }
        }
    }
}
 
Example #4
Source File: Naming.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
private boolean markedAsNotUsable(Method obj) {
    for (Attribute a : obj.getAttributes()) {
        if (a instanceof Deprecated) {
            return true;
        }
    }
    Code code = obj.getCode();
    if (code == null) {
        return false;
    }
    byte[] codeBytes = code.getCode();
    if (codeBytes.length > 1 && codeBytes.length < 10) {
        int lastOpcode = codeBytes[codeBytes.length - 1] & 0xff;
        if (lastOpcode != Const.ATHROW) {
            return false;
        }
        for (int b : codeBytes) {
            if ((b & 0xff) == Const.RETURN) {
                return false;
            }
        }
        return true;
    }
    return false;
}
 
Example #5
Source File: MethodFactory.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public Method analyze(IAnalysisCache analysisCache, MethodDescriptor descriptor) throws CheckedAnalysisException {
    JavaClass jclass = analysisCache.getClassAnalysis(JavaClass.class, descriptor.getClassDescriptor());
    Method[] methodList = jclass.getMethods();

    Method result = null;

    // As a side-effect, cache all of the Methods for this JavaClass
    for (Method method : methodList) {
        MethodDescriptor methodDescriptor = DescriptorFactory.instance().getMethodDescriptor(
                descriptor.getSlashedClassName(), method.getName(), method.getSignature(), method.isStatic());

        // Put in cache eagerly
        analysisCache.eagerlyPutMethodAnalysis(Method.class, methodDescriptor, method);

        if (methodDescriptor.equals(descriptor)) {
            result = method;
        }
    }

    return result;
}
 
Example #6
Source File: BugInstance.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
public BugInstance addSomeSourceForTopTwoStackValues(ClassContext classContext, Method method, Location location) {
    int pc = location.getHandle().getPosition();
    try {
        OpcodeStack stack = OpcodeStackScanner.getStackAt(classContext.getJavaClass(), method, pc);
        BugAnnotation a1 = getSomeSource(classContext, method, location, stack, 1);
        BugAnnotation a0 = getSomeSource(classContext, method, location, stack, 0);
        addOptionalUniqueAnnotations(a0, a1);
    } catch (UnreachableCodeException e) {
        if (SystemProperties.ASSERTIONS_ENABLED) {
            AnalysisContext.logError(e.getMessage(), e);
        }
        assert true;
    }
    return this;

}
 
Example #7
Source File: UnusedMethodCheck.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/** @see com.puppycrawl.tools.checkstyle.bcel.IObjectSetVisitor */
public void leaveSet(Set aJavaClasses)
{
    final Iterator it = aJavaClasses.iterator();
    while (it.hasNext()) {
        final JavaClass javaClass = (JavaClass) it.next();
        final String className = javaClass.getClassName();
        final JavaClassDefinition classDef = findJavaClassDef(javaClass);
        final MethodDefinition[] methodDefs = classDef.getMethodDefs();
        for (int i = 0; i < methodDefs.length; i++) {
            if (!classDef.hasReference(methodDefs[i], getReferenceDAO())) {
                final Method method = methodDefs[i].getMethod();
                if (!ignore(className, method)) {
                    log(
                        javaClass,
                        0,
                        "unused.method",
                        new Object[] {methodDefs[i]});
                }
            }
        }
    }
}
 
Example #8
Source File: PLSETestCase.java    From commons-bcel with Apache License 2.0 6 votes vote down vote up
/**
 * BCEL-295:
 */
public void testB295() throws Exception
{
    final JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.PLSETestClass2");
    final ClassGen cg = new ClassGen(clazz);
    final ConstantPoolGen pool = cg.getConstantPool();
    final Method m = cg.getMethodAt(1);  // 'main'
    final LocalVariableTable lvt = m.getLocalVariableTable();
    final LocalVariable lv = lvt.getLocalVariable(2, 4);  // 'i'
    //System.out.println(lv);
    final MethodGen mg = new MethodGen(m, cg.getClassName(), pool);
    final LocalVariableTable new_lvt = mg.getLocalVariableTable(mg.getConstantPool());
    final LocalVariable new_lv = new_lvt.getLocalVariable(2, 4);  // 'i'
    //System.out.println(new_lv);
    assertEquals("live range length", lv.getLength(), new_lv.getLength());
}
 
Example #9
Source File: UnsafeJacksonDeserializationDetector.java    From Android_Code_Arbiter with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void visitClassContext(ClassContext classContext) {
    JavaClass javaClass = classContext.getJavaClass();
    if (OBJECT_MAPPER_CLASSES.contains(javaClass.getClassName())) {
        return;
    }
    for (Field field : javaClass.getFields()) {
        analyzeField(field, javaClass);
    }
    for (Method m : javaClass.getMethods()) {
        try {
            analyzeMethod(m, classContext);
        }
        catch (CFGBuilderException | DataflowAnalysisException e) {
        }
    }
}
 
Example #10
Source File: Lookup.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static @CheckForNull JavaClass findSuperImplementor(JavaClass clazz, String name, String signature, BugReporter bugReporter) {
    try {
        JavaClass c = clazz;
        while (true) {
            c = c.getSuperClass();
            if (c == null) {
                return null;
            }
            Method m = findImplementation(c, name, signature);
            if (m != null && !m.isAbstract()) {
                return c;
            }

        }
    } catch (ClassNotFoundException e) {
        bugReporter.reportMissingClass(e);
        return null;
    }
}
 
Example #11
Source File: InvalidJUnitTest.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
private boolean hasTestMethods(JavaClass jClass) {
    boolean foundTest = false;
    Method[] methods = jClass.getMethods();
    for (Method m : methods) {
        if (m.isPublic() && m.getName().startsWith("test") && m.getSignature().equals("()V")) {
            return true;
        }
        if (m.getName().startsWith("runTest") && m.getSignature().endsWith("()V")) {
            return true;
        }
    }
    if (hasSuite(methods)) {
        return true;
    }

    try {
        JavaClass sClass = jClass.getSuperClass();
        if (sClass != null) {
            return hasTestMethods(sClass);
        }
    } catch (ClassNotFoundException e) {
        AnalysisContext.reportMissingClass(e);
    }

    return false;
}
 
Example #12
Source File: BuildNonnullReturnDatabase.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void visitClassContext(ClassContext classContext) {
    boolean fullAnalysis = AnalysisContext.currentAnalysisContext().getBoolProperty(
            FindBugsAnalysisFeatures.INTERPROCEDURAL_ANALYSIS_OF_REFERENCED_CLASSES);
    if (!fullAnalysis && !AnalysisContext.currentAnalysisContext()./*
                                                                   * getSubtypes
                                                                   * ().
                                                                   */isApplicationClass(classContext.getJavaClass())) {
        return;
    }
    if (VERBOSE_DEBUG) {
        System.out.println("Visiting class " + classContext.getJavaClass().getClassName());
    }

    for (Method m : classContext.getMethodsInCallOrder()) {
        considerMethod(classContext, m);
    }
}
 
Example #13
Source File: JavaClassGenerator.java    From JQF with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private Method generateMethod(String className, SourceOfRandomness r) {
    int flags = r.nextInt(0, Short.MAX_VALUE);
    Type returnType = r.nextBoolean() ? Type.VOID : generateType(r, true);
    String methodName = generateMemberName(r);
    int numArgs = r.nextInt(4);
    Type[] argTypes = new Type[numArgs];
    String[] argNames = new String[numArgs];
    for (int i = 0; i < numArgs; i++) {
        argTypes[i] = generateType(r, true);
        argNames[i] = generateMemberName(r);
    }
    InstructionList code = generateCode(r, argTypes, returnType);
    MethodGen methodGen = new MethodGen(flags, returnType, argTypes, argNames, methodName, className, code, constants);
    // Validate flags
    Assume.assumeFalse(methodGen.isFinal() && methodGen.isAbstract());
    return methodGen.getMethod();
}
 
Example #14
Source File: SpringCsrfUnrestrictedRequestMappingDetector.java    From Android_Code_Arbiter with GNU Lesser General Public License v3.0 6 votes vote down vote up
private static boolean isVulnerable(Method method) {

        // If the method is not annotated with `@RequestMapping`, there is no vulnerability.
        AnnotationEntry requestMappingAnnotation = findRequestMappingAnnotation(method);
        if (requestMappingAnnotation == null) {
            return false;
        }

        // If the `@RequestMapping` annotation is used without the `method` annotation attribute,
        // there is a vulnerability.
        ElementValuePair methodAnnotationAttribute = findMethodAnnotationAttribute(requestMappingAnnotation);
        if (methodAnnotationAttribute == null) {
            return true;
        }

        // If the `@RequestMapping` annotation is used with the `method` annotation attribute equal to `{}`,
        // there is a vulnerability.
        ElementValue methodAnnotationAttributeValue = methodAnnotationAttribute.getValue();
        if (isEmptyArray(methodAnnotationAttributeValue)) {
            return true;
        }

        // If the `@RequestMapping` annotation is used with the `method` annotation attribute but contains a mix of
        // unprotected and protected HTTP request methods, there is a vulnerability.
        return isMixOfUnprotectedAndProtectedHttpRequestMethods(methodAnnotationAttributeValue);
    }
 
Example #15
Source File: BuildUnconditionalParamDerefDatabase.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
public boolean isCaught(ClassContext classContext, Method method, UnconditionalValueDerefSet entryFact, ValueNumber paramVN) {
    boolean caught = true;

    Set<Location> dereferenceSites = entryFact.getDerefLocationSet(paramVN);
    if (dereferenceSites != null && !dereferenceSites.isEmpty()) {
        ConstantPool cp = classContext.getJavaClass().getConstantPool();

        for (Location loc : dereferenceSites) {
            if (!FindNullDeref.catchesNull(cp, method.getCode(), loc)) {
                caught = false;
            }
        }

    }
    return caught;
}
 
Example #16
Source File: HiddenStaticMethodCheck.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/** @see AbstractReferenceCheck */
public boolean ignore(String aClassName, Method aMethod) {
    final String methodName = aMethod.getName();
    return (/*super.ignore(aClassName, aMethod)
            || */methodName.equals("<init>")
            || methodName.equals("<clinit>")
            || methodName.equals("class$")
            || aMethod.toString().indexOf("[Synthetic]") > -1);
}
 
Example #17
Source File: PreorderVisitor.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
/** If currently visiting a method, get the method's Method object */
public Method getMethod() {
    if (!visitingMethod) {
        throw new IllegalStateException("getMethod called while not visiting method");
    }
    return method;
}
 
Example #18
Source File: FindSpinLoop.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void visit(Method obj) {
    if (DEBUG) {
        System.out.println("Saw " + getFullyQualifiedMethodName());
    }
    stage = 0;
}
 
Example #19
Source File: TypeAnalysis.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Constructor.
 *
 * @param method
 *            TODO
 * @param methodGen
 *            the MethodGen whose CFG we'll be analyzing
 * @param cfg
 *            the control flow graph
 * @param dfs
 *            DepthFirstSearch of the method
 * @param typeMerger
 *            object to merge types
 * @param visitor
 *            a TypeFrameModelingVisitor to use to model the effect of
 *            instructions
 * @param lookupFailureCallback
 *            lookup failure callback
 * @param exceptionSetFactory
 *            factory for creating ExceptionSet objects
 */
public TypeAnalysis(Method method, MethodGen methodGen, CFG cfg, DepthFirstSearch dfs, TypeMerger typeMerger,
        TypeFrameModelingVisitor visitor, RepositoryLookupFailureCallback lookupFailureCallback,
        ExceptionSetFactory exceptionSetFactory) {
    super(dfs);
    this.method = method;
    Code code = method.getCode();
    if (code == null) {
        throw new IllegalArgumentException(method.getName() + " has no code");
    }
    for (Attribute a : code.getAttributes()) {
        if (a instanceof LocalVariableTypeTable) {
            visitor.setLocalTypeTable((LocalVariableTypeTable) a);
        }
    }
    this.methodGen = methodGen;
    this.cfg = cfg;
    this.typeMerger = typeMerger;
    this.visitor = visitor;
    this.thrownExceptionSetMap = new HashMap<>();
    this.lookupFailureCallback = lookupFailureCallback;
    this.exceptionSetFactory = exceptionSetFactory;
    this.instanceOfCheckMap = new HashMap<>();
    if (DEBUG) {
        System.out.println("\n\nAnalyzing " + methodGen);
    }
}
 
Example #20
Source File: FindMaskedFields.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void visit(Method obj) {
    super.visit(obj);
    numParms = getNumberMethodArguments();
    if (!obj.isStatic()) {
        numParms++;
    }
    // System.out.println(obj);
    // System.out.println(numParms);
    staticMethod = obj.isStatic();
}
 
Example #21
Source File: AbstractTestCase.java    From commons-bcel with Apache License 2.0 5 votes vote down vote up
protected Method getMethod(final JavaClass cl, final String methodname)
{
    final Method[] methods = cl.getMethods();
    for (final Method m : methods) {
        if (m.getName().equals(methodname))
        {
            return m;
        }
    }
    return null;
}
 
Example #22
Source File: DuplicateBranches.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
private byte[] getCodeBytes(Method m, int start, int end) {
    byte[] code = m.getCode().getCode();
    byte[] bytes = new byte[end - start];
    System.arraycopy(code, start, bytes, 0, end - start);

    try {
        ByteSequence sequence = new ByteSequence(code);
        while ((sequence.available() > 0) && (sequence.getIndex() < start)) {
            Instruction.readInstruction(sequence);
        }

        int pos;
        while (sequence.available() > 0 && ((pos = sequence.getIndex()) < end)) {
            Instruction ins = Instruction.readInstruction(sequence);
            if ((ins instanceof BranchInstruction) && !(ins instanceof TABLESWITCH) && !(ins instanceof LOOKUPSWITCH)) {
                BranchInstruction bi = (BranchInstruction) ins;
                int offset = bi.getIndex();
                int target = offset + pos;
                if (target >= end) { // or target < start ??
                    byte hiByte = (byte) ((target >> 8) & 0x000000FF);
                    byte loByte = (byte) (target & 0x000000FF);
                    bytes[pos + bi.getLength() - 2 - start] = hiByte;
                    bytes[pos + bi.getLength() - 1 - start] = loByte;
                }
            }
        }
    } catch (IOException ioe) {
    }

    return bytes;
}
 
Example #23
Source File: NoiseNullDeref.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void analyzeMethod(ClassContext classContext, Method method) throws DataflowAnalysisException, CFGBuilderException {
    if (DEBUG || DEBUG_NULLARG) {
        System.out.println("Pre FND ");
    }

    MethodGen methodGen = classContext.getMethodGen(method);
    if (methodGen == null) {
        return;
    }

    // UsagesRequiringNonNullValues uses =
    // classContext.getUsagesRequiringNonNullValues(method);
    this.method = method;

    if (DEBUG || DEBUG_NULLARG) {
        System.out.println("FND: " + SignatureConverter.convertMethodSignature(methodGen));
    }

    findPreviouslyDeadBlocks();

    vnaDataflow = classContext.getValueNumberDataflow(method);

    // Create a NullDerefAndRedundantComparisonFinder object to do the
    // actual
    // work. It will call back to report null derefs and redundant null
    // comparisons
    // through the NullDerefAndRedundantComparisonCollector interface we
    // implement.
    NullDerefAndRedundantComparisonFinder worker = new NullDerefAndRedundantComparisonFinder(classContext, method, this);
    worker.execute();

}
 
Example #24
Source File: PublicSemaphores.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void visit(Code obj) {
    Method m = getMethod();
    if (m.isStatic() || alreadyReported) {
        return;
    }

    state = SEEN_NOTHING;
    super.visit(obj);
}
 
Example #25
Source File: GeneratingAnnotatedClassesTestCase.java    From commons-bcel with Apache License 2.0 5 votes vote down vote up
/**
 * Just check that we can dump a class that has a method annotation on it
 * and it is still there when we read it back in
 */
public void testGenerateMethodLevelAnnotations1()
        throws ClassNotFoundException
{
    // Create HelloWorld
    final ClassGen cg = createClassGen("HelloWorld");
    final ConstantPoolGen cp = cg.getConstantPool();
    final InstructionList il = new InstructionList();
    buildClassContentsWithAnnotatedMethods(cg, cp, il);
    // Check annotation is OK
    int i = cg.getMethods()[0].getAnnotationEntries().length;
    assertTrue(
            "Prior to dumping, main method should have 1 annotation but has "
                    + i, i == 1);
    dumpClass(cg, "temp1" + File.separator + "HelloWorld.class");
    final JavaClass jc2 = getClassFrom("temp1", "HelloWorld");
    // Check annotation is OK
    i = jc2.getMethods()[0].getAnnotationEntries().length;
    assertTrue("JavaClass should say 1 annotation on main method but says "
            + i, i == 1);
    final ClassGen cg2 = new ClassGen(jc2);
    // Check it now it is a ClassGen
    final Method[] m = cg2.getMethods();
    i = m[0].getAnnotationEntries().length;
    assertTrue("The main 'Method' should have one annotation but has " + i,
            i == 1);
    final MethodGen mg = new MethodGen(m[0], cg2.getClassName(), cg2
            .getConstantPool());
    // Check it finally when the Method is changed to a MethodGen
    i = mg.getAnnotationEntries().length;
    assertTrue("The main 'MethodGen' should have one annotation but has "
            + i, i == 1);

    assertTrue(wipe("temp1", "HelloWorld.class"));
}
 
Example #26
Source File: FinalizerNullsFields.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void visit(Method obj) {
    if ("finalize".equals(obj.getName())) {
        inFinalize = true;
    } else {
        inFinalize = false;
    }
}
 
Example #27
Source File: OpcodeStackScanner.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
Scanner(JavaClass theClass, Method targetMethod, int targetPC) {
    if (DEBUG) {
        System.out.println("Scanning " + theClass.getClassName() + "." + targetMethod.getName());
    }
    this.theClass = theClass;
    this.targetMethod = targetMethod;
    this.targetPC = targetPC;
}
 
Example #28
Source File: MethodGenTestCase.java    From commons-bcel with Apache License 2.0 5 votes vote down vote up
private void testInvalidNullMethodBody(final String className) throws ClassNotFoundException {
    final JavaClass jc = Repository.lookupClass(className);
    final ClassGen classGen = new ClassGen(jc);
    for (final Method method : jc.getMethods()) {
        new MethodGen(method, jc.getClassName(), classGen.getConstantPool());
    }
}
 
Example #29
Source File: ClassGen.java    From commons-bcel with Apache License 2.0 5 votes vote down vote up
/**
 * Initialize with existing class.
 * @param clazz JavaClass object (e.g. read from file)
 */
public ClassGen(final JavaClass clazz) {
    super(clazz.getAccessFlags());
    classNameIndex = clazz.getClassNameIndex();
    superclass_name_index = clazz.getSuperclassNameIndex();
    className = clazz.getClassName();
    superClassName = clazz.getSuperclassName();
    fileName = clazz.getSourceFileName();
    cp = new ConstantPoolGen(clazz.getConstantPool());
    major = clazz.getMajor();
    minor = clazz.getMinor();
    final Attribute[] attributes = clazz.getAttributes();
    // J5TODO: Could make unpacking lazy, done on first reference
    final AnnotationEntryGen[] annotations = unpackAnnotations(attributes);
    final Method[] methods = clazz.getMethods();
    final Field[] fields = clazz.getFields();
    final String[] interfaces = clazz.getInterfaceNames();
    for (final String interface1 : interfaces) {
        addInterface(interface1);
    }
    for (final Attribute attribute : attributes) {
        if (!(attribute instanceof Annotations)) {
            addAttribute(attribute);
        }
    }
    for (final AnnotationEntryGen annotation : annotations) {
        addAnnotationEntry(annotation);
    }
    for (final Method method : methods) {
        addMethod(method);
    }
    for (final Field field : fields) {
        addField(field);
    }
}
 
Example #30
Source File: Util.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static int getSizeOfSurroundingTryBlock(@CheckForNull Method method, Class<? extends Throwable> exceptionClass, int pc) {
    if (method == null) {
        return Integer.MAX_VALUE;
    }

    return getSizeOfSurroundingTryBlock(method, ClassName.toSlashedClassName(exceptionClass), pc);
}