请问谁碰到过这个问题,能不能详细解释以下,多谢

解决方案 »

  1.   

    没有碰到过,但是从内容上看,可能是指static {
     .....
    }代码(clinit)过长??
      

  2.   

    public class a{
        static Hashtable hashtable = new Hashtable();
        static{
          这里我创建对象,然后放到hashtable里,这里代码特别长,如果,多了,就报上面的错误
        }
    }
      

  3.   

    应该只是单个 method(包括 clinit)有这个限制吧?一个 class 总的代码量应该是没有限制的。拆一下吧,拆成多个 method 就 OK 了  :>
      

  4.   

    class好象也有限制吧
    好象也不能太大吧
    最好不要写那么大的类或方法
    会出现莫名其妙的异常
      

  5.   

    测试了一下,没有这个限制!!!!static 和方法都没有!!
    你用的是哪个版本?
      

  6.   

    > 不会吧?难道我以前写的那些代码都没超过64K?单个 method 超过 64K 的情况应该不多吧?
      

  7.   

    > 测试了一下,没有这个限制!!!!static 和方法都没有!!
    > 你用的是哪个版本?hbwhwang 老兄怎么做的测试?咋跟我试验的结果不一样呢?~~我用的是 JDK 1.5.0-06,下面的程序就会报楼主说道那个编译错误:package test;public class HugeCode {    public static void main(String[] args) {
            int i=1;
            i = 2;
            i = 2;
            ……(重复 38528 次以上,因为每重复一次会使代码的 bytecode 增加两个字节)
        }
    }
      

  8.   

    找到出处了,hehe   ^_^http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html#9279
    这是 The Java Virtual Machine Specification里面有一句:
    The value of the code_length item must be less than 65536.
      

  9.   

    maquan('ma:kju) 
     多谢
      

  10.   

    4.8.1 Static Constraints
    The static constraints on a class file are those defining the well-formedness of the file. With the exception of the static constraints on the Java virtual machine code of the class file, these constraints have been given in the previous section. The static constraints on the Java virtual machine code in a class file specify how Java virtual machine instructions must be laid out in the code array and what the operands of individual instructions must be. The static constraints on the instructions in the code array are as follows:
    The code array must not be empty, so the code_length item cannot have the value 0. The value of the code_length item must be less than 65536.
      

  11.   

    我也遇到过这个问题,就是用tomcat编写的jsp頁面在webLogic下编译的时候,报 try{}catch{}块的大小不能大于64K,但在tomcat下可以通过,而且可以正常运行。有点困惑了,会不会JAVA虚拟机的问题?
      

  12.   

    > 我也遇到过这个问题,就是用tomcat编写的jsp頁面在webLogic下编译的时候,
    > 报 try{}catch{}块的大小不能大于64K,但在tomcat下可以通过,而且可以正
    > 常运行。有点困惑了,会不会JAVA虚拟机的问题?如果你的 WebLogic 也是运行在 Sun 的 JRE 下,那就不是 JVM 的问题了。不同的 Servlet container,对 JSP 的翻译是不一样的,看情形,应该是 WebLogic 翻译出来的 .java 比 Tomcat 翻译出来的 .java 要大一些(内容要多一些)。