intellij-ghidra icon indicating copy to clipboard operation
intellij-ghidra copied to clipboard

Cannot add facet if Ghidra is built with a newer JDK than what IntelliJ uses.

Open agatti opened this issue 7 months ago • 2 comments

Describe the bug:

The plugin cannot work if Ghidra was compiled with a newer Java version than the one IntelliJ is running on.

Steps to reproduce:

  1. Have intellij-ghidra version 0.5.0 installed, straight from JetBrains' servers.
  2. Build Ghidra with Java 21 or higher.
  3. Load IntelliJ making sure the internal runtime is the one provided by JetBrains (hence using Java 17).
  4. Open a project, then add a Ghidra facet to a module.
  5. It won't be possible to commit changes in the dialog due to an internal exception.

The exception is as follows (kept just the interesting bits):

2024-07-23 16:33:40,661 [  51937] SEVERE - #c.i.i.p.PluginManager - ghidra/GhidraApplicationLayout has been compiled by a more recent version of the Java Runtime (class file version 65.0), this version of the Java Runtime only recognizes class file versions up to 61.0
java.lang.UnsupportedClassVersionError: ghidra/GhidraApplicationLayout has been compiled by a more recent version of the Java Runtime (class file version 65.0), this version of the Java Runtime only recognizes class file versions up to 61.0
        at java.base/java.lang.ClassLoader.defineClass1(Native Method)
# <Internal class loader frames omitted>
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
        at com.codingmates.ghidra.intellij.ide.facet.model.ProxyKt.createApplicationLayoutProxy(proxy.kt:46)
        at com.codingmates.ghidra.intellij.ide.facet.GhidraFacetSettings.resolve(GhidraFacetSettings.kt:19)
        at com.codingmates.ghidra.intellij.ide.facet.GhidraFacetConfigurationEditor.apply(GhidraFacetConfigurationEditor.kt:102)
        at com.intellij.openapi.options.UnnamedConfigurableGroup.apply(UnnamedConfigurableGroup.java:54)
        at com.intellij.facet.impl.ProjectFacetsConfigurator.applyEditors(ProjectFacetsConfigurator.java:253)
# <Internal IntelliJ frames omitted>

The exception is caught by IntelliJ itself and won't provide any feedback to the user (ie. you can click as many times as you want on either "Ok" or "Apply" but nothing will really happen).

Expected behavior:

Ideally there should be a better way to figure out Ghidra's directory layout, but if that's not possible then I guess some feedback to the user may help clarifying the situation. This is especially annoying if you have your package manager handle either Ghidra or IntelliJ (or both of them - look at Nix, Arch, etc.), or if you upgrade the default JVM at the wrong moment in time and IntelliJ starts misbehaving when you upgrade your Ghidra installation.

agatti avatar Jul 23 '24 14:07 agatti