src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyMap.java

Print this page




 154         out.writeObject(properties.getProperties());
 155     }
 156 
 157     private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
 158         in.defaultReadObject();
 159 
 160         final Property[] props = (Property[]) in.readObject();
 161         this.properties = EMPTY_HASHMAP.immutableAdd(props);
 162 
 163         assert className != null;
 164         final Class<?> structure = Context.forStructureClass(className);
 165         for (final Property prop : props) {
 166             prop.initMethodHandles(structure);
 167         }
 168     }
 169 
 170     /**
 171      * Public property map allocator.
 172      *
 173      * <p>It is the caller's responsibility to make sure that {@code properties} does not contain
 174      * properties with keys that are valid array indices.</p>
 175      *
 176      * @param properties   Collection of initial properties.
 177      * @param className    class name
 178      * @param fieldCount   Number of fields in use.
 179      * @param fieldMaximum Number of fields available.
 180      * @param spillLength  Number of used spill slots.
 181      * @return New {@link PropertyMap}.
 182      */
 183     public static PropertyMap newMap(final Collection<Property> properties, final String className, final int fieldCount, final int fieldMaximum,  final int spillLength) {
 184         final PropertyHashMap newProperties = EMPTY_HASHMAP.immutableAdd(properties);
 185         return new PropertyMap(newProperties, className, fieldCount, fieldMaximum, spillLength, false);
 186     }
 187 
 188     /**
 189      * Public property map allocator. Used by nasgen generated code.
 190      *
 191      * <p>It is the caller's responsibility to make sure that {@code properties} does not contain
 192      * properties with keys that are valid array indices.</p>
 193      *
 194      * @param properties Collection of initial properties.
 195      * @return New {@link PropertyMap}.
 196      */
 197     public static PropertyMap newMap(final Collection<Property> properties) {
 198         return properties == null || properties.isEmpty()? newMap() : newMap(properties, JO.class.getName(), 0, 0, 0);
 199     }
 200 
 201     /**
 202      * Return a sharable empty map.
 203      *
 204      * @return New empty {@link PropertyMap}.
 205      */
 206     public static PropertyMap newMap() {
 207         return new PropertyMap(EMPTY_HASHMAP, JO.class.getName(), 0, 0, 0, false);
 208     }
 209 
 210     /**
 211      * Return number of properties in the map.
 212      *




 154         out.writeObject(properties.getProperties());
 155     }
 156 
 157     private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
 158         in.defaultReadObject();
 159 
 160         final Property[] props = (Property[]) in.readObject();
 161         this.properties = EMPTY_HASHMAP.immutableAdd(props);
 162 
 163         assert className != null;
 164         final Class<?> structure = Context.forStructureClass(className);
 165         for (final Property prop : props) {
 166             prop.initMethodHandles(structure);
 167         }
 168     }
 169 
 170     /**
 171      * Public property map allocator.
 172      *
 173      * <p>It is the caller's responsibility to make sure that {@code properties} does not contain
 174      * properties with duplicate keys or keys that represent valid array indices.</p>
 175      *
 176      * @param properties   Collection of initial properties.
 177      * @param className    class name
 178      * @param fieldCount   Number of fields in use.
 179      * @param fieldMaximum Number of fields available.
 180      * @param spillLength  Number of used spill slots.
 181      * @return New {@link PropertyMap}.
 182      */
 183     public static PropertyMap newMap(final Collection<Property> properties, final String className, final int fieldCount, final int fieldMaximum,  final int spillLength) {
 184         final PropertyHashMap newProperties = PropertyHashMap.create(properties);
 185         return new PropertyMap(newProperties, className, fieldCount, fieldMaximum, spillLength, false);
 186     }
 187 
 188     /**
 189      * Public property map allocator. Used by nasgen generated code.
 190      *
 191      * <p>It is the caller's responsibility to make sure that {@code properties} does not contain
 192      * properties with duplicate keys or keys that represent valid array indices.</p>
 193      *
 194      * @param properties Collection of initial properties.
 195      * @return New {@link PropertyMap}.
 196      */
 197     public static PropertyMap newMap(final Collection<Property> properties) {
 198         return properties == null || properties.isEmpty()? newMap() : newMap(properties, JO.class.getName(), 0, 0, 0);
 199     }
 200 
 201     /**
 202      * Return a sharable empty map.
 203      *
 204      * @return New empty {@link PropertyMap}.
 205      */
 206     public static PropertyMap newMap() {
 207         return new PropertyMap(EMPTY_HASHMAP, JO.class.getName(), 0, 0, 0, false);
 208     }
 209 
 210     /**
 211      * Return number of properties in the map.
 212      *