Saturday, June 12, 2010

[Java] native keyword ?

 

Ok , I have used the native keyword in java alot when I use the JNI.
What I am trying to understand is if I can use native keyword the same way as c uses extern.
But not having to create a dll or anything just simple load an existing dll and using a particular function in it by looking up that functions mangled name using something like objdump,...etc

The only thing I could see being a problem is if their is parameters to the function.... problems with the type ,size ,...etc with this.
But if the parameters corresponded to the same thing as java parameters then would it work?

Also using gcj to compile java into machine code. If I used the native command would it work like extern to be resolved be the linker ... enabling me to call c/c++ from compiled java into .o files so I can call c without a user defined dll or interface like JNI CNI ,...etc

Anybody know?
What exactly the keyword native gets compiled down to when in a class file and how the JVM translates this into machine code?

basically I have c .o files with functions in them that I would like to call from java. gcj allows me to compile the java into .o files as well and then link to an .exe with all those c .o files. But I want away to call the c function from the java functions in the .exe. I know calling java from c would be as easy as looking up the names with objdump and putting an extern command in my c files before I compile them into .o files. My problem is how to call c from java .o files normal I would use native command and go thru a library but now I am linking to an exe file so all I need is the native command to beable to call back c functions????

That is why I am wanting to know how native works?

__._,_.___
Recent Activity:
Visit http://aiaiai.com or http://jgame.org for more groups to join.
Java Official Group is created for the following topics: Java 2 Enterprise Edition - J2EE, Java 2 Standard Edition - J2SE, Java 2 Micro Edition - J2ME, XML, XSL, XSD, XPATH, Web Services, Jini, JXTA for all type of Java Geeks.
Whoever posts spam / ads / job related message will be BANNED IMMEDIATELY
MARKETPLACE

Stay on top of your group activity without leaving the page you're on - Get the Yahoo! Toolbar now.


Get great advice about dogs and cats. Visit the Dog & Cat Answers Center.


Get real-time World Cup coverage on the Yahoo! Toolbar. Download now to win a signed team jersey!

.

__,_._,___

No comments:

Post a Comment