当前位置:网站首页>Learn to record and analyze

Learn to record and analyze

2020-11-08 15:22:28 Irving the procedural ape

Learn to record and analyze

Record the difficulties in learning , A little white !

I have not read the source code , Pure Xiaobai , I wrote this article just to improve myself !!! I hope you can point out the mistakes .

Curious, I looked through Integer.valueOf() Method source code

public static Integer valueOf(int i) {  if (i >= IntegerCache.low && i <= IntegerCache.high)   return IntegerCache.cache[i + (-IntegerCache.low)];  return new Integer(i); }

First of all, the parameters explain :

static final int low = -128;static final int high;static final Integer[] cache;static Integer[] archivedCache;

high No assignment , So we continue to track down high attribute

 static {  int h = 127;  // If you specify -Djava.lang.Integer.IntegerCache.high=XXX( Enter your own data ) Parameters   // The following statement will be executed , Then dynamic settings h yes 127 Or set the input data   String integerCacheHighPropValue =   // The method is by passing a key, Get the value set manually at startup    VM.getSavedProperty("java.lang.Integer.IntegerCache.high");  if (integerCacheHighPropValue != null) {   try {       h = Math.max(parseInt(integerCacheHighPropValue), 127);   	 //	    // public static int max(int a, int b) {  		//	 return (a >= b) ? a : b; 		//	}       // Maximum array size is Integer.MAX_VALUE    //32 Bit system 2147483647=2^32    h = Math.min(h, Integer.MAX_VALUE - (-low) -1);      } catch( NumberFormatException nfe) {    // If the property cannot be parsed into an int, ignore it.   }  } 	// find high The value of the property is determined by h Local attribute assignment   high = h;  // Load IntegerCache.archivedCache from archive, if possible  VM.initializeFromArchive(IntegerCache.class);   int size = (high - low) + 1;// Can be saved 256 Number .  // As for why 256? I'm not going to talk about , Suggest yourself to search the computer storage data related concepts !  // Use the archived cache if it exists and is large enough.........

版权声明
本文为[Irving the procedural ape]所创,转载请带上原文链接,感谢