Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 46659 invoked from network); 3 Jul 2007 22:37:00 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Jul 2007 22:37:00 -0000 Received: (qmail 3957 invoked by uid 500); 3 Jul 2007 22:37:03 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 3896 invoked by uid 500); 3 Jul 2007 22:37:03 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 3885 invoked by uid 99); 3 Jul 2007 22:37:03 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Jul 2007 15:37:03 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Jul 2007 15:36:59 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 8F40D1A981D; Tue, 3 Jul 2007 15:36:39 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r553008 - in /db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/classfile: ClassHolder.java ClassInvestigator.java Date: Tue, 03 Jul 2007 22:36:39 -0000 To: derby-commits@db.apache.org From: djd@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070703223639.8F40D1A981D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: djd Date: Tue Jul 3 15:36:38 2007 New Revision: 553008 URL: http://svn.apache.org/viewvc?view=rev&rev=553008 Log: Allow the class holder code to support a different major/minor version if the class is read in. Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/classfile/ClassHolder.java db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/classfile/ClassInvestigator.java Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/classfile/ClassHolder.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/classfile/ClassHolder.java?view=diff&rev=553008&r1=553007&r2=553008 ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/classfile/ClassHolder.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/classfile/ClassHolder.java Tue Jul 3 15:36:38 2007 @@ -57,7 +57,26 @@ /* ** Fields */ - + + /** + * Minor class format number defaults to + * VMDescriptor.JAVA_CLASS_FORMAT_MINOR_VERSION + * which currently corresponds to a really old (JDK 1.0.2) setting. + * The default major and minor value is used by the generated code for Derby's + * SQL statements. Currently there is no need to bump the version + * number as the generated code does not take advantage of any of the + * new elements in the class file format. If such a need exists then + * this can be bumped. One issue is that the change in format numbers + * is not well documented. + */ + protected int minor_version = VMDescriptor.JAVA_CLASS_FORMAT_MINOR_VERSION; + + /** + * Minor class format number defaults to + * VMDescriptor.JAVA_CLASS_FORMAT_MAJOR_VERSION + */ + protected int major_version = VMDescriptor.JAVA_CLASS_FORMAT_MAJOR_VERSION; + protected int access_flags; protected int this_class; protected int super_class; @@ -118,8 +137,8 @@ /* Write out the header */ out.putU4(VMDescriptor.JAVA_CLASS_FORMAT_MAGIC); - out.putU2(VMDescriptor.JAVA_CLASS_FORMAT_MINOR_VERSION); - out.putU2(VMDescriptor.JAVA_CLASS_FORMAT_MAJOR_VERSION); + out.putU2(minor_version); + out.putU2(major_version); // special case checking that the number of constant // pool entries does not exceed the limit of 65535 Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/classfile/ClassInvestigator.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/classfile/ClassInvestigator.java?view=diff&rev=553008&r1=553007&r2=553008 ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/classfile/ClassInvestigator.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/classfile/ClassInvestigator.java Tue Jul 3 15:36:38 2007 @@ -49,12 +49,21 @@ ClassInput classInput = new ClassInput(is); // Check the header - checkHeader(classInput); + int magic = classInput.getU4(); + int minor_version = classInput.getU2(); + int major_version = classInput.getU2(); + + if (magic != VMDescriptor.JAVA_CLASS_FORMAT_MAGIC) + throw new ClassFormatError(); // Read in the Constant Pool int constantPoolCount = classInput.getU2(); ClassInvestigator ci = new ClassInvestigator(constantPoolCount); + + ci.minor_version = minor_version; + ci.major_version = major_version; + // Yes, index starts at 1, The '0'th constant pool entry // is reserved for the JVM and is not present in the class file. for (int i = 1; i < constantPoolCount; ) { @@ -451,25 +460,13 @@ CONSTANT_Utf8_info newCpe = new CONSTANT_Utf8_info(newName); cptHashTable.remove(cpe.getKey()); - cptHashTable.put(cpe.getKey(), cpe); + cptHashTable.put(newCpe.getKey(), newCpe); newCpe.index = index; cptEntries.setElementAt(newCpe, index); } - /* - ** - */ - static private void checkHeader(ClassInput in) throws IOException { - int magic = in.getU4(); - int minor_version = in.getU2(); - int major_version = in.getU2(); - - - if (magic != VMDescriptor.JAVA_CLASS_FORMAT_MAGIC) - throw new ClassFormatError(); - } private static ConstantPoolEntry getConstant(ClassInput in) throws IOException {