Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 84641 - StringIndexOutOfBoundsException in console
Summary: StringIndexOutOfBoundsException in console
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.1   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.1 M5   Edit
Assignee: Luc Bourlier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 84876 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-02-07 18:45 EST by Brock Janiczak CLA
Modified: 2005-02-15 20:35 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Brock Janiczak CLA 2005-02-07 18:45:20 EST
Version: 3.1.0
Build id: I20050201-0800

I found the following exception in my eclipse log.  No error dialog was
displayed.  Sorry, but i don' thave any steps to reproduce.  I was probably
running an external tool at the time.

org.eclipse.swt.SWTException: Failed to execute runnable
(java.lang.StringIndexOutOfBoundsException: String index out of range: 1620)
    at org.eclipse.swt.SWT.error(SWT.java:2839)
    at org.eclipse.swt.SWT.error(SWT.java:2762)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:121)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:2854)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2518)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1585)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1551)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:290)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:144)
    at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:102)
    at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:227)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:276)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:131)
    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:324)
    at org.eclipse.core.launcher.Main.basicRun(Main.java:261)
    at org.eclipse.core.launcher.Main.run(Main.java:817)
    at org.eclipse.core.launcher.Main.main(Main.java:801)Caused by:
java.lang.StringIndexOutOfBoundsException: String index out of range: 1620
    at java.lang.String.charAt(String.java:444)
    at java.util.regex.Pattern$Caret.match(Pattern.java:2874)
    at java.util.regex.Pattern$Start.match(Pattern.java:2814)
    at java.util.regex.Matcher.find(Matcher.java:722)
    at java.util.regex.Matcher.find(Matcher.java:414)
    at
org.eclipse.ui.internal.console.ConsoleDocumentAdapter.countLines(ConsoleDocumentAdapter.java:305)
    at
org.eclipse.ui.internal.console.ConsoleDocumentAdapter.documentAboutToBeChanged(ConsoleDocumentAdapter.java:289)
    at
org.eclipse.jface.text.AbstractDocument.fireDocumentAboutToBeChanged(AbstractDocument.java:608)
    at org.eclipse.jface.text.AbstractDocument.replace(AbstractDocument.java:1025)
    at
org.eclipse.ui.internal.console.ConsoleDocument.replace(ConsoleDocument.java:83)
    at
org.eclipse.ui.internal.console.IOConsolePartitioner$1.run(IOConsolePartitioner.java:521)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
    at
org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:118)   
    ... 17 moreFailed to execute runnable
(java.lang.StringIndexOutOfBoundsException: String index out of range: 1620)
Comment 1 Kevin Barnes CLA 2005-02-08 13:35:40 EST
This looks like bug 77130. Haven't been able to reproduce. The code looks good to me. Possibly a bug 
in Pattern? What VM are you using?
Comment 2 Brock Janiczak CLA 2005-02-08 17:45:31 EST
java version "1.4.2_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_06-b03)
Java HotSpot(TM) Client VM (build 1.4.2_06-b03, mixed mode)
Comment 3 Brock Janiczak CLA 2005-02-09 06:05:11 EST
Test case to show it is a bug in the JDK, although there is possibly a workaround:

public class Test84641 {
    private static Pattern pattern = Pattern.compile("^.*$", Pattern.MULTILINE);
//$NON-NLS-1$

    public static void main(String[] args) {
        Matcher matcher = pattern.matcher("\r");
        while (matcher.find()) {
        }
    }
}
Comment 4 Darin Wright CLA 2005-02-09 08:51:38 EST
Please check for an existing bug against the JDK. 
Comment 5 Kevin Barnes CLA 2005-02-09 11:45:08 EST
Sun's bug number 4994840 looks like the one. (fixed in 1.5 apparently)
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4994840
This is also an issue on Apple's 1.4.2 VM (and IBM's?).
Only work around suggested is to strip \r from the end of strings manually.
Comment 6 Kevin Barnes CLA 2005-02-09 12:02:35 EST
The test case in Eclipse is to run the following with console output on: 

public class CarriageReturn {
    public static void main(String[] args) {
        System.out.print("\r");
    }
}
Comment 7 Kevin Barnes CLA 2005-02-09 12:06:22 EST
fixed in ConsoleDocumentAdapter with work around suggested in jdk bug report.
Comment 8 Kevin Barnes CLA 2005-02-09 12:07:02 EST
Luc, please verify
Comment 9 Darin Wright CLA 2005-02-10 08:29:44 EST
*** Bug 84876 has been marked as a duplicate of this bug. ***
Comment 10 Luc Bourlier CLA 2005-02-15 20:35:08 EST
Verified.