4 Replies Latest reply on Oct 7, 2004 3:17 AM by ymruan

    Can Javassist control class file's version?

    ymruan


      Hi,
      When I use javassist to transfers class files,I met this problem.When source class files' version is upper to 1.4. the target classes can not be invoked in an applet(JRE 1.4). Get a class.FormatError(extra bytes).
      When I change the class version info by myself.(eg. form CAFE BABE 0000 002E... to CAFE BABE 0003 002D... )This problem is not existed.(Because JRE1.4's profilers).
      So How can I control the output class file's version?Thanks!


        • 1. Re: Can Javassist control class file's version?
          ymruan

           

          The classes are not complied by myself!the version info in class files is 0000 002E .


          0000 002E means that the version of the class file is 46.0.
          JDK 1.4 or older compilers use the version 45.x format.
          So my guess is that class file might be compiled by JDK 1.5.

          However, I am not sure if this solution would
          bring any potential troubles.


          I don't think so (at least) unless you use JDK1.5 syntax.

          Chiba

          • 2. Re: Can Javassist control class file's version?
            chiba

            What is your compiler? javac of JDK1.5?
            JRE 1.4 might refuse a class file generated
            by 1.5 compiler.

            • 3. Re: Can Javassist control class file's version?
              ymruan

              Hi professor,
              The classes are not complied by myself!the version info in class files is 0000 002E .
              The problem can be resolved simply by manually revising the version code. However, I am not sure if this solution would
              bring any potential troubles. For instance, is there any differnce in class format for different versions?

              • 4. Re: Can Javassist control class file's version?
                chiba

                 

                The classes are not complied by myself!the version info in class files is 0000 002E .


                0000 002E means that the version of the class file is 46.0.
                JDK 1.4 or older compilers use the version 45.x format.
                So my guess is that class file might be compiled by JDK 1.5.

                However, I am not sure if this solution would
                bring any potential troubles.


                I don't think so (at least) unless you use JDK1.5 syntax.

                Chiba