Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 77f2cb1

Browse files
committed
快照20
2 parents 31543e7 + 7d48471 commit 77f2cb1

54 files changed

Lines changed: 29671 additions & 19126 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/java/lang/Enum.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,11 @@ public final Class<E> getDeclaringClass() {
176176
* same enum type. The natural order implemented by this
177177
* method is the order in which the constants are declared.
178178
*/
179-
// 按自然顺序标胶枚举实例的值
179+
// 比较枚举实例的值;声明靠前的枚举,其"值"较小
180180
public final int compareTo(E o) {
181181
Enum<?> other = (Enum<?>) o;
182182
Enum<E> self = this;
183+
183184
if(self.getClass() != other.getClass() && // optimization
184185
self.getDeclaringClass() != other.getDeclaringClass()) {
185186
throw new ClassCastException();
@@ -224,10 +225,14 @@ public final int compareTo(E o) {
224225
*/
225226
public static <T extends Enum<T>> T valueOf(Class<T> enumType, String name) {
226227
T result = enumType.enumConstantDirectory().get(name);
227-
if(result != null)
228+
229+
if(result != null) {
228230
return result;
229-
if(name == null)
231+
}
232+
233+
if(name == null) {
230234
throw new NullPointerException("Name is null");
235+
}
231236
throw new IllegalArgumentException("No enum constant " + enumType.getCanonicalName() + "." + name);
232237
}
233238

src/java/lang/Math.java

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,15 @@ public static long multiplyHigh(long x, long y) {
380380
}
381381
}
382382

383+
/*
384+
* 向下取整除法:
385+
*
386+
* 11/ 8 = 1.375 ==> 1
387+
* -11/ 8 = -1.375 ==> -2
388+
* 11/-8 = -1.375 ==> -2
389+
* -11/-8 = 1.375 ==> 1
390+
*/
391+
383392
/**
384393
* Returns the largest (closest to positive infinity)
385394
* {@code int} value that is less than or equal to the algebraic quotient.
@@ -416,7 +425,7 @@ public static long multiplyHigh(long x, long y) {
416425
* @see #floor(double)
417426
* @since 1.8
418427
*/
419-
// 除法,如果两数符号不同,则向下取整
428+
// 向下取整除法
420429
public static int floorDiv(int x, int y) {
421430
int r = x / y;
422431
// if the signs are different and modulo not zero, round down
@@ -453,7 +462,7 @@ public static int floorDiv(int x, int y) {
453462
* @see #floor(double)
454463
* @since 9
455464
*/
456-
// 除法,如果两数符号不同,则向下取整
465+
// 向下取整除法
457466
public static long floorDiv(long x, int y) {
458467
return floorDiv(x, (long) y);
459468
}
@@ -485,7 +494,7 @@ public static long floorDiv(long x, int y) {
485494
* @see #floor(double)
486495
* @since 1.8
487496
*/
488-
// 除法,如果两数符号不同,则向下取整
497+
// 向下取整除法
489498
public static long floorDiv(long x, long y) {
490499
long r = x / y;
491500
// if the signs are different and modulo not zero, round down
@@ -495,6 +504,29 @@ public static long floorDiv(long x, long y) {
495504
return r;
496505
}
497506

507+
/*
508+
* 取模运算:
509+
*
510+
* 11 MOD 8 => 从0开始,顺时针前进11步,得到3
511+
* -11 MOD 8 => 从0开始,逆时针前进11步,得到5
512+
*
513+
* 0
514+
* 7 1
515+
* 6 2
516+
* 5 3
517+
* 4
518+
*
519+
*
520+
* 11 MOD -8 => 从0开始,顺时针前进11步,得到-5
521+
* -11 MOD -5 => 从0开始,逆时针前进11步,得到-3
522+
*
523+
* 0
524+
* -1 -7
525+
* -2 -6
526+
* -3 -5
527+
* -4
528+
*/
529+
498530
/**
499531
* Returns the floor modulus of the {@code int} arguments.
500532
* <p>

src/java/lang/System.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@
8888
*
8989
* @since 1.0
9090
*/
91-
// System工具类
91+
// 系统工具类
9292
public final class System {
9393

94-
// @see #initPhase2()
94+
/** @see #initPhase2() */
9595
static ModuleLayer bootLayer;
9696

97-
// The security manager for the system. */
97+
/** The security manager for the system. */
9898
// 当前使用的安全管理器,默认为null
9999
private static volatile SecurityManager security;
100100

@@ -264,10 +264,8 @@ public static void setErr(PrintStream err) {
264264

265265
// 为字段System.in关联(初始化)标准输入流
266266
private static native void setIn0(InputStream in);
267-
268267
// 为字段System.out关联(初始化)标准输出流
269268
private static native void setOut0(PrintStream out);
270-
271269
// 为字段System.err关联(初始化)标准错误流
272270
private static native void setErr0(PrintStream err);
273271

@@ -863,7 +861,11 @@ public static String getenv(String name) {
863861
*
864862
* @see java.util.Date
865863
*/
866-
// 返回以毫秒为单位的当前时间,其表现为当前时间与GMT时间(格林威治时间)1970年1月1号0时0分0秒所差的毫秒数(具体粒度由底层操作系统决定)
864+
/*
865+
* 返回当前时间点与新纪元时间点之间的毫秒差值(具体粒度由底层操作系统决定)
866+
*
867+
* 新纪元时间点:UTC/GMT时间1970年1月1号0时0分0秒
868+
*/
867869
@HotSpotIntrinsicCandidate
868870
public static native long currentTimeMillis();
869871

0 commit comments

Comments
 (0)