GetStaticMethodID Problem
Want to load a jfloat array into a java.nio.FloatBuffer in C
The easiest way to do this is using the static method
FloatBuffer.wrap(float[]);
So I get the classID:
jclass floatBufClass = (*env)->FindClass(env,"java/nio/FloatBuffer");
if(floatBufClass == NULL){
return (NULL);
}
This appears to work
then go for the methodID:
jmethodID cid = (*env)->GetStaticMethodID(env, floatBufClass,"wrap","([F)Ljava/nio/FloatBuffer");
if(cid == NULL){
return(NULL);
}
Get the error on the Java side:
Exception in thread"main" java.lang.NoSuchMethodError: wrap
Any ideas?
Jim
# 1
<snip>
> > jmethodID cid = (*env)->GetStaticMethodID(env,
> floatBufClass, "wrap", "([F)Ljava/nio/FloatBuffer");
> if(cid == NULL) {
>return(NULL);
>
The 'javap' tool is your friend:
[jim@daisy ~]$ /usr/java/jdk1.6.0/bin/javap -s java.nio.FloatBuffer
Compiled from "FloatBuffer.java"
public abstract class java.nio.FloatBuffer extends java.nio.Buffer implements java.lang.Comparable{
final float[] hb;
Signature: [F
final int offset;
Signature: I
boolean isReadOnly;
Signature: Z
...
...
...
public static java.nio.FloatBuffer wrap(float[]);
Signature: ([F)Ljava/nio/FloatBuffer;
The signature String in calls such as GetStaticMethodID must match the output from 'javap' *exactly*. When referring to non-primitive types in signature Strings the proper form is:
Lsomepacakge/somesubpackage/SomeClass;
You forgot the trailing semi-colon in your code.
Jim S.