eclipse-platform/.github

[Externalize Strings Dialog] StringIndexOutOfBoundsException

Closed this issue · 1 comments

Let's make sure issue is not already fixed in latest builds first.

Steps to reproduce

Open the "Externalize Strings..." dialog with this simple class

public class NLTest {

   public static final String SYMBOL_AMPERSAND = "&";  //$NON-NLS-1$
   public static final String SYMBOL_QUOTA     = "\""; //$NON-NLS-1$
}

I expected: The NLS dialog should open

But got: The NLS dialog did not opened

With this workaround the NLS dialog opens

public class NLTest {

   public static final String SYMBOL_AMPERSAND = "&";                                       //$NON-NLS-1$
   public static final String SYMBOL_QUOTA     = new StringBuilder().append('"').toString();
}

Here is some relevant log output

From the terminal

java.lang.StringIndexOutOfBoundsException: begin 3, end 0, length 3
        at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4606)
        at java.base/java.lang.String.substring(String.java:2709)
        at org.eclipse.jdt.internal.corext.refactoring.nls.NLSHint.stripQuotes(NLSHint.java:266)
        at org.eclipse.jdt.internal.corext.refactoring.nls.NLSHint.createSubstitutions(NLSHint.java:221)
        at org.eclipse.jdt.internal.corext.refactoring.nls.NLSHint.<init>(NLSHint.java:106)
        at org.eclipse.jdt.internal.corext.refactoring.nls.NLSRefactoring.<init>(NLSRefactoring.java:92)
        at org.eclipse.jdt.internal.corext.refactoring.nls.NLSRefactoring.create(NLSRefactoring.java:113)
        at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizard.lambda$0(ExternalizeWizard.java:84)
        at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
        at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizard.open(ExternalizeWizard.java:81)
        at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run(ExternalizeStringsAction.java:191)
        at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run(ExternalizeStringsAction.java:156)
        at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:278)
        at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:252)
        at org.eclipse.jface.action.Action.runWithEvent(Action.java:474)
        at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:581)
        at org.eclipse.jface.action.ActionContributionItem.lambda$4(ActionContributionItem.java:415)
        at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:91)
        at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4326)
        at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1174)
        at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4124)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3712)

Tested under this environment:

  • OS & version: Windows 10
  • Eclipse IDE/Platform version (as shown in Help > About): I20240731-1800

Community

  • I understand reporting an issue to this OSS project does not mandate anyone to fix it. Other contributors may consider the issue, or not, at their own convenience. The most efficient way to get it fixed is that I fix it myself and contribute it back as a good quality patch to the project.
jukzi commented

The affected class NLSHint is part of jdt.ui please recreate the issue at https://github.com/eclipse-jdt/eclipse.jdt.ui/issues/new, as we can not move issues between organizations.
Closing as not platform.