amitdev / PMD-Intellij

Plugin for doing static analysis in Intellij using PMD
http://plugins.intellij.net/plugin/?id=1137
MIT License
71 stars 23 forks source link

Make PMD plugin compatible with IntelliJ 2024.1 #162

Closed uhafner closed 7 months ago

uhafner commented 8 months ago

In IntelliJ 2024.1 RC I get the following exceptions:

java.lang.NullPointerException: Cannot invoke "java.lang.Class.getClassLoader()" because the return value of "com.intellij.openapi.util.IconPathPatcher.getContextClass(String)" is null
    at com.intellij.ui.icons.IconTransform.applyPatchers(IconTransform.kt:112)
    at com.intellij.ui.icons.IconTransform.patchPath(IconTransform.kt:77)
    at com.intellij.ui.icons.CachedImageIconKt.patchIconPath(CachedImageIcon.kt:50)
    at com.intellij.openapi.util.IconLoaderKt.findIconUsingDeprecatedImplementation(IconLoader.kt:361)
    at com.intellij.openapi.util.IconLoaderKt.findIconUsingDeprecatedImplementation$default(IconLoader.kt:354)
    at com.intellij.openapi.util.IconLoader.getIcon(IconLoader.kt:112)
    at com.intellij.openapi.util.IconLoader.getIcon(IconLoader.kt:100)
    at com.intellij.plugins.bodhi.pmd.PMDResultPanel$ReRunAction.<init>(PMDResultPanel.java:452)
    at com.intellij.plugins.bodhi.pmd.PMDResultPanel.createActions(PMDResultPanel.java:243)
    at com.intellij.plugins.bodhi.pmd.PMDResultPanel.<init>(PMDResultPanel.java:91)
    at com.intellij.plugins.bodhi.pmd.PMDProjectComponent.projectOpened(PMDProjectComponent.java:156)
    at com.intellij.openapi.project.impl.ProjectManagerImplKt$runInitProjectActivities$3$1$1.invoke(ProjectManagerImpl.kt:1010)
    at com.intellij.openapi.project.impl.ProjectManagerImplKt$runInitProjectActivities$3$1$1.invoke(ProjectManagerImpl.kt:1009)
    at com.intellij.openapi.progress.CoroutinesKt.blockingContextInner(coroutines.kt:320)
    at com.intellij.openapi.progress.CoroutinesKt.access$blockingContextInner(coroutines.kt:1)
    at com.intellij.openapi.progress.CoroutinesKt$blockingContext$2.invokeSuspend(coroutines.kt:197)
    at com.intellij.openapi.progress.CoroutinesKt$blockingContext$2.invoke(coroutines.kt)
    at com.intellij.openapi.progress.CoroutinesKt$blockingContext$2.invoke(coroutines.kt)
    at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:78)
    at kotlinx.coroutines.CoroutineScopeKt.coroutineScope(CoroutineScope.kt:264)
    at com.intellij.openapi.progress.CoroutinesKt.blockingContext(coroutines.kt:196)
    at com.intellij.openapi.project.impl.ProjectManagerImplKt$runInitProjectActivities$3.invokeSuspend(ProjectManagerImpl.kt:1009)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
    at com.intellij.openapi.application.impl.DispatchedRunnable.run(DispatchedRunnable.kt:43)
    at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:209)
    at com.intellij.openapi.application.TransactionGuardImpl.access$100(TransactionGuardImpl.java:22)
    at com.intellij.openapi.application.TransactionGuardImpl$1.run(TransactionGuardImpl.java:191)
    at com.intellij.openapi.application.impl.RwLockHolder.runIntendedWriteActionOnCurrentThread(RwLockHolder.kt:204)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:830)
    at com.intellij.openapi.application.impl.ApplicationImpl$2.run(ApplicationImpl.java:419)
    at com.intellij.openapi.application.impl.RwLockHolder.runWithEnabledImplicitRead(RwLockHolder.kt:138)
    at com.intellij.openapi.application.impl.RwLockHolder.runWithImplicitRead(RwLockHolder.kt:129)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWithImplicitRead(ApplicationImpl.java:1152)
    at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:81)
    at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:123)
    at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:43)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:792)
    at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:739)
    at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:733)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:761)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.kt:698)
    at com.intellij.ide.IdeEventQueue._dispatchEvent$lambda$12(IdeEventQueue.kt:593)
    at com.intellij.openapi.application.impl.RwLockHolder.runWithoutImplicitRead(RwLockHolder.kt:105)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.kt:593)
    at com.intellij.ide.IdeEventQueue.access$_dispatchEvent(IdeEventQueue.kt:77)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:362)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:361)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:843)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:361)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:356)
    at com.intellij.ide.IdeEventQueueKt.performActivity$lambda$1(IdeEventQueue.kt:1021)
    at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:106)
    at com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:1021)
    at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$7(IdeEventQueue.kt:356)
    at com.intellij.openapi.application.impl.RwLockHolder.runIntendedWriteActionOnCurrentThread(RwLockHolder.kt:209)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:830)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:398)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)
zman0900 commented 7 months ago

After I installed the final 2024.1, it offered update to plugin 1.8.18. After updating, it show the same error as above. That 1.8.18 version seem very old based on the releases tagged here, but IntelliJ is not offering any further updates.

jborgers commented 7 months ago

There is an incompatibility with 2024.1 Intellij api. I use plugin version 1.8.28, which is also not working with 2024.1. Investigating.

veda-tschoening commented 7 months ago

Does it help to collect all of the different exceptions here? Because mine looks different:

Error instantiating a rule

java.lang.ClassNotFoundException: net.sourceforge.pmd.lang.java.rule.bestpractices.PrimitiveWrapperInstantiationRule PluginClassLoader(plugin=PluginDescriptor(name=PMDPlugin, id=PMDPlugin, descriptorPath=plugin.xml, path=~\AppData\Roaming\JetBrains\IntelliJIdea2024.1\plugins\PMD-Intellij, version=1.8.18, package=null, isBundled=false), packagePrefix=null, state=active)
    at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.kt:156)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
amitdev commented 7 months ago

Idea 2024.1 seems to have lot of changes - I've a simple fix that might work even though many API calls are deprecated. We probably need to fix those at some time and also support PMD 7.0 to keep this project alive

amitdev commented 7 months ago

The code changes are merged, but release is blocked by https://github.com/JetBrains/intellij-platform-gradle-plugin/issues/1255

amitdev commented 7 months ago

Was able to get a release out!