count-negative / qwickie

Automatically exported from code.google.com/p/qwickie
15 stars 7 forks source link

ClassCastException JavaNature cannot be cast to IJavaProject on Eclipse 2024-3 #10

Open hkuhn42 opened 8 months ago

hkuhn42 commented 8 months ago

If i click a wicket:id in the new eclipse version, nothing happens and the following error shows up in the log:

!ENTRY org.eclipse.ui 4 0 2024-03-27 08:59:27.580 !MESSAGE Unhandled event loop exception !STACK 0 java.lang.ClassCastException: class org.eclipse.jdt.internal.core.JavaNature cannot be cast to class org.eclipse.jdt.core.IJavaProject (org.eclipse.jdt.internal.core.JavaNature and org.eclipse.jdt.core.IJavaProject are in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @2b407207) at qwickie.util.FileSearcher.getSourceFolders(FileSearcher.java:103) at qwickie.util.FileSearcher.removeSourceFolder(FileSearcher.java:126) at qwickie.hyperlink.WicketHyperlink.open(WicketHyperlink.java:103) at org.eclipse.jface.text.hyperlink.HyperlinkManager.mouseUp(HyperlinkManager.java:426) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:224) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89) at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4274) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4072) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3660) 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)

ZwoCa commented 7 months ago

I can confirm this. It still worked in Eclipse 2023-12, but broke when I updated to 2024-3.

There is a second log entry as well:

eclipse.buildId=4.31.0.20240307-1200
java.version=17.0.11
java.vendor=Eclipse Adoptium
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=de_DE
Framework arguments:  -perspective org.eclipse.jdt.ui.JavaPerspective -product org.eclipse.epp.package.java.product
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -perspective org.eclipse.jdt.ui.JavaPerspective -product org.eclipse.epp.package.java.product

org.eclipse.jface.text
Error
Fri Apr 26 10:23:29 CEST 2024
Unexpected runtime error while computing a text hover

java.lang.ClassCastException: class org.eclipse.jdt.internal.core.JavaNature cannot be cast to class org.eclipse.jdt.core.IJavaProject (org.eclipse.jdt.internal.core.JavaNature and org.eclipse.jdt.core.IJavaProject are in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @165952a3)
    at qwickie.util.FileSearcher.getSourceFolders(FileSearcher.java:103)
    at qwickie.util.FileSearcher.<init>(FileSearcher.java:48)
    at qwickie.hyperlink.WicketHyperlink.getHtmlFiles(WicketHyperlink.java:271)
    at qwickie.hover.QWickieHover.getHoverInfo(QWickieHover.java:87)
    at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo2(BestMatchHover.java:169)
    at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo2(BestMatchHover.java:130)
    at org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy.getHoverInfo2(JavaEditorTextHoverProxy.java:89)
    at org.eclipse.jface.text.TextViewerHoverManager$1.run(TextViewerHoverManager.java:155)
lonvarscsak commented 5 months ago

I can confirm this still happens in 2024-06 when opening new files.

vrozkovec commented 4 months ago

Hi, I may have fixed the plugin in my fork: https://github.com/vrozkovec/qwickie/commit/bd5f2942446a2cccb2289d310ce1ce72ff1f1f05

It is a naive quickfix and may not be a correct one, however it seems to work in Eclipse 2024-06 (4.32.0).

You can try it yourself:

Use at your own risk :)

[1] image

hkuhn42 commented 3 months ago

Very nice! I will give it a try! Thanks