JDK目录下的SRC.ZIP文件,也就是常说的JAVA原源码的压缩包。我打开看里面的某个类的方法时,怎么都是空实现,就是一些注释啊?求解!
拿下来点看看:
public final class StrictMath { /**
* Don't let anyone instantiate this class.
*/
private StrictMath() {} /**
* The <code>double</code> value that is closer than any other to
* <i>e</i>, the base of the natural logarithms.
*/
public static final double E = 2.7182818284590452354; /**
* The <code>double</code> value that is closer than any other to
* <i>pi</i>, the ratio of the circumference of a circle to its
* diameter.
*/
public static final double PI = 3.14159265358979323846; /**
* Returns the trigonometric sine of an angle. Special cases:
* <ul><li>If the argument is NaN or an infinity, then the
* result is NaN.
* <li>If the argument is zero, then the result is a zero with the
* same sign as the argument.</ul>
*
* @param a an angle, in radians.
* @return the sine of the argument.
*/
public static native double sin(double a);
/**
* Returns the trigonometric cosine of an angle. Special cases:
* <ul><li>If the argument is NaN or an infinity, then the
* result is NaN.</ul>
*
* @param a an angle, in radians.
* @return the cosine of the argument.
*/
public static native double cos(double a);
拿下来点看看:
public final class StrictMath { /**
* Don't let anyone instantiate this class.
*/
private StrictMath() {} /**
* The <code>double</code> value that is closer than any other to
* <i>e</i>, the base of the natural logarithms.
*/
public static final double E = 2.7182818284590452354; /**
* The <code>double</code> value that is closer than any other to
* <i>pi</i>, the ratio of the circumference of a circle to its
* diameter.
*/
public static final double PI = 3.14159265358979323846; /**
* Returns the trigonometric sine of an angle. Special cases:
* <ul><li>If the argument is NaN or an infinity, then the
* result is NaN.
* <li>If the argument is zero, then the result is a zero with the
* same sign as the argument.</ul>
*
* @param a an angle, in radians.
* @return the sine of the argument.
*/
public static native double sin(double a);
/**
* Returns the trigonometric cosine of an angle. Special cases:
* <ul><li>If the argument is NaN or an infinity, then the
* result is NaN.</ul>
*
* @param a an angle, in radians.
* @return the cosine of the argument.
*/
public static native double cos(double a);
解决方案 »
- java udp接受原理是怎么样的,如果客户端很多向服务器发送数据包,服务器会不会丢失数据?
- 关于MouseListener类无法覆盖
- 如何让使用SWT/JFace写的客户端程序在任务栏显示?
- 数组与Object类的问题。
- 请教:用sdk1.5+eclipce 3.2+myeclipce 5.0+tomcat 5.5或近似工具进行环境配置
- 请问对应目录的File对象,怎样获得按字母顺序排序后的,子目录(子文件)File对象列表?
- 关于package的小问题?
- 推荐一本权威的,而且深入、全面的JAVA书。
- 异常的继承和搜索??高手请进!!
- 请教几个关于JATable的问题?
- Java 参数传输问题(非标题党)
- java 关于Calendar的roll()方法
用native关键字修饰的方法,是通过Java本地调用而实现滴。
这些方法的具体实现被封装在动态链接库文件中了。
底层应该由虚拟机和操作系统紧密结合在一起了。
Java 底层类库源代码、JVM 源代码,以及本地方法的源代码。需要这些源代码的话,
可以到 OpenJDK 上去下载 JDK 所有的源代码。Java 类库中 StrictMath 类的实现使用的是开源的 fdlibm 代码。http://download.java.net/openjdk/jdk6/OpenJDK 源代码的压缩包有 46.9MB,解压后是 254MB,大概有 28000 多个文件。StrictMath.c 源代码位于 %HOME%/jdk/src/share/native/java/lang/StrictMath.c 中,所用到的
fdlibm 源代码在 %HOME%/jdk/src/share/native/java/lang/fdlibm/src 中。