Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7706929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:13:58+00:00 2026-06-01T00:13:58+00:00

ok so my java code: private static native void setNativeFiles(mFileDescriptor[] r); public void setFiles(mFileDescriptor[]

  • 0

ok so my java code:

private static native void setNativeFiles(mFileDescriptor[] r);
public void setFiles(mFileDescriptor[] files){
    setNativeFiles(files);
}

static class mFileDescriptor{
    private FileDescriptor fd;
    private long offset;
    private long size;

    public FileDescriptor getFd() {
        return fd;
    }
    public void setFd(FileDescriptor fd) {
        this.fd = fd;
    }
    public long getOffset() {
        return offset;
    }
    public void setOffset(long offset) {
        this.offset = offset;
    }
    public long getSize() {
        return size;
    }
    public void setSize(long size) {
        this.size = size;
    }
}

mFileDescriptor is an innerclass btw…

my c code:

void Java_com_ultrasound_JNIinterface_setNativeFiles(JNIEnv* env, jclass mclass, jobjectArray arr){
LOGI("Setting Native files");
jclass filedescriptor = env->FindClass("com/ultrasound/JNIinterface/mFileDescriptor");
int length = env->GetArrayLength(arr);
for(int index = 0; index < length; index++)
{
    //jclass mvclass = env->GetObjectClass(obj);
    jmethodID mid = env->GetMethodID(filedescriptor, "getFd", "()Ljava/io/FileDescriptor;");
    jobject temp = env->CallObjectMethod( arr, mid);
    int mvdata0 = reinterpret_cast<int>(&temp);

    mid = env->GetMethodID(filedescriptor, "getOffset", "()L");
    temp = env->CallObjectMethod( arr, mid);
    long mvdata1 = reinterpret_cast<long>(&temp);

    mid = env->GetMethodID(filedescriptor, "getSize", "()L");
    temp = env->CallObjectMethod( arr, mid);
    long mvdata2 = reinterpret_cast<long>(&temp);

    mFileDescriptor * fp;
    switch(index){
    case 0:
        fp = &ch0Descript;
        fp->fd = mvdata0;
        fp->offset = mvdata1;
        fp->size = mvdata2;
        break;
    case 1:
        fp = &ch1Descript;
        fp->fd = mvdata0;
        fp->offset = mvdata1;
        fp->size = mvdata2;
        break;
    case 2:
        fp = &ch2Descript;
        fp->fd = mvdata0;
        fp->offset = mvdata1;
        fp->size = mvdata2;
        break;
    default:
        LOGE("Native file indexing failed");
    }
}
LOGI("Native files set");

}

whenever I call setFiles I get this:

03-23 00:13:11.080: I/(9879): Setting Native files
03-23 00:13:11.080: I/(9879): Right before loop
03-23 00:13:11.080: I/(9879): IN FOR LOOP
03-23 00:13:11.501: W/ActivityManager(175): Activity pause timeout for HistoryRecord{406814b8 com.ultrasound/.UltraSoundJNIActivity}
03-23 00:13:12.241: W/dalvikvm(9879): threadid=10: spin on suspend #1 threadid=1 (pcf=0)
03-23 00:13:12.982: W/dalvikvm(9879): threadid=10: spin on suspend #2 threadid=1 (pcf=0)
03-23 00:13:12.982: I/dalvikvm(9879): "Thread-10" prio=5 tid=10 RUNNABLE
03-23 00:13:12.982: I/dalvikvm(9879):   | group="main" sCount=0 dsCount=0 obj=0x40651440 self=0x136c48
03-23 00:13:12.982: I/dalvikvm(9879):   | sysTid=9892 nice=0 sched=0/0 cgrp=default handle=1279040
03-23 00:13:12.982: I/dalvikvm(9879):   | schedstat=( 1495360 488283 24 )
03-23 00:13:12.982: I/dalvikvm(9879):   at com.ultrasound.JNIinterface$1.run(JNIinterface.java:~31)
03-23 00:13:12.982: I/dalvikvm(9879):   at java.lang.Thread.run(Thread.java:1019)
03-23 00:13:12.982: I/dalvikvm(9879): "main" prio=5 tid=1 RUNNABLE
03-23 00:13:12.982: I/dalvikvm(9879):   | group="main" sCount=1 dsCount=0 obj=0x40161190 self=0xce68
03-23 00:13:12.982: I/dalvikvm(9879):   | sysTid=9879 nice=0 sched=0/0 cgrp=default handle=-1345002432
03-23 00:13:12.982: I/dalvikvm(9879):   | schedstat=( 64514163 45135496 61 )
03-23 00:13:12.992: I/dalvikvm(9879):   at com.ultrasound.JNIinterface.setNativeFiles(Native Method)
03-23 00:13:12.992: I/dalvikvm(9879):   at com.ultrasound.JNIinterface.setFiles(JNIinterface.java:105)
03-23 00:13:12.992: I/dalvikvm(9879):   at com.ultrasound.UltraSoundJNIActivity.onCreate(UltraSoundJNIActivity.java:59)
03-23 00:13:12.992: I/dalvikvm(9879):   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-23 00:13:12.992: I/dalvikvm(9879):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)
03-23 00:13:12.992: I/dalvikvm(9879):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
03-23 00:13:12.992: I/dalvikvm(9879):   at android.app.ActivityThread.access$1500(ActivityThread.java:123)
03-23 00:13:12.992: I/dalvikvm(9879):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
03-23 00:13:12.992: I/dalvikvm(9879):   at android.os.Handler.dispatchMessage(Handler.java:99)
03-23 00:13:12.992: I/dalvikvm(9879):   at android.os.Looper.loop(Looper.java:130)
03-23 00:13:12.992: I/dalvikvm(9879):   at android.app.ActivityThread.main(ActivityThread.java:3835)
03-23 00:13:12.992: I/dalvikvm(9879):   at java.lang.reflect.Method.invokeNative(Native Method)
03-23 00:13:12.992: I/dalvikvm(9879):   at java.lang.reflect.Method.invoke(Method.java:507)
03-23 00:13:12.992: I/dalvikvm(9879):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
03-23 00:13:12.992: I/dalvikvm(9879):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
03-23 00:13:12.992: I/dalvikvm(9879):   at dalvik.system.NativeStart.main(Native Method)
03-23 00:13:13.743: W/dalvikvm(9879): threadid=10: spin on suspend #3 threadid=1 (pcf=0)
03-23 00:13:13.743: I/dalvikvm(9879): "Thread-10" prio=5 tid=10 RUNNABLE

which eventually led to “Fatal spin-on-suspend: dumping threads”

I think its the getObjectMethod call since i put a log in right before the for loop and after the first data. Any help??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T00:13:59+00:00Added an answer on June 1, 2026 at 12:13 am

    Your code has several problems:

    1. com/ultrasound/JNIinterface/mFileDescriptor -> com/ultrasound/JNIinterface$mFileDescriptor

    2. Piece of code that casts address (!) of a jobject returned from getFd to long is just wrong

    3. ()L in getOffset and getSize methods must be ()J

    4. CallLongMethod must be used instead of CallObjectMethod

    5. temp is not needed, result of CallLongMethod should be assigned directly to mvdata variables (which must be of type jlong)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following java code: public class CheckInnerStatic { private static class Test
I have the following (Java) code: public class TestBlah { private static final String
Consider this code: package Prova; import java.util.ArrayList; public class Prova { private ArrayList<String> people;
Given is the following code: import java.io.Serializable; import java.util.concurrent.locks.ReentrantLock; class Data { private int
Using GWT I have a Java class: public class Pojo { private String name;
I wrote the following code: import java.lang.*; import DB.*; private Boolean validateInvoice(String i) {
I want to access a static JavaFX class member from Java using the Javafx
I perform some decoding process in the native code and call a Java method
So i have the following code in C that utilizes Java Native Interface however
I am creating a database in android using this code: public class PackageDBHelper extends

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.