Bad Magic Number 50

I've had great fun and success developing an IDEA plugin using the Community Edition on Mac OSX.  Now I'm ready to make it available to other folks in the development group, who are running Ultimate Edition.  I'm having no luck.

When the IU (Ultimate Edition) starts up it complains about a "bad magic number 50" (or somesuch) in my plugin. My plugin does not load.

I'm pretty sure that this is because the plugin was compiled with Java 6 and the Ultimate Edition runs using Java 5. No problem, thought I, I will just define my Community Edition plugin project to use Java 5. No luck.  I even pointed the Community Edition "IDEA SDK" to my Ultimate Edition. No luck.

For grins, I tried running IC Under Java 5 but it wouldn't even startup.

I don't understand why IC runs under Java 6 and IU runs under Java 5 (on the Mac at least).

I would like to know how to generate my plugin using Java 5 bytecode so I can make it run under Ultimate Edition.

Thanks
John Lindwall

4 comments
Comment actions Permalink

did you try setting the target compiler level to 5 ?

0
Comment actions Permalink

Yes, I do have the "Project language level" set to "5.0 - 'enum' keyword, autoboxing, etc."

It doesn't help my problem.

Thanks for the suggestion though. And just to be thorough, here is the actual exception I'm, getting:

Bad version number in .class file [Plugin: Template Variables]: Bad version number in .class file [Plugin: Template Variables]
com.intellij.diagnostic.PluginException: Bad version number in .class file [Plugin: Template Variables]
    at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentsRegistry.a(ComponentManagerImpl.java:31)
    at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentsRegistry.a(ComponentManagerImpl.java:62)
    at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentsRegistry.access$100(ComponentManagerImpl.java:10)
    at com.intellij.openapi.components.impl.ComponentManagerImpl.a(ComponentManagerImpl.java:36)
    at com.intellij.openapi.components.impl.ComponentManagerImpl.initComponents(ComponentManagerImpl.java:48)
    at com.intellij.openapi.components.impl.ComponentManagerImpl.init(ComponentManagerImpl.java:132)
    at com.intellij.openapi.project.impl.ProjectImpl.init(ProjectImpl.java:145)
    at com.intellij.openapi.project.impl.ProjectManagerImpl.a(ProjectManagerImpl.java:250)
    at com.intellij.openapi.project.impl.ProjectManagerImpl.a(ProjectManagerImpl.java:81)
    at com.intellij.openapi.project.impl.ProjectManagerImpl.access$200(ProjectManagerImpl.java:377)
    at com.intellij.openapi.project.impl.ProjectManagerImpl$6.run(ProjectManagerImpl.java:12)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$3.run(ProgressManagerImpl.java:3)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$TaskRunnable.run(ProgressManagerImpl.java:2)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$4.run(ProgressManagerImpl.java:3)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:5)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:32)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:6)
    at com.intellij.openapi.application.impl.ApplicationImpl$7$1.run(ApplicationImpl.java:2)
    at com.intellij.openapi.application.impl.ApplicationImpl$6.run(ApplicationImpl.java:2)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:417)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:269)
    at java.util.concurrent.FutureTask.run(FutureTask.java:123)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:651)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:676)
    at java.lang.Thread.run(Thread.java:613)
    at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:6)
Caused by: java.lang.UnsupportedClassVersionError: Bad version number in .class file
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:675)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:520)
    at com.intellij.util.lang.UrlClassLoader._defineClass(UrlClassLoader.java:119)
    at com.intellij.util.lang.UrlClassLoader.defineClass(UrlClassLoader.java:115)
    at com.intellij.util.lang.UrlClassLoader._findClass(UrlClassLoader.java:91)
    at com.intellij.ide.plugins.cl.PluginClassLoader.loadClassInsideSelf(PluginClassLoader.java:94)
    at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.java:57)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:242)
    at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentsRegistry.a(ComponentManagerImpl.java:44)

0
Comment actions Permalink

Thibault,

I finally realized you meant the -target option of javac!  I'm trying it now and still having an "bad version" issue though the stacktrace is different then before. I wonder if some of my dependent jars are Java 6 classes?  I'll check.

The .class files of my plug-in are all now version 49 (which means Java 5 AFAIK).  Thanks for the help ... I'm getting closer.

Here is the stacktrace I'm seeing now:

Bad version number in .class file: Bad version number in .class file
java.lang.UnsupportedClassVersionError: Bad version number in .class file
 at java.lang.ClassLoader.defineClass1(Native Method)
 at java.lang.ClassLoader.defineClass(ClassLoader.java:675)
 at java.lang.ClassLoader.defineClass(ClassLoader.java:520)
 at com.intellij.util.lang.UrlClassLoader._defineClass(UrlClassLoader.java:119)
 at com.intellij.util.lang.UrlClassLoader.defineClass(UrlClassLoader.java:115)
 at com.intellij.util.lang.UrlClassLoader._findClass(UrlClassLoader.java:91)
 at com.intellij.ide.plugins.cl.PluginClassLoader.loadClassInsideSelf(PluginClassLoader.java:94)
 at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.java:57)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
 at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374)
 at com.shopzilla.ideaplugin.templateVariables.ui.TemplateVariablesUI.<init>(TemplateVariablesUI.java:60)
 at com.shopzilla.ideaplugin.templateVariables.TemplateVariablesUIRegistrar$1$1.addNotify(TemplateVariablesUIRegistrar.java:40)
 at java.awt.Container.addNotify(Container.java:2544)
 at javax.swing.JComponent.addNotify(JComponent.java:4478)
 at java.awt.Container.addNotify(Container.java:2544)
 at javax.swing.JComponent.addNotify(JComponent.java:4478)
 at java.awt.Container.addNotify(Container.java:2544)
 at javax.swing.JComponent.addNotify(JComponent.java:4478)
 at java.awt.Container.addNotify(Container.java:2544)
 at javax.swing.JComponent.addNotify(JComponent.java:4478)
 at java.awt.Container.addNotify(Container.java:2544)
 at javax.swing.JComponent.addNotify(JComponent.java:4478)
 at java.awt.Container.addNotify(Container.java:2544)
 at javax.swing.JComponent.addNotify(JComponent.java:4478)
 at java.awt.Container.addNotify(Container.java:2544)
 at javax.swing.JComponent.addNotify(JComponent.java:4478)
 at java.awt.Container.addImpl(Container.java:1052)
 at java.awt.Container.add(Container.java:351)
 at com.intellij.openapi.ui.ThreeComponentsSplitter.setLastComponent(ThreeComponentsSplitter.java:334)
 at com.intellij.openapi.wm.impl.ToolWindowsPane.a(ToolWindowsPane.java:145)
 at com.intellij.openapi.wm.impl.ToolWindowsPane.access$400(ToolWindowsPane.java:139)
 at com.intellij.openapi.wm.impl.ToolWindowsPane$AddDockedComponentCmd.run(ToolWindowsPane.java:12)
 at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:3)
 at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
 at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
 at com.intellij.ide.IdeEventQueue.f(IdeEventQueue.java:96)
 at com.intellij.ide.IdeEventQueue.b(IdeEventQueue.java:254)
 at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:209)
 at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
 at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
 at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
 at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
 at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

0
Comment actions Permalink

Problem solved, thanks to Thibault's tip.

  • I had to set "-target 1.5" in the Compiler settings to force the generated classes of my plugin to be version 49.
  • I had to similarly recompile the source code of one of the jars in my plugin's lib dir to also force Java 1.5 class files.


Thanks,
John Lindwall

0

Please sign in to leave a comment.