Skip Menu |
 

This queue is for tickets about the JSPL CPAN distribution.

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

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

Bug Information
Severity: Important
Broken in: 1.07
Fixed in: (no value)



Subject: Constructur executed with wrong class
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 1333
Download (untitled) / with headers
text/plain 1.3k
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<---------------------------------------------------------------
MIME-Version: 1.0
Subject: Workaround
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Message-ID: <rt-3.8.HEAD-17500-1341231380-1173.78138-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: binary
From: cg [...] mcs.de
X-RT-Original-Encoding: utf-8
Content-Length: 223
Download (untitled) / with headers
text/plain 223b
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 is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

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