Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 337085

Summary: "var" variables in user .cfg files modify xdc.global in XGCONF
Product: [Technology] RTSC Reporter: Jon Rowlands <rowlands>
Component: CoreAssignee: Sasha Slijepcevic <sascha>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: d-russo, rowlands
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: All   
Whiteboard: target:3.22.03

Description Jon Rowlands CLA 2011-02-13 22:55:59 EST
XGCONF incorrectly executes the user .cfg using xdc.global scope, instead
of in a capsule scope. This modifies the JavaScript execution environment
for everyone. For example, the following causes failures:

  var Error = xdc.useModule("xdc.runtime.Error");

Subsequently, .xs code in other packages that uses the standard JavaScript
expression "throw new Error()" will fail as:

  xdc.services.intern.xsr.Value$Obj@1d43d1e::
     xdc.runtime.Error is not a function, it is object.

The root cause is inappropriate use of utils.evaluateScript() in the
generated .cfg file, function _loadOrEval(). Should replace with some
function that lets the caller specify a scope.
Comment 1 Sasha Slijepcevic CLA 2011-03-03 20:38:24 EST
A similar problem was addressed in SDOCM46701.
Comment 2 Sasha Slijepcevic CLA 2011-04-15 22:17:45 EDT
- fixed in xdc-x00

The code in the generated cfg script
evaluateScript(script);
is replaced with
try {
    var tempScope = {};
    var cx = Packages.org.mozilla.javascript.Context.getCurrentContext();
    var rdr = new java.io.BufferedReader(new java.io.StringReader(script));
    Packages.config.Shell.evaluateLoad(cx, tempScope, rdr, "", 1);
}
finally {
    rdr.close();
}
Comment 3 Dave Russo CLA 2011-11-09 18:55:23 EST
closing "ancient" resolved bugs