Solved

JNI - mapping integer pointers in vc++ through JNI

Posted on 2001-07-26
5
740 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
table example 4 29
How to execute a Python program and gather return output in Java 2 31
What's wrong with this code? 4 23
ejb on wildfly 5 20
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

823 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