FULL PRODUCT VERSION : java version "1.8.0_77" Java(TM) SE Runtime Environment (build 1.8.0_77-b03) Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode) ADDITIONAL OS VERSION INFORMATION : Darwin Kernel Version 15.3.0 A DESCRIPTION OF THE PROBLEM : The `this` value in the `with` is broken by the repetition of a function call. This is a code that the reproduces the problem. ``` function Foo() { this.bar = "bar"; this.baz = "baz"; } Foo.prototype._h = function(str) { print("expect `bar`: " + this.bar); } Foo.prototype._e = function() { print("expect `baz`: " + this.baz); } function makeFunction() { return new Function("with(this) { return _h(_e()); }"); } var fn = makeFunction(); var foo = null; for (var i=0; i < 20; i++) { foo = new Foo(); fn.call(foo); } // jjs sample.js // Output: // expect `baz`: baz // expect `bar`: bar // expect `baz`: baz // expect `bar`: bar // expect `baz`: baz // expect `bar`: bar // expect `baz`: baz // expect `bar`: bar // expect `baz`: baz // expect `bar`: bar // expect `baz`: baz // expect `bar`: bar // expect `baz`: baz // expect `bar`: bar // expect `baz`: baz // expect `bar`: bar // expect `baz`: baz // expect `bar`: bar // expect `baz`: baz // expect `bar`: bar // expect `baz`: baz // expect `bar`: bar // expect `baz`: baz // expect `bar`: bar // expect `baz`: baz // expect `bar`: bar // expect `baz`: baz // expect `bar`: bar // expect `baz`: baz // expect `bar`: bar // expect `baz`: baz // expect `bar`: bar // expect `baz`: undefined // expect `bar`: undefined // expect `baz`: undefined // expect `bar`: undefined // expect `baz`: undefined // expect `bar`: undefined // expect `baz`: undefined // expect `bar`: undefined ``` As can be seen from the reproduction code, by calling the function with the `with` statement more than 17 times , it seems the scope is broken. REPRODUCIBILITY : This bug can be reproduced always.
|