wheredevel / beanshell2

Automatically exported from code.google.com/p/beanshell2
0 stars 0 forks source link

print command fails if a class named String is defined (except the java.lang.String class) #69

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.in Beanshell Desktop type :
2.class String { };
3.print(1);

What is the expected output? What do you see instead?
Expected : 1
Real : // Error: EvalError: Error in method invocation: Static method valueOf( 
int ) not found in class'String' : at Line: 35 : in file: 
/bsh/commands/print.bsh : String .valueOf ( arg ) 

Called from method: print : at Line: 1 : in file: <unknown file> : print ( 1 ) 

What version of the product are you using? On what operating system?
bsh-2.1b5.jar on Windows 7 x64

Please provide any additional information below.
This is also triggered with :
bsh % print(1);
1
bsh % import *;
bsh % print(1);
// Error: EvalError: Ambigous class names: [java.lang.String, 
com.sun.org.apache.xpath.internal.operations.String] : at Line: 35 : in file: 
/bsh/commands/print.bsh : String .valueOf ( arg ) 

Called from method: print : at Line: 1 : in file: <unknown file> : print ( 1 ) 
----------
The patch seems obvious in bsh/commands/print.bsh
At line 35, replace :
        this.interpreter.println(String.valueOf(arg));
by 
        this.interpreter.println(java.lang.String.valueOf(arg));

This issue may affect other scripts in bsh/commands
--Regards

Original issue reported on code.google.com by marc.de...@gmail.com on 22 May 2012 at 3:40

GoogleCodeExporter commented 8 years ago
Don't know if this must be fixed.
The fix would be either to full qualify class names in all commands (like 
"print") or a different handling of namespaces when executing a command (not 
using the caller namespace).
Must dig into it..

Original comment by pejob...@gmail.com on 23 May 2012 at 6:11

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r117.

Original comment by pejob...@gmail.com on 10 Sep 2012 at 1:25

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r118.

Original comment by pejob...@gmail.com on 10 Sep 2012 at 1:27

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r119.

Original comment by pejob...@gmail.com on 10 Sep 2012 at 1:29

GoogleCodeExporter commented 8 years ago
Lingering too long, just applied suggested quick-fix.
If other scripts in bsh/commands are affected, this should be reported in 
separate issues.
There are no unit test for commands :(

Original comment by pejob...@gmail.com on 10 Sep 2012 at 1:33