10.4.  Incorrect Use of a Constructor

Error Message

# died: Undefined subroutine &main::com::pdfunit::filter::region::PageRegion 
# called at C:/.../pdfunit-typical-error_incorrect-use-of-constructor.t line 36.

Explanation

To invoke the constructor of a Java class the function new has to be used. Otherwise this error occurs.

Code with Error

lives_ok {
  my $ulX    =   0;
  my $ulY    =   0;
  my $width  = 210;
  my $height =  50;
  my $headerRegion =PageRegion->($ulX, $ulY, $width, $height);  # syntax error, missing 'new'

} "typical error, incorrect constructor syntax";

Good Code

lives_ok {
  my $ulX    =   0;
  my $ulY    =   0;
  my $width  = 210;
  my $height =  50;
  my $headerRegion =PageRegion->new($ulX, $ulY, $width, $height); # ok

} "no error, correct constructor syntax";