Subject: | Constructur executed with wrong class |
Hello!
When two classes inherit from the same base class and share the
constructor of the base class the class name supplied to the
constructor references the wrong package. Please see the attached code.
I would expect the constructor calls from JavaScript to print class B
and class C as the perl code does. As it is it prints class C both
times. See example output:
[lf@luke ctsv2]$ perl jtest
Called in perl:
Constructor called with class B
Constructor called with class C
Called in JavaScript:
Constructor called with class C
Constructor called with class C
This is with perl 5.8.8 on Linux (Centos 5.8) with XUL Runner 1.9.2
(Spidermonkey 1.8.0).
Could you please shed some light on this? Thanks.
Cheers,
Christian
----8<---------------------------------------------------------------
package A;
sub new
{
my $class = shift;
print "Constructor called with class $class\n";
bless {}, $class;
}
package B;
use base qw(A);
package C;
use base qw(A);
package main;
use JSPL;
my $ctx = JSPL->stock_context;
my $ctl = $ctx->get_controller;
$ctl->install('B' => ['B', undef], 'C' => ['C', undef]);
print "Called in perl:\n\n";
B->new;
C->new;
print "\nCalled in JavaScript:\n\n";
$ctx->eval(q|
new B;
new C;
|);
----8<---------------------------------------------------------------