Note that there are some explanatory texts on larger screens.

plurals
  1. POReturning an int from native function(c++, jni) crashes application
    primarykey
    data
    text
    <p>Trying to figure out why c++ function call returning an int crashes the whole application without any errors/warnings.</p> <p>Here is working code:</p> <pre><code> jint Java_org_ntorrent_DummyTorrentInfoProvider_next( JNIEnv * env, jobject obj, jint number) { jint test = rand(); __android_log_print(ANDROID_LOG_DEBUG, "HelloNDK!", "rand() = %d", test); return number; } </code></pre> <p>And this code crashes application without warnings:</p> <pre><code> jint Java_org_ntorrent_DummyTorrentInfoProvider_next( JNIEnv * env, jobject obj, jint number) { jint test = rand(); __android_log_print(ANDROID_LOG_DEBUG, "HelloNDK!", "rand() = %d", test); return number + test; } </code></pre> <p>Before the application crashes i can see my log message(__android_log_print) in log cat</p> <p>EDIT: Even if I replace "number + test" with "1" the application still crashing... It only works if I return "number"...</p> <p>EDIT#2: Java-side code:</p> <pre><code> package org.ntorrent; import java.util.ArrayList; import java.util.Random; public class DummyTorrentInfoProvider implements TorrentInfoProvider { public native Integer next(Integer number); //public Integer next() { return _random.nextInt(); } public native void test(); private Random _random = new Random(100); @Override public ArrayList getTorrents() { test(); ArrayList torrents = new ArrayList(); torrents.add( new TorrentInfo("test torrent number 1", next(1), 3f, 5f)); torrents.add( new TorrentInfo("test torrent number 2", next(2), 4f, 15f)); torrents.add( new TorrentInfo("test torrent number 555")); torrents.add( new TorrentInfo("test torrent number 3", next(3), 13f, 5f)); return torrents; } static { System.loadLibrary("test"); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload