moditect / moditect

Tooling for the Java Module System
Apache License 2.0
553 stars 71 forks source link

Eclipse and moditect-maven-plugin are not friends... #256

Open eitan-rosenberg opened 1 month ago

eitan-rosenberg commented 1 month ago

I have 2 dependencies

Both are using moditect-maven-plugin to add module descriptors to support Java 9+ the base code is java 8 (Multi-Release JAR Files).

In Eclipse, I am unable to use those dependencies in module base project.

Currently, to solve the problem I download the code add module-info.java or Automatic-Module-Name and recreate the jar

Can you please shed some light here?

aalmiray commented 1 month ago

What's the problem exactly? Are the generated module descriptors faulty or is Eclipse IDE unable to understand them?

Stacktraces and error reports could help us find out more.

eitan-rosenberg commented 1 month ago

It might be faulty, but it is impossible to tell because I get :

eclipse.buildId=4.33.0.I20240903-0240 java.version=23 java.vendor=Oracle Corporation BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US Command-line arguments: -os win32 -ws win32 -arch x86_64

org.eclipse.jdt.ui
Error
Mon Oct 14 19:49:04 IDT 2024
The Class File Viewer cannot handle the given input ('org.eclipse.jdt.internal.ui.javaeditor.JarEntryEditorInput').

org.eclipse.core.runtime.CoreException: The Class File Viewer cannot handle the given input ('org.eclipse.jdt.internal.ui.javaeditor.JarEntryEditorInput').
    at org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditor.doSetInputCached(ClassFileEditor.java:672)
    at org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditor.lambda$1(ClassFileEditor.java:663)
    at org.eclipse.jdt.core.JavaCore.lambda$1(JavaCore.java:6204)
    at org.eclipse.jdt.internal.core.JavaModelManager.callReadOnly(JavaModelManager.java:5755)
    at org.eclipse.jdt.core.JavaCore.callReadOnly(JavaCore.java:6188)
    at org.eclipse.jdt.core.JavaCore.runReadOnly(JavaCore.java:6203)
    at org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditor.doSetInput(ClassFileEditor.java:663)
    at org.eclipse.ui.texteditor.AbstractTextEditor.lambda$1(AbstractTextEditor.java:3171)
    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:2341)
    at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
    at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2338)
    at org.eclipse.ui.texteditor.AbstractTextEditor.internalInit(AbstractTextEditor.java:3188)
    at org.eclipse.ui.texteditor.AbstractTextEditor.init(AbstractTextEditor.java:3213)
    at org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditor.lambda$0(ClassFileEditor.java:656)
    at org.eclipse.jdt.core.JavaCore.lambda$1(JavaCore.java:6204)
    at org.eclipse.jdt.internal.core.JavaModelManager.cacheZipFiles(JavaModelManager.java:5770)
    at org.eclipse.jdt.internal.core.JavaModelManager.callReadOnly(JavaModelManager.java:5759)
    at org.eclipse.jdt.core.JavaCore.callReadOnly(JavaCore.java:6188)
    at org.eclipse.jdt.core.JavaCore.runReadOnly(JavaCore.java:6203)
    at org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditor.init(ClassFileEditor.java:656)
    at org.eclipse.ui.internal.EditorReference.initialize(EditorReference.java:353)
    at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:344)
    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:56)
    at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:977)
    at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:939)
    at org.eclipse.e4.core.internal.di.InjectorImpl.internalInject(InjectorImpl.java:139)
    at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:386)
    at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:312)
    at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:203)
    at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:90)
    at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:59)
    at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:42)
    at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.createWidget(ContributedPartRenderer.java:132)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:991)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:658)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:762)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$2.run(PartRenderingEngine.java:727)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:711)
    at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.lambda$0(PartServiceImpl.java:105)
    at org.eclipse.e4.ui.services.internal.events.UIEventHandler.lambda$0(UIEventHandler.java:38)
    at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:183)
    at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:133)
    at org.eclipse.swt.widgets.Display.syncExec(Display.java:4855)
    at org.eclipse.e4.ui.workbench.swt.DisplayUISynchronize.syncExec(DisplayUISynchronize.java:34)
    at org.eclipse.e4.ui.services.internal.events.UIEventHandler.handleEvent(UIEventHandler.java:38)
    at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:206)
    at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:201)
    at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
    at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:151)
    at org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:131)
    at org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:73)
    at org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:44)
    at org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:55)
    at org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:60)
    at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:424)
    at org.eclipse.e4.ui.model.application.ui.impl.ElementContainerImpl.setSelectedElementGen(ElementContainerImpl.java:168)
    at org.eclipse.e4.ui.model.application.ui.impl.ElementContainerImpl.setSelectedElement(ElementContainerImpl.java:187)
    at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.showElementInWindow(ModelServiceImpl.java:654)
    at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.bringToTop(ModelServiceImpl.java:618)
    at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.delegateBringToTop(PartServiceImpl.java:796)
    at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.bringToTop(PartServiceImpl.java:401)
    at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.showPart(PartServiceImpl.java:1271)
    at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:3228)
    at org.eclipse.ui.internal.WorkbenchPage.lambda$11(WorkbenchPage.java:3118)
    at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
    at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3116)
    at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3086)
    at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3077)
    at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor(EditorUtility.java:390)
    at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInSpecificEditor(EditorUtility.java:191)
    at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor(EditorUtility.java:169)
    at org.eclipse.jdt.ui.actions.OpenAction.run(OpenAction.java:288)
    at org.eclipse.jdt.ui.actions.OpenAction.run(OpenAction.java:254)
    at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:274)
    at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:252)
    at org.eclipse.jdt.internal.ui.packageview.PackageExplorerActionGroup.handleOpen(PackageExplorerActionGroup.java:366)
    at org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$3.open(PackageExplorerPart.java:545)
    at org.eclipse.ui.OpenAndLinkWithEditorHelper$InternalListener.open(OpenAndLinkWithEditorHelper.java:48)
    at org.eclipse.jface.viewers.StructuredViewer$2.run(StructuredViewer.java:799)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
    at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:174)
    at org.eclipse.jface.viewers.StructuredViewer.fireOpen(StructuredViewer.java:796)
    at org.eclipse.jface.viewers.StructuredViewer.handleOpen(StructuredViewer.java:1110)
    at org.eclipse.jface.util.OpenStrategy.fireOpenEvent(OpenStrategy.java:295)
    at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:330)
    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)
    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)

I cannot use requires io.vavr;

I have other jar that is also multi-Release org.slf4j:slf4j-api that work just fine: 2024-10-14_20-03-15

And in eclipse: It can be seen that module-info for org.slf4j:slf4j-api looks good 2024-10-14_20-13-18

My project module-info: 2024-10-14_20-20-36

aalmiray commented 1 month ago

Could this be an issue on Eclipse itself? This is what Jarviz can tell me about vavr 0.10.5

$ jarviz module descriptor --gav io.vavr:vavr:0.10.5
subject: vavr-0.10.5.jar
name: io.vavr
version: 0.10.5
open: false
automatic: false
exports:
  io.vavr
  io.vavr.collection
  io.vavr.concurrent
  io.vavr.control
requires:
  io.vavr.match
  java.base mandated

$ jarviz bytecode show --gav io.vavr:vavr:0.10.5
subject: vavr-0.10.5.jar
Unversioned classes. Bytecode version: 52 (Java 8) total: 388
Versioned classes 9. Bytecode version: 53 (Java 9) total: 1

Have any other users of vavr found issues when consuming the library in a Java module? cc: @pivovarit

pivovarit commented 1 month ago

No, it's the only such case, and my gut feeling is that this is an Eclipse issue. Intellij IDEA doesn't complain and you can build projects with 0.10.5 version of Vavr without issues with Maven/Gradle

more context: https://github.com/vavr-io/vavr/issues/2905

eitan-rosenberg commented 1 month ago

I agree that it is an Eclipse issue.

But may I remark also that this happens only when using moditect-maven-plugin org.slf4j:slf4j-api works just fine. Using maven works and also netbeans-23. I need to talk to Eclipse people....

aalmiray commented 1 month ago

I don't understand how the moditect maven plugin could affect the Eclipse IDE in resolving a module.

eitan-rosenberg commented 1 month ago

I will try Eclipse forums Thank you