Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #19004

Re: JNI return jobjectArray

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail
From markspace <-@.>
Newsgroups comp.lang.java.programmer
Subject Re: JNI return jobjectArray
Date Sun, 30 Sep 2012 19:21:51 -0700
Organization A noiseless patient Spider
Lines 63
Message-ID <k4auo2$fvf$1@dont-email.me> (permalink)
References <k4a9gd$usp$1@online.de> <k4af7c$tdo$1@dont-email.me> <k4aghk$45u$1@online.de>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Mon, 1 Oct 2012 02:21:54 +0000 (UTC)
Injection-Info mx04.eternal-september.org; posting-host="104ea93b2a90d763b2b4538d1ef3ad00"; logging-data="16367"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ToPbGzrP/QYz9vQZri5Po93aNglUuRU0="
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20120907 Thunderbird/15.0.1
In-Reply-To <k4aghk$45u$1@online.de>
Cancel-Lock sha1:qZs95FToQHuqQCYLFAPcTRbOUIg=
Xref csiph.com comp.lang.java.programmer:19004

Show key headers only | View raw


On 9/30/2012 3:23 PM, Philipp Kraus wrote:

> You are not right,


I'm not right?  And yet...


 > heap, but how can I push back
 > the reference


...the problem still exists.


> In detail I have got a native (C) methode, that shows in Java:


Truthfully, there is not enough detail here for me to guess what the 
problem really is.  You're showing method signatures but no code.


> If I call in Java this code:
>
> Double[] x = null;
> Double[][] y = null;
>
> myclass.mymethod(x, y);


No this will not work.  I guess I was not specific enough: *you* have to 
create a reference to the array reference you want to modify.  That 
doesn't happen if the parameter is null.

   Double x = { {1.2} };

Now you have something to modify.  Java does NOT have pass by reference, 
you must do it yourself.  I did a Google search, and I didn't see the 
solution, so here I guess is some lost knowledge.  This is Java, you'll 
have to translate to C++ on your own:

class Example {

   // manual "pass by reference"
   void makeNewDoubleArray( Double [][] x ) {
     x[0] = new Double[] { 1.1, 2.2, 3.3 };
   }

   public static void main( String... args ) {
     Double[] y = {0.0};
     Double[][] wrapper = { {} };
     wrapper[0] = y;           // pack
     makeNewDoubleArray( wrapper );
     y = wrapper[0]            // unpack
     System.out.println( java.util.Arrays.deepToString( y ) );
   }
}

Code is untested; watch out for silly errors.



Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

JNI return jobjectArray Philipp Kraus <philipp.kraus@flashpixx.de> - 2012-09-30 22:23 +0200
  Re: JNI return jobjectArray markspace <-@.> - 2012-09-30 14:56 -0700
    Re: JNI return jobjectArray Philipp Kraus <philipp.kraus@flashpixx.de> - 2012-10-01 00:23 +0200
      Re: JNI return jobjectArray markspace <-@.> - 2012-09-30 19:21 -0700
        Re: JNI return jobjectArray Lew <lewbloch@gmail.com> - 2012-09-30 21:14 -0700
          Re: JNI return jobjectArray markspace <-@.> - 2012-10-01 08:32 -0700
      Re: JNI return jobjectArray "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2012-10-01 09:39 +0100
  Re: JNI return jobjectArray Roedy Green <see_website@mindprod.com.invalid> - 2012-10-01 10:21 -0700
  Re: JNI return jobjectArray Steven Simpson <ss@domain.invalid> - 2012-10-01 23:46 +0100

csiph-web