Class ConstructorThrow

All Implemented Interfaces:
Detector, Priorities, org.apache.bcel.classfile.Visitor

public class ConstructorThrow extends OpcodeStackDetector
This detector can find constructors that throw exception.
  • Constructor Details

    • ConstructorThrow

      public ConstructorThrow(BugReporter bugReporter)
  • Method Details

    • visit

      public void visit(org.apache.bcel.classfile.JavaClass obj)
      Visit a class to find the constructor, then collect all the methods that gets called in it. Also, we are checking for final declaration on the class, or a final finalizer, as if present no finalizer attack can happen.
      Overrides:
      visit in class BetterVisitor
    • visitAfter

      public void visitAfter(org.apache.bcel.classfile.JavaClass obj)
      Overrides:
      visitAfter in class PreorderVisitor
    • sawOpcode

      public void sawOpcode(int seen)
      1. Check for any throw expression in the constructor. 2. Check for any exception throw inside constructor, or any of the called methods. If the class is final, we are fine, no finalizer attack can happen. In the first pass the detector shouldn't report, because there could be a final finalizer and a throwing constructor. Reporting in this case would be a false positive as classes with a final finalizer are not vulnerable to the finalizer attack.
      Specified by:
      sawOpcode in class OpcodeStackDetector
      See Also: