File tree Expand file tree Collapse file tree 3 files changed +48
-0
lines changed
src/main/java/com/crossoverjie/classloader Expand file tree Collapse file tree 3 files changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .crossoverjie .classloader ;
2
+
3
+ /**
4
+ * Function:
5
+ *
6
+ * @author crossoverJie
7
+ * Date: 05/03/2018 23:11
8
+ * @since JDK 1.8
9
+ */
10
+ public class ChildClass extends SuperClass {
11
+ static {
12
+ System .out .println ("ChildClass init" );
13
+ }
14
+ }
Original file line number Diff line number Diff line change
1
+ package com .crossoverjie .classloader ;
2
+
3
+ /**
4
+ * Function:
5
+ *
6
+ * @author crossoverJie
7
+ * Date: 05/03/2018 23:12
8
+ * @since JDK 1.8
9
+ */
10
+ public class Main {
11
+ public static void main (String [] args ) {
12
+ System .out .println (ChildClass .A );
13
+ }
14
+ }
Original file line number Diff line number Diff line change
1
+ package com .crossoverjie .classloader ;
2
+
3
+ /**
4
+ * Function:
5
+ *
6
+ * @author crossoverJie
7
+ * Date: 05/03/2018 23:11
8
+ * @since JDK 1.8
9
+ */
10
+ public class SuperClass {
11
+
12
+ /**
13
+ * 如果使用了 final 修饰的常量,再使用时父类也不会初始化
14
+ */
15
+ public static int A = 1 ;
16
+
17
+ static {
18
+ System .out .println ("SuperClass init" );
19
+ }
20
+ }
You can’t perform that action at this time.
0 commit comments