JDK 源代码中的搞笑之处
|
Funny Things in JDK Source
|
虽然完整版的 JDK 源代码现已开放了,但安装在 Java\jdk[版本号] 目录下的公共 src.zip 仍然是我最经常参考的资源。每次我遇到一个 API 问题,都会刊这个公共源代码。解决问题之余,我还找到很多有趣的东西,有时还搞笑。这里距三个例子。 |
Though the
full version of JDK source is available now, but the public src.zip
installed under Java\jdk[version_number] directory is still my most
frequent refered resource. Every time I encounter an API problem, this
public source is read. And besides solving those problems, I've also
found many interesting things which are sometimes also funny. Here are
three exaples. |
大概从 JDK 5.0 开始,类 java.lang.Object
引入了一个叫 wait(long timeout, int nanos)
的方法。等等,nanos,纳秒?众所周知,即使在强大的 Windows 多媒体 API 里面,计时器的精度也只有一毫秒,也就是一兆纳秒。尽管 Java 非常棒,但不能处理纳秒。而源代码证明了这一点,纳秒被舍入到最接近的毫秒,0 或 1……精彩…… |
Maybe since JDK 5.0, a method called wait(long timeout, int nanos)
is introduced into Class java.lang.Object
.Object.
Wait a minute, nanos, is it nanoseconds? It's no secret thst even
in powerful Windows multimedia API, the precision of timer is only one
millisecond, that is a million nanosecond. Though Java is pretty great,
it can not deal with nanoseconds. And the source proves it, that
nanoseconds are rounded to the nearest millisecond, 0 or 1... Amazing... |
今天我想得到一个 JDialog
的所有者,但却没有 getOwner()
方法。最后我才明白 JDialog
的所有者就是它的父组件,用 getParent()
就可以了。那现在所有者等同于父级了? |
Today I wanted to get a JDialog
's owner, but there's no method called getOwner()
. Finally I was awear that the owner of a JDialog
is exactly its parent component, and just using getParent()
is okey. So owner is synonymous with parent now? |
最后,我想提下 JSpinner
的实现有错。一些安装在 JSpinner
上的侦听器丝毫不起作用。我在 JSpinner.java
里找到这段注释:“还是不对,我们没其他办法了,SpinnerModel
和 JFormattedTextField
现已不同步了。”JDK 的开发者的诚实值得感谢。我的解决方法是直接操控复合式组件 JSpinner
中的 JFormattedTextField
。 |
相关推荐
java的jdk源代码,适合想要深入学习java的朋友
JDK1.8源代码
Java开发怎么能不看源代码,API文档、反编译都不如直接看源代码!!!
这是JDK1.3的源代码,供学习参考。 它是早期发布的Jdk的源代码。
JDK1.6源代码,这是第一部分,有兴趣的可以看一下
jdk8源代码src.zip文件,下载下来用eclipse关联即可查看源代码,给那些开始未安装源代码之后又想查看源代码的人提供下载途径,
这是JDK12的源代码,供学习参考。 它是Jdk中的源代码。
Java jdk里面的源文件,java源代码,jdk里面的源代码
这是JDK1.4的源代码,供学习参考。 它是早期发布的Jdk的源代码。
这是JDK1.6的源代码,供学习参考。 它是早期发布的Jdk的源代码。
jdk-1.6.0的源代码,由于级别不够分为三部分上传这里只需要极少的分数就可以下载.......
jdk1.4.2源代码............
JDK源码,JDK各种类、方法源代码,JDK自带这里专门拿出来
这是JDK1.1的源代码,供学习参考。 它是最早发布的Java的代码。
jdk源代码下载 喜欢研究的下 jdk源代码下载 喜欢研究的下 jdk源代码下载 喜欢研究的下
java JDK 实例开发宝典 源代码
这是JDK1.2的源代码,供学习参考。 它是早期发布的Java的代码。
java jdk 完整版源码压缩包,用的时候直接import就好了
JAVA开发必备,java-jdk源代码免费分享,谁用谁知道,JAVA开发必备,java-jdk源代码免费分享,谁用谁知道,JAVA开发必备,java-jdk源代码免费分享,谁用谁知道
jdk8u源码,挂tz下载,分享给大家,官网下载实在是太慢了。包含linux、windows、等多个平台的源码,原地址http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/4db0e91b95c8/src/windows/,欢迎下载