Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Support for Java-21 String Templates(Java-21 has a new String Template feature but Eclipse doesn't appear to support it)
Support for Java-21 String Templates [message #1862508] Thu, 07 December 2023 19:48 Go to next message
Eclipse UserFriend
I've downloaded Eclipse 2023-12 and this release and the prior release don't support Java-21's String Template feature. When are we going to see it?
Re: Support for Java-21 String Templates [message #1862511 is a reply to message #1862508] Fri, 08 December 2023 03:56 Go to previous messageGo to next message
Eclipse UserFriend
This is marked as completed:

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/544
Re: Support for Java-21 String Templates [message #1862563 is a reply to message #1862511] Tue, 12 December 2023 01:43 Go to previous messageGo to next message
Eclipse UserFriend
I have done a small test here, and it seems that it will be available on the next release.

I install eclipse-SDK-4.30-win32-x86_64.zip from https://download.eclipse.org/eclipse/downloads/drops4/R-4.30-202312010110/

I update this installation from https://download.eclipse.org/eclipse/updates/4.31-I-builds/

So now I have Version: 2024-03 (4.31) Build id: I20231211-1800.

I created a project that use --enable-preview.

I enter this code:

int x = 10;
int y = 20;

String result = STR."\{x} + \{y} = \{x + y}";

This seems to work.

There is a problem though...

I am using "Save Actions" and this fail.

I am getting: (I know that this is still in development, but I thought that it would not harm if I mention it)
A save participant caused problems.
The save participant 'Code Clean Up' caused an exception: java.lang.NullPointerException: Cannot invoke "org.eclipse.jdt.core.dom.Expression.getStartPosition()" because "expression" is null. See the error log for details.

java.lang.NullPointerException: Cannot invoke "org.eclipse.jdt.core.dom.Expression.getStartPosition()" because "expression" is null
at org.eclipse.jdt.core.dom.ASTConverter.convertToVariableDeclarationFragment(ASTConverter.java:4037)
at org.eclipse.jdt.core.dom.ASTConverter.convertToVariableDeclarationStatement(ASTConverter.java:4115)
at org.eclipse.jdt.core.dom.ASTConverter.checkAndAddMultipleLocalDeclaration(ASTConverter.java:544)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1368)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2607)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2055)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2524)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2537)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2046)
at org.eclipse.jdt.core.dom.ASTConverter.convertToVariableDeclarationFragment(ASTConverter.java:4035)
at org.eclipse.jdt.core.dom.ASTConverter.convertToVariableDeclarationStatement(ASTConverter.java:4115)
at org.eclipse.jdt.core.dom.ASTConverter.checkAndAddMultipleLocalDeclaration(ASTConverter.java:548)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:736)
at org.eclipse.jdt.core.dom.ASTConverter.buildBodyDeclarations(ASTConverter.java:208)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:3439)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1521)
at org.eclipse.jdt.core.dom.CompilationUnitResolver.convert(CompilationUnitResolver.java:344)
at org.eclipse.jdt.core.dom.ASTParser.internalCreateASTCached(ASTParser.java:1269)
at org.eclipse.jdt.core.dom.ASTParser.lambda$0(ASTParser.java:1120)
at org.eclipse.jdt.internal.core.JavaModelManager.cacheZipFiles(JavaModelManager.java:5821)
at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:1120)
at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:868)
at org.eclipse.jdt.internal.corext.fix.CleanUpPostSaveListener.createAst(CleanUpPostSaveListener.java:597)
at org.eclipse.jdt.internal.corext.fix.CleanUpPostSaveListener.saved(CleanUpPostSaveListener.java:374)
at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitDocumentProvider$4.run(CompilationUnitDocumentProvider.java:1611)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitDocumentProvider.notifyPostSaveListeners(CompilationUnitDocumentProvider.java:1605)
at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitDocumentProvider.commitWorkingCopy(CompilationUnitDocumentProvider.java:1389)
at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitDocumentProvider$3.execute(CompilationUnitDocumentProvider.java:1464)
at org.eclipse.ui.editors.text.TextFileDocumentProvider$DocumentProviderOperation.run(TextFileDocumentProvider.java:133)
at org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation.execute(WorkspaceModifyDelegatingOperation.java:71)
at org.eclipse.ui.actions.WorkspaceModifyOperation.lambda$0(WorkspaceModifyOperation.java:112)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2453)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2478)
at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:131)
at org.eclipse.ui.internal.editors.text.WorkspaceOperationRunner.run(WorkspaceOperationRunner.java:76)
at org.eclipse.ui.internal.editors.text.WorkspaceOperationRunner.run(WorkspaceOperationRunner.java:66)
at org.eclipse.ui.editors.text.TextFileDocumentProvider.executeOperation(TextFileDocumentProvider.java:461)
at org.eclipse.ui.editors.text.TextFileDocumentProvider.saveDocument(TextFileDocumentProvider.java:783)
at org.eclipse.ui.texteditor.AbstractTextEditor.performSave(AbstractTextEditor.java:5018)
at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor.performSave(CompilationUnitEditor.java:1267)
at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor.doSave(CompilationUnitEditor.java:1321)
at org.eclipse.ui.texteditor.AbstractTextEditor$TextEditorSavable.doSave(AbstractTextEditor.java:7233)
at org.eclipse.ui.Saveable.doSave(Saveable.java:213)
at org.eclipse.ui.internal.SaveableHelper.doSaveModel(SaveableHelper.java:326)
at org.eclipse.ui.internal.SaveablesList.lambda$2(SaveablesList.java:804)
at org.eclipse.ui.internal.SaveableHelper.lambda$3(SaveableHelper.java:270)
at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:434)
at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:354)
at org.eclipse.ui.internal.WorkbenchWindow.lambda$7(WorkbenchWindow.java:2335)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2332)
at org.eclipse.ui.internal.SaveableHelper.runProgressMonitorOperation(SaveableHelper.java:277)
at org.eclipse.ui.internal.SaveablesList.saveModels(SaveablesList.java:812)
at org.eclipse.ui.internal.WorkbenchPage.saveAll(WorkbenchPage.java:3615)
at org.eclipse.ui.internal.WorkbenchPage.saveAllEditors(WorkbenchPage.java:3593)
at org.eclipse.ui.internal.handlers.SaveAllHandler.execute(SaveAllHandler.java:51)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:277)
at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:98)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58)
at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:298)
at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:232)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:174)
at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:165)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:488)
at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:485)
at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:204)
at org.eclipse.ui.internal.handlers.LegacyHandlerService.executeCommand(LegacyHandlerService.java:385)
at org.eclipse.ui.internal.actions.CommandAction.runWithEvent(CommandAction.java:141)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:581)
at org.eclipse.jface.action.ActionContributionItem.lambda$5(ActionContributionItem.java:454)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4273)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4071)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3659)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1152)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1043)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:152)
at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:648)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:555)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:173)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:208)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:651)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:588)
at org.eclipse.equinox.launcher.Main.run(Main.java:1459)

Re: Support for Java-21 String Templates [message #1862566 is a reply to message #1862563] Tue, 12 December 2023 03:45 Go to previous messageGo to next message
Eclipse UserFriend
Yes, I noticed from email discussions that the enhancement was committed right after the final release build for 4.30. I would highly recommend reporting issues here:

https://github.com/eclipse-jdt

I also get the sense that one will get answers faster on the discussions:

https://github.com/eclipse-jdt/eclipse.jdt.core/discussions

than in the forum.
Re: Support for Java-21 String Templates [message #1862578 is a reply to message #1862566] Tue, 12 December 2023 08:13 Go to previous message
Eclipse UserFriend
Ed Merks wrote on Tue, 12 December 2023 08:45
Yes, I noticed from email discussions that the enhancement was committed right after the final release build for 4.30. I would highly recommend reporting issues here:

https://github.com/eclipse-jdt

I also get the sense that one will get answers faster on the discussions:

https://github.com/eclipse-jdt/eclipse.jdt.core/discussions

than in the forum.


posted:
https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1736
Previous Topic:Errors hovering, Open Declaration, Open Type Hierarchy and Open Call Hierarchy
Next Topic:Unable to install WTP on Eclipse 2023-09 due to missing JustJ Adoptium OpenJDK requirement
Goto Forum:
  


Current Time: Mon Apr 21 11:52:25 EDT 2025

Powered by FUDForum. Page generated in 0.04065 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top