Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
agatti opened this issue Jul 23, 2024 · 2 comments
Assignees

Comments

@agatti
Copy link
Contributor

agatti commented Jul 23, 2024

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.

@garyttierney
Copy link
Owner

Hm, I think this could be solved by forking a new JVM (with whatever the project SDK is configured as) to run the directory layout code instead of trying to do it in-process, looking at now.

@agatti
Copy link
Contributor Author

agatti commented Jul 23, 2024

In the meantime, a temporary workaround is to force IntelliJ to use a runtime based on JDK 21 (see https://www.jetbrains.com/help/idea/switching-boot-jdk.html) - but a solution for this is needed until this plugin stops supporting IntelliJ versions that default to a JDK 17 runtime.

Keep in mind that Ghidra won't build on anything earlier than JDK 21 since mid-April, so starting from the next stable version of Ghidra this plugin won't work at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants