public void start ( String [ ] args ) throws Exception { OptionParserCommandLine commandLineArgs = new OptionParserCommandLine ( ) ; options = commandLineArgs . parse ( args ) ; if ( options == null ) { // Abort return ; } startup = commandLineArgs . startup ( ) ; // initialize editor settings configEditor ( ) ; // initialize JShell instance try { resetState ( ) ; } catch ( IllegalStateException ex ) { // Display just the cause (not a exception backtrace) cmderr . println ( ex . getMessage ( ) ) ; //abort return ; } // Read replay history from last jshell session into previous history replayableHistoryPrevious = ReplayableHistory . fromPrevious ( prefs ) ; // load snippet/command files given on command-line for ( String loadFile : commandLineArgs . nonOptions ( ) ) { runFile ( loadFile , "jshell" ) ; } // if we survived that... if ( regenerateOnDeath ) { // initialize the predefined feedback modes initFeedback ( commandLineArgs . feedbackMode ( ) ) ; } // check again, as feedback setting could have failed if ( regenerateOnDeath ) { // if we haven't died, and the feedback mode wants fluff, print welcome if ( feedback . shouldDisplayCommandFluff ( ) ) { hardmsg ( "jshell.msg.welcome" , version ( ) ) ; } // Be sure history is always saved so that user code isn't lost Thread shutdownHook = new Thread ( ) { @ Override public void run ( ) { replayableHistory . storeHistory ( prefs ) ; } } ; Runtime . getRuntime ( ) . addShutdownHook ( shutdownHook ) ; // execute from user input try ( IOContext in = new ConsoleIOContext ( this , cmdin , console ) ) { while ( regenerateOnDeath ) { if ( ! live ) { resetState ( ) ; } run ( in ) ; } } finally { replayableHistory . storeHistory ( prefs ) ; closeState ( ) ; try { Runtime . getRuntime ( ) . removeShutdownHook ( shutdownHook ) ; } catch ( Exception ex ) { // ignore, this probably caused by VM aready being shutdown // and this is the last act anyhow } } } closeState ( ) ; }
The entry point into the JShell tool .