Java URL类源码剖析

前几天重新把URL厘清了一下(这里), 趁热打铁,把JDK的URL类源码也仔细读了,务求把URL的方方面面都了然于胸。 注:在此用的JDK8的版本。 首先,URL在java.net这个包,类签名如下: public final class URL implements java.io.Serializable 可见URL是一个final类,即URL类无法被继承,并实现了Serializable接口,即URL对象可被序列化。 再看URL主要的实例属性: private String protocol; private String host; private int port; private String file; private transient String query; private String authority; private transient String path; private String ref;…

JNI in a Nutshell

1.Create Java Source code with native methods native returnType method(arguments) 2.Compile Java source code and obtain the class files 3.Generate C/C++ headers for the native methods; javah gets the info it needs from the class files. 4.Write the C/C++ source code for the…