by Giorgio Maone » Wed Nov 24, 2010 9:07 pm
al_9x wrote:Giorgio Maone wrote:However, this is moot because I've just found a wonderful hack which allows me to intercept the java properties without triggering the JVM and without disabling the plugin.
What is it?
Code: Select all
(function() {
const w = window;
const k = function() {};
w.watch('java', k); // wonderful trick reducing w.java resolution by a 100 factor,
w.watch('Packages', k); // by skipping InitJavaProperties() and undeffing Packages and java
const g = function() {
const d = w.document;
const o = d.createElement("object");
o.type = "application/x-java-vm";
o.data = "data:" + o.type + ",";
d.body.appendChild(o);
d.body.removeChild(o);
w.__defineGetter__("java", k);
w.__defineGetter__("Packages", k);
}
w.__defineGetter__("java", g);
w.__defineGetter__("Packages", g);
})()
EDIT:
actually it looks like I talked too fast. The code above does reduce the execution time by two orders of magnitude, but unless I disable the plugin the JVM gets instantiated anyway
So I'll end combining plugin disablement and the trick above to keep the execution time well under 10 milliseconds while effectively intercepting the Java properties without instantiating the JVM.
EDIT 2
Here's the reason why I was mislead about the extent of the trick above. It works fully on Fx 3.6 (speedup + JVM prevention), but only grants the speedup on Minefield, where the JVM instantiation can only be prevented by disabling the plugin.
However the overhead of the plugin status management is negligible enough not to grant a separate codepath for the 1.9.x branch.
[quote="al_9x"][quote="Giorgio Maone"]However, this is moot because I've just found a wonderful hack which allows me to intercept the java properties without triggering the JVM and [b]without disabling the plugin[/b].[/quote]
What is it?[/quote]
[code]
(function() {
const w = window;
const k = function() {};
w.watch('java', k); // wonderful trick reducing w.java resolution by a 100 factor,
w.watch('Packages', k); // by skipping InitJavaProperties() and undeffing Packages and java
const g = function() {
const d = w.document;
const o = d.createElement("object");
o.type = "application/x-java-vm";
o.data = "data:" + o.type + ",";
d.body.appendChild(o);
d.body.removeChild(o);
w.__defineGetter__("java", k);
w.__defineGetter__("Packages", k);
}
w.__defineGetter__("java", g);
w.__defineGetter__("Packages", g);
})()
[/code]
[b]EDIT[/b]:
actually it looks like I talked too fast. The code above does reduce the execution time by two orders of magnitude, but unless I disable the plugin the JVM gets instantiated anyway :(
So I'll end combining plugin disablement and the trick above to keep the execution time well under 10 milliseconds while effectively intercepting the Java properties without instantiating the JVM.
[b]EDIT 2[/b]
Here's the reason why I was mislead about the extent of the trick above. It works fully on Fx 3.6 (speedup + JVM prevention), but only grants the speedup on Minefield, where the JVM instantiation can only be prevented by disabling the plugin.
However the overhead of the plugin status management is negligible enough not to grant a separate codepath for the 1.9.x branch.