Bug 553528 - IAE in DefaultCodeFormatterConstants#getIndentStyle
Summary: IAE in DefaultCodeFormatterConstants#getIndentStyle
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.14   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2019-11-27 06:07 EST by Karsten Thoms CLA
Modified: 2023-11-14 10:18 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 Karsten Thoms CLA 2019-11-27 06:07:28 EST
I'm recognizing an IAE which populates the error log while typing, so this happens frequently. This occurs in my Xtext dev workspace, but I did not see this in other workspaces so far. When I have more insights I'll add details.


java.lang.IllegalArgumentException: Alignment value is not an integer: null
	at org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants.getIndentStyle(DefaultCodeFormatterConstants.java:4888)
	at org.eclipse.jdt.internal.ui.text.java.JavaStringAutoIndentStrategy.getBinaryOperatorAlignmentStyle(JavaStringAutoIndentStrategy.java:248)
	at org.eclipse.jdt.internal.ui.text.java.JavaStringAutoIndentStrategy.getExtraIndentAfterNewLine(JavaStringAutoIndentStrategy.java:260)
	at org.eclipse.jdt.internal.ui.text.java.JavaStringAutoIndentStrategy.javaStringIndentAfterNewLine(JavaStringAutoIndentStrategy.java:193)
	at org.eclipse.jdt.internal.ui.text.java.JavaStringAutoIndentStrategy.customizeDocumentCommand(JavaStringAutoIndentStrategy.java:295)
	at org.eclipse.jface.text.TextViewer.customizeDocumentCommand(TextViewer.java:3606)
	at org.eclipse.jface.text.TextViewer.handleVerifyEvent(TextViewer.java:3636)
	at org.eclipse.jface.text.source.projection.ProjectionViewer.handleVerifyEvent(ProjectionViewer.java:1248)
	at org.eclipse.jface.text.TextViewer$TextVerifyListener.verifyText(TextViewer.java:426)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:277)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4406)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1512)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1535)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1520)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1324)
	at org.eclipse.swt.custom.StyledText.modifyContent(StyledText.java:7402)
	at org.eclipse.swt.custom.StyledText.sendKeyEvent(StyledText.java:8311)
	at org.eclipse.swt.custom.StyledText.paste(StyledText.java:7498)
	at org.eclipse.jface.text.TextViewer.paste(TextViewer.java:3908)
	at org.eclipse.jface.text.TextViewer.doOperation(TextViewer.java:3839)
	at org.eclipse.jface.text.source.SourceViewer.doOperation(SourceViewer.java:1064)
	at org.eclipse.jface.text.source.projection.ProjectionViewer.doOperation(ProjectionViewer.java:1466)
	at org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer.doOperation(JavaSourceViewer.java:199)
	at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewer.doOperation(CompilationUnitEditor.java:206)
	at org.eclipse.jdt.internal.ui.javaeditor.ClipboardOperationAction.doPasteWithImportsOperation(ClipboardOperationAction.java:542)
	at org.eclipse.jdt.internal.ui.javaeditor.ClipboardOperationAction.internalDoOperation(ClipboardOperationAction.java:332)
	at org.eclipse.jdt.internal.ui.javaeditor.ClipboardOperationAction$1.run(ClipboardOperationAction.java:282)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:72)
	at org.eclipse.jdt.internal.ui.javaeditor.ClipboardOperationAction.run(ClipboardOperationAction.java:279)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:474)
	at org.eclipse.jface.commands.ActionHandler.execute(ActionHandler.java:121)
	at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:95)
	at jdk.internal.reflect.GeneratedMethodAccessor378.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:318)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:252)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:173)
	at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:156)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:498)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:487)
	at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:213)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.executeCommand(KeyBindingDispatcher.java:308)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.press(KeyBindingDispatcher.java:584)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.processKeyEvent(KeyBindingDispatcher.java:653)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.filterKeySequenceBindings(KeyBindingDispatcher.java:443)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.access$2(KeyBindingDispatcher.java:386)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher$KeyDownFilter.handleEvent(KeyBindingDispatcher.java:96)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
	at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1120)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4401)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1512)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1535)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1520)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1549)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1545)
	at org.eclipse.swt.widgets.Canvas.sendKeyEvent(Canvas.java:522)
	at org.eclipse.swt.widgets.Control.doCommandBySelector(Control.java:1093)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:6248)
	at org.eclipse.swt.internal.cocoa.OS.$$YJP$$objc_msgSend(Native Method)
	at org.eclipse.swt.internal.cocoa.OS.objc_msgSend(OS.java)
	at org.eclipse.swt.internal.cocoa.NSResponder.interpretKeyEvents(NSResponder.java:71)
	at org.eclipse.swt.widgets.Composite.keyDown(Composite.java:604)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:6080)
	at org.eclipse.swt.internal.cocoa.OS.$$YJP$$objc_msgSendSuper(Native Method)
	at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(OS.java)
	at org.eclipse.swt.widgets.Widget.callSuper(Widget.java:235)
	at org.eclipse.swt.widgets.Widget.windowSendEvent(Widget.java:2158)
	at org.eclipse.swt.widgets.Shell.windowSendEvent(Shell.java:2401)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:6200)
	at org.eclipse.swt.internal.cocoa.OS.$$YJP$$objc_msgSendSuper(Native Method)
	at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(OS.java)
	at org.eclipse.swt.widgets.Display.applicationSendEvent(Display.java:5426)
	at org.eclipse.swt.widgets.Display.applicationProc(Display.java:5586)
	at org.eclipse.swt.internal.cocoa.OS.$$YJP$$objc_msgSend(Native Method)
	at org.eclipse.swt.internal.cocoa.OS.objc_msgSend(OS.java)
	at org.eclipse.swt.internal.cocoa.NSApplication.sendEvent(NSApplication.java:131)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3807)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1160)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1049)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:633)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:557)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:150)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:137)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:107)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:660)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:597)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1468)
Caused by: java.lang.NumberFormatException: null
	at java.base/java.lang.Integer.parseInt(Integer.java:614)
	at java.base/java.lang.Integer.parseInt(Integer.java:770)
	at org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants.getIndentStyle(DefaultCodeFormatterConstants.java:4879)
	... 100 more
Comment 1 Karsten Thoms CLA 2019-11-27 06:14:40 EST
The error occurs while I'm typing in a class that has currently syntax issues. When the issue is resolved, the error does not happen anymore.
Comment 2 Stephan Herrmann CLA 2019-11-27 13:21:57 EST
Incidentally, I had a somewhat similar exception recently, which happened when I tried to copy/edit a formatter profile:

java.lang.IllegalArgumentException: Alignment value is not an integer: null
    at org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants.getWrappingStyle(DefaultCodeFormatterConstants.java:5312)
    at org.eclipse.jdt.internal.ui.preferences.formatter.FormatterModifyDialog$LineWrapPreference.updateWidget(FormatterModifyDialog.java:211)
    at org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialog$Preference.init(ModifyDialog.java:280)
    at org.eclipse.jdt.internal.ui.preferences.formatter.FormatterModifyDialog$LineWrapPreference.init(FormatterModifyDialog.java:205)
    at org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialog$ProfilePreferenceTree.addChild(ModifyDialog.java:907)
    at org.eclipse.jdt.internal.ui.preferences.formatter.FormatterModifyDialog.lambda$20(FormatterModifyDialog.java:1225)
    at org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialog$ProfilePreferenceTree$PrefBuilder.build(ModifyDialog.java:839)
    at org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialog$ProfilePreferenceTree$PrefBuilder.build(ModifyDialog.java:1)
    at org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialog$ProfilePreferenceTree$SectionBuilder.build(ModifyDialog.java:822)
    at org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialog$ProfilePreferenceTree$SectionBuilder.build(ModifyDialog.java:1)
    at org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialog$ProfilePreferenceTree$SectionBuilder.build(ModifyDialog.java:822)
    at org.eclipse.jdt.internal.ui.preferences.formatter.FormatterModifyDialog.createLineWrapTree(FormatterModifyDialog.java:1207)
    at org.eclipse.jdt.internal.ui.preferences.formatter.FormatterModifyDialog.createPreferenceTree(FormatterModifyDialog.java:575)
    at org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialog.createMainArea(ModifyDialog.java:1262)
    at org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialog.createDialogArea(ModifyDialog.java:1246)


I only had a brief look at the code but wondered if this could happen, if a new formatter option has been added, but some persisted state didn't yet have it? Or an incompatibility between JDT/Core and JDT/UI plugins??

Anyway, it seems that both cases originate in JDT/UI, which calls JDT/Core with an illegal null value.
Comment 3 Mateusz Matela CLA 2019-12-01 09:29:45 EST
(In reply to Karsten Thoms from comment #0)
> I'm recognizing an IAE which populates the error log while typing, so this
> happens frequently. This occurs in my Xtext dev workspace, but I did not see
> this in other workspaces so far. When I have more insights I'll add details.

Can you share contents of your .metadata\.plugins\org.eclipse.core.runtime\.settings workspace folder (mainly jdt.core and jdt.ui files)? And a sample code that you're editing?

(In reply to Stephan Herrmann from comment #2)
> I only had a brief look at the code but wondered if this could happen, if a
> new formatter option has been added, but some persisted state didn't yet
> have it? Or an incompatibility between JDT/Core and JDT/UI plugins??

To avoid such problems, jdt.ui always uses ProfileVersioner to make sure that loaded formatter profiles are updated. Hard to tell where this could go wrong, apart from manual tempering with workspace settings files.
Comment 4 Karsten Thoms CLA 2019-12-03 04:47:39 EST
I'm editing, for example, class org.eclipse.xtext.resource.XtextResource from 
https://github.com/eclipse/xtext-core.git

In this project we have checked in formatter settings.
https://github.com/eclipse/xtext-core/tree/master/org.eclipse.xtext/.settings
Comment 5 Eclipse Genie CLA 2021-11-23 09:50:43 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 6 Eclipse Genie CLA 2023-11-14 10:18:26 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.