Red Hat Bugzilla – Bug 1069676
samples/util.js script is not compatible with a 1.7 jdk
Last modified: 2014-09-05 17:07:07 EDT
Description of problem: samples/util.js script is not compatible with a 1.7 jdk Version-Release number of selected component (if applicable): 3.1.2 and 3.2.0 How reproducible: Always Steps to Reproduce: 1. edit the rhq-cli-env file to point the RHQ_CLI_JAVA_HOME variable to a 1.7 jdk 2. login with rhq-cli 3. load the util.js exec -f samples/util.js Actual results: Received error: InterpretedFunction: debuggableView: sun.org.mozilla.javascript.InterpreterData@58e395e8 configurationk'getMapVWk'valuesVWkiteratorVWQtViteratork'hasNextVWWT'... functionName: asHash script: false Expected results: the util.js script loads and returns to the prompt as it does with a 1.6 jdk Additional info:
Which version of JDK do you use? I've verified it works on: Oracle: java version "1.7.0_51" Java(TM) SE Runtime Environment (build 1.7.0_51-b13) Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode) and OpenJDK: java version "1.7.0_45" OpenJDK Runtime Environment (rhel-2.4.3.3.el6-x86_64 u45-b15) OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode) and IBM: java version "1.7.0" Java(TM) SE Runtime Environment (build pxa6470sr4ifix-20130305_01(SR4+IV37419)) IBM J9 VM (build 2.6, JRE 1.7.0 Linux amd64-64 Compressed References 20130205_137358 (JIT enabled, AOT enabled) J9VM - R26_Java726_SR4_20130205_1656_B137358 JIT - r11.b03_20130131_32403 GC - R26_Java726_SR4_20130205_1656_B137358_CMPRSS J9CL - 20130205_137358) JCL - 20130303_01 based on Oracle 7u13-b08 by "works" I mean: rhqadmin@localhost:7080$ exec -f samples/util.js InterpretedFunction: allIds: [arguments, prototype, name, arity, length] arity: 1 attributes: className: Function debuggableView: org.mozilla.javascript.InterpreterData@47117da8 empty: true configurationl'getMapWXl'valuesWXliteratorWXRuWiteratorl'hasNe... extensible: true functionName: asHash ids: [] immunePrototypeProperty: length: 1 parentScope: org.rhq.scripting.javascript.engine.ExternalScriptable@4d50c50b prototype: org.mozilla.javascript.BaseFunction@71b87cd4 script: false sealed: false typeOf: function This is not an error, this is just printed representation of module. Import is successful, I can successfully any function from util.js module. Tried also on Oracle JDK1.6 and it behaves exactly like this.
When I use a JDK 1.6 I don't get the printed message, it just returns to the cli prompt. If it's not an error but a printed representation, then the customer and I were both mistaken. I have the customer test the functions. customer is using java version "1.7.0_51" OpenJDK Runtime Environment (rhel-2.4.4.1.el6_5-x86_64 u51-b02) OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode)
When executing the script using -f option, we print the result of the execution. This is the result of the last statement in that script. The old version of Rhino (javascript interpreter) that is used in JON 3.1.x with Java6 most probably didn't return the function object as the result of its declaration in the file. I suppose the following will happen in the combinations of JON and JDK versions: JON | JDK | Result ------------------------------ 3.1.x | 1.6 | nothing printed 3.1.x | 1.7 | stuff printed 3.2.x | 1.6 | stuff printed 3.2.x | 1.7 | stuff printed 3.2.x with Java6 SHOULD produce the output because in 3.2.x we no longer use Rhino bundled with the JDK but use our own. As Libor said above, this is not an error per se but a consequence of trying to print the result of the script running (which is something we've been doing since day 1). What's printed is the representation of the asHash function that happens to be defined as the last one in samples/util.js. I suggest closing this as NOTABUG, because "fixing" this would be a change in behavior of the exec command (the fix would be to not print the result of the script execution but only let the script print stuff to output).
Agreed, working as expected and well-explained for necessary customer feedback.