src/java.base/share/classes/java/io/ObjectInputStream.java
Print this page
rev 13936 : 8151957: ObjectInputStream.java -incorrect HashMap initial size allocation, and useless variable set
Summary: Initialize primClasses primitive type name-to-class mapping using a new Map.of() conveience method.
Reviewed-by: XXX
*** 1,7 ****
/*
! * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 34,44 ****
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.Arrays;
! import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import static java.io.ObjectStreamClass.processQueue;
import jdk.internal.misc.Unsafe;
import sun.reflect.misc.ReflectUtil;
--- 34,44 ----
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.Arrays;
! import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import static java.io.ObjectStreamClass.processQueue;
import jdk.internal.misc.Unsafe;
import sun.reflect.misc.ReflectUtil;
*** 210,233 ****
private static final int NULL_HANDLE = -1;
/** marker for unshared objects in internal handle table */
private static final Object unsharedMarker = new Object();
! /** table mapping primitive type names to corresponding class objects */
! private static final HashMap<String, Class<?>> primClasses
! = new HashMap<>(8, 1.0F);
! static {
! primClasses.put("boolean", boolean.class);
! primClasses.put("byte", byte.class);
! primClasses.put("char", char.class);
! primClasses.put("short", short.class);
! primClasses.put("int", int.class);
! primClasses.put("long", long.class);
! primClasses.put("float", float.class);
! primClasses.put("double", double.class);
! primClasses.put("void", void.class);
! }
private static class Caches {
/** cache of subclass security audit results */
static final ConcurrentMap<WeakClassKey,Boolean> subclassAudits =
new ConcurrentHashMap<>();
--- 210,233 ----
private static final int NULL_HANDLE = -1;
/** marker for unshared objects in internal handle table */
private static final Object unsharedMarker = new Object();
! /**
! * immutable table mapping primitive type names to corresponding
! * class objects
! */
! private static final Map<String, Class<?>> primClasses =
! Map.of("boolean", boolean.class,
! "byte", byte.class,
! "char", char.class,
! "short", short.class,
! "int", int.class,
! "long", long.class,
! "float", float.class,
! "double", double.class,
! "void", void.class);
private static class Caches {
/** cache of subclass security audit results */
static final ConcurrentMap<WeakClassKey,Boolean> subclassAudits =
new ConcurrentHashMap<>();