eclipse-jdt / eclipse.jdt.ui

Eclipse Public License 2.0
37 stars 90 forks source link

Update to M3 wrecked JUnit Container / Unable to compute bundle location for 'org.hamcrest' with range [2.2.0,2.3.0) #1610

Closed laeubi closed 2 months ago

laeubi commented 2 months ago

I updated my IDE (from Eclipse for RCP and RAP Developers 4.33.0.20240711-1200 > Eclipse for RCP and RAP Developers 4.33.0.20240822-0820) as now

Version: 2024-09 M3 (4.33.0 M3)
Build id: 20240822-1019

and now one of my projects is wrecked with

java.lang.IllegalStateException: Unable to compute bundle location for 'org.hamcrest' with range [2.2.0,2.3.0)
    at org.eclipse.jdt.internal.junit.buildpath.BuildPathSupport$JUnitPluginDescription.getLibraryEntry(BuildPathSupport.java:236)
    at org.eclipse.jdt.internal.junit.buildpath.BuildPathSupport.getHamcrestLibraryEntry(BuildPathSupport.java:435)
    at org.eclipse.jdt.internal.junit.buildpath.JUnitContainerInitializer.getNewContainer(JUnitContainerInitializer.java:147)
    at org.eclipse.jdt.internal.junit.buildpath.JUnitContainerInitializer.initialize(JUnitContainerInitializer.java:108)
    at org.eclipse.jdt.internal.core.JavaModelManager.initializeContainer(JavaModelManager.java:3285)
    at org.eclipse.jdt.internal.core.JavaModelManager.getClasspathContainer(JavaModelManager.java:2212)
    at org.eclipse.jdt.core.JavaCore.getClasspathContainer(JavaCore.java:4008)
    at org.eclipse.jdt.internal.core.JavaProject.resolveClasspath(JavaProject.java:3150)
    at org.eclipse.jdt.internal.core.JavaProject.resolveClasspath(JavaProject.java:3314)
    at org.eclipse.jdt.internal.core.JavaProject.getResolvedClasspath(JavaProject.java:2428)
    at org.eclipse.jdt.internal.core.JavaProject.computePackageFragmentRoots(JavaProject.java:799)
    at org.eclipse.jdt.internal.core.JavaProject.computePackageFragmentRoots(JavaProject.java:1074)
    at org.eclipse.jdt.internal.core.JavaProject.computePackageFragmentRoots(JavaProject.java:1020)
    at org.eclipse.jdt.internal.core.JavaProject.getAllPackageFragmentRoots(JavaProject.java:1797)
    at org.eclipse.jdt.internal.core.JavaProjectElementInfo.getProjectCache(JavaProjectElementInfo.java:225)
    at org.eclipse.jdt.internal.core.JavaProjectElementInfo.newNameLookup(JavaProjectElementInfo.java:313)
    at org.eclipse.jdt.internal.core.JavaProject.newNameLookup(JavaProject.java:2798)
    at org.eclipse.jdt.internal.core.SearchableEnvironment.<init>(SearchableEnvironment.java:107)
    at org.eclipse.jdt.internal.core.SearchableEnvironment.<init>(SearchableEnvironment.java:148)
    at org.eclipse.jdt.internal.core.CancelableNameEnvironment.<init>(CancelableNameEnvironment.java:32)
    at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:253)
    at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:346)
    at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.makeConsistent(ReconcileWorkingCopyOperation.java:186)
    at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.java:92)
    at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:739)
    at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:804)
    at org.eclipse.jdt.internal.core.CompilationUnit.reconcile(CompilationUnit.java:1303)
    at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:132)
    at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy$1.run(JavaReconcilingStrategy.java:94)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
    at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:91)
    at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.initialReconcile(JavaReconcilingStrategy.java:189)
    at org.eclipse.jdt.internal.ui.text.CompositeReconcilingStrategy.initialReconcile(CompositeReconcilingStrategy.java:125)
    at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.initialReconcile(JavaCompositeReconcilingStrategy.java:139)
    at org.eclipse.jface.text.reconciler.MonoReconciler.initialProcess(MonoReconciler.java:100)
    at org.eclipse.jdt.internal.ui.text.JavaReconciler.initialProcess(JavaReconciler.java:421)
    at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:177)

I can't even expand the project anymore because it results in

java.lang.NullPointerException: Cannot invoke "org.eclipse.jdt.core.IClasspathEntry.getEntryKind()" because "entry" is null
    at org.eclipse.jdt.internal.ui.packageview.ClassPathContainer.getChildren(ClassPathContainer.java:190)
    at org.eclipse.jdt.internal.ui.navigator.NonEssentialEmptyLibraryContainerFilter.doSelect(NonEssentialEmptyLibraryContainerFilter.java:36)
    at org.eclipse.jdt.internal.ui.navigator.NonEssentialElementsFilter.select(NonEssentialElementsFilter.java:75)
    at org.eclipse.jface.viewers.ViewerFilter.filter(ViewerFilter.java:62)
    at org.eclipse.jface.viewers.StructuredViewer.getFilteredChildren(StructuredViewer.java:855)
    at org.eclipse.jface.viewers.AbstractTreeViewer.getSortedChildren(AbstractTreeViewer.java:673)
    at org.eclipse.jface.viewers.AbstractTreeViewer.createChildren(AbstractTreeViewer.java:866)
    at org.eclipse.jface.viewers.TreeViewer.createChildren(TreeViewer.java:611)
    at org.eclipse.jface.viewers.AbstractTreeViewer.createChildren(AbstractTreeViewer.java:819)
    at org.eclipse.jface.viewers.AbstractTreeViewer.handleTreeExpand(AbstractTreeViewer.java:1603)
    at org.eclipse.jface.viewers.TreeViewer.handleTreeExpand(TreeViewer.java:904)
    at org.eclipse.jface.viewers.AbstractTreeViewer$3.treeExpanded(AbstractTreeViewer.java:1615)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:149)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:91)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:5855)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1617)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1643)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1626)
    at org.eclipse.swt.widgets.Tree.gtk_test_expand_row(Tree.java:2620)
    at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:2624)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:6168)
    at org.eclipse.swt.internal.gtk3.GTK3.gtk_main_do_event(Native Method)
    at org.eclipse.swt.widgets.Display.eventProc(Display.java:1598)
    at org.eclipse.swt.internal.gtk3.GTK3.gtk_main_iteration_do(Native Method)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4514)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1151)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1042)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:153)
    at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:639)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:546)
    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:143)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:109)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:439)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:271)
    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:668)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:605)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1481)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1454)

The project also has an error marker:

Description Resource    Path    Location    Type
Invalid classpath container: 'JUnit 4' in project 'xxxx'
laeubi commented 2 months ago

As a workaround I edited the classpath settings directly in the filesystem

grafik

so I can use the project again.

laeubi commented 2 months ago

These are the bundles that show up in my install

grafik

laeubi commented 2 months ago

JUnit 5 is also party wrecked now as it pulls in an almost empty hamcrest-core leading to compile errors:

grafik

HannesWell commented 2 months ago

As a workaround I edited the classpath settings directly in the filesystem

I get the same error but even for a JUnit-4 container: Invalid classpath container: 'JUnit 4' in project 'org.eclipse.xtext.xbase.lib.tests'

Using a Eclipse IDE for Eclipse Committers

Version: 2024-09 M3 (4.33.0 M3)
Build id: 20240822-1019
laeubi commented 2 months ago

I get the same error but even for a JUnit-4 container:

As mentioned the JUnit 4 breaks completely, JUnit 5 breaks if you use any Hamcrest class, the while Eclipse SDK workspace is now broken as well because of org.eclipse.osgi what is a dependency of almost everything:

grafik

stephan-herrmann commented 2 months ago

Moved to JDT/UI, where the junit containers are implemented.

HannesWell commented 2 months ago

As suggested by @laeubi I verified that this can be fixed by widening the version range in BuildPathSupport.HAMCREST_PLUGIN and BuildPathSupport.HAMCREST_CORE_PLUGIN. According to the release notes it looks like https://github.com/hamcrest/JavaHamcrest/releases/tag/v3.0 only changed the class-file version corresponding to Java-1.8, so it should be a drop-in replacement since JDT only support Java-1.8 now (luckily). Adapting the version range seems therefore sufficient.

cdietrich commented 2 months ago

see the same https://github.com/eclipse/xtext/issues/3178

jukzi commented 2 months ago

i get similar: "Invalid classpath container: 'JUnit 4' in project 'org.eclipse.osgi"