Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4309152

# Compiler silently generates bytecode that exceeds VM limits

XMLWordPrintable

    • 10
    • generic, x86, sparc
    • generic, linux, solaris_2.5, solaris_2.5.1, solaris_2.6, solaris_8, windows_95, windows_98, windows_nt, windows_2000, windows_xp
    • Verified

        The compiler does not properly enforce certain limits on the number or size
        of various classfile components. This results in code that appears to compile
        successfully, but fails at runtime during verification.

        These were originally reported as separate bugs, which have now been closed
        as duplicates of this one. The original bug numbers are included with each
        item below.

        1. The number of method arguments may not exceed 255. (4225910)
           JDK 1.2 and JDK 1.3. Can cause a compiler crash (4692666).

        2. This limit applies to constructor arguments as well. (4060622)
           JDK 1.1.3 and JDK 1.3.

        3. The number of constant pool entries is limited to 65535. (4185425)
           JDK 1.3 only.

        4. The number of dimensions in an array is limited to 255. (4067883)
           JDK 1.1.3. Causes compile-time crash in JDK 1.3, so bug remains open.

        5. The maximum size of the bytecodes for a method is 64k. (4204625)
           JDK 1.1.6 and JDK 1.3. Reported not present in JDK 1.2.

        6. There is a 64k limit on UTF-8 encoded strings. (4071592)

        There are numerous other limits described in JVMS 2e 4.10 which are most
        likely not being enforced by the compiler.

        william.maddox@Eng 2000-02-01

        I removed a completely unrelated program and stacktrace that has nothing
        whatsoever to do with this bug, filed by skT88420 on 02/02/2000, review
        ID: 100704.

        This bug is for the internal use of the compiler team, to consolidate
        reports of unchecked VM limits only. Please do not add additional items
        to it -- file separate bugs, and we will add a reference here if needed.

        william.maddox@Eng 2000-02-02


        Name: ks88420 Date: 09/11/2000


        /*

        An exception has occurred in the compiler (1.3.0rc2). Please file a bug at the J
        ava Developer Connection (http://java.sun.com/cgi-bin/bugreport.cgi). Include y
        our program and the following diagnostic in your report. Thank you.

        */
        import java.sql.*;
        import java.io.*;
        import javax.servlet.*;
        import javax.servlet.http.*;

        public class Display extends HttpServlet {
            Connection con;
            Statement st, st1, st2, st3;
            String
                strcategorycode, categorycode, jscategorycode, subcategorycode, scategorycode, code2;
            int inthidden, intcategorycode, h3, h2;
            public void init(ServletConfig config)
                throws ServletException
            {
                super.init(config);
            }
            public void service(HttpServletRequest req, HttpServletResponse res)
                throws
                         ServletException, IOException
            {
                res.setContentType("text/html");
                ServletOutputStream sos = res.getOutputStream();
                sos.print("<html><head><script language=\"javascript\">" +
                          "function click1()" +
                          "{ document.addcatform.h1.value=\"1\" " +
                          " }" +
                          "</script>" +
                          "</head><body bgcolor=lightblue><table width=\"100%\" align=\"center\" border=\"1\">");
                sos.print("<tr><th>Item Name</th></tr>");

                try
                {
                    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                    con = DriverManager.getConnection("jdbc:odbc:shopcart");
                    st1 = con.createStatement();

                    String tempcategorycode = req.getParameter("code");
                    String hidden1 = req.getParameter("h2");
                    jscategorycode = tempcategorycode;

                    System.out.println("hideen value:" + hidden1);
                    System.out.println("code:" + jscategorycode);

                    if (hidden1 != null)
                        h3 = Integer.parseInt(hidden1);
                    subcategorycode = tempcategorycode.substring(0, h3);

                    int h4 = h3;
                    System.out.println("h4" + h4);
                    String concatcategorycode = subcategorycode + "%";

                    System.out.println("scode:" + subcategorycode);
                    System.out.println("ccode:" + concatcategorycode);
                    ResultSet rs = st1.executeQuery("select * from CategoryMaster where categorycode like '" + concatcategorycode + "'");

                    while (rs.next())
                    {

                        h2 = h3 + 2;
                        code2 = rs.getString(1);
                        if (code2.equals(jscategorycode) == false)
                            sos.print("<tr><td><a href=\"http://localhost:8080/servlet/Display?code=" + code2 + "&h2=" + h2 + "\">" + rs.getString("categoryname") + "</a></td></tr>");
                    }
                    st2 = con.createStatement();
                    ResultSet rs1 = st2.executeQuery("select * from CategoryMaster where categorycode like '" + tempcategorycode + "'");

                    // rs1.next();
                    // String dcategorycode=rs1.getString(1);

                    rs1.last();
                    // for(int ccode=0;ccode<
                    String dcategorycode = rs1.getString(1);

                    System.out.println("catcode:" + dcategorycode);
                    System.out.println("h3:" + h3);
                    System.out.println("h2:" + h2);
                    // strcategorycode=code2.substring(h3,h2);
                    System.out.println("sat");
                    // st3=con.createStatement();
                    // ResultSet rs2=st3.executeQuery("select count(*) from
                    // CategoryMaster where categorycode like '"

                    // String sub1categorycode=dcategorycode.substring(0,h2-2);
                    // String sub2categorycode=dcategorycode.substring(h2,12);
                    // String
                    // concat1categorycode=sub1categorycode+"%"+sub2categorycode;

                    // System.out.println("strcategorycode :"+strcategorycode);
                    String js1 = req.getParameter("h1");

        // st3=con.createStatement("select * from CategoryMaster where categorycode
        // String str1categorycode=rs2.getString(1);
        // System.out.println("str1:"+str1categorycode);

                    if (js1 != null)
                    {
                        intcategorycode = Integer.parseInt(strcategorycode);
                        inthidden = Integer.parseInt(js1);
                    }
                    String incategoryname = req.getParameter("categoryname");

                    st = con.createStatement();
                    System.out.println("a1r");
                    if (inthidden == 1)
                    {
                        intcategorycode = intcategorycode + 1;
                        if (intcategorycode > 9)
                        {
                            scategorycode = subcategorycode + intcategorycode;
                        } else {
                            scategorycode = subcategorycode + "0" + intcategorycode;
                        }
                        System.out.println("scategorycode:" + scategorycode);
                        int lencategorycode = scategorycode.length();
                        System.out.println("lencategorycode" + lencategorycode);
                        for (int i = lencategorycode; i < 12; i = i + 1)
                        {
                            System.out.println("i:" + i);
                            categorycode = scategorycode + "0";
                            scategorycode = categorycode;
                        }
                        System.out.println("lencategorycode" + lencategorycode);
                        String s = "insert into CategoryMaster(categorycode,categoryname) values ('" + categorycode + "','" + incategoryname + "')";
                        System.out.println(s);
                        st.executeUpdate(s);
                    }
                    System.out.println("ar");
                    sos.print("</table>");
                    sos.print("<form onsubmit=\"click1()\" name=\"addcatform\" action=\"http://localhost:8080/servlet/Display\">" +
                              "<table><tr><td> Categoryname:<input type=\"text\" size=\"30\"name=\"categoryname\"></td></tr>" +
                              "<tr><td><input type=\"hidden\" value=\"0\" name=\"h1\"><inputtype=\"hidden\" value=\"2\" name=\"h2\">" +
                              "<input type=\"hidden\" name=\"code\" value=\"" + jscategorycode + "\"><td><tr>" +
                              "<tr><td> <input type=\"submit\" value=\"AddCategory\" name=\"AddCategory\" size=\"25\"></td></tr>" +
                              "</table></form></body></html>");
                }
                catch(Exception e)
                {
                    System.out.println(e);
                }
            }
        }
        /*
        An exception has occurred in the compiler (1.3.0rc2). Please file a bug at the J
        ava Developer Connection (http://java.sun.com/cgi-bin/bugreport.cgi). Include y
        our program and the following diagnostic in your report. Thank you.
        java.lang.ClassFormatError: com/sun/tools/javac/v8/comp/Flow (Illegal constant p
        ool index)
                at java.lang.ClassLoader.defineClass0(Native Method)
                at java.lang.ClassLoader.defineClass(ClassLoader.java:486)
                at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:11
        1)
                at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
                at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
                at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
                at java.security.AccessController.doPrivileged(Native Method)
                at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
                at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
                at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
                at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
                at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
                at com.sun.tools.javac.v8.JavaCompiler.compile(JavaCompiler.java:380)
                at com.sun.tools.javac.v8.Main.compile(Main.java:247)
                at com.sun.tools.javac.Main.main(Main.java:16)
        */
        (Review ID: 109480)
        ======================================================================

        raghunath.verabelli - 09/20/2001.

        One of our Licensees (Sybase Inc) reported a program which compiles fine with 1.3, 1.3.1, 1.4-beta releases, but fails during the runtime with "Illegal constant pool type" error. However, with 1.2.2 the bug manifests itself as a compile-time bug rather than a runtime bug. They are encountering the error because they are hitting the hard limit on the length of a string constant.
        I believe it should be caught during the compilation phase rather than runtime.

        java SplashImage
        Exception in thread "main" java.lang.ClassFormatError: SplashImage
        (Illegal constant pool type)
        at java.lang.ClassLoader.defineClass0(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$100(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)

        Attached is SplashImage.java file.
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)


              gafter Neal Gafter
              wmaddoxsunw William Maddox (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: