Menu

Getting java.lang.StringIndexOutOfBoundsExcep

2009-06-29
2013-05-20
  • Rajiv Gupta

    Rajiv Gupta - 2009-06-29

    I have a wrapper script to use over standard perl. The wrapper script is also a perl script, script is given at the bottom. There are couple of reasons I have to do this, first we a have to use -M option (to include some module at compile time) to compile second to execute directly from the ID there is another script which needs to be executed and that script will submit eval to run another scripts.

    It works perfectly with module completion, but in-case of method completion suppose when I do

    my $obj = Mod::

    it throws the exception given below:

    Exception in thread "AutoAssist Delay" org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.StringIndexOutOfBoundsException: String index out of range: 0)                                                                                                                                              
            at org.eclipse.swt.SWT.error(SWT.java:3884)                                                                                                        
            at org.eclipse.swt.SWT.error(SWT.java:3799)                                                                                                        
            at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:195)                                                                            
            at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:150)                                                                        
            at org.eclipse.swt.widgets.Display.syncExec(Display.java:4113)                                                                                     
            at org.eclipse.jface.text.contentassist.ContentAssistant$AutoAssistListener.showAssist(ContentAssistant.java:365)                                  
            at org.eclipse.jface.text.contentassist.ContentAssistant$AutoAssistListener.run(ContentAssistant.java:277)                                         
            at java.lang.Thread.run(Thread.java:619)                                                                                                           
    Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 0                                                                         
            at java.lang.String.charAt(String.java:687)                                                                                                        
            at org.epic.perleditor.templates.perl.SubroutineProposal.getImage(SubroutineProposal.java:168)                                                     
            at org.eclipse.jface.text.contentassist.CompletionProposalPopup.handleSetData(CompletionProposalPopup.java:837)                                    
            at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$24(CompletionProposalPopup.java:817)                                        
            at org.eclipse.jface.text.contentassist.CompletionProposalPopup$3.handleEvent(CompletionProposalPopup.java:583)                                    
            at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)                                                                                
            at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1176)                                                                                      
            at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1200)                                                                                      
            at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1185)                                                                                      
            at org.eclipse.swt.widgets.Table.checkData(Table.java:286)                                                                                         
            at org.eclipse.swt.widgets.Table.cellDataProc(Table.java:223)                                                                                      
            at org.eclipse.swt.widgets.Display.cellDataProc(Display.java:707)                                                                                  
            at org.eclipse.swt.internal.gtk.OS._gtk_tree_view_column_cell_set_cell_data(Native Method)                                                         
            at org.eclipse.swt.internal.gtk.OS.gtk_tree_view_column_cell_set_cell_data(OS.java:11077)                                                          
            at org.eclipse.swt.widgets.Table.getItemHeight(Table.java:1518)                                                                                    
            at org.eclipse.jface.text.contentassist.CompletionProposalPopup.getMinimalHeight(CompletionProposalPopup.java:682)                                 
            at org.eclipse.jface.text.contentassist.ContentAssistant$LayoutManager.computeBoundsBelowAbove(ContentAssistant.java:681)                          
            at org.eclipse.jface.text.contentassist.CompletionProposalPopup.getLocation(CompletionProposalPopup.java:1139)                                     
            at org.eclipse.jface.text.contentassist.CompletionProposalPopup.setProposals(CompletionProposalPopup.java:1124)
            at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$7(CompletionProposalPopup.java:1088)
            at org.eclipse.jface.text.contentassist.CompletionProposalPopup$2.run(CompletionProposalPopup.java:499)
            at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
            at org.eclipse.jface.text.contentassist.CompletionProposalPopup.showProposals(CompletionProposalPopup.java:482)
            at org.eclipse.jface.text.contentassist.ContentAssistant$2.run(ContentAssistant.java:376)
            at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
            at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
            at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3468)
            at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3115)
            at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405)
            at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
            at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
            at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
            at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
            at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
            at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
            at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
            at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
            at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
            at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
            at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
            at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
            at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
            at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
            at org.eclipse.equinox.launcher.Main.main(Main.java:1287)

    I works fine with normal bash script but not works with perl. I want to use perl because it requires extensive parsing to parse my project related arguments. All this required so that I can run and debug directly from the IDE. The script is given below:

    #!/usr/local/bin/perl
    my $ARG_STRING = join " ", @ARGV;
    my @PERL_ARGS=();
    my $PERL_ARGS_STRING ="";
    my @NATE_ARGS=();
    my $NATE_ARGS_STRING = "";
    my @INC_ARG=();
    my @NON_INC_ARG=();

    my $DEFAULT_NATE_DIR="lib";
    my $DEFAULT_NATE_LIB="testN";

    my $NATE_DIR = defined $ENV{'NATE_DIR'} ? $ENV{'NATE_DIR'} : $DEFAULT_NATE_DIR;
    my $NATE_LIB = defined $ENV{'NATE_LIB'} ? $ENV{'NATE_LIB'} : $DEFAULT_NATE_LIB;

    my $NATE_BIN_DIR="$NATE_DIR/../bin";
    my $NATE_LIB_DIR=$NATE_DIR;
    my $LINT = "NATE::Lint";
    my $ntest = "$NATE_BIN_DIR/ntest";

    if ($ARG_STRING =~ /\s*\-c{1}\s+(\-w)?.*/i)
    {
        if(-d $NATE_LIB_DIR && -d $NATE_LIB){
            push @PERL_ARGS, "-I$NATE_DIR";
            push @PERL_ARGS, "-M$LINT";
            push @PERL_ARGS, @ARGV;
        }else{
            push @PERL_ARGS, @ARGV;
        }
        $PERL_ARGS_STRING = join " " , @PERL_ARGS;
        goto END;
    }

    if ($ARG_STRING =~ /\s*\-d{1}\s*(.*)/i)
    {
        my @array = split (" ",$ARG_STRING);
        if(-d $NATE_LIB_DIR && -d $NATE_BIN_DIR){
            my $lts = parse_args(@array);
            if (not defined $lts){
                push @PERL_ARGS, @ARGV;
            }else{
                #not sure what we want to do as no test case is supplied. Simply
                #execute with default argument.
                push @PERL_ARGS, @INC_ARG;
                push @PERL_ARGS, $ntest;
                push @NATE_ARGS, "PERLDB_OPTS=\"NonStop\"";
                #set Nate dubug runid by
                my $test_name = $lts;
                $test_name = $1 if($test_name =~ /\S*\/(\S*)\.pl/);
                my $nate_debug_id = "NATE_DEBUG_RUNID=\"01_".$test_name."\"";
                push @NATE_ARGS, $nate_debug_id;
                push @NATE_ARGS, @NON_INC_ARG;
                push @NATE_ARGS, $lts;
            }

        }else{
            push @PERL_ARGS, @ARGV;
        }
            $PERL_ARGS_STRING = join " " , @PERL_ARGS;
        $NATE_ARGS_STRING = join " " , @NATE_ARGS;
        goto END;
    }

    #It is not debug not compile
    # Parse all args to know if it is execution or just auto completion

    my $final_tc = parse_args(@ARGV);
    if (not defined $final_tc){
        #not sure what we want to do as no test case is supplied. Simply
        #execute with default argument.

        push @PERL_ARGS, @ARGV;
    }else{

        push @PERL_ARGS, @INC_ARG;
        push @PERL_ARGS, $ntest;
        push @NATE_ARGS, @NON_INC_ARG;
        push @NATE_ARGS, $final_tc;
    }

    $PERL_ARGS_STRING = join " " , @PERL_ARGS;
    $NATE_ARGS_STRING = join " " , @NATE_ARGS;
    goto END;

    END:
    print "\nExecuting : \"/usr/local/bin/perl $PERL_ARGS_STRING $NATE_ARGS_STRING \"\n";
    system("/usr/local/bin/perl $PERL_ARGS_STRING $NATE_ARGS_STRING ");
    #my $out = `/usr/local/bin/perl $PERL_ARGS_STRING $NATE_ARGS_STRING `;
    #print $out;

    sub parse_args{
        #parse all arguments.
        @INC_ARG=();
        @NON_INC_ARG=();
       
        my $testcase;
        foreach my $arg (@_){
            #print "$arg \n";
            if ($arg =~ /^\s*(\-\S+)\s*/i){
                push @INC_ARG, $1;
            }else{
                $arg =~ /^\s*(\S+\.pl)/ ? $testcase = $arg : push @NON_INC_ARG, $arg;
            }
        }
        return($testcase);
    }

    Any help will be greatly appreciated.

    Thanks,
    Rajiv Gupta

     
    • Jan Ploski

      Jan Ploski - 2009-07-02

      Your wrapper script works fine for me if the statement which prints "Executing: ..." is removed.

       

Log in to post a comment.