本文整理汇总了Java中javax.script.Bindings.remove方法的典型用法代码示例。如果您正苦于以下问题:Java Bindings.remove方法的具体用法?Java Bindings.remove怎么用?Java Bindings.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.script.Bindings
的用法示例。
在下文中一共展示了Bindings.remove方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: megamorphicPropertyReadTest
import javax.script.Bindings; //导入方法依赖的package包/类
@Test
public void megamorphicPropertyReadTest() throws ScriptException {
final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
final ScriptEngine engine = factory.getScriptEngine();
final Bindings scope = engine.getBindings(ScriptContext.ENGINE_SCOPE);
boolean ret;
// Why 16 is the upper limit of this loop? The default nashorn dynalink megamorphic threshold is 16.
// See jdk.nashorn.internal.runtime.linker.Bootstrap.NASHORN_DEFAULT_UNSTABLE_RELINK_THRESHOLD
// We do, 'eval' of the same in this loop twice. So, 16*2 = 32 times that callsite in the script
// is exercised - much beyond the default megamorphic threshold.
for (int i = 0; i < 16; i++) {
scope.remove(VAR_NAME);
ret = lookupVar(engine, VAR_NAME);
assertFalse(ret, "Expected false in iteration " + i);
scope.put(VAR_NAME, "foo");
ret = lookupVar(engine, VAR_NAME);
assertTrue(ret, "Expected true in iteration " + i);
}
}