8067420: BrowserJSObjectLinker should give priority to beans linker for property get/set
Reviewed-by: lagergren, attila, hannesw
This commit is contained in:
parent
f6c045bef0
commit
05bf0c5a45
@ -1,4 +1,4 @@
|
|||||||
#// Usage: jjs -fx browser.js
|
#// Usage: jjs -fx browser_dom.js
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
@ -32,7 +32,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (!$OPTIONS._fx) {
|
if (!$OPTIONS._fx) {
|
||||||
print("Usage: jjs -fx browser.js");
|
print("Usage: jjs -fx browser_dom.js");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,10 +74,10 @@ EOF, "text/html");
|
|||||||
var btn = document.createElement("button");
|
var btn = document.createElement("button");
|
||||||
var n = 0;
|
var n = 0;
|
||||||
// attach a button handler - nashorn function!
|
// attach a button handler - nashorn function!
|
||||||
btn.onclick = new EventListener(function() {
|
btn.onclick = function() {
|
||||||
n++; print("You clicked " + n + " time(s)");
|
n++; print("You clicked " + n + " time(s)");
|
||||||
print("you clicked OK " + wv.engine.executeScript("okCount"));
|
print("you clicked OK " + wv.engine.executeScript("okCount"));
|
||||||
});
|
};
|
||||||
// attach text to button
|
// attach text to button
|
||||||
var t = document.createTextNode("Click Me!");
|
var t = document.createTextNode("Click Me!");
|
||||||
btn.appendChild(t);
|
btn.appendChild(t);
|
||||||
|
@ -118,20 +118,21 @@ final class BrowserJSObjectLinker implements TypeBasedGuardingDynamicLinker {
|
|||||||
private GuardedInvocation lookup(final CallSiteDescriptor desc, final LinkRequest request, final LinkerServices linkerServices) throws Exception {
|
private GuardedInvocation lookup(final CallSiteDescriptor desc, final LinkRequest request, final LinkerServices linkerServices) throws Exception {
|
||||||
final String operator = CallSiteDescriptorFactory.tokenizeOperators(desc).get(0);
|
final String operator = CallSiteDescriptorFactory.tokenizeOperators(desc).get(0);
|
||||||
final int c = desc.getNameTokenCount();
|
final int c = desc.getNameTokenCount();
|
||||||
|
GuardedInvocation inv;
|
||||||
|
try {
|
||||||
|
inv = nashornBeansLinker.getGuardedInvocation(request, linkerServices);
|
||||||
|
} catch (Throwable th) {
|
||||||
|
inv = null;
|
||||||
|
}
|
||||||
|
|
||||||
switch (operator) {
|
switch (operator) {
|
||||||
case "getProp":
|
case "getProp":
|
||||||
case "getElem":
|
case "getElem":
|
||||||
case "getMethod":
|
case "getMethod":
|
||||||
if (c > 2) {
|
return c > 2? findGetMethod(desc, inv) : findGetIndexMethod(inv);
|
||||||
return findGetMethod(desc);
|
|
||||||
}
|
|
||||||
// For indexed get, we want GuardedInvocation from beans linker and pass it.
|
|
||||||
// BrowserJSObjectLinker.get uses this fallback getter for explicit signature method access.
|
|
||||||
return findGetIndexMethod(nashornBeansLinker.getGuardedInvocation(request, linkerServices));
|
|
||||||
case "setProp":
|
case "setProp":
|
||||||
case "setElem":
|
case "setElem":
|
||||||
return c > 2 ? findSetMethod(desc) : findSetIndexMethod();
|
return c > 2? findSetMethod(desc, inv) : findSetIndexMethod();
|
||||||
case "call":
|
case "call":
|
||||||
return findCallMethod(desc);
|
return findCallMethod(desc);
|
||||||
default:
|
default:
|
||||||
@ -139,7 +140,10 @@ final class BrowserJSObjectLinker implements TypeBasedGuardingDynamicLinker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static GuardedInvocation findGetMethod(final CallSiteDescriptor desc) {
|
private static GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final GuardedInvocation inv) {
|
||||||
|
if (inv != null) {
|
||||||
|
return inv;
|
||||||
|
}
|
||||||
final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND);
|
final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND);
|
||||||
final MethodHandle getter = MH.insertArguments(JSOBJECT_GETMEMBER, 1, name);
|
final MethodHandle getter = MH.insertArguments(JSOBJECT_GETMEMBER, 1, name);
|
||||||
return new GuardedInvocation(getter, IS_JSOBJECT_GUARD);
|
return new GuardedInvocation(getter, IS_JSOBJECT_GUARD);
|
||||||
@ -150,7 +154,10 @@ final class BrowserJSObjectLinker implements TypeBasedGuardingDynamicLinker {
|
|||||||
return inv.replaceMethods(getter, inv.getGuard());
|
return inv.replaceMethods(getter, inv.getGuard());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static GuardedInvocation findSetMethod(final CallSiteDescriptor desc) {
|
private static GuardedInvocation findSetMethod(final CallSiteDescriptor desc, final GuardedInvocation inv) {
|
||||||
|
if (inv != null) {
|
||||||
|
return inv;
|
||||||
|
}
|
||||||
final MethodHandle getter = MH.insertArguments(JSOBJECT_SETMEMBER, 1, desc.getNameToken(2));
|
final MethodHandle getter = MH.insertArguments(JSOBJECT_SETMEMBER, 1, desc.getNameToken(2));
|
||||||
return new GuardedInvocation(getter, IS_JSOBJECT_GUARD);
|
return new GuardedInvocation(getter, IS_JSOBJECT_GUARD);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user