Today, when studying object source code, encountered the native keyword. This is simply a local method, which is declared as the native method when invoking code in a method that is not written in the Java language, or in the Java language of a method, directly manipulating computer hardware.
The following is the object source code,
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 ());
}//Beginner Java, when the object ToString, always wondering what is behind a string of numbers, it is 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 {}
Java Native Keywords