Closed sourceforge-issue-exporter closed 5 years ago
Logged In: YES user_id=244345 Originator: YES
File Added: BugReport.java
Original comment by: miguillo
BugReport.java
Original comment by: miguillo
Original comment by: miguillo
echo.java
Original comment by: miguillo
Logged In: YES user_id=244345 Originator: YES
File Added: echo.java
Original comment by: miguillo
Logged In: YES user_id=406180 Originator: NO
fixed in BeanShell2 fork
http://code.google.com/p/beanshell2/issues/detail?id=22
Original comment by: fschmidt2
merged commit beanshell/beanshell@92c3850b
BugReport.java.txt Sourced missing attachments.
package net.example.bugreport.commands;
import bsh.CallStack;
import bsh.Interpreter;
public class echo {
public static void invoke( Interpreter env, CallStack callstack, String string) {
env.println(string);
}
}
--> $0 = class net.example.bugreport.commands.echo :Class
bsh % importCommands('net.example.bugreport.commands');
--> void
bsh % echo("hello BeanShell");
hello BeanShell
--> void
bsh % Echo("hello BeanShell");
// Error: Evaluation Error: Command not found: Echo(String) : at Line: 44 : in file: <unknown file> : Echo ( "hello BeanShell" )
Closed: works as expected
I have this issue (source code and terminal dump below). (This is perhaps the same problem as bug #1447187). When adding new compiled commands with <code>importCommands(...)</code>, there is a case sensitiveness problem. If one type a the command with different case, Bsh believe it as found the command and try the instantiate it, but it can't. <pre> BeanShell 2.0b5 - by Pat Niemeyer (pat@pat.net) bsh % echo("toto"); toto bsh % Echo("toto"); Exception in thread "main" java.lang.NoClassDefFoundError: net/example/bugreport/commands/Echo (wrong name: net/example/bugreport/commands/echo) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access$000(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at bsh.classpath.ClassManagerImpl.classForName(ClassManagerImpl.java:217) at bsh.NameSpace.getCommand(NameSpace.java:961) at bsh.Name.invokeLocalMethod(Name.java:925) at bsh.Name.invokeMethod(Name.java:804) at bsh.BSHMethodInvocation.eval(BSHMethodInvocation.java:75) at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:102) at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:47) at bsh.Interpreter.run(Interpreter.java:465) at net.example.bugreport.BugReport.main(BugReport.java:22) </pre> Same thing with debug activated: <pre> BeanShell 2.0b5 - by Pat Niemeyer (pat@pat.net) bsh % debug(); // Debug: eval(String): getBshPrompt() // Debug: eval: nameSpace = NameSpace: global (bsh.NameSpace@5afd29) // Debug: Time to initialize interpreter: 0 // Debug: invokeLocalMethod: getBshPrompt // Debug: trying to resolve variable: bsh // Debug: resolved variable: bsh in namespace: NameSpace: getBshPrompt (bsh.NameSpace@1a2961b) (method) // Debug: trying to resolve variable: prompt // Debug: End of File! bsh % echo("toto"); >PrimaryExpression > MethodInvocation > AmbigousName: echo > Arguments > PrimaryExpression > Literal // Debug: invokeLocalMethod: echo // Debug: getCommand: echo // Debug: searching for script: /net/example/bugreport/commands/echo.bsh // Debug: searching for class: net.example.bugreport.commands.echo // Debug: Trying to load class: net.example.bugreport.commands.echo // Debug: invoke static Method // Debug: getResolvedMethod cache MISS: class net.example.bugreport.commands.echo - invoke // Debug: Searching for method: invoke( bsh.Interpreter, bsh.CallStack, java.lang.String ) in 'net.example.bugreport.commands.echo' // Debug: Looking for most specific method: invoke // Debug: cacheResolvedMethod putting: class net.example.bugreport.commands.echo public static void net.example.bugreport.commands.echo.invoke(bsh.Interpreter,bsh.CallStack,java.lang.String) // Debug: Invoking method (entry): public static void net.example.bugreport.commands.echo.invoke(bsh.Interpreter,bsh.CallStack,java.lang.String) with args: // Debug: args[0] = bsh.Interpreter@1ac3c08 type = class bsh.Interpreter // Debug: args[1] = CallStack: NameSpace: global (bsh.NameSpace@5afd29) type = class bsh.CallStack // Debug: args[2] = toto type = class java.lang.String // Debug: Invoking method (after massaging values): public static void net.example.bugreport.commands.echo.invoke(bsh.Interpreter,bsh.CallStack,java.lang.String) with args: // Debug: args[0] = bsh.Interpreter@1ac3c08 type = class bsh.Interpreter // Debug: args[1] = CallStack: NameSpace: global (bsh.NameSpace@5afd29) type = class bsh.CallStack // Debug: args[2] = toto type = class java.lang.String toto // Debug: eval(String): getBshPrompt() // Debug: eval: nameSpace = NameSpace: global (bsh.NameSpace@5afd29) // Debug: Time to initialize interpreter: 0 // Debug: invokeLocalMethod: getBshPrompt // Debug: trying to resolve variable: bsh // Debug: resolved variable: bsh in namespace: NameSpace: getBshPrompt (bsh.NameSpace@1c5c1) (method) // Debug: trying to resolve variable: prompt // Debug: End of File! bsh % Echo("toto"); >PrimaryExpression > MethodInvocation > AmbigousName: Echo > Arguments > PrimaryExpression > Literal // Debug: invokeLocalMethod: Echo // Debug: getCommand: Echo // Debug: searching for script: /net/example/bugreport/commands/Echo.bsh // Debug: searching for class: net.example.bugreport.commands.Echo // Debug: Trying to load class: net.example.bugreport.commands.Echo Exception in thread "main" java.lang.NoClassDefFoundError: net/example/bugreport/commands/Echo (wrong name: net/example/bugreport/commands/echo) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access$000(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at bsh.classpath.ClassManagerImpl.classForName(ClassManagerImpl.java:217) at bsh.NameSpace.getCommand(NameSpace.java:961) at bsh.Name.invokeLocalMethod(Name.java:925) at bsh.Name.invokeMethod(Name.java:804) at bsh.BSHMethodInvocation.eval(BSHMethodInvocation.java:75) at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:102) at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:47) at bsh.Interpreter.run(Interpreter.java:465) at net.example.bugreport.BugReport.main(BugReport.java:18)
</pre>
net/example/bugreport/BugReport.java: <pre> package net.example.bugreport;
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintStream;
import bsh.EvalError; import bsh.Interpreter;
public class BugReport { public static void main(String[] args) { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); PrintStream out = new PrintStream(System.out); Interpreter interpreter = new Interpreter(in, out, out, true); try { interpreter .eval("importCommands(\"net.example.bugreport.commands\")"); interpreter.run(); } catch (EvalError e) { e.printStackTrace();
}
} } </pre> net/example/bugreport/commands/echo.java (it's "echo", not "Echo"): <pre> package net.example.bugreport.commands;
import bsh.CallStack; import bsh.Interpreter;
public class echo { public static void invoke( Interpreter env, CallStack callstack, String string) { env.println(string); } }
</pre> Specs: JRE 1.6.0_04
Reported by: miguillo
Original Ticket: "beanshell/bugs/311":https://sourceforge.net/p/beanshell/bugs/311