Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JNI

 
Leandro Oliveira
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is the source code for class Java.lang.Object.
I would like to know what does 'registerNatives()'
do in the source code???
I would like to study very hard java, do you think it's a good choice to study all classes including the low level JNI interface???

package java.lang;
public class Object {
private static native void registerNatives();
static {
registerNatives();
}
public final native Class getClass();
public native int hashCode();
public boolean equals(Object obj) {
return (this == obj);
}
protected native Object clone() throws CloneNotSupportedException;
public String toString() {
return getClass().getName() + "@" + Integer.toHexString(hashCode());
}
public final native void notify();
public final native void notifyAll();
public final native void wait(long timeout) throws InterruptedException;
public final void wait(long timeout, int nanos) throws InterruptedException {
if (timeout < 0) {
throw new IllegalArgumentException("timeout value is negative");
}
if (nanos < 0 || nanos > 999999) {
throw new IllegalArgumentException(
"nanosecond timeout value out of range");
}
if (nanos >= 500000 || (nanos != 0 && timeout == 0)) {
timeout++;
}
wait(timeout);
}
public final void wait() throws InterruptedException {
wait(0);
}
protected void finalize() throws Throwable { }
}
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Studying JNI is a good idea. Studying the low level JNI interfaces is pretty much un-necessary unless you intend to do something fairly low level yourself.
For most application programmers their time would be better spent understanding other things.
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, the registerNatives method finds all the native methods required by the JVM. You know, the ones that do things like hooking up the operating system files to in/out/err streams, and talking to the hardware etc.
 
Leandro Oliveira
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is it the same as
System.loadLibrary("library_name");
but it loads all the libraries??? is this???
thanks a lot!!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic