nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/StoredScript.java
changeset 26764 c777787a937d
parent 26068 5488f52c2788
child 26768 751b0f427090
equal deleted inserted replaced
26668:1b1ec4291abc 26764:c777787a937d
    25 
    25 
    26 package jdk.nashorn.internal.runtime;
    26 package jdk.nashorn.internal.runtime;
    27 
    27 
    28 import java.io.Serializable;
    28 import java.io.Serializable;
    29 import java.util.Arrays;
    29 import java.util.Arrays;
       
    30 import java.util.LinkedHashMap;
    30 import java.util.Map;
    31 import java.util.Map;
    31 
    32 
    32 /**
    33 /**
    33  * Class representing a persistent compiled script.
    34  * Class representing a persistent compiled script.
    34  */
    35  */
    81     /**
    82     /**
    82      * Returns a map of class names to class bytes.
    83      * Returns a map of class names to class bytes.
    83      * @return map of class bytes
    84      * @return map of class bytes
    84      */
    85      */
    85     public Map<String, byte[]> getClassBytes() {
    86     public Map<String, byte[]> getClassBytes() {
    86         return classBytes;
    87         final Map<String, byte[]> clonedMap = new LinkedHashMap<>();
       
    88         for (final Map.Entry<String, byte[]> entry : classBytes.entrySet()) {
       
    89             clonedMap.put(entry.getKey(), entry.getValue().clone());
       
    90         }
       
    91         return clonedMap;
    87     }
    92     }
    88 
    93 
    89     /**
    94     /**
    90      * Returns the constants array.
    95      * Returns the constants array.
    91      * @return constants array
    96      * @return constants array
    92      */
    97      */
    93     public Object[] getConstants() {
    98     public Object[] getConstants() {
    94         return constants;
    99         return constants.clone();
    95     }
   100     }
    96 
   101 
    97     Map<Integer, FunctionInitializer> getInitializers() {
   102     /**
    98         return initializers;
   103      * Returns the function initializers map.
       
   104      * @return The initializers map.
       
   105      */
       
   106     public Map<Integer, FunctionInitializer> getInitializers() {
       
   107         final Map<Integer, FunctionInitializer> clonedMap = new LinkedHashMap<>();
       
   108         for (final Map.Entry<Integer, FunctionInitializer> entry : initializers.entrySet()) {
       
   109             clonedMap.put(entry.getKey(), new FunctionInitializer(entry.getValue()));
       
   110         }
       
   111         return clonedMap;
    99     }
   112     }
   100 
   113 
   101     @Override
   114     @Override
   102     public int hashCode() {
   115     public int hashCode() {
   103         int hash = mainClassName.hashCode();
   116         int hash = mainClassName.hashCode();