This queue is for tickets about the JSPL CPAN distribution.

Report information
The Basics
Id:
78138
Status:
open
Priority:
Low/Low
Queue:

People
Owner:
sog [...] msg.com.mx
Requestors:
cg [...] mcs.de
Cc:
AdminCc:

BugTracker
Severity:
Important
Broken in:
1.07
Fixed in:
(no value)



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<---------------------------------------------------------------
Subject: Workaround
From: cg@mcs.de
I'm currently working around this problem by creating a unique anonymous code reference for each constructor like so: $ctl->install('B' => ['B', sub { &{B->can('new')}(@_) }], 'C' => ['C', sub { &{C->can('new')}(@_) }]);


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.