hi,

On Monday 31 May 2004 16:50, Patrick LeBoutillier wrote:
> nadim,
> This is most certainly a package problem. Inline::Java will bind you
> code in the current
> package. Maybe un your case  the package in not "main" when you require
> the .pl file.
I'm in package PBS::PBS and I evaluate this code:

#>>>>> start of file './Pbsfile.pl'

#line 0 './Pbsfile.pl'
package PBS::Runs::PBS_1 ;
use strict ;
use warnings ;
use PBS::Constants ;
use PBS::Shell ;
use PBS::Output ;
use PBS::Rules ;
use PBS::Triggers ;
use PBS::PostBuild ;
use PBS::PBSConfig ;
use PBS::Config ;
use PBS::Check ;
use PBS::PBS ;
use PBS::Digest;
PBS::Digest::AddFileDependencies('PBSFILE:./Pbsfile.pl') ;

#line 1 './Pbsfile.pl'

use Inline Java => <<'END_OF_JAVA_CODE' => DEBUG => 4;
      class Pod_alu {
         public Pod_alu(){
         }

         public int add(int i, int j){
            return i + j ;
         }

         public int subtract(int i, int j){
            return i - j ;
         }
      }
END_OF_JAVA_CODE

#~ my $alu = (__PACKAGE__ . "::Pod_alu")->new ;
my $alu = new Pod_alu() ;

print($alu->add(9, 16) . "\n") ; # prints 25
print($alu->subtract(9, 16) . "\n") ; # prints -7

# load OK
1 ;

#<<<<< end of file './Pbsfile.pl'

> Try this test:
> my $alu = new PBS::Runs::PBS_1::Pod_alu() ;

That works but it's kind of bad news as the the package is allocated 
dynamicaly by the build system. writting this fixes it, but talk about 
ugly stuff!

my $alu = (__PACKAGE__ . "::Pod_alu")->new ;

I still fail to understand why I have I have to qualify 'new' as I execute 
it in the same package as the one where the Inline::Java stuff is.

> or try putting 
> package main ; 
> at the beginning of the Pbsfile.pl file.
Not a good idea in this case because it would change the package for the 
rest of the function calls (in the script)  which have to be in a specific 
(dynamic) package.

> In any case export the DEBUG option will show you what Inline::Java is
> trying to do.
hmmm, It didn't help me the least in this case but it's good to know where 
to switch on the light.

Cheers, Nadim


Reply via email to