5 Replies Latest reply on Dec 10, 2006 9:10 AM by wessan

    Illegal class modifiers

    wessan

      Hi,

      I'm getting java.lang.ClassFormatError: Illegal class modifiers in class test/app1/EmployeeImpl: 0x431

      This is probably caused by JDK 1.6 as I switched the JDK. I don't modify the modifiers of the class. Is this a known problem, or am I doing something wrong? Is there any solution?

        • 1. Re: Illegal class modifiers
          starksm64

          Full details of the issue are needed:
          http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossHelp

          • 2. Re: Illegal class modifiers
            wessan

            OK ... this is as much deatils as I can provide:

            This is an example exception thrown:

            Exception in thread "main" java.lang.ClassFormatError: Illegal class modifiers in class test/cz/solari/shards/example/app1/EmployeeImpl: 0x431
             at java.lang.ClassLoader.defineClass1(Native Method)
             at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
             at java.lang.ClassLoader.defineClass(ClassLoader.java:465)
             at cz.solari.shards.loader.Loader.findClass(Loader.java:136)
             at cz.solari.shards.loader.Loader.loadClass(Loader.java:70)
             at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
             at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
             at test.cz.solari.shards.source.DefaultSourceTest.main(DefaultSourceTest.java:23)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:597)


            It seems that the generated bytecode is incorrect. The code passed to defineClass method is generated using CtClass.toByteCode() method. The class may be altered (fields/methods may be added) by the custom ClassLoader however the class modifiers are never changed. It seems that Javassist doesn't throw any excetion during compilation, just the ClassLoader does.
            I tried it with both JDK 1.6 and JDK 1.5 with both of them the same exception is thrown.

            • 3. Re: Illegal class modifiers
              starksm64

              More than that is needed. An example of how to reproduce the problem in a jira issue is what is needed.

              http://jira.jboss.com/jira/browse/JASSIST

              • 4. Re: Illegal class modifiers
                wessan

                Ok ... I'll try extract a working example as soon as I'll have time ... I have tried removing final keyword from the class declaration and now it works. So I guess that the problem is caused by final keyword in the original class.

                • 5. Re: Illegal class modifiers
                  wessan

                  OK ... ignore the topic, I think I have already found the problem. I guess it's on my side afterall.