How do I get a byte array from an object passed into the JNI?

This is what my java code looks like:
public class streamedData
protected byte[] m_value = null;
public byte[] getByteArray ()
return m_value;
/* code not pertaining to this question snipped. */
jclass streamedDataClass = env->GetObjectClass(jstreamedData);
// Get methodIDs for the various NPKI_Extension methods
value = env->GetMethodID(streamedDataClass, "getByteArray", "()[B");
lstreamedData->value = (unsigned char *)malloc (lstreamedData->length);
if (lstreamedData->value == NULL)
return INSUFFICIENT_MEMORY;
memset (lstreamedData->value, 0, lstreamedData->length);
memcpy (lstreamedData->value, env->CallByteMethodA(streamedDataClass, value, NULL), lstreamedData->length);
This is not working.
My question is, how do I get a copy of or read m_value in the JNI layer? Do I have to make the byte array public and access it as a field ID?
Any help would be appreciated. Why oh why can't there be a CallByteArrayMethod????

My question is, how do I get a copy of or read m_value in the JNI layer? Do I have to make the byte array public and access it as a field ID?
You can retrieve a handle to the byte array, through a method call, as you're doing now, or by directly accessing it through GetFieldID.
In the case of the method call, you'll want to do:jmethodID getByteArrayMethod = env->GetMethodID(streamedDataClass, "getByteArray", "()[B");
jbyteArray byteArray = static_cast<jbyteArray>( env->CallObjectMethod( jstreamedData, getByteArrayMethod ) );In the case of field access, you can do:jfieldID m_valueFieldID = env->GetFieldID( streamedDataClass, "m_value", "[B" );
jbyteArray byteArray = static_cast<jbyteArray>( env->GetObjectField( jstreamedData, m_valueFieldID ) );Once you have byteArray, you need to access it using the array operations:lstreamedData->value = env->GetByteArrayElements( byteArray, 0 );
// Do what you want to do, then release the array
env->ReleaseByteArrayElements( byteArray, lstreamedData->value, 0 );As always, Jace, http://jace.reyelts.com/jace, makes this easier. For example,void printByteArray( jobject jstreamedData ) {
  streamedData data( jstreamedData );
  JArray<JByte> byteArray = streamedData.m_value();
  for ( int i = 0; i < byteArray.length(); ++i ) {
    cout << byteArray[ i ];
}God bless,
-Toby Reyelts

Similar Messages

  • How do I get 2 video clips from Canon IXUS 75 into iMovie?

    How do I get 2 video clips from Canon IXUS 75 into iMovie?  I've tried several different things, but nothing seems to work...  I'll appreciate any help..  Thank you in advance.  (I do this all the time, but with a different camera...)  ;-/

    Thank you -- I was able to find an answer in the previous posts and I just figure it out!  ;-}

  • How do I get a text file from Photoshop  to work in the main sequence in pp?

    How do I get a text file to work properly in the master sequence. I moved it from Photoshop, which I learned to do from a tutorial, but when I move the animated text sequence to the master, it either isnt running, or it is scaled way too big. How do I get it to run in the main sequence?

    "Wont Work Here" !  Does not mean much.
    Are you having an audio or a video issue? 
    Looks like no video clip on the video layer above that section of audio.
    I am teaching myself this stuff completely on the fly
    I suggest you do the Basic Tutorials ( Adobe TV for example) in both Premiere Pro and PhotoShop.
    You need to be competent in the basics and fundamentals of these apps and that will also help you describe and discuss the issues.   Check the 'Products on this site....
    Adobe TV

  • How do I get iphone5 video clips from my camera roll into videos, then into icloud?

    How do I get video clips from my iphone5 camera roll into videos, then into icloud?

    Thank you -- I was able to find an answer in the previous posts and I just figure it out!  ;-}

  • How do I get a property value from my PreUUTLoop callback into my MainSequence?

    I am trying to get a propety value (it's a VISA session number) from my PreUUTLoop callback into my MainSequence so that I can then contol my piece og GPIB equipment. How do I do that? Do I use a parameter or local variable, or something else? What mechanism do I use to pass it?
    Thanks

    Hi,
    You will need to write it to a variable in the FileGlobals, that way it will be accessible to both sequences.
    Regards
    Ray Farmer
    Regards
    Ray Farmer

  • How can I get a birthday reminder from items which are in the read-only cal

    I am looking for a solution to get a reminder message for birtdays which are within the read-only calender imported/updated from he address book. I so far have not found the option where to turn on the reminder and I do not want to duplicate items (ie creating another birthday calender inside iCal).
    Thanks for comments.
    PB G4 Ti, 1GHz, 10.2.8   Mac OS X (10.4.7)  

    Hi ontour,
    This limitation is one of the many reasons I wrote Dates to iCal. It is a replacement for the Birthdays calendar in iCal, so you would need to turn the Birthdays calendar off in iCal's preferences.
    See here: http://discussions.apple.com/thread.jspa?threadID=466478
    Best wishes
    John M

  • How do I get my scrivener files from my old apple to the new one?

    I just bought a new macbook pro and am trying to transfer files from my scrivner, which is an app for my current book, from my old mac to new.  How do I do this?
    Thanks

    Simply copy any Scrivener files to the new computer, however you want to do it.  Copy via flash drive, use Ogelthorpe's link, burn a CD or DVD, etc.  On the new computer, download and install Scrivener from their web site, then you can open the files.
    If you aren't sure where you put your current Scrivener file, open Scrivener and hold down the command key while clicking the name of the file in the window's title bar.  That shows you where it is.

  • How do I get all my music from 3 seperate devices into one place without a computer???

    I have a new iPad. My friends old iPhone. And my old iPod. My laptop crashed and now all my music is just on my iPod. I have some downloaded music on my iPhone and iPad. All my music is in different places because my brother and sister and I share our music with eachother. Help?? I just want all my music from all 3 devices into one place so I can put ALL my music on ALL my devices without a computer. Thanks!

    Not possible without a computer.  You will absolutely need a computer if you want to do this. You will also need iTunes to sync it back on to the devices.

  • How do I get iTunes to recognize my iPod while plugged into the TC?

    Ok So I have an Apple Time Capsule which I use as my router and NAS drive. Though I also plug my iPod into the usb port on it. The iPod is recognized on my computer and over the network easily although how can I get iTunes to recognize it and be able to add music and video?

    Double-Dee91 wrote:
    I have an Apple Time Capsule which I use as my router and NAS drive. Though I also plug my iPod into the usb port on it.
    Even though it's physically possible, I doubt an iPod is intended to work that way. Why do you want to do that?
    The iPod is recognized on my computer and over the network easily although how can I get iTunes to recognize it and be able to add music and video?
    What I believe you're seeing is the disk drive function of your iPod, which is different from the music player function. I'd give up trying to play music from your iPod while connected to a Time Capsule.

  • How can I get my Nikon D3x raw images to download into the organizer of Elements 6.0

    I recently purchased a Nikon D3x and have been unable to view my raw images in Elements 6.0. I have downloaded the Raw 5.4 update. When that did not work, i uninstalled Elements and the 5.4 update and reinstalled them again. I am able to download the raw photos into the  Elements Downloader, but once the photos go to the organizer, i get  the screen saying that "the file is damaged or is a format that cannot be included". According to the Adobe Tech Support Dept., Elements 6.0 is able to support the Nikon D3x, with the Raw 5.4 update. Has anyone else run into this problem and have a solution?
    I would greatly appreciate any help.

    journey01 wrote:
    Thank you for your response dj_paige.
    I was able to see that the 4.2 that came with the Elements 6.0 is still on my computer (by going to the (Orange tab ) Edit/Help/About plug in). I could not find the 4.2 listed separately anywhere on the computer so that I could delete it. Is there a way to do this?  I am  a true novice, so when you say to make sure the old plug in is removed from the File Formats folder are you talking about in Tools?
    I am talking about the File Formats folder that gets created when you install PSE. You have obviously been to that folder already because you said you installed Adobe Camera Raw 5.4. Go to that folder in Windows, and make sure that the old plug-in (which was named CameraRaw.8bi, but may have been renamed by you) is deleted from that folder (not renamed, not moved to a subfolder). Then, following the instructions are on the page where you downloaded Camera Raw 5.4, install the new plug-in.

  • How to get correct byte array from String

    I have a string which contains binary value from 0 to 255. Now, if I use String.getBytes(),all the chars in the string which range from 128 to 160 will be convert to 63.
    What's the problem?

    You're assuming that you're working with Ascii values.
    You're actually working with Unicode values.
    When you use getChar() on a String, you get back a 16bit integer, the unicode index. When you do a getBytes() the Unicode values get mapped back to the default codepage of your machine.
    Eg. on an english pc, the default locale is Windows latin, codepage 1252. On non-english pcs, it could be any encoding scheme.
    If you're on a machine set up for a chinese locale, then the Unicode
    values get mapped to your chinese codepage. The extended ascii values,
    above 127 may not be defined in your codepage.
    Try String.getBytes ( "Cp1252" );
    Although I suspect that, whatever you're trying to do, it's probably not the right approach....
    regards,
    Owen

  • How can I get ALL my songs from my ext.HD into my new Mac?

    They are ALL backed up from my old computer onto an external HD. But they stay there. The only ones I can get are those that I purchased from the iTunes store. How can I transfer the others? Any suggestions?

    greetings ecojoan !
    you mean you intend to add those files from the external drive to the iTunes library on your startup disk, you e.g. choose +add to library+ from the file menu, and iTunes won't add the files ?
    if so, you could try this:
    check if you have read & write permissions for your iTunes music folder. in finder, right-click on it and +get info+. unlock the little padlock (you may have to enter your admin password) and change the permission settings. next, click on the little gear-shaped icon and +apply to enclosed items+ like so
    you may also give everyone read & write access. if this doesn't help, try the same on your iTunes folder (not just the iTunes music folder).
    try adding one of the problem files.
    what happens ?

  • HT4623 how can i get my contact back from my old iPhone to the new iphone

    my iphone broke i buy a new one and i dont know how to get my contacs back and picture / videos

    did you have a backup of the old phone and do you still have it?

  • How can I get Directory and Files from a Maped Networkdrive of the AppS

    Hello,
    we have the following Situation.
    We have a Windows-Server (Server-A) in an Network with ActivDirectory and an Windows-Server (Server-B with an WebApplicationServer outside of these ActivDirectory as standalone.
    On Server-B we mapped a Directory from Server-A (FileExplorer and then MapNetworkDrives) as Drive Q.
    Now i tried to get the Directory of Q:\abcd but it doesn't work.
    I tried the FM EPS_GET_DIRECTORY_LISTING and also RZL_READ_DIR, but both doesn't worked.
    RZL_READ_DIR is doing a "CALL 'ALERTS' ..." and is comming back with sy-subrc = 1
    EPS_GET_DIRECTORY_LISTING is doing a "CALL 'C_DIR_READ_FINISH'..." and comes back with "Wrong order of calls" in the Field file-errmsg. Next Call is "CALL 'C_DIR_READ_START'..." and this comes back with "opendir" in Field file-errmsg.
    I tried the same with two Servers in the same ActivDirectory-Network. The Result was the same, i don't get the directory of the mapped drive. But now i get from the Call "CALL 'C_DIR_READ_START'..." the file-errmsg "opendir: Not a directory" and file-errno 20.
    Is there any idea for solving my Problem?
    I have to get this directory, read the files from the List and have to rename them after wriing the data to our databasefile.
    I want to read them with OPEN DATASET, rename them by writing a new File (also OPEN DATASET) and after that i do an DELETE DATASET.
    Thanks and Greetings Matthias
    Edited by: Matthias Horstmann on Mar 25, 2009 4:12 PM
    Filled in Scenario with 2 Servers in same AD-Network

    Halo Mattias,
    i using this function get file file name and directory:
    at selection-screen on value-request for p_file.
      call function 'F4_FILENAME'
        exporting
          program_name  = syst-cprog
          dynpro_number = syst-dynnr
          field_name    = 'P_FILE'
        importing
          file_name     = p_file.
    Rgds,
    Wilibrodus

  • How do i get my music files from my media player into i-tunes?

    i have tried to import my music from my old windows media player and it wont do anything. i just got my first ipod. i dont want to have to duplicate all the music on my computer twice just to have it in my itunes player?!?! please help!

    I have also tried to use Window Mieda Player to import my music. Only iTunes can import music to you iPod. If your iPod came with a cd to install drivers for it, It will also have iTunes on it. I am sorry. By the way, congradulations on your first iPod!
      Windows XP Pro   Hp Desktop iPod Nano

Maybe you are looking for

  • How can you permanently add a new field to the Advanced User Search?

    We have a number of USR UDF attributes that need to be used in the Advanced Search: Users window. These will be used very often so we would rather not require our Admins to have to select the Add Fields button, scroll down to the attribute they want,

  • Lightjet Print Sharpening

    I do all of my personal stuff on large format Epson inkjets. No problem there with Lightroom. Great output. For years I never take a camera to family events to avoid having to supply them...know what I mean. These guys want (for the most part) 4x6s 5

  • AFP problem in 10.3 workstation

    Here is my problem, I have two machines running 10.3 when I click on go - connect to server and enter my server that I want to connect to it tells me it could not connect to the server becuase the username or password is incorrect. What file do I nee

  • Pop Up info

    I want to use a pop up that gets it's information from a table. For example I have 6 sheets with the same pop up and I don't want to have to edit all 6 sheets, just one table and all pop up's have the new value from the table below. A list of text wh

  • VZ webmail and contacts

    I just got my Galaxy SIII on Friday. I am still getting all of the creature comforts in place. I am struggling to get my webmail contacts to sync. My Verizon account shows up on the phone and the email messages are all there, but no contacts. When I