org.mozilla.javascript.tools.shell.Global.getClass()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 JavaScript  
字(5.5k)|赞(0)|评价(0)|浏览(178)

本文整理了Java中org.mozilla.javascript.tools.shell.Global.getClass()方法的一些代码示例,展示了Global.getClass()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Global.getClass()方法的具体详情如下:
包路径:org.mozilla.javascript.tools.shell.Global
类名称:Global
方法名:getClass

Global.getClass介绍

暂无

代码示例

代码示例来源:origin: ro.isdc.wro4j/rhino

/**
 * Load and execute a script compiled to a class file.
 * <p>
 * This method is defined as a JavaScript function.
 * When called as a JavaScript function, a single argument is
 * expected. This argument should be the name of a class that
 * implements the Script interface, as will any script
 * compiled by jsc.
 *
 * @exception IllegalAccessException if access is not available
 *            to the class
 * @exception InstantiationException if unable to instantiate
 *            the named class
 */
public static void loadClass(Context cx, Scriptable thisObj,
               Object[] args, Function funObj)
  throws IllegalAccessException, InstantiationException
{
  Class<?> clazz = getClass(args);
  if (!Script.class.isAssignableFrom(clazz)) {
    throw reportRuntimeError("msg.must.implement.Script");
  }
  Script script = (Script) clazz.newInstance();
  script.exec(cx, thisObj);
}

代码示例来源:origin: org.jvnet.hudson/embedded-rhino-debugger

/**
 * Load and execute a script compiled to a class file.
 * <p>
 * This method is defined as a JavaScript function.
 * When called as a JavaScript function, a single argument is
 * expected. This argument should be the name of a class that
 * implements the Script interface, as will any script
 * compiled by jsc.
 *
 * @exception IllegalAccessException if access is not available
 *            to the class
 * @exception InstantiationException if unable to instantiate
 *            the named class
 */
public static void loadClass(Context cx, Scriptable thisObj,
               Object[] args, Function funObj)
  throws IllegalAccessException, InstantiationException
{
  Class<?> clazz = getClass(args);
  if (!Script.class.isAssignableFrom(clazz)) {
    throw reportRuntimeError("msg.must.implement.Script");
  }
  Script script = (Script) clazz.newInstance();
  script.exec(cx, thisObj);
}

代码示例来源:origin: com.github.tntim96/rhino

/**
 * Load and execute a script compiled to a class file.
 * <p>
 * This method is defined as a JavaScript function.
 * When called as a JavaScript function, a single argument is
 * expected. This argument should be the name of a class that
 * implements the Script interface, as will any script
 * compiled by jsc.
 *
 * @exception IllegalAccessException if access is not available
 *            to the class
 * @exception InstantiationException if unable to instantiate
 *            the named class
 */
public static void loadClass(Context cx, Scriptable thisObj,
               Object[] args, Function funObj)
  throws IllegalAccessException, InstantiationException
{
  Class<?> clazz = getClass(args);
  if (!Script.class.isAssignableFrom(clazz)) {
    throw reportRuntimeError("msg.must.implement.Script");
  }
  Script script = (Script) clazz.newInstance();
  script.exec(cx, thisObj);
}

代码示例来源:origin: ro.isdc.wro4j/rhino

/**
 * Load a Java class that defines a JavaScript object using the
 * conventions outlined in ScriptableObject.defineClass.
 * <p>
 * This method is defined as a JavaScript function.
 * @exception IllegalAccessException if access is not available
 *            to a reflected class member
 * @exception InstantiationException if unable to instantiate
 *            the named class
 * @exception InvocationTargetException if an exception is thrown
 *            during execution of methods of the named class
 * @see org.mozilla.javascript.ScriptableObject#defineClass(Scriptable,Class)
 */
@SuppressWarnings({"unchecked"})
public static void defineClass(Context cx, Scriptable thisObj,
                Object[] args, Function funObj)
  throws IllegalAccessException, InstantiationException,
      InvocationTargetException
{
  Class<?> clazz = getClass(args);
  if (!Scriptable.class.isAssignableFrom(clazz)) {
    throw reportRuntimeError("msg.must.implement.Scriptable");
  }
  ScriptableObject.defineClass(thisObj, (Class<? extends Scriptable>)clazz);
}

代码示例来源:origin: org.jvnet.hudson/embedded-rhino-debugger

/**
 * Load a Java class that defines a JavaScript object using the
 * conventions outlined in ScriptableObject.defineClass.
 * <p>
 * This method is defined as a JavaScript function.
 * @exception IllegalAccessException if access is not available
 *            to a reflected class member
 * @exception InstantiationException if unable to instantiate
 *            the named class
 * @exception InvocationTargetException if an exception is thrown
 *            during execution of methods of the named class
 * @see org.mozilla.javascript.ScriptableObject#defineClass(Scriptable,Class)
 */
@SuppressWarnings({"unchecked"})
public static void defineClass(Context cx, Scriptable thisObj,
                Object[] args, Function funObj)
  throws IllegalAccessException, InstantiationException,
      InvocationTargetException
{
  Class<?> clazz = getClass(args);
  if (!Scriptable.class.isAssignableFrom(clazz)) {
    throw reportRuntimeError("msg.must.implement.Scriptable");
  }
  ScriptableObject.defineClass(thisObj, (Class<? extends Scriptable>)clazz);
}

代码示例来源:origin: com.github.tntim96/rhino

/**
 * Load a Java class that defines a JavaScript object using the
 * conventions outlined in ScriptableObject.defineClass.
 * <p>
 * This method is defined as a JavaScript function.
 * @exception IllegalAccessException if access is not available
 *            to a reflected class member
 * @exception InstantiationException if unable to instantiate
 *            the named class
 * @exception InvocationTargetException if an exception is thrown
 *            during execution of methods of the named class
 * @see org.mozilla.javascript.ScriptableObject#defineClass(Scriptable,Class)
 */
@SuppressWarnings({"unchecked"})
public static void defineClass(Context cx, Scriptable thisObj,
                Object[] args, Function funObj)
  throws IllegalAccessException, InstantiationException,
      InvocationTargetException
{
  Class<?> clazz = getClass(args);
  if (!Scriptable.class.isAssignableFrom(clazz)) {
    throw reportRuntimeError("msg.must.implement.Scriptable");
  }
  ScriptableObject.defineClass(thisObj, (Class<? extends Scriptable>)clazz);
}

相关文章