code: public Object wrap(Context cx, Scriptable scope,
                         Object obj, Class<?> staticType)
      {
          if (obj == null || obj == Undefined.instance
              || obj instanceof Scriptable)
          {
              return obj;
          }
          if (staticType != null && staticType.isPrimitive()) {
              if (staticType == Void.TYPE)
                  return Undefined.instance;
              if (staticType == Character.TYPE)
                  return Integer.valueOf(((Character) obj).charValue());
              return obj;
          }
          if (!isJavaPrimitiveWrap()) {
              if (obj instanceof String ||
                  obj instanceof Boolean ||
                  obj instanceof Integer ||
                  obj instanceof Short ||
                  obj instanceof Long ||
                  obj instanceof Float ||
                  obj instanceof Double)
              {
                  return obj;
              } else if (obj instanceof Character) {
                  return String.valueOf(((Character)obj).charValue());
              }
          }
          Class<?> cls = obj.getClass();
          if (cls.isArray()) {
              return NativeJavaArray.wrap(scope, obj);
          }
          return wrapAsJavaObject(cx, scope, obj, staticType);
      }
docs: Wrap the object.
  <p>
  The value returned must be one of
  <UL>
  <LI>java.lang.Boolean</LI>
  <LI>java.lang.String</LI>
  <LI>java.lang.Number</LI>
  <LI>org.mozilla.javascript.Scriptable objects</LI>
  <LI>The value returned by Context.getUndefinedValue()</LI>
  <LI>null</LI>
  </UL>
  @param cx the current Context for this thread
  @param scope the scope of the executing script
  @param obj the object to be wrapped. Note it can be null.
  @param staticType type hint. If security restrictions prevent to wrap
  object based on its class, staticType will be used instead.
  @return the wrapped value.