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

ClassFormatError: "bad constant pool index" error with code that works in 1.1.x

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Not an Issue
    • Affects Version/s: 1.2.0
    • Fix Version/s: None
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
    • CPU:
      x86, sparc
    • OS:
      solaris_2, solaris_2.5.1, solaris_2.6, windows_nt

      Description

      I use an older version of jconnect (2.0 ?), I can compile and run the following
      simple program, however, when I use the same jconnect with JDK 1.2, I get
      the following runtime error:

      Initializing connection to jdbc:sybase:Tds:eusmilsyb.Ebay:6500
      Exception in thread "main" java.lang.ClassFormatError: com/sybase/tds/Tds (Local variable name has bad constant pool index)
              at java.lang.ClassLoader.defineClass0(Native Method)
              at java.lang.ClassLoader.defineClass(ClassLoader.java:337)
              at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:99)
              at java.net.URLClassLoader.defineClass(URLClassLoader.java:207)
              at java.net.URLClassLoader.findClass(URLClassLoader.java:154)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:193)
              at java.lang.Class.forName(Native Method)
              at com.sybase.jdbc.ProtocolManager.getProtocol(ProtocolManager.java)
              at com.sybase.jdbc.SybDriver.parseUrl(SybDriver.java)
              at com.sybase.jdbc.SybDriver.connect(SybDriver.java)
              at java.sql.DriverManager.getConnection(DriverManager.java:120)
              at BadConstantPoolIndex.initDB(BadConstantPoolIndex.java:41)
              at BadConstantPoolIndex.<init>(BadConstantPoolIndex.java:24)
              at BadConstantPoolIndex.main(BadConstantPoolIndex.java:93)

      If I use the newer version (3.0) this error does not occur. I submitted
      this bug becuase it may be of interest, and other users may have similar
      problems.

      To reproduce this, extract the attached file (jconnect.jar) and set
      CLASSPATH to:
      <where-ever>/jconnect.jar:.

      Here is the code:

      //
      import java.util.Properties;
      import java.sql.*;

      public class BadConstantPoolIndex {
          // Sybase JDBC driver package
        private static final String SybaseDriverString = "com.sybase.jdbc.SybDriver";

        private static final String DbUrl = "jdbc:sybase:Tds:eusmilsyb.Ebay:6500";
        private static final String DbUserName = "chamness";
        private static final String DbPassword = "chamness";

        private Properties LoginInfo;
        private Statement DbStatement;

      private boolean DebugFlag = true;

        public BadConstantPoolIndex() {
            // Initialize Licensee database.
            LoginInfo = new Properties();
            LoginInfo.put("user", DbUserName);
            LoginInfo.put("password", DbPassword);
            DbStatement = initDB( DbUrl, SybaseDriverString, LoginInfo);
        }

        private synchronized Statement initDB( String url, String driver,
      Properties loginInfo) {
            Connection con = null;
            Statement stmt = null;

            if (DebugFlag) {
                System.out.println("Initializing connection to " + url);
            }

            // Force the Sybase jdbc driver to be loaded
            try {
                Class.forName( SybaseDriverString);
             
                // Connect to the database at that URL.
                con = DriverManager.getConnection( url, loginInfo);
                stmt = con.createStatement();
            }
            catch(ClassNotFoundException e) {
                System.err.println("ClassNotFoundException: " + e.getMessage());
                System.err.println("The client was unable to load the Sybase JDBC drivers.");
                System.exit(0);
            }
            catch(SQLException e) {
                System.err.println("****************************************************************");
                System.err.println("* It would seem that the database is not up right now.");
                System.err.println("* The database URL was:" + url);
                System.err.println("* and the exception thrown was:");
                System.err.println("* SQLException: " + e.getMessage());
                System.err.println("* and here's the stack trace:");
                System.err.println("****************************************************************");
                e.printStackTrace();

                if (DebugFlag) {
                    System.out.println("Continuing... (Non-Debug mode would exit)");
                } else {
                    System.exit(0);
                }
            }

            if (DebugFlag) {
                System.out.println("Database connection successful.");
            }
            return stmt;
        }

          /**
           * Prints out SQL error information and stack trace diagnostics.
           * @param exception the SQLException.
           * @param sqlCommand the SQL command that was attempted.
           */
        protected void handleSqlError(SQLException exception, String sqlCommand) {
            System.out.println("Error while executing the following SQL statement:");
            System.out.println(sqlCommand);
            if (exception != null) {
      System.err.println("Exception: " + exception.getMessage());
            } else {
      System.err.println("Exception not thrown (was it an error?)");
            }
            System.err.println("DB URL: " + DbUrl);
            System.err.println("DB User: " + DbUserName);
            if (exception != null) {
      exception.printStackTrace();
            }
        }

        public static void main(String[] args) {
            BadConstantPoolIndex t = new BadConstantPoolIndex();
        }
      }

      dale.mcduffie@Eng 1998-05-06

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              apalanissunw Anand Palaniswamy (Inactive)
              Reporter:
              dmcduffisunw Dale Mcduffie (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: