挖坑神器

Class<?> clazz = Class.forName(
"java.lang.Integer$IntegerCache");
Field field = clazz.getDeclaredField("cache");
field.setAccessible(true);
Integer[] cache = (Integer[]) field.get(clazz);

// Rewrite the Integer cache
for (int i = 0; i < cache.length; i++) {
cache[i] = new Integer(
new Random().nextInt(cache.length));
}
for (int i = 0; i < 10; i++) {
System.out.println((Integer) i);
}
posted @ 2019-11-15 18:27  hello|world  阅读(178)  评论(0编辑  收藏  举报