nashorn/src/jdk/nashorn/internal/objects/NativeJava.java
changeset 16522 d643e3ee819c
parent 16272 675a0caf75bc
child 16777 207a993adb9a
--- a/nashorn/src/jdk/nashorn/internal/objects/NativeJava.java	Wed Jul 05 18:46:02 2017 +0200
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeJava.java	Tue Mar 12 18:12:42 2013 +0530
@@ -223,6 +223,23 @@
     }
 
     /**
+     * Returns name of a java type {@link StaticClass}.
+     * @param self not used
+     * @param type the type whose name is returned
+     * @return name of the given type
+     */
+    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
+    public static Object typeName(final Object self, final Object type) {
+        if (type instanceof StaticClass) {
+            return ((StaticClass)type).getRepresentedClass().getName();
+        } else if (type instanceof Class) {
+            return ((Class<?>)type).getName();
+        } else {
+            return UNDEFINED;
+        }
+    }
+
+    /**
      * Given a JavaScript array and a Java type, returns a Java array with the same initial contents, and with the
      * specified component type. Example:
      * <pre>