changeset 1583:1b47169055e2

8146251: Avoid annotation to specify documentation for JS builtin functions Reviewed-by: attila
author sundar
date Wed, 30 Dec 2015 09:27:19 +0530
parents 78b227229d59
children da397aea8ada
files buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ClassGenerator.java buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ConstructorGenerator.java buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MemberInfo.java buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/PrototypeGenerator.java buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInfoCollector.java buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInstrumentor.java buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/StringConstants.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeObject.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/annotations/Constructor.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/annotations/Function.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/FinalScriptFunctionData.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/FunctionDocumentation.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptFunction.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptFunctionData.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/Functions.properties
diffstat 15 files changed, 197 insertions(+), 112 deletions(-) [+]
line wrap: on
line diff
--- a/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ClassGenerator.java	Thu Dec 24 10:33:11 2015 -0800
+++ b/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ClassGenerator.java	Wed Dec 30 09:27:19 2015 +0530
@@ -59,8 +59,8 @@
 import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTION_CREATEBUILTIN_SPECS_DESC;
 import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTION_SETARITY;
 import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTION_SETARITY_DESC;
-import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTION_SETDOCUMENTATION;
-import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTION_SETDOCUMENTATION_DESC;
+import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTION_SETDOCUMENTATIONKEY;
+import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTION_SETDOCUMENTATIONKEY_DESC;
 import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTION_TYPE;
 import static jdk.nashorn.internal.tools.nasgen.StringConstants.SETTER_PREFIX;
 import static jdk.nashorn.internal.tools.nasgen.StringConstants.TYPE_OBJECT;
@@ -274,7 +274,7 @@
         addField(cv, name, OBJECT_DESC);
     }
 
-    static void newFunction(final MethodGenerator mi, final String className, final MemberInfo memInfo, final List<MemberInfo> specs) {
+    static void newFunction(final MethodGenerator mi, final String objName, final String className, final MemberInfo memInfo, final List<MemberInfo> specs) {
         final boolean arityFound = (memInfo.getArity() != MemberInfo.DEFAULT_ARITY);
 
         mi.loadLiteral(memInfo.getName());
@@ -294,12 +294,9 @@
             mi.invokeVirtual(SCRIPTFUNCTION_TYPE, SCRIPTFUNCTION_SETARITY, SCRIPTFUNCTION_SETARITY_DESC);
         }
 
-        String doc = memInfo.getDocumentation();
-        if (doc != null) {
-            mi.dup();
-            mi.loadLiteral(memInfo.getDocumentation());
-            mi.invokeVirtual(SCRIPTFUNCTION_TYPE, SCRIPTFUNCTION_SETDOCUMENTATION, SCRIPTFUNCTION_SETDOCUMENTATION_DESC);
-        }
+        mi.dup();
+        mi.loadLiteral(memInfo.getDocumentationKey(objName));
+        mi.invokeVirtual(SCRIPTFUNCTION_TYPE, SCRIPTFUNCTION_SETDOCUMENTATIONKEY, SCRIPTFUNCTION_SETDOCUMENTATIONKEY_DESC);
     }
 
     static void linkerAddGetterSetter(final MethodGenerator mi, final String className, final MemberInfo memInfo) {
--- a/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ConstructorGenerator.java	Thu Dec 24 10:33:11 2015 -0800
+++ b/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ConstructorGenerator.java	Wed Dec 30 09:27:19 2015 +0530
@@ -42,8 +42,8 @@
 import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTION_INIT_DESC4;
 import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTION_SETARITY;
 import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTION_SETARITY_DESC;
-import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTION_SETDOCUMENTATION;
-import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTION_SETDOCUMENTATION_DESC;
+import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTION_SETDOCUMENTATIONKEY;
+import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTION_SETDOCUMENTATIONKEY_DESC;
 import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTION_SETPROTOTYPE;
 import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTION_SETPROTOTYPE_DESC;
 import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTION_TYPE;
@@ -161,13 +161,11 @@
                 mi.invokeVirtual(SCRIPTFUNCTION_TYPE, SCRIPTFUNCTION_SETARITY,
                         SCRIPTFUNCTION_SETARITY_DESC);
             }
-            final String doc = constructor.getDocumentation();
-            if (doc != null) {
-                mi.loadThis();
-                mi.loadLiteral(doc);
-                mi.invokeVirtual(SCRIPTFUNCTION_TYPE, SCRIPTFUNCTION_SETDOCUMENTATION,
-                        SCRIPTFUNCTION_SETDOCUMENTATION_DESC);
-            }
+
+            mi.loadThis();
+            mi.loadLiteral(scriptClassInfo.getName());
+            mi.invokeVirtual(SCRIPTFUNCTION_TYPE, SCRIPTFUNCTION_SETDOCUMENTATIONKEY,
+                        SCRIPTFUNCTION_SETDOCUMENTATIONKEY_DESC);
         }
         mi.returnVoid();
         mi.computeMaxs();
@@ -208,7 +206,7 @@
                 continue;
             }
             mi.loadThis();
-            newFunction(mi, scriptClassInfo.getJavaName(), memInfo, scriptClassInfo.findSpecializations(memInfo.getJavaName()));
+            newFunction(mi, scriptClassInfo.getName(), scriptClassInfo.getJavaName(), memInfo, scriptClassInfo.findSpecializations(memInfo.getJavaName()));
             mi.putField(className, memInfo.getJavaName(), OBJECT_DESC);
         }
     }
--- a/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MemberInfo.java	Thu Dec 24 10:33:11 2015 -0800
+++ b/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MemberInfo.java	Wed Dec 30 09:27:19 2015 +0530
@@ -85,8 +85,6 @@
     private MemberInfo.Kind kind;
     // script property name
     private String name;
-    // documentation for this member
-    private String documentation;
     // script property attributes
     private int attributes;
     // name of the java member
@@ -139,20 +137,6 @@
     }
 
     /**
-     * @return the documentation
-     */
-    public String getDocumentation() {
-        return documentation;
-    }
-
-    /**
-     * @param doc the documentation to set
-     */
-    public void setDocumentation(final String doc) {
-        this.documentation = doc;
-    }
-
-    /**
      * Tag something as specialized constructor or not
      * @param isSpecializedConstructor boolean, true if specialized constructor
      */
@@ -560,4 +544,25 @@
     void setArity(final int arity) {
         this.arity = arity;
     }
+
+    String getDocumentationKey(final String objName) {
+        if (kind == Kind.FUNCTION) {
+            StringBuilder buf = new StringBuilder(objName);
+            switch (where) {
+                case CONSTRUCTOR:
+                    break;
+                case PROTOTYPE:
+                    buf.append(".prototype");
+                    break;
+                case INSTANCE:
+                    buf.append(".this");
+                    break;
+            }
+            buf.append('.');
+            buf.append(name);
+            return buf.toString();
+        }
+
+        return null;
+    }
 }
--- a/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/PrototypeGenerator.java	Thu Dec 24 10:33:11 2015 -0800
+++ b/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/PrototypeGenerator.java	Wed Dec 30 09:27:19 2015 +0530
@@ -142,7 +142,7 @@
                 continue;
             }
             mi.loadThis();
-            newFunction(mi, scriptClassInfo.getJavaName(), memInfo, scriptClassInfo.findSpecializations(memInfo.getJavaName()));
+            newFunction(mi, scriptClassInfo.getName(), scriptClassInfo.getJavaName(), memInfo, scriptClassInfo.findSpecializations(memInfo.getJavaName()));
             mi.putField(className, memInfo.getJavaName(), OBJECT_DESC);
         }
     }
--- a/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInfoCollector.java	Thu Dec 24 10:33:11 2015 -0800
+++ b/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInfoCollector.java	Wed Dec 30 09:27:19 2015 +0530
@@ -206,7 +206,6 @@
                         // These could be "null" if values are not supplied,
                         // in which case we have to use the default values.
                         private String  name;
-                        private String  documentation;
                         private Integer attributes;
                         private Integer arity;
                         private Where   where;
@@ -223,13 +222,6 @@
                                     name = null;
                                 }
                                 break;
-                            case "documentation":
-                                this.documentation = (String)annotationValue;
-                                if (documentation.isEmpty()) {
-                                    documentation = null;
-                                }
-
-                                break;
                             case "attributes":
                                 this.attributes = (Integer)annotationValue;
                                 break;
@@ -279,7 +271,6 @@
                                 memInfo.setName(name == null ? methodName : name);
                             }
 
-                            memInfo.setDocumentation(documentation);
                             memInfo.setAttributes(attributes == null ? MemberInfo.DEFAULT_ATTRIBUTES : attributes);
 
                             memInfo.setArity((arity == null)? MemberInfo.DEFAULT_ARITY : arity);
--- a/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInstrumentor.java	Thu Dec 24 10:33:11 2015 -0800
+++ b/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInstrumentor.java	Wed Dec 30 09:27:19 2015 +0530
@@ -170,7 +170,7 @@
 
                             if (memInfo.isInstanceFunction()) {
                                 super.visitVarInsn(ALOAD, 0);
-                                ClassGenerator.newFunction(delegateMV, scriptClassInfo.getJavaName(), memInfo, scriptClassInfo.findSpecializations(memInfo.getJavaName()));
+                                ClassGenerator.newFunction(delegateMV, scriptClassInfo.getName(), scriptClassInfo.getJavaName(), memInfo, scriptClassInfo.findSpecializations(memInfo.getJavaName()));
                                 super.visitFieldInsn(PUTFIELD, scriptClassInfo.getJavaName(),
                                     memInfo.getJavaName(), OBJECT_DESC);
                             }
--- a/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/StringConstants.java	Thu Dec 24 10:33:11 2015 -0800
+++ b/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/StringConstants.java	Wed Dec 30 09:27:19 2015 +0530
@@ -118,8 +118,8 @@
     static final String SCRIPTFUNCTION_TYPE = TYPE_SCRIPTFUNCTION.getInternalName();
     static final String SCRIPTFUNCTION_SETARITY = "setArity";
     static final String SCRIPTFUNCTION_SETARITY_DESC = Type.getMethodDescriptor(Type.VOID_TYPE, Type.INT_TYPE);
-    static final String SCRIPTFUNCTION_SETDOCUMENTATION = "setDocumentation";
-    static final String SCRIPTFUNCTION_SETDOCUMENTATION_DESC = Type.getMethodDescriptor(Type.VOID_TYPE, TYPE_STRING);
+    static final String SCRIPTFUNCTION_SETDOCUMENTATIONKEY = "setDocumentationKey";
+    static final String SCRIPTFUNCTION_SETDOCUMENTATIONKEY_DESC = Type.getMethodDescriptor(Type.VOID_TYPE, TYPE_STRING);
     static final String SCRIPTFUNCTION_SETPROTOTYPE = "setPrototype";
     static final String SCRIPTFUNCTION_SETPROTOTYPE_DESC = Type.getMethodDescriptor(Type.VOID_TYPE, TYPE_OBJECT);
     static final String SCRIPTFUNCTION_CREATEBUILTIN = "createBuiltin";
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeObject.java	Thu Dec 24 10:33:11 2015 -0800
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeObject.java	Wed Dec 30 09:27:19 2015 +0530
@@ -148,8 +148,7 @@
      * @param buf external buffer - should be a nio ByteBuffer
      * @return the 'obj' object
      */
-    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR,
-        documentation = "sets ByteBuffer to hold indexed data (nashorn extension)")
+    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
     public static ScriptObject setIndexedPropertiesToExternalArrayData(final Object self, final Object obj, final Object buf) {
         Global.checkObject(obj);
         final ScriptObject sobj = (ScriptObject)obj;
@@ -169,8 +168,7 @@
      * @param  obj object to get prototype from
      * @return the prototype of an object
      */
-    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR,
-        documentation = "returns the prototype of the specified object")
+    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
     public static Object getPrototypeOf(final Object self, final Object obj) {
         if (obj instanceof ScriptObject) {
             return ((ScriptObject)obj).getProto();
@@ -197,8 +195,7 @@
      * @param  proto prototype object to be used
      * @return object whose prototype is set
      */
-    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR,
-        documentation = "sets the prototype of the given object (ES6)")
+    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
     public static Object setPrototypeOf(final Object self, final Object obj, final Object proto) {
         if (obj instanceof ScriptObject) {
             ((ScriptObject)obj).setPrototypeOf(proto);
@@ -219,8 +216,7 @@
      * @param prop  property descriptor
      * @return property descriptor
      */
-    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR,
-        documentation = "returns a property descriptor for an own property (not inherited property)")
+    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
     public static Object getOwnPropertyDescriptor(final Object self, final Object obj, final Object prop) {
         if (obj instanceof ScriptObject) {
             final String       key  = JSType.toString(prop);
@@ -244,8 +240,7 @@
      * @param obj  object to query for property names
      * @return array of property names
      */
-    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR,
-        documentation = "returns an array of all properties (enumerable or not) found directly on the given object")
+    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
     public static ScriptObject getOwnPropertyNames(final Object self, final Object obj) {
         if (obj instanceof ScriptObject) {
             return new NativeArray(((ScriptObject)obj).getOwnKeys(true));
@@ -263,8 +258,7 @@
      * @param obj  object to query for property names
      * @return array of property names
      */
-    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR,
-        documentation = "returns an array of all symbol properties found directly on the given object (ES6)")
+    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
     public static ScriptObject getOwnPropertySymbols(final Object self, final Object obj) {
         if (obj instanceof ScriptObject) {
             return new NativeArray(((ScriptObject)obj).getOwnSymbols(true));
@@ -282,8 +276,7 @@
      * @param props properties to define
      * @return object created
      */
-    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR,
-        documentation = "creates a new object with the specified prototype object and properties")
+    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
     public static ScriptObject create(final Object self, final Object proto, final Object props) {
         if (proto != null) {
             Global.checkObject(proto);
@@ -309,8 +302,7 @@
      * @param attr attributes for property descriptor
      * @return object
      */
-    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR,
-        documentation = "adds an own property and/or update the attributes of an existing own property of an object")
+    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
     public static ScriptObject defineProperty(final Object self, final Object obj, final Object prop, final Object attr) {
         final ScriptObject sobj = Global.checkObject(obj);
         sobj.defineOwnProperty(JSType.toPropertyKey(prop), attr, true);
@@ -325,8 +317,7 @@
      * @param props properties
      * @return object
      */
-    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR,
-        documentation = "defines new or modifies existing properties directly on the given object")
+    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
     public static ScriptObject defineProperties(final Object self, final Object obj, final Object props) {
         final ScriptObject sobj     = Global.checkObject(obj);
         final Object       propsObj = Global.toObject(props);
@@ -348,8 +339,7 @@
      * @param obj  object to seal
      * @return sealed object
      */
-    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR,
-        documentation = "prevents new properties from being added to the given object and marks existing properties as non-configurable")
+    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
     public static Object seal(final Object self, final Object obj) {
         if (obj instanceof ScriptObject) {
             return ((ScriptObject)obj).seal();
@@ -368,8 +358,7 @@
      * @param obj object to freeze
      * @return frozen object
      */
-    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR,
-        documentation = "prevents new properties from being added to the given object and prevents existing properties from being removed or re-configured")
+    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
     public static Object freeze(final Object self, final Object obj) {
         if (obj instanceof ScriptObject) {
             return ((ScriptObject)obj).freeze();
@@ -387,8 +376,7 @@
      * @param obj  object, for which to set the internal extensible property to false
      * @return object
      */
-    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR,
-        documentation = "prevents new properties from ever being added to the given object")
+    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
     public static Object preventExtensions(final Object self, final Object obj) {
         if (obj instanceof ScriptObject) {
             return ((ScriptObject)obj).preventExtensions();
@@ -406,8 +394,7 @@
      * @param obj check whether an object is sealed
      * @return true if sealed, false otherwise
      */
-    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR,
-        documentation = "tells if an object is sealed or not")
+    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
     public static boolean isSealed(final Object self, final Object obj) {
         if (obj instanceof ScriptObject) {
             return ((ScriptObject)obj).isSealed();
@@ -425,8 +412,7 @@
      * @param obj check whether an object
      * @return true if object is frozen, false otherwise
      */
-    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR,
-        documentation = "tells if an object is fronzen or not")
+    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
     public static boolean isFrozen(final Object self, final Object obj) {
         if (obj instanceof ScriptObject) {
             return ((ScriptObject)obj).isFrozen();
@@ -444,8 +430,7 @@
      * @param obj check whether an object is extensible
      * @return true if object is extensible, false otherwise
      */
-    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR,
-        documentation = "tells if an object is extensible or not")
+    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
     public static boolean isExtensible(final Object self, final Object obj) {
         if (obj instanceof ScriptObject) {
             return ((ScriptObject)obj).isExtensible();
@@ -463,8 +448,7 @@
      * @param obj  object from which to extract keys
      * @return array of keys in object
      */
-    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR,
-        documentation = "returns an array of the given object's own enumerable properties")
+    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
     public static ScriptObject keys(final Object self, final Object obj) {
         if (obj instanceof ScriptObject) {
             final ScriptObject sobj = (ScriptObject)obj;
@@ -487,7 +471,7 @@
      * @param value  value of object to be instantiated
      * @return the new NativeObject
      */
-    @Constructor(documentation = "creates a new script object or converts given value as a script object")
+    @Constructor
     public static Object construct(final boolean newObj, final Object self, final Object value) {
         final JSType type = JSType.ofNoFunction(value);
 
@@ -521,8 +505,7 @@
      * @param self self reference
      * @return ToString of object
      */
-    @Function(attributes = Attribute.NOT_ENUMERABLE,
-        documentation = "returns a string representing of this object")
+    @Function(attributes = Attribute.NOT_ENUMERABLE)
     public static String toString(final Object self) {
         return ScriptRuntime.builtinObjectToString(self);
     }
@@ -575,8 +558,7 @@
      * @param v property to check for
      * @return true if property exists in object
      */
-    @Function(attributes = Attribute.NOT_ENUMERABLE,
-        documentation = "tells whether this object has the specified property or not")
+    @Function(attributes = Attribute.NOT_ENUMERABLE)
     public static boolean hasOwnProperty(final Object self, final Object v) {
         // Convert ScriptObjects to primitive with String.class hint
         // but no need to convert other primitives to string.
@@ -593,8 +575,7 @@
      * @param v v prototype object to check against
      * @return true if object is prototype of v
      */
-    @Function(attributes = Attribute.NOT_ENUMERABLE,
-        documentation = "tests for this object in another object's prototype chain")
+    @Function(attributes = Attribute.NOT_ENUMERABLE)
     public static boolean isPrototypeOf(final Object self, final Object v) {
         if (!(v instanceof ScriptObject)) {
             return false;
@@ -620,8 +601,7 @@
      * @param v property to check if enumerable
      * @return true if property is enumerable
      */
-    @Function(attributes = Attribute.NOT_ENUMERABLE,
-        documentation = "tells whether the given property is enumerable or not")
+    @Function(attributes = Attribute.NOT_ENUMERABLE)
     public static boolean propertyIsEnumerable(final Object self, final Object v) {
         final String str = JSType.toString(v);
         final Object obj = Global.toObject(self);
@@ -696,8 +676,7 @@
      * @param source the source object whose properties are bound to the target
      * @return the target object after property binding
      */
-    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR,
-        documentation = "binds the source object's properties to the target object (nashorn extension)")
+    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
     public static Object bindProperties(final Object self, final Object target, final Object source) {
         // target object has to be a ScriptObject
         final ScriptObject targetObj = Global.checkObject(target);
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/annotations/Constructor.java	Thu Dec 24 10:33:11 2015 -0800
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/annotations/Constructor.java	Wed Dec 30 09:27:19 2015 +0530
@@ -48,9 +48,4 @@
      *         arity.
      */
     public int arity() default -2;
-
-    /**
-     * @return the documentation string for this constructor.
-     */
-    public String documentation() default "";
 }
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/annotations/Function.java	Thu Dec 24 10:33:11 2015 -0800
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/annotations/Function.java	Wed Dec 30 09:27:19 2015 +0530
@@ -60,9 +60,4 @@
      * @return where this function lives.
      */
     public Where where() default Where.PROTOTYPE;
-
-    /**
-     * @return return the documentation string for this function.
-     */
-    public String documentation() default "";
 }
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/FinalScriptFunctionData.java	Thu Dec 24 10:33:11 2015 -0800
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/FinalScriptFunctionData.java	Wed Dec 30 09:27:19 2015 +0530
@@ -36,6 +36,9 @@
  */
 final class FinalScriptFunctionData extends ScriptFunctionData {
 
+    // documentation key for this function, may be null
+    private String docKey;
+
     private static final long serialVersionUID = -930632846167768864L;
 
     /**
@@ -73,6 +76,23 @@
     }
 
     @Override
+    String getDocumentationKey() {
+        return docKey;
+    }
+
+    @Override
+    void setDocumentationKey(final String docKey) {
+        this.docKey = docKey;
+    }
+
+    @Override
+    String getDocumentation() {
+        String doc = docKey != null?
+            FunctionDocumentation.getDoc(docKey) : null;
+        return doc != null? doc : super.getDocumentation();
+    }
+
+    @Override
     protected boolean needsCallee() {
         final boolean needsCallee = code.getFirst().needsCallee();
         assert allNeedCallee(needsCallee);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/FunctionDocumentation.java	Wed Dec 30 09:27:19 2015 +0530
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2015, 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
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.runtime;
+
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+/**
+ * Utility class to fetch documentation for built-in functions, constructors.
+ */
+final class FunctionDocumentation {
+    private FunctionDocumentation() {}
+
+    private static final String DOCS_RESOURCE = "jdk.nashorn.internal.runtime.resources.Functions";
+
+    private static final ResourceBundle FUNC_DOCS;
+    static {
+        FUNC_DOCS = ResourceBundle.getBundle(DOCS_RESOURCE, Locale.getDefault());
+    }
+
+    static String getDoc(final String docKey) {
+        try {
+            return FUNC_DOCS.getString(docKey);
+        } catch (final RuntimeException ignored) {
+            return null;
+        }
+    }
+}
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptFunction.java	Thu Dec 24 10:33:11 2015 -0800
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptFunction.java	Wed Dec 30 09:27:19 2015 +0530
@@ -655,12 +655,21 @@
     }
 
     /**
-     * Set the documentation for this function
+     * Get the documentation key for this function
      *
-     * @param doc documentation String for this function
+     * @return the documentation key
      */
-    public final void setDocumentation(final String doc) {
-        data.setDocumentation(doc);
+    public final String getDocumentationKey() {
+        return data.getDocumentationKey();
+    }
+
+    /**
+     * Set the documentation key for this function
+     *
+     * @param docKey documentation key String for this function
+     */
+    public final void setDocumentationKey(final String docKey) {
+        data.setDocumentationKey(docKey);
     }
 
     /**
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptFunctionData.java	Thu Dec 24 10:33:11 2015 -0800
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptFunctionData.java	Wed Dec 30 09:27:19 2015 +0530
@@ -70,9 +70,6 @@
     // value, the function might still be capable of receiving variable number of arguments, see isVariableArity.
     private int arity;
 
-    // this may be null, if not available
-    private String documentation;
-
     /**
      * A pair of method handles used for generic invoker and constructor. Field is volatile as it can be initialized by
      * multiple threads concurrently, but we still tolerate a race condition in it as all values stored into it are
@@ -121,8 +118,12 @@
         return arity;
     }
 
-    final String getDocumentation() {
-        return documentation != null? documentation : toSource();
+    String getDocumentation() {
+        return toSource();
+    }
+
+    String getDocumentationKey() {
+        return null;
     }
 
     final boolean isVariableArity() {
@@ -149,10 +150,10 @@
      *
      * @param doc documentation for this function
      */
-    void setDocumentation(final String doc) {
-        this.documentation = doc;
+    void setDocumentationKey(final String docKey) {
     }
 
+
     CompiledFunction bind(final CompiledFunction originalInv, final ScriptFunction fn, final Object self, final Object[] args) {
         final MethodHandle boundInvoker = bindInvokeHandle(originalInv.createComposableInvoker(), fn, self, args);
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/Functions.properties	Wed Dec 30 09:27:19 2015 +0530
@@ -0,0 +1,44 @@
+Object.setIndexedPropertiesToExternalArrayData=sets ByteBuffer to hold indexed data (nashorn extension)
+
+Object.getPrototypeOf=returns the prototype of the specified object
+
+Object.setPrototypeOf=sets the prototype of the given object (ES6)
+
+Object.getOwnPropertyDescriptor=returns a property descriptor for an own property (not inherited property)
+
+Object.getOwnPropertyNames=returns an array of all properties (enumerable or not) found directly on the given object
+
+Object.getOwnPropertySymbols=returns an array of all symbol properties found directly on the given object (ES6)
+
+Object.create=creates a new object with the specified prototype object and properties
+
+Object.defineProperty=adds an own property and/or update the attributes of an existing own property of an object
+
+Object.defineProperties=defines new or modifies existing properties directly on the given object
+
+Object.seal=prevents new properties from being added to the given object and marks existing properties as non-configurable
+
+Object.freeze=prevents new properties from being added to the given object and prevents existing properties from being removed or re-configured
+
+Object.preventExtensions=prevents new properties from ever being added to the given object
+
+Object.isSealed=tells if an object is sealed or not
+
+Object.isFrozen=tells if an object is fronzen or not
+
+Object.isExtensible=tells if an object is extensible or not
+
+Object.keys=returns an array of the given object's own enumerable properties
+
+Object=creates a new script object or converts given value as a script object
+
+Object.prototype.toString=returns a string representing of this object
+
+Object.prototype.hasOwnProperty=tells whether this object has the specified property or not
+
+Object.prototype.isPrototypeOf=tests for this object in another object's prototype chain
+
+Object.prototype.propertyIsEnumerable=tells whether the given property is enumerable or not
+
+Object.bindProperties=binds the source object's properties to the target object (nashorn extension)
+