8147591: Revisit Collection.toArray(new T[size]) calls in nashorn and dynalink code
authormhaupt
Thu, 28 Jan 2016 11:20:44 +0100
changeset 35407 204abe4d8cbc
parent 35406 b49d0656c449
child 35408 a077e87423b1
8147591: Revisit Collection.toArray(new T[size]) calls in nashorn and dynalink code Reviewed-by: hannesw, mhaupt, sundar Contributed-by: srinivas.dama@oracle.com
nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/TypeConverterFactory.java
nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/AccessibleMembersLookup.java
nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/linker/support/CompositeGuardingDynamicLinker.java
nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/linker/support/CompositeTypeBasedGuardingDynamicLinker.java
nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/support/ChainedCallSite.java
nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/NashornException.java
nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java
nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FunctionSignature.java
nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/Block.java
nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/LiteralNode.java
nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/debug/ASTWriter.java
nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/debug/ObjectSizeCalculator.java
nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeArray.java
nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeDebug.java
nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFunction.java
nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeObject.java
nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyMap.java
nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptFunction.java
nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java
nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Timing.java
nashorn/test/src/jdk/nashorn/internal/test/framework/ParallelTestRunner.java
nashorn/test/src/jdk/nashorn/internal/test/framework/ScriptRunnable.java
nashorn/test/src/jdk/nashorn/internal/test/framework/TestFinder.java
nashorn/tools/fxshell/jdk/nashorn/tools/FXShell.java
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/TypeConverterFactory.java	Tue Jan 26 13:46:00 2016 +0100
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/TypeConverterFactory.java	Thu Jan 28 11:20:44 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -209,8 +209,8 @@
                 c.add((ConversionComparator)factory);
             }
         }
-        this.factories = l.toArray(new GuardingTypeConverterFactory[l.size()]);
-        this.comparators = c.toArray(new ConversionComparator[c.size()]);
+        this.factories = l.toArray(new GuardingTypeConverterFactory[0]);
+        this.comparators = c.toArray(new ConversionComparator[0]);
         this.autoConversionStrategy = autoConversionStrategy;
     }
 
@@ -285,7 +285,7 @@
             return handle;
         }
         final MethodHandle newHandle =
-                MethodHandles.filterArguments(handle, pos, converters.toArray(new MethodHandle[converters.size()]));
+                MethodHandles.filterArguments(handle, pos, converters.toArray(new MethodHandle[0]));
         converters.clear();
         return newHandle;
     }
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/AccessibleMembersLookup.java	Tue Jan 26 13:46:00 2016 +0100
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/AccessibleMembersLookup.java	Thu Jan 28 11:20:44 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -133,7 +133,7 @@
     }
 
     Class<?>[] getInnerClasses() {
-        return innerClasses.toArray(new Class<?>[innerClasses.size()]);
+        return innerClasses.toArray(new Class<?>[0]);
     }
 
     /**
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/linker/support/CompositeGuardingDynamicLinker.java	Tue Jan 26 13:46:00 2016 +0100
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/linker/support/CompositeGuardingDynamicLinker.java	Thu Jan 28 11:20:44 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -112,7 +112,7 @@
         for(final GuardingDynamicLinker linker: linkers) {
             l.add(Objects.requireNonNull(linker));
         }
-        this.linkers = l.toArray(new GuardingDynamicLinker[l.size()]);
+        this.linkers = l.toArray(new GuardingDynamicLinker[0]);
     }
 
     /**
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/linker/support/CompositeTypeBasedGuardingDynamicLinker.java	Tue Jan 26 13:46:00 2016 +0100
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/linker/support/CompositeTypeBasedGuardingDynamicLinker.java	Thu Jan 28 11:20:44 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -157,7 +157,7 @@
         for(final TypeBasedGuardingDynamicLinker linker: linkers) {
             l.add(Objects.requireNonNull(linker));
         }
-        this.classToLinker = new ClassToLinker(l.toArray(new TypeBasedGuardingDynamicLinker[l.size()]));
+        this.classToLinker = new ClassToLinker(l.toArray(new TypeBasedGuardingDynamicLinker[0]));
     }
 
     /**
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/support/ChainedCallSite.java	Tue Jan 26 13:46:00 2016 +0100
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/support/ChainedCallSite.java	Thu Jan 28 11:20:44 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -209,7 +209,7 @@
                 invocations = newInvocations.getFirst();
                 break;
             default:
-                invocations = newInvocations.toArray(new GuardedInvocation[newInvocations.size()]);
+                invocations = newInvocations.toArray(new GuardedInvocation[0]);
         }
         setTarget(target);
         return target;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/NashornException.java	Tue Jan 26 13:46:00 2016 +0100
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/NashornException.java	Thu Jan 28 11:20:44 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -182,7 +182,7 @@
                         st.getFileName(), st.getLineNumber()));
             }
         }
-        return filtered.toArray(new StackTraceElement[filtered.size()]);
+        return filtered.toArray(new StackTraceElement[0]);
     }
 
     /**
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java	Tue Jan 26 13:46:00 2016 +0100
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java	Thu Jan 28 11:20:44 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -2996,8 +2996,8 @@
 
             // Copy values and labels to arrays.
             final int       size   = tree.size();
-            final Integer[] values = tree.keySet().toArray(new Integer[size]);
-            final Label[]   labels = tree.values().toArray(new Label[size]);
+            final Integer[] values = tree.keySet().toArray(new Integer[0]);
+            final Label[]   labels = tree.values().toArray(new Label[0]);
 
             // Discern low, high and range.
             final int lo    = values[0];
@@ -5203,7 +5203,7 @@
                 }
             }
         }
-        return names.toArray(new String[names.size()]);
+        return names.toArray(new String[0]);
     }
 
     private static String commonPrefix(final String s1, final String s2) {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FunctionSignature.java	Tue Jan 26 13:46:00 2016 +0100
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FunctionSignature.java	Thu Jan 28 11:20:44 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -141,7 +141,7 @@
             paramTypeList.add(paramType.getTypeClass());
         }
 
-        this.methodType = MH.type(returnType.getTypeClass(), paramTypeList.toArray(new Class<?>[paramTypes.length]));
+        this.methodType = MH.type(returnType.getTypeClass(), paramTypeList.toArray(new Class<?>[0]));
     }
 
     /**
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/Block.java	Tue Jan 26 13:46:00 2016 +0100
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/Block.java	Thu Jan 28 11:20:44 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -136,7 +136,7 @@
      * @param statements All statements in the block
      */
     public Block(final long token, final int finish, final int flags, final List<Statement> statements) {
-        this(token, finish, flags, statements.toArray(new Statement[statements.size()]));
+        this(token, finish, flags, statements.toArray(new Statement[0]));
     }
 
     private Block(final Block block, final int finish, final List<Statement> statements, final int flags, final Map<String, Symbol> symbols, final LocalVariableConversion conversion) {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/LiteralNode.java	Tue Jan 26 13:46:00 2016 +0100
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/LiteralNode.java	Thu Jan 28 11:20:44 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -250,7 +250,7 @@
     }
 
     private static Expression[] valueToArray(final List<Expression> value) {
-        return value.toArray(new Expression[value.size()]);
+        return value.toArray(new Expression[0]);
     }
 
     /**
@@ -941,7 +941,7 @@
         }
 
         private ArrayLiteralNode setValue(final LexicalContext lc, final List<Expression> value) {
-            return setValue(lc, value.toArray(new Expression[value.size()]));
+            return setValue(lc, value.toArray(new Expression[0]));
         }
 
         @Override
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/debug/ASTWriter.java	Tue Jan 26 13:46:00 2016 +0100
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/debug/ASTWriter.java	Thu Jan 28 11:20:44 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -98,7 +98,7 @@
     public Node[] toArray() {
         final List<Node> preorder = new ArrayList<>();
         printAST(new StringBuilder(), preorder, null, "root", root, 0);
-        return preorder.toArray(new Node[preorder.size()]);
+        return preorder.toArray(new Node[0]);
     }
 
     @SuppressWarnings("unchecked")
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/debug/ObjectSizeCalculator.java	Tue Jan 26 13:46:00 2016 +0100
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/debug/ObjectSizeCalculator.java	Thu Jan 28 11:20:44 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -328,7 +328,7 @@
             this.fieldsSize = newFieldsSize;
             this.objectSize = roundTo(objectHeaderSize + newFieldsSize, objectPadding);
             this.referenceFields = newReferenceFields.toArray(
-                    new Field[newReferenceFields.size()]);
+                    new Field[0]);
         }
 
         void visit(final Object obj, final ObjectSizeCalculator calc) {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeArray.java	Tue Jan 26 13:46:00 2016 +0100
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeArray.java	Thu Jan 28 11:20:44 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -1264,7 +1264,7 @@
             // behaviour of sort is implementation-defined.
         }
 
-        return list.toArray(new Object[array.length]);
+        return list.toArray(new Object[0]);
     }
 
     /**
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeDebug.java	Tue Jan 26 13:46:00 2016 +0100
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeDebug.java	Thu Jan 28 11:20:44 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -379,7 +379,7 @@
     @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
     public static Object getRuntimeEvents(final Object self) {
         final LinkedList<RuntimeEvent<?>> q = getEventQueue(self);
-        return q.toArray(new RuntimeEvent<?>[q.size()]);
+        return q.toArray(new RuntimeEvent<?>[0]);
     }
 
     /**
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFunction.java	Tue Jan 26 13:46:00 2016 +0100
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFunction.java	Thu Jan 28 11:20:44 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -130,7 +130,7 @@
             return (Object[])array;
         } else if (array instanceof List) {
             final List<?> list = (List<?>)array;
-            return list.toArray(new Object[list.size()]);
+            return list.toArray(new Object[0]);
         } else if (array == null || array == UNDEFINED) {
             return ScriptRuntime.EMPTY_ARRAY;
         } else if (array instanceof JSObject) {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeObject.java	Tue Jan 26 13:46:00 2016 +0100
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeObject.java	Thu Jan 28 11:20:44 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -702,7 +702,7 @@
             }
 
             if (!propList.isEmpty()) {
-                targetObj.addBoundProperties(sourceObj, propList.toArray(new Property[propList.size()]));
+                targetObj.addBoundProperties(sourceObj, propList.toArray(new Property[0]));
             }
         } else if (source instanceof ScriptObjectMirror) {
             // get enumerable, immediate properties of mirror
@@ -819,7 +819,7 @@
             }
         }
 
-        targetObj.addBoundProperties(source, properties.toArray(new AccessorProperty[properties.size()]));
+        targetObj.addBoundProperties(source, properties.toArray(new AccessorProperty[0]));
     }
 
     private static MethodHandle getBoundBeanMethodGetter(final Object source, final MethodHandle methodGetter) {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyMap.java	Tue Jan 26 13:46:00 2016 +0100
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyMap.java	Thu Jan 28 11:20:44 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -377,7 +377,7 @@
                 if (Context.DEBUG) {
                     protoInvalidations.add(size);
                 }
-                SwitchPoint.invalidateAll(protoSwitches.values().toArray(new SwitchPoint[size]));
+                SwitchPoint.invalidateAll(protoSwitches.values().toArray(new SwitchPoint[0]));
                 protoSwitches.clear();
             }
         }
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptFunction.java	Tue Jan 26 13:46:00 2016 +0100
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptFunction.java	Thu Jan 28 11:20:44 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -993,7 +993,7 @@
         if (bestInvoker.getSwitchPoints() != null) {
             sps.addAll(Arrays.asList(bestInvoker.getSwitchPoints()));
         }
-        final SwitchPoint[] spsArray = sps.isEmpty() ? null : sps.toArray(new SwitchPoint[sps.size()]);
+        final SwitchPoint[] spsArray = sps.isEmpty() ? null : sps.toArray(new SwitchPoint[0]);
 
         return new GuardedInvocation(
                 boundHandle,
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java	Tue Jan 26 13:46:00 2016 +0100
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java	Thu Jan 28 11:20:44 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -1334,7 +1334,7 @@
         for (ScriptObject self = this; self != null; self = self.getProto()) {
             keys.addAll(Arrays.asList(self.getOwnKeys(String.class, true, nonEnumerable)));
         }
-        return keys.toArray(new String[keys.size()]);
+        return keys.toArray(new String[0]);
     }
 
     /**
@@ -2146,7 +2146,7 @@
         }
 
         switchPoints.add(getMap().getSwitchPoint(name));
-        return switchPoints.toArray(new SwitchPoint[switchPoints.size()]);
+        return switchPoints.toArray(new SwitchPoint[0]);
     }
 
     private void checkSharedProtoMap() {
@@ -2505,7 +2505,7 @@
             for (ScriptObject self = object; self != null; self = self.getProto()) {
                 keys.addAll(Arrays.asList(self.getOwnKeys(String.class, false, nonEnumerable)));
             }
-            this.values = keys.toArray(new String[keys.size()]);
+            this.values = keys.toArray(new String[0]);
         }
     }
 
@@ -2523,7 +2523,7 @@
                     valueList.add(self.get(key));
                 }
             }
-            this.values = valueList.toArray(new Object[valueList.size()]);
+            this.values = valueList.toArray(new Object[0]);
         }
     }
 
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Timing.java	Tue Jan 26 13:46:00 2016 +0100
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Timing.java	Thu Jan 28 11:20:44 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -176,7 +176,7 @@
             } catch (final IOException e) {
                 throw new RuntimeException(e);
             }
-            return strs.toArray(new String[strs.size()]);
+            return strs.toArray(new String[0]);
         }
 
         @Override
--- a/nashorn/test/src/jdk/nashorn/internal/test/framework/ParallelTestRunner.java	Tue Jan 26 13:46:00 2016 +0100
+++ b/nashorn/test/src/jdk/nashorn/internal/test/framework/ParallelTestRunner.java	Thu Jan 28 11:20:44 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -166,7 +166,7 @@
             final List<String> args = getCompilerArgs();
             int errors;
             try {
-                errors = evaluateScript(out, err, args.toArray(new String[args.size()]));
+                errors = evaluateScript(out, err, args.toArray(new String[0]));
             } catch (final AssertionError e) {
                 final PrintWriter writer = new PrintWriter(err);
                 e.printStackTrace(writer);
@@ -199,7 +199,7 @@
             final ByteArrayOutputStream err = new ByteArrayOutputStream();
 
             try {
-                final int errors = evaluateScript(out, err, args.toArray(new String[args.size()]));
+                final int errors = evaluateScript(out, err, args.toArray(new String[0]));
 
                 if (errors != 0 || err.size() > 0) {
                     if (expectRunFailure) {
--- a/nashorn/test/src/jdk/nashorn/internal/test/framework/ScriptRunnable.java	Tue Jan 26 13:46:00 2016 +0100
+++ b/nashorn/test/src/jdk/nashorn/internal/test/framework/ScriptRunnable.java	Thu Jan 28 11:20:44 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -108,7 +108,7 @@
         int errors;
 
         try {
-            errors = evaluateScript(out, err, args.toArray(new String[args.size()]));
+            errors = evaluateScript(out, err, args.toArray(new String[0]));
         } catch (final AssertionError e) {
             final PrintWriter writer = new PrintWriter(err);
             e.printStackTrace(writer);
@@ -144,7 +144,7 @@
         final File errorFileHandle  = new File(errorFileName);
 
         try (OutputStream outputFile = new FileOutputStream(outputFileName); OutputStream errorFile = new FileOutputStream(errorFileName)) {
-            final int errors = evaluateScript(outputFile, errorFile, args.toArray(new String[args.size()]));
+            final int errors = evaluateScript(outputFile, errorFile, args.toArray(new String[0]));
 
             if (errors != 0 || errorFileHandle.length() > 0) {
                 if (expectRunFailure) {
--- a/nashorn/test/src/jdk/nashorn/internal/test/framework/TestFinder.java	Tue Jan 26 13:46:00 2016 +0100
+++ b/nashorn/test/src/jdk/nashorn/internal/test/framework/TestFinder.java	Thu Jan 28 11:20:44 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -392,7 +392,7 @@
         if (hasOptimisticOverride()) {
             final List<String> newList = new ArrayList<>(Arrays.asList(args));
             newList.add("--optimistic-types=" + OPTIMISTIC_OVERRIDE);
-            return newList.toArray(new String[newList.size()]);
+            return newList.toArray(new String[0]);
         }
         return args;
     }
--- a/nashorn/tools/fxshell/jdk/nashorn/tools/FXShell.java	Tue Jan 26 13:46:00 2016 +0100
+++ b/nashorn/tools/fxshell/jdk/nashorn/tools/FXShell.java	Thu Jan 28 11:20:44 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -134,7 +134,7 @@
         }
 
         // Create a Nashorn script engine with specified arguments.
-        engine = factory.getScriptEngine(args.toArray(new String[args.size()]));
+        engine = factory.getScriptEngine(args.toArray(new String[0]));
 
         // Load initial scripts.
         for (String path : paths) {