Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 352413

Summary: [1.7] Debugger should support binary literals and underscores while setting literals
Product: [Eclipse Project] JDT Reporter: Satyam Kandula <satyam.kandula>
Component: DebugAssignee: Michael Rennie <Michael_Rennie>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: curtis.windatt.public, Michael_Rennie, Olivier_Thomann
Version: 3.7Flags: curtis.windatt.public: review+
Target Milestone: 3.7.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
First draft
none
updated patch none

Description Satyam Kandula CLA 2011-07-19 04:28:14 EDT
Change value window in the debugger doesn't accept underscores in literals, whereas Java7 supports.

This is not important and probably unnecessary. Only one use case I think that may make it necessary is - copy/paste the integer from code to this window.
Comment 1 Olivier Thomann CLA 2011-07-19 15:08:11 EDT
Same issue with binary literals, where I entered "0b111" for the int value.

java.lang.NumberFormatException: For input string: "b111"
	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
	at java.lang.Integer.parseInt(Integer.java:447)
	at java.lang.Integer.valueOf(Integer.java:526)
	at java.lang.Integer.decode(Integer.java:919)
	at org.eclipse.jdt.internal.debug.eval.ast.engine.ASTInstructionCompiler.parseIntValue(ASTInstructionCompiler.java:2915)
	at org.eclipse.jdt.internal.debug.eval.ast.engine.ASTInstructionCompiler.visit(ASTInstructionCompiler.java:2887)
	at org.eclipse.jdt.core.dom.NumberLiteral.accept0(NumberLiteral.java:135)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2518)
	at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2566)
	at org.eclipse.jdt.core.dom.ReturnStatement.accept0(ReturnStatement.java:136)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2518)
	at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2589)
	at org.eclipse.jdt.core.dom.Block.accept0(Block.java:136)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2518)
	at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2566)
	at org.eclipse.jdt.core.dom.MethodDeclaration.accept0(MethodDeclaration.java:504)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2518)
	at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2589)
	at org.eclipse.jdt.core.dom.TypeDeclaration.accept0(TypeDeclaration.java:484)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2518)
	at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2589)
	at org.eclipse.jdt.core.dom.CompilationUnit.accept0(CompilationUnit.java:219)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2518)
	at org.eclipse.jdt.internal.debug.eval.ast.engine.ASTEvaluationEngine.createExpressionFromAST(ASTEvaluationEngine.java:448)
	at org.eclipse.jdt.internal.debug.eval.ast.engine.ASTEvaluationEngine.getCompiledExpression(ASTEvaluationEngine.java:267)
	at org.eclipse.jdt.internal.debug.eval.ast.engine.ASTEvaluationEngine.evaluate(ASTEvaluationEngine.java:119)
	at org.eclipse.jdt.internal.debug.ui.actions.JavaObjectValueEditor.evaluate(JavaObjectValueEditor.java:166)
	at org.eclipse.jdt.internal.debug.ui.actions.JavaObjectValueEditor.access$0(JavaObjectValueEditor.java:148)
	at org.eclipse.jdt.internal.debug.ui.actions.JavaObjectValueEditor$1.runInUIThread(JavaObjectValueEditor.java:114)
	at org.eclipse.ui.progress.UIJob$1.run(UIJob.java:95)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:969)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:885)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:87)
	at org.eclipse.ui.internal.Workbench$3.run(Workbench.java:539)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:519)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	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:344)
	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:592)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Comment 2 Michael Rennie CLA 2011-07-19 15:27:21 EDT
(In reply to comment #1)
> Same issue with binary literals, where I entered "0b111" for the int value.
> 

I quickly debugged this and the instruction compiler is passing the correct literal to Integer.decode, which is failing to decode it. This feels like something Integer should handle for us in the decode method. In the meantime Olivier mentioned he had some code that could handle this for us.
Comment 3 Olivier Thomann CLA 2011-07-19 15:35:45 EDT
Created attachment 199941 [details]
First draft

This needs some polishing and review. It adds support for binary literals as well as underscores in literals.
Comment 4 Olivier Thomann CLA 2011-07-21 09:33:53 EDT
Libraries won't support the new format (either underscores or binary literals) immediately. So you actually need to do some processing on the literal to remove underscores and make sure that the binary literals are handled.
Comment 5 Michael Rennie CLA 2011-07-27 01:25:36 EDT
Created attachment 200410 [details]
updated patch

Completes the first draft patch with support for short, float, double and byte processing. Also fixes the 'Change Value' var view action and adds regression tests.
Comment 6 Michael Rennie CLA 2011-07-27 01:26:27 EDT
Curtis please review for 3.7.1
Comment 7 Curtis Windatt CLA 2011-07-28 15:25:24 EDT
+1 for 3.7.1 inclusion
Comment 8 Curtis Windatt CLA 2011-08-02 15:45:55 EDT
Patch committed and released to HEAD and 3.7.1