• Post Reply Bookmark Topic Watch Topic
  • New Topic

native keyword ?  RSS feed

Sam Doder
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!