Command with main() method not callable via the main() method.

Project:JNode Shell
Component:Code
Category:bug report
Priority:normal
Assigned:Stephen Crawley
Status:closed
Description

The org.jnode.shell.command.bsh.BshCommand has a main() method and in spite of that, if I try to invoke it in a special usecase via the main() method it throws ShellInvocationException at line: throw new ShellInvocationException("Commands with new-style syntax cannot be invoked this way"); in AbstractCommand.java.

I think regardless of the command being a new style command or not if it has a main method implemented then that should be usable. Such restriction would also render the reuse of new style JNode commands by direct invocation in a standard JVM imposible. Such usecase can be important also during the development of the command.

The bug can be easily reproduced with the following command:

java org.jnode.shell.command.bsh.BshCommand

#1

Priority:critical» normal
Assigned to:Anonymous» Stephen Crawley

I'll look into it.

#2

Status:active» postponed

One solution is to remove the "main" method from all commands that use the new JNode syntax mechanism. Smiling

Right now this is just a minor inconvenience. If you run the command by typing "bsh" or "org.jnode.shell.command.bsh.BshCommand" at the command prompt, it will work. If you want a command for testing out the "java" command, stick with classic Java programs ... or modify the JavaCommand class to run the java class using an invoker.

In the long term we need a proper fix for this, and I have an idea that might work. But don't imagine that this will make JNode commands run in a classic JVM. A lot more is needed to do that. For example, we'll need to deal with the problem of extracting information from JNode plugin extensions ... to get the JNode command syntax.

#3

Status:postponed» active

I needed the feature very much so I locally disabled throwing that exception and I could already run the bsh command without arguments with the main method.
I would like this to be fixed sooner than later if possible.

#4

I've checked in a short term fix. Please tell me if it works for you.

#5

bsh starts up with your temporary fix but it has no exclusive access to the console. Successive commands are sent either to bsh or to the shell randomly. Use the the java command to reproduce it.

#6

It sound like "java" is returning / exiting and returning control to the shell while some interactive "bsh" thread is still trying to read from the console. IMO, that has to be a bug in "java" or "bsh".

JNode's console layer has no support for exclusive access to / control of a console, either on the input or output sides. AFAIK, it never has. There are some cases where this would seem to be a good thing to do. However, there are likely to be significant drawbacks / usability issues. I recommend that we don't go down that path ... at least not now.

BTW, in UNIX and Linux if you create two processes that are simultaneously reading keyboard input, lines will go to either of them randomly, just like you are describing. It is just one of those things that a sensible user does not do.

#7

Status:active» fixed

It seems like there is nothing more to do on this issue. Marking as fixed.

#8

Status:fixed» closed