Hi,
the following behaviour occurs when setting the classpath through the CLASSPATH configuration option (on Linux with Perl 5.8.8 and up-to-date modules). It does not appear when setting it through the CLASSPATH env variable or a -cp option in EXTRA_JAVA_ARGS. The latter is a bad idea as it circumvents Inline::Java's internal classpath tweaking and in my app the use of the env variable has its own sort of problems ... so here I am.
This is how to reproduce it:
1. Create file Pod_alu.java containing the following well-known piece of java code and compile it into file Pod_alu.class:
public 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 ;
}
}
2. Create two subdirectories named "sub-dir" and "sub#dir".
3. Copy the Pod_alu.class file in both subdirectories.
4. Run this piece of Perl code:
use Inline(
Java => 'STUDY',
CLASSPATH => 'sub#dir',
STUDY => [ 'Pod_alu' ],
);
use Inline::Java;
my $alu = new Pod_alu() ;
print($alu->add(9, 16) . "\n") ; # prints 25
print($alu->subtract(9, 16) . "\n") ; # prints -7
The code should display a message like
Class Pod_alu not found at /usr/lib/perl5/site_perl/5.8.8/i686-linux/Inline/Java.pm line 619
BEGIN failed--compilation aborted at p line 6, <GEN8> line 4.
When you change the CLASSPATH setting in the perl code from "sub#dir" to "sub-dir" it should work.
This behaviour is strange enough that I wanted to hear the forum's comments and having it reproduced by someone else before calling it a bug in Inline::Java. Java once had in fact a problem with '#' characters in the classpath (if I remember correctly back in 1.2 or even earlier) but that has long been fixed (at least I thought...).
Thanks for any comment.
Christian
|