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.


Try this test:

my $alu = new PBS::Runs::PBS_1::Pod_alu() ;

or try putting

package main ;

a the beginning of the Pbsfile.pl file.


In any case export the DEBUG option will show you what Inline::Java is trying to do.


Cheers,

Patrick



nadim wrote:

Hi, This is more of a question to Patrick but I think it might be of interrest to the rest of the group.

I took the example find in the documentation of I::J and put it in a perl script named 'Pbsfile.pl'. If I run it this way:

[EMAIL PROTECTED] lang]$ perl Pbsfile.pl
25
-7

which is fine.

Now Pbsfiles are input files to my build system. They normaly look something like:

AddRule 'test', ['*.lib' => 'a', 'b', 'c'], "touch %FILE_TO_BUILD" ;

if(GetConfig('EXTRA_OBJECT_FILES'))
        {
        AddRule('extra_object_file', ['*.lib' => 'd']) ;
        AddRule('d', ['d'], "touch %FILE_TO_BUILD") ;
        }

AddRule 'dep1', ['a' => 'a.dep'], "touch %FILE_TO_BUILD" ;
....

The build system adds bits and pieces when It load the files.

so the I::J example:

use Inline Java => <<'END_OF_JAVA_CODE' ;
     class Pod_alu {
...
print($alu->subtract(9, 16) . "\n") ; # prints -7

becomes this:

#>>>>> 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' ;
     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 = 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'

But that gives me the following error:

Can't locate object method "new" via package "Pod_alu" (perhaps you forgot to load "Pod_alu"?) at './Pbsfile.pl' line 17.
...propagated at /usr/local/lib/perl5/site_perl/5.8.0/PBS/PBS.pm line 514.


Any idea of what I am doing wrong?

Cheers, Nadim.





--
=====================
Patrick LeBoutillier
Laval, Quebec, Canada



Reply via email to