code: public static <T> T getTypedProperty(Scriptable s, String name, Class<T> type) {
          Object val = getProperty(s, name);
          if(val == Scriptable.NOT_FOUND) {
              val = null;
          }
          return type.cast(Context.jsToJava(val, type));
      }
docs: Gets a named property from an object or any object in its prototype chain
  and coerces it to the requested Java type.
  <p>
  Searches the prototype chain for a property named <code>name</code>.
  <p>
  @param s a JavaScript object
  @param name a property name
  @param type the required Java type of the result
  @return the value of a property with name <code>name</code> found in
  <code>obj</code> or any object in its prototype chain, or
  null if not found. Note that it does not return
  {@link Scriptable#NOT_FOUND} as it can ordinarily not be
  converted to most of the types.
  @since 1.7R3