Solved

JNI - mapping integer pointers in vc++ through JNI

Posted on 2001-07-26
5
738 Views
Last Modified: 2013-11-23
Hi! Anyone,
I have a native function defined in VC++ which is returning int*.  Actually I would like to map this int * with JNI.  Do anyone throw some light on this.  

Thanks in advance.
Jeganathan
0
Comment
Question by:Jeganathan
5 Comments
 
LVL 3

Expert Comment

by:stimpyjcat
ID: 6322669
If you mean you simply want to store it, you can stuff it into int or long member data using JNI member access methods.

Otherwise you'll need to clarify what you mean by mapping the integer pointer.

0
 

Author Comment

by:Jeganathan
ID: 6326141
My VC++ native function looks something like this

JNIEXPORT int* JNICALL readSrl(JNIEnv *env, jobject obj)
{
  int* srl = new int[8];

  byte [] b = {1,2,3,4,5,6,7,8};

  for(int i=0; i<8; ++i)
    srl[i] = b[i];

 return srl;
}

Can anyone suggest the method signature that should be declared in Java using this native function.  





}
0
 
LVL 3

Accepted Solution

by:
stimpyjcat earned 50 total points
ID: 6326438
So it's not that you want to store a pointer to an integer, you want to store an array of integers.

To see the proper signature for returning an array of integers, do the following:

1) compile a simple java function which returns the type you're interested in (int[]), e.g.

public class Serial {
int[] readSrl() {
     return new int[] { 1,2,3,4,5,6,7,8 };
}
}

2) run javap to get the signature

javap -s Serial

It might be preferable to convert the serial to a string, since it's far easier to construct a jstring from a character array than to construct an array of jints and populate it.  If you're only interested in the unique pattern of bits, that might be preferable.  If you're interested in the individual integers, though, you should construct a java array of integers instead.

There are array copy functions in JNI which can make this a little easier; see the JNI tutorial at java.sun.com.
0
 

Expert Comment

by:CleanupPing
ID: 9061947
Jeganathan:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 9208320
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:


[points to stimpyjcat]


Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
sudhakar_koundinya
EE Cleanup Volunteer
---------------------
If you feel that your question was not properly addressed, or that none of the comments received were appropriate answers, please post your concern in THIS thread.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Java array passed to SQL where clause 23 64
more than one jdk and one jre 1 34
MySQL  on Tomcat 8 30
java stored proc example 9 24
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now