Detailed analysis of java root-class objects, javaobject
The Object class is the ancestor of all other classes in Java, and there is no way to talk about Object-class Java object-oriented. As the base class of all other classes, what attributes and actions an Object has are the reflection behind the Java language design.
The Object class is located in the java. lang package. The java. lang package contains the most basic and core classes of Java and will be automatically imported during compilation. The Object class has no defined attributes. There are 13 Methods in total. The specific class definition structure is as follows:
In Java, functions modified with the native keyword indicate that the implementation of this method is not completed in Java, but completed by C/C ++ and compiled. dll, called by Java. The specific implementation of the method is in the dll file. For different platforms, the specific implementation should be different. Native is used to indicate the Operating System. This method must be provided and Java needs to use it. Specifically, the registerNatives () method itself maps methods in C/C ++ to native methods in Java to implement decoupling of method names.
In this case, some may ask why the registerNatives () modifier is private and has not been executed? In fact, in Java source code, the declaration of this method is followed by a static code block:
Java code
Private static native void registerNatives ();
Static {
RegisterNatives ();
}
private static native void registerNatives();static { registerNatives();}
3. protected native Object clone () throws CloneNotSupportedException;
Check that the clode () method is a method declared as native. Therefore, we know that the clone () method is not a Java native method, the specific implementation is completed in C/C ++. The purpose of clone is to create and return a copy of this object. Image point understanding, there is a Cruz, you look good, want a exactly the same. You can call this method to create an identical corouz like magic. The configuration is the same and looks the same. But from now on, if the original cruze had a new decoration, it had nothing to do with the cloned cruze. The object you cloned remains unchanged because you have performed any operations on the cloned Cruz. Java terminology: the clone function returns a reference pointing to a new cloned object, which occupies different heap spaces from the original object.
Java enterprise-level general permission security framework source code SpringMVC mybatis or hibernate + ehcache shiro druid bootstrap HTML5
[Download java framework source code]