我正在寻找一些帮助,通过perl Inline :: Java将这些代码正确地提供给funciton。 当我调用stupid()方法传递两个参数时,我的问题出现了。 我的apache日志(附在下面)返回No public method' stupid'为class' main :: MathFunctions'定义。
注意:第342行是print $jfunc->stupid($tapsRe{$i},$tapsIm{$i}) . "\n";
我在MathFunctions类中的另一种方法(twoComplimentNbit
)工作得很好。
任何人都可以指出我在这里失踪的东西吗?
BEGIN {
$ENV{CLASSPATH} .= ":/var/www/java/commons-lang-2.6/commons-lang-2.6.jar";
$ENV{CLASSPATH} .= ":/var/www/java/commons-math-2.2/commons-math-2.2.jar";
}
use Inline::Java;
use Inline (Java => <<'END_OF_JAVA_CODE', AUTOSTUDY => 1, DEBUG => 6,
import org.apache.commons.math.complex.*;
import org.apache.commons.math.MathException;
import org.apache.commons.math.transform.FastFourierTransformer;
import java.util.*;
class MathFunctions {
public static int twoComplimentNbit(int val, int bits) {
val &= (int) (1 << bits) - 1;
int R = (int) (1 << bits - 1);
if (val < R) {
return val;
} else {
return val - R * 2;
}
}
public double stupid (float REAL, float IMG) {
Complex result = new Complex(REAL,IMG);
double realOne = result.getReal();
double imgOne = result.getImaginary();
return realOne;
}
}
END_OF_JAVA_CODE
SHARED_JVM => 1,
DIRECTORY => '/tmp',
);
my $jfunc = new MathFunctions();
输出:
[Fri Jun 27 16:11:45 2014] [error] [perl][3] packet sent is call_method 2031 MathFunctions fastAtan2 (double,double) scalar:LTAuMDAxOTU2OTY5NjQ2MDM2Mzc= scalar:MC4wMDE5NTY5Njk2NDYwMzYzNw==
[Fri Jun 27 16:11:45 2014] [error] [perl][3] packet recv is ok scalar:LTAuNzg1Mzk4Mg==
[Fri Jun 27 16:11:45 2014] [error] [perl][5] stupid
[Fri Jun 27 16:11:45 2014] [error] No public method 'stupid' defined for class 'main::MathFunctions' at /var/www/pre_eq-dev.cgi line 342
[Fri Jun 27 16:11:45 2014] [error] [perl][4] destroying Inline::Java::Object
[Fri Jun 27 16:11:45 2014] [error] [perl][4] destroying Inline::Java::Object::Tie
[Fri Jun 27 16:11:45 2014] [error] [perl][2] destroying object in java (main::MathFunctions):
[Fri Jun 27 16:11:45 2014] [error] [perl][3] deleting object main::MathFunctions=HASH(0x8cd4248) 2031 (MathFunctions)
[Fri Jun 27 16:11:45 2014] [error] [perl][3] packet sent is delete_object 2031
[Fri Jun 27 16:11:45 2014] [error] [perl][3] packet recv is ok undef:
[Fri Jun 27 16:11:45 2014] [error] [perl][4] destroying Inline::Java::Protocol
[Fri Jun 27 16:11:45 2014] [error] [perl][4] destroying Inline::Java::Object::Private
[Fri Jun 27 16:11:45 2014] [error] [perl][1] killed by natural death.
[Fri Jun 27 16:11:45 2014] [error] [perl][1] JVM non-owner exiting...
[Fri Jun 27 16:11:45 2014] [error] [perl][1] exiting with 9
[Fri Jun 27 16:11:45 2014] [error] [perl][4] destroying Inline::Java::Object::Tie
[Fri Jun 27 16:11:45 2014] [error] [perl][4] script marked as DONE, object destruction not propagated to Java
[Fri Jun 27 16:11:45 2014] [error] [perl][4] destroying Inline::Java::Protocol
[Fri Jun 27 16:11:45 2014] [error] [perl][4] destroying Inline::Java::Object::Private
[Fri Jun 27 16:11:45 2014] [error] [perl][4] destroying Inline::Java::Object::Tie
[Fri Jun 27 16:11:45 2014] [error] [perl][4] script marked as DONE, object destruction not propagated to Java