Uploaded image for project: 'BlueJ'
  1. BlueJ
  2. BLUEJ-1033

Occasional exceptions during editing

    Details

    • Type: Bug
    • Status: Closed
    • Priority: High
    • Resolution: Done
    • Affects Version/s: 4.1.0
    • Fix Version/s: 4.1.1
    • Component/s: Editor
    • Sprint:
      4.1.1

      Description

      I get occasional exceptions in the debug log during editing. I can reproduce this reliably. Stack trace:

      Exception during compilation: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
      java.lang.RuntimeException: java.lang.RuntimeException: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
      	at com.sun.tools.javac.main.Main.compile(Main.java:559)
      	at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
      	at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
      	at bluej.compiler.CompilerAPICompiler.compile(CompilerAPICompiler.java:230)
      	at bluej.compiler.Job.compile(Job.java:97)
      	at bluej.compiler.CompilerThread.run(CompilerThread.java:72)
      Caused by: java.lang.RuntimeException: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
      	at bluej.compiler.EventqueueCompileObserverAdapter.runOnEventQueue(EventqueueCompileObserverAdapter.java:74)
      	at bluej.compiler.EventqueueCompileObserverAdapter.compilerMessage(EventqueueCompileObserverAdapter.java:87)
      	at bluej.compiler.CompilerAPICompiler$1.report(CompilerAPICompiler.java:180)
      	at com.sun.tools.javac.api.ClientCodeWrapper$WrappedDiagnosticListener.report(ClientCodeWrapper.java:593)
      	at com.sun.tools.javac.util.Log.writeDiagnostic(Log.java:616)
      	at com.sun.tools.javac.util.Log$DefaultDiagnosticHandler.report(Log.java:600)
      	at com.sun.tools.javac.util.Log.report(Log.java:562)
      	at com.sun.tools.javac.util.AbstractLog.error(AbstractLog.java:107)
      	at com.sun.tools.javac.parser.JavacParser.error(JavacParser.java:3859)
      	at com.sun.tools.javac.parser.JavacParser.reportSyntaxError(JavacParser.java:458)
      	at com.sun.tools.javac.parser.JavacParser.reportSyntaxError(JavacParser.java:447)
      	at com.sun.tools.javac.parser.JavacParser.accept(JavacParser.java:492)
      	at com.sun.tools.javac.parser.JavacParser.block(JavacParser.java:2317)
      	at com.sun.tools.javac.parser.JavacParser.block(JavacParser.java:2322)
      	at com.sun.tools.javac.parser.JavacParser.methodDeclaratorRest(JavacParser.java:3586)
      	at com.sun.tools.javac.parser.JavacParser.classOrInterfaceBodyDeclaration(JavacParser.java:3532)
      	at com.sun.tools.javac.parser.JavacParser.classOrInterfaceBody(JavacParser.java:3436)
      	at com.sun.tools.javac.parser.JavacParser.classDeclaration(JavacParser.java:3285)
      	at com.sun.tools.javac.parser.JavacParser.classOrInterfaceOrEnumDeclaration(JavacParser.java:3226)
      	at com.sun.tools.javac.parser.JavacParser.typeDeclaration(JavacParser.java:3215)
      	at com.sun.tools.javac.parser.JavacParser.parseCompilationUnit(JavacParser.java:3155)
      	at com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:628)
      	at com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:665)
      	at com.sun.tools.javac.main.JavaCompiler.parseFiles(JavaCompiler.java:950)
      	at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:857)
      	at com.sun.tools.javac.main.Main.compile(Main.java:523)
      	... 5 more
      Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
      	at java.lang.String.substring(String.java:1967)
      	at bluej.editor.moe.MoeSyntaxDocument.getText(MoeSyntaxDocument.java:954)
      	at bluej.editor.moe.MoeEditor.getPosFromColumn(MoeEditor.java:850)
      	at bluej.editor.moe.MoeEditor.displayDiagnostic(MoeEditor.java:781)
      	at bluej.pkgmgr.Package.showEditorDiagnostic(Package.java:2261)
      	at bluej.pkgmgr.Package.access$3(Package.java:2237)
      	at bluej.pkgmgr.Package$PackageCompileObserver.errorMessage(Package.java:2824)
      	at bluej.pkgmgr.Package$PackageCompileObserver.compilerMessage(Package.java:2792)
      	at bluej.collect.DataCollectionCompileObserverWrapper.compilerMessage(DataCollectionCompileObserverWrapper.java:73)
      	at bluej.compiler.EventqueueCompileObserverAdapter.lambda$1(EventqueueCompileObserverAdapter.java:87)
      	at bluej.compiler.EventqueueCompileObserverAdapter.lambda$0(EventqueueCompileObserverAdapter.java:58)
      	at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
      	at java.security.AccessController.doPrivileged(Native Method)
      	at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
      	at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
      	at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
      	at com.sun.glass.ui.gtk.GtkApplication.lambda$null$49(GtkApplication.java:139)
      	at java.lang.Thread.run(Thread.java:745)
      

      To reproduce, use the following source code:

      import java.net.*;
      import java.io.InputStream;
      import java.io.InputStreamReader;
      import java.io.Reader;
      
      public class Wat
      {
      
          /**
           * Constrictor for objects of class Wat
           */
          public Wat()
          {
              // initialise instance variables
          }
      
          void something() throws Exception
          {
              URL u = new URL("https://bluej.org/doesnotexist.html");
              
              
              InputStream is = u.openStream();
              
              Reader r = new InputStreamReader(is);
              char buf[] = new char[1024];
              int rr = r.read(buf);
              
              System.out.println("rr = " + rr + " bytes = " + new String(buf));
          }
      }
      

      Position the cursor on the line above "InputStream is = ..." (horizontally level with the "I"). Type "/*" (i.e. the beginning of a multi-line comment). Then press the up arrow to move the cursor to another line.

        Attachments

          Activity

            People

            • Assignee:
              nccb Neil Brown
              Reporter:
              davmac Davin McCall
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: