This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit c18a8e7671199d612089c935d8b4757bd2db4171
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Nov 28 10:39:39 2022 +0000

    Update to Commons BCEL 6.7.0-RC1
---
 MERGE.txt                                          |   2 +-
 java/org/apache/tomcat/util/bcel/Const.java        | 214 ++++++++++++---------
 .../bcel/classfile/AnnotationElementValue.java     |  45 ++---
 .../util/bcel/classfile/AnnotationEntry.java       |  45 +++--
 .../tomcat/util/bcel/classfile/Annotations.java    |  33 ++--
 .../util/bcel/classfile/ArrayElementValue.java     |  44 ++---
 .../util/bcel/classfile/ClassElementValue.java     |  35 ++--
 .../util/bcel/classfile/ClassFormatException.java  |  64 ++++--
 .../tomcat/util/bcel/classfile/ClassParser.java    | 137 +++++++------
 .../tomcat/util/bcel/classfile/Constant.java       | 136 +++++++------
 .../tomcat/util/bcel/classfile/ConstantClass.java  |  28 ++-
 .../tomcat/util/bcel/classfile/ConstantDouble.java |  31 ++-
 .../tomcat/util/bcel/classfile/ConstantFloat.java  |  31 ++-
 .../util/bcel/classfile/ConstantInteger.java       |  31 ++-
 .../tomcat/util/bcel/classfile/ConstantLong.java   |  37 ++--
 .../tomcat/util/bcel/classfile/ConstantPool.java   | 145 +++++++++-----
 .../tomcat/util/bcel/classfile/ConstantUtf8.java   |  58 +++---
 .../tomcat/util/bcel/classfile/ElementValue.java   | 194 ++++++++++++-------
 .../util/bcel/classfile/ElementValuePair.java      |  37 ++--
 .../util/bcel/classfile/EnumElementValue.java      |  38 ++--
 .../tomcat/util/bcel/classfile/JavaClass.java      |  72 ++++---
 .../util/bcel/classfile/SimpleElementValue.java    |  70 +++----
 .../apache/tomcat/util/bcel/classfile/Utility.java |  32 +--
 webapps/docs/changelog.xml                         |   4 +
 24 files changed, 833 insertions(+), 730 deletions(-)

diff --git a/MERGE.txt b/MERGE.txt
index 4d7b5de0c8..89c8ebc774 100644
--- a/MERGE.txt
+++ b/MERGE.txt
@@ -36,7 +36,7 @@ BCEL
 Sub-tree:
 src/main/java/org/apache/bcel
 The SHA1 ID / tag for the most recent commit to be merged to Tomcat is:
-40d5eb4eda290c74b533f389fbc4e3495a4513f6 (2021-09-01)
+b015e90257850e810e57d1244664300f50de4a4c (2022-11-28)
 
 Codec
 -----
diff --git a/java/org/apache/tomcat/util/bcel/Const.java 
b/java/org/apache/tomcat/util/bcel/Const.java
index ad19386963..301ace69dc 100644
--- a/java/org/apache/tomcat/util/bcel/Const.java
+++ b/java/org/apache/tomcat/util/bcel/Const.java
@@ -6,14 +6,13 @@
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
  *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 package org.apache.tomcat.util.bcel;
 
@@ -22,169 +21,212 @@ package org.apache.tomcat.util.bcel;
  */
 public final class Const {
 
-    /** One of the access flags for fields, methods, or classes.
-     *  @see <a 
href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.1-200-E.1";>
-     *  Flag definitions for Classes in the Java Virtual Machine Specification 
(Java SE 9 Edition).</a>
-     *  @see <a 
href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.5";>
-     *  Flag definitions for Fields in the Java Virtual Machine Specification 
(Java SE 9 Edition).</a>
-     *  @see <a 
href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.6";>
-     *  Flag definitions for Methods in the Java Virtual Machine Specification 
(Java SE 9 Edition).</a>
-     *  @see <a 
href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.6-300-D.1-D.1";>
-     *  Flag definitions for Inner Classes in the Java Virtual Machine 
Specification (Java SE 9 Edition).</a>
+    /**
+     * Java class file format Magic number (0xCAFEBABE)
+     *
+     * @see <a 
href="https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.1-200-A";>
 The ClassFile Structure
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final int JVM_CLASSFILE_MAGIC = 0xCAFEBABE;
+
+    /**
+     * One of the access flags for fields, methods, or classes.
+     *
+     * @see <a 
href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.1-200-E.1";>
 Flag definitions for
+     *      Classes in the Java Virtual Machine Specification (Java SE 9 
Edition).</a>
+     * @see <a 
href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.5";> 
Flag definitions for Fields
+     *      in the Java Virtual Machine Specification (Java SE 9 Edition).</a>
+     * @see <a 
href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.6";> 
Flag definitions for Methods
+     *      in the Java Virtual Machine Specification (Java SE 9 Edition).</a>
+     * @see <a 
href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.6-300-D.1-D.1";>
 Flag
+     *      definitions for Inner Classes in the Java Virtual Machine 
Specification (Java SE 9 Edition).</a>
      */
     public static final short ACC_FINAL      = 0x0010;
 
-    /** One of the access flags for fields, methods, or classes.
+    /**
+     * One of the access flags for fields, methods, or classes.
+     *
+     * @see #ACC_FINAL
      */
     public static final short ACC_INTERFACE    = 0x0200;
 
-    /** One of the access flags for fields, methods, or classes.
+    /**
+     * One of the access flags for fields, methods, or classes.
+     *
+     * @see #ACC_FINAL
      */
     public static final short ACC_ABSTRACT     = 0x0400;
 
-    /** One of the access flags for fields, methods, or classes.
+    /**
+     * One of the access flags for fields, methods, or classes.
+     *
+     * @see #ACC_FINAL
      */
     public static final short ACC_ANNOTATION   = 0x2000;
 
     /**
      * Marks a constant pool entry as type UTF-8.
-     * @see  <a 
href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.7";>
-     * The Constant Pool in The Java Virtual Machine Specification</a>
+     *
+     * @see <a 
href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.7";>
 The Constant Pool in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final byte CONSTANT_Utf8 = 1;
+
+    /*
+     * The description of the constant pool is at: 
https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4
+     * References below are to the individual sections
      */
-    public static final byte CONSTANT_Utf8               = 1;
 
     /**
      * Marks a constant pool entry as type Integer.
-     * @see  <a 
href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.4";>
-     * The Constant Pool in The Java Virtual Machine Specification</a>
+     *
+     * @see <a 
href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.4";>
 The Constant Pool in The
+     *      Java Virtual Machine Specification</a>
      */
-    public static final byte CONSTANT_Integer            = 3;
+    public static final byte CONSTANT_Integer = 3;
 
     /**
      * Marks a constant pool entry as type Float.
-     * @see  <a 
href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.4";>
-     * The Constant Pool in The Java Virtual Machine Specification</a>
+     *
+     * @see <a 
href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.4";>
 The Constant Pool in The
+     *      Java Virtual Machine Specification</a>
      */
-    public static final byte CONSTANT_Float              = 4;
+    public static final byte CONSTANT_Float = 4;
 
     /**
      * Marks a constant pool entry as type Long.
-     * @see  <a 
href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.5";>
-     * The Constant Pool in The Java Virtual Machine Specification</a>
+     *
+     * @see <a 
href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.5";>
 The Constant Pool in The
+     *      Java Virtual Machine Specification</a>
      */
-    public static final byte CONSTANT_Long               = 5;
+    public static final byte CONSTANT_Long = 5;
 
     /**
      * Marks a constant pool entry as type Double.
-     * @see  <a 
href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.5";>
-     * The Constant Pool in The Java Virtual Machine Specification</a>
+     *
+     * @see <a 
href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.5";>
 The Constant Pool in The
+     *      Java Virtual Machine Specification</a>
      */
-    public static final byte CONSTANT_Double             = 6;
+    public static final byte CONSTANT_Double = 6;
 
     /**
      * Marks a constant pool entry as a Class
-     * @see  <a 
href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.1";>
-     * The Constant Pool in The Java Virtual Machine Specification</a>
+     *
+     * @see <a 
href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.1";>
 The Constant Pool in The
+     *      Java Virtual Machine Specification</a>
      */
-    public static final byte CONSTANT_Class              = 7;
+    public static final byte CONSTANT_Class = 7;
 
     /**
-     * Marks a constant pool entry as type String
-     * @see  <a 
href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.3";>
-     * The Constant Pool in The Java Virtual Machine Specification</a>
+     * Marks a constant pool entry as a Field Reference.
+     *
+     * @see <a 
href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.2";>
 The Constant Pool in The
+     *      Java Virtual Machine Specification</a>
      */
-    public static final byte CONSTANT_String             = 8;
+    public static final byte CONSTANT_Fieldref = 9;
 
     /**
-     * Marks a constant pool entry as a Field Reference.
-     * @see  <a 
href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.2";>
-     * The Constant Pool in The Java Virtual Machine Specification</a>
+     * Marks a constant pool entry as type String
+     *
+     * @see <a 
href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.3";>
 The Constant Pool in The
+     *      Java Virtual Machine Specification</a>
      */
-    public static final byte CONSTANT_Fieldref           = 9;
+    public static final byte CONSTANT_String = 8;
 
     /**
      * Marks a constant pool entry as a Method Reference.
-     * @see  <a 
href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.2";>
-     * The Constant Pool in The Java Virtual Machine Specification</a>
+     *
+     * @see <a 
href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.2";>
 The Constant Pool in The
+     *      Java Virtual Machine Specification</a>
      */
-    public static final byte CONSTANT_Methodref          = 10;
+    public static final byte CONSTANT_Methodref = 10;
 
     /**
      * Marks a constant pool entry as an Interface Method Reference.
-     * @see  <a 
href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.2";>
-     * The Constant Pool in The Java Virtual Machine Specification</a>
+     *
+     * @see <a 
href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.2";>
 The Constant Pool in The
+     *      Java Virtual Machine Specification</a>
      */
     public static final byte CONSTANT_InterfaceMethodref = 11;
 
     /**
      * Marks a constant pool entry as a name and type.
-     * @see  <a 
href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.6";>
-     * The Constant Pool in The Java Virtual Machine Specification</a>
+     *
+     * @see <a 
href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.6";>
 The Constant Pool in The
+     *      Java Virtual Machine Specification</a>
      */
-    public static final byte CONSTANT_NameAndType        = 12;
+    public static final byte CONSTANT_NameAndType = 12;
 
     /**
      * Marks a constant pool entry as a Method Handle.
-     * @see  <a 
href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.8";>
-     * The Constant Pool in The Java Virtual Machine Specification</a>
+     *
+     * @see <a 
href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.8";>
 The Constant Pool in The
+     *      Java Virtual Machine Specification</a>
      */
-    public static final byte CONSTANT_MethodHandle       = 15;
+    public static final byte CONSTANT_MethodHandle = 15;
 
     /**
      * Marks a constant pool entry as a Method Type.
-     * @see  <a 
href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.9";>
-     * The Constant Pool in The Java Virtual Machine Specification</a>
+     *
+     * @see <a 
href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.9";>
 The Constant Pool in The
+     *      Java Virtual Machine Specification</a>
      */
-    public static final byte CONSTANT_MethodType         = 16;
+    public static final byte CONSTANT_MethodType = 16;
 
     /**
      * Marks a constant pool entry as dynamically computed.
-     * @see  <a 
href="https://bugs.openjdk.java.net/secure/attachment/74618/constant-dynamic.html";>
-     * Change request for JEP 309</a>
+     *
+     * @see <a 
href="https://bugs.openjdk.java.net/secure/attachment/74618/constant-dynamic.html";>
 Change request for JEP
+     *      309</a>
      */
-    public static final byte CONSTANT_Dynamic            = 17;
+    public static final byte CONSTANT_Dynamic = 17;
 
     /**
      * Marks a constant pool entry as an Invoke Dynamic
-     * @see  <a 
href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.10";>
-     * The Constant Pool in The Java Virtual Machine Specification</a>
+     *
+     * @see <a 
href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.10";>
 The Constant Pool in The
+     *      Java Virtual Machine Specification</a>
      */
-    public static final byte CONSTANT_InvokeDynamic      = 18;
+    public static final byte CONSTANT_InvokeDynamic = 18;
 
     /**
      * Marks a constant pool entry as a Module Reference.
      *
-     * <p>Note: Early access Java 9 support- currently subject to change</p>
-     *
-     * @see <a 
href="https://cr.openjdk.java.net/~mr/jigsaw/spec/lang-vm.html#jigsaw-2.6";>
-     * JPMS: Modules in the Java Language and JVM</a>
+     * @see <a 
href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.4.11";>
 The Constant Pool in The
+     *      Java Virtual Machine Specification</a>
      */
-    public static final byte CONSTANT_Module             = 19;
+    public static final byte CONSTANT_Module = 19;
 
     /**
      * Marks a constant pool entry as a Package Reference.
      *
-     * <p>Note: Early access Java 9 support- currently subject to change</p>
-     *
-     * @see <a 
href="https://cr.openjdk.java.net/~mr/jigsaw/spec/lang-vm.html#jigsaw-2.6";>
-     * JPMS: Modules in the Java Language and JVM</a>
+     * @see <a 
href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.4.12";>
 The Constant Pool in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final byte CONSTANT_Package = 20;
+
+    /**
+     * The names of the types of entries in a constant pool. Use 
getConstantName instead
      */
-    public static final byte CONSTANT_Package            = 20;
+    private static final String[] CONSTANT_NAMES = {"", "CONSTANT_Utf8", "", 
"CONSTANT_Integer", "CONSTANT_Float", "CONSTANT_Long", "CONSTANT_Double",
+            "CONSTANT_Class", "CONSTANT_String", "CONSTANT_Fieldref", 
"CONSTANT_Methodref", "CONSTANT_InterfaceMethodref", "CONSTANT_NameAndType", 
"", "",
+            "CONSTANT_MethodHandle", "CONSTANT_MethodType", 
"CONSTANT_Dynamic", "CONSTANT_InvokeDynamic", "CONSTANT_Module", 
"CONSTANT_Package"};
 
     /**
-     * The names of the types of entries in a constant pool.
-     * Use getConstantName instead
+     * The maximum number of dimensions in an array ({@value}). One of the 
limitations of the Java Virtual Machine.
+     *
+     * @see <a 
href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.3.2-150";>
 Field Descriptors in
+     *      The Java Virtual Machine Specification</a>
      */
-    private static final String[] CONSTANT_NAMES = {
-    "", "CONSTANT_Utf8", "", "CONSTANT_Integer",
-    "CONSTANT_Float", "CONSTANT_Long", "CONSTANT_Double",
-    "CONSTANT_Class", "CONSTANT_String", "CONSTANT_Fieldref",
-    "CONSTANT_Methodref", "CONSTANT_InterfaceMethodref",
-    "CONSTANT_NameAndType", "", "", "CONSTANT_MethodHandle",
-    "CONSTANT_MethodType", "CONSTANT_Dynamic", "CONSTANT_InvokeDynamic",
-    "CONSTANT_Module", "CONSTANT_Package"};
+    public static final int MAX_ARRAY_DIMENSIONS = 255;
 
-    public static String getConstantName(int index) {
+    /**
+     * Get the CONSTANT_NAMES entry at the given index.
+     *
+     * @param index The index for which the constant name is required
+     * @return the CONSTANT_NAMES entry at the given index
+     */
+    public static String getConstantName(final int index) {
         return CONSTANT_NAMES[index];
     }
 }
diff --git 
a/java/org/apache/tomcat/util/bcel/classfile/AnnotationElementValue.java 
b/java/org/apache/tomcat/util/bcel/classfile/AnnotationElementValue.java
index 3c43a5774b..db09a573d6 100644
--- a/java/org/apache/tomcat/util/bcel/classfile/AnnotationElementValue.java
+++ b/java/org/apache/tomcat/util/bcel/classfile/AnnotationElementValue.java
@@ -1,46 +1,39 @@
 /*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 package org.apache.tomcat.util.bcel.classfile;
 
-public class AnnotationElementValue extends ElementValue
-{
+public class AnnotationElementValue extends ElementValue {
     // For annotation element values, this is the annotation
     private final AnnotationEntry annotationEntry;
 
-    AnnotationElementValue(final int type, final AnnotationEntry 
annotationEntry,
-            final ConstantPool cpool)
-    {
+    AnnotationElementValue(final int type, final AnnotationEntry 
annotationEntry, final ConstantPool cpool) {
         super(type, cpool);
         if (type != ANNOTATION) {
-            throw new IllegalArgumentException(
-                    "Only element values of type annotation can be built with 
this ctor - type specified: " + type);
+            throw new ClassFormatException("Only element values of type 
annotation can be built with this ctor - type specified: " + type);
         }
         this.annotationEntry = annotationEntry;
     }
 
-    @Override
-    public String stringifyValue()
-    {
-        return annotationEntry.toString();
+    public AnnotationEntry getAnnotationEntry() {
+        return annotationEntry;
     }
 
-    public AnnotationEntry getAnnotationEntry()
-    {
-        return annotationEntry;
+    @Override
+    public String stringifyValue() {
+        return annotationEntry.toString();
     }
 }
diff --git a/java/org/apache/tomcat/util/bcel/classfile/AnnotationEntry.java 
b/java/org/apache/tomcat/util/bcel/classfile/AnnotationEntry.java
index f4fb7e97a2..52e6a6206b 100644
--- a/java/org/apache/tomcat/util/bcel/classfile/AnnotationEntry.java
+++ b/java/org/apache/tomcat/util/bcel/classfile/AnnotationEntry.java
@@ -1,19 +1,18 @@
 /*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 package org.apache.tomcat.util.bcel.classfile;
 
@@ -22,17 +21,18 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.tomcat.util.bcel.Const;
-
 /**
- * represents one annotation in the annotation table
+ * Represents one annotation in the annotation table
  */
 public class AnnotationEntry {
 
+    static final AnnotationEntry[] EMPTY_ARRAY = {};
+
     private final int typeIndex;
+
     private final ConstantPool constantPool;
 
-    private final List<ElementValuePair> element_value_pairs;
+    private final List<ElementValuePair> elementValuePairs;
 
     /*
      * Creates an AnnotationEntry from a DataInputStream
@@ -46,11 +46,11 @@ public class AnnotationEntry {
         this.constantPool = constantPool;
 
         typeIndex = input.readUnsignedShort();
-        final int num_element_value_pairs = input.readUnsignedShort();
+        final int numElementValuePairs = input.readUnsignedShort();
 
-        element_value_pairs = new ArrayList<>(num_element_value_pairs);
-        for (int i = 0; i < num_element_value_pairs; i++) {
-            element_value_pairs.add(new ElementValuePair(input, constantPool));
+        elementValuePairs = new ArrayList<>(numElementValuePairs);
+        for (int i = 0; i < numElementValuePairs; i++) {
+            elementValuePairs.add(new ElementValuePair(input, constantPool));
         }
     }
 
@@ -58,14 +58,13 @@ public class AnnotationEntry {
      * @return the annotation type name
      */
     public String getAnnotationType() {
-        final ConstantUtf8 c = (ConstantUtf8) 
constantPool.getConstant(typeIndex, Const.CONSTANT_Utf8);
-        return c.getBytes();
+        return constantPool.getConstantUtf8(typeIndex).getBytes();
     }
 
     /**
      * @return the element value pairs in this annotation entry
      */
     public List<ElementValuePair> getElementValuePairs() {
-        return element_value_pairs;
+        return elementValuePairs;
     }
 }
diff --git a/java/org/apache/tomcat/util/bcel/classfile/Annotations.java 
b/java/org/apache/tomcat/util/bcel/classfile/Annotations.java
index 60cb253a44..c7d197f841 100644
--- a/java/org/apache/tomcat/util/bcel/classfile/Annotations.java
+++ b/java/org/apache/tomcat/util/bcel/classfile/Annotations.java
@@ -1,19 +1,18 @@
 /*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 package org.apache.tomcat.util.bcel.classfile;
 
@@ -25,6 +24,8 @@ import java.io.IOException;
  */
 public class Annotations {
 
+    static final Annotations[] EMPTY_ARRAY = {};
+
     private final AnnotationEntry[] annotationTable;
 
     /**
@@ -32,15 +33,17 @@ public class Annotations {
      * @param constantPool Array of constants
      */
     Annotations(final DataInput input, final ConstantPool constantPool) throws 
IOException {
-        final int annotation_table_length = input.readUnsignedShort();
-        annotationTable = new AnnotationEntry[annotation_table_length];
-        for (int i = 0; i < annotation_table_length; i++) {
+        final int annotationTableLength = input.readUnsignedShort();
+        annotationTable = new AnnotationEntry[annotationTableLength];
+        for (int i = 0; i < annotationTableLength; i++) {
             annotationTable[i] = new AnnotationEntry(input, constantPool);
         }
     }
 
 
     /**
+     * Gets the array of annotation entries in this annotation
+     *
      * @return the array of annotation entries in this annotation
      */
     public AnnotationEntry[] getAnnotationEntries() {
diff --git a/java/org/apache/tomcat/util/bcel/classfile/ArrayElementValue.java 
b/java/org/apache/tomcat/util/bcel/classfile/ArrayElementValue.java
index 8377707d27..48a3644729 100644
--- a/java/org/apache/tomcat/util/bcel/classfile/ArrayElementValue.java
+++ b/java/org/apache/tomcat/util/bcel/classfile/ArrayElementValue.java
@@ -1,19 +1,18 @@
 /*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 package org.apache.tomcat.util.bcel.classfile;
 
@@ -22,23 +21,23 @@ public class ArrayElementValue extends ElementValue
     // For array types, this is the array
     private final ElementValue[] elementValues;
 
-    ArrayElementValue(final int type, final ElementValue[] datums, final 
ConstantPool cpool)
-    {
+    ArrayElementValue(final int type, final ElementValue[] datums, final 
ConstantPool cpool) {
         super(type, cpool);
         if (type != ARRAY) {
-            throw new IllegalArgumentException(
-                    "Only element values of type array can be built with this 
ctor - type specified: " + type);
+            throw new ClassFormatException("Only element values of type array 
can be built with this ctor - type specified: " + type);
         }
         this.elementValues = datums;
     }
 
+    public ElementValue[] getElementValuesArray() {
+        return elementValues;
+    }
+
     @Override
-    public String stringifyValue()
-    {
+    public String stringifyValue() {
         final StringBuilder sb = new StringBuilder();
         sb.append('[');
-        for (int i = 0; i < elementValues.length; i++)
-        {
+        for (int i = 0; i < elementValues.length; i++) {
             sb.append(elementValues[i].stringifyValue());
             if (i + 1 < elementValues.length) {
                 sb.append(',');
@@ -47,9 +46,4 @@ public class ArrayElementValue extends ElementValue
         sb.append(']');
         return sb.toString();
     }
-
-    public ElementValue[] getElementValuesArray()
-    {
-        return elementValues;
-    }
 }
diff --git a/java/org/apache/tomcat/util/bcel/classfile/ClassElementValue.java 
b/java/org/apache/tomcat/util/bcel/classfile/ClassElementValue.java
index 10fa589f7a..0c6b21abbc 100644
--- a/java/org/apache/tomcat/util/bcel/classfile/ClassElementValue.java
+++ b/java/org/apache/tomcat/util/bcel/classfile/ClassElementValue.java
@@ -1,26 +1,22 @@
 /*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 package org.apache.tomcat.util.bcel.classfile;
 
-import org.apache.tomcat.util.bcel.Const;
-
-public class ClassElementValue extends ElementValue
-{
+public class ClassElementValue extends ElementValue {
     // For primitive types and string type, this points to the value entry in
     // the cpool
     // For 'class' this points to the class entry in the cpool
@@ -33,10 +29,7 @@ public class ClassElementValue extends ElementValue
 
 
     @Override
-    public String stringifyValue()
-    {
-        final ConstantUtf8 cu8 = (ConstantUtf8) 
super.getConstantPool().getConstant(idx,
-                Const.CONSTANT_Utf8);
-        return cu8.getBytes();
+    public String stringifyValue() {
+        return super.getConstantPool().getConstantUtf8(idx).getBytes();
     }
 }
diff --git 
a/java/org/apache/tomcat/util/bcel/classfile/ClassFormatException.java 
b/java/org/apache/tomcat/util/bcel/classfile/ClassFormatException.java
index f841735361..1701ae6345 100644
--- a/java/org/apache/tomcat/util/bcel/classfile/ClassFormatException.java
+++ b/java/org/apache/tomcat/util/bcel/classfile/ClassFormatException.java
@@ -1,36 +1,66 @@
 /*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 package org.apache.tomcat.util.bcel.classfile;
 
 /**
- * Thrown when the BCEL attempts to read a class file and determines
- * that the file is malformed or otherwise cannot be interpreted as a
- * class file.
+ * Thrown when the BCEL attempts to read a class file and determines that a 
class is malformed or otherwise cannot be interpreted as a class file.
  */
 public class ClassFormatException extends RuntimeException {
 
     private static final long serialVersionUID = 3243149520175287759L;
 
+    /**
+     * Constructs a new instance with {@code null} as its detail message. The 
cause is not initialized, and may subsequently be initialized by a call to
+     * {@link #initCause}.
+     */
     public ClassFormatException() {
     }
 
+    /**
+     * Constructs a new instance with the specified detail message. The cause 
is not initialized, and may subsequently be initialized by a call to
+     * {@link #initCause}.
+     *
+     * @param message the detail message. The detail message is saved for 
later retrieval by the {@link #getMessage()} method.
+     */
+    public ClassFormatException(final String message) {
+        super(message);
+    }
+
+    /**
+     * Constructs a new instance with the specified detail message and cause.
+     * <p>
+     * Note that the detail message associated with {@code cause} is 
<i>not</i> automatically incorporated in this runtime exception's detail 
message.
+     *
+     * @param message the detail message (which is saved for later retrieval 
by the {@link #getMessage()} method).
+     * @param cause   the cause (which is saved for later retrieval by the 
{@link #getCause()} method). (A {@code null} value is permitted, and indicates 
that
+     *                the cause is nonexistent or unknown.)
+     */
+    public ClassFormatException(final String message, final Throwable cause) {
+        super(message, cause);
+    }
 
-    public ClassFormatException(final String s) {
-        super(s);
+    /**
+     * Constructs a new instance with the specified cause and a detail message 
of {@code (cause==null ? null : cause.toString())} (which typically contains the
+     * class and detail message of {@code cause}). This constructor is useful 
for runtime exceptions that are little more than wrappers for other throwables.
+     *
+     * @param cause the cause (which is saved for later retrieval by the 
{@link #getCause()} method). (A {@code null} value is permitted, and indicates 
that the
+     *              cause is nonexistent or unknown.)
+     */
+    public ClassFormatException(final Throwable cause) {
+        super(cause);
     }
 }
diff --git a/java/org/apache/tomcat/util/bcel/classfile/ClassParser.java 
b/java/org/apache/tomcat/util/bcel/classfile/ClassParser.java
index 90fb145428..8783fe9233 100644
--- a/java/org/apache/tomcat/util/bcel/classfile/ClassParser.java
+++ b/java/org/apache/tomcat/util/bcel/classfile/ClassParser.java
@@ -1,19 +1,18 @@
 /*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 package org.apache.tomcat.util.bcel.classfile;
 
@@ -28,31 +27,27 @@ import java.util.List;
 import org.apache.tomcat.util.bcel.Const;
 
 /**
- * Wrapper class that parses a given Java .class file. The method <A
- * href ="#parse">parse</A> returns a <A href ="JavaClass.html">
- * JavaClass</A> object on success. When an I/O error or an
- * inconsistency occurs an appropriate exception is propagated back to
- * the caller.
+ * Wrapper class that parses a given Java .class file. The method <a href 
="#parse">parse</a> returns a
+ * <a href ="JavaClass.html"> JavaClass</a> object on success. When an I/O 
error or an inconsistency occurs an
+ * appropriate exception is propagated back to the caller.
  *
- * The structure and the names comply, except for a few conveniences,
- * exactly with the <A href="http://docs.oracle.com/javase/specs/";>
- * JVM specification 1.0</a>. See this paper for
- * further details about the structure of a bytecode file.
+ * The structure and the names comply, except for a few conveniences, exactly 
with the
+ * <a href="http://docs.oracle.com/javase/specs/";> JVM specification 1.0</a>. 
See this paper for further details about
+ * the structure of a bytecode file.
  */
 public final class ClassParser {
 
-    private static final int MAGIC = 0xCAFEBABE;
-
+    private static final int BUFSIZE = 8192;
     private final DataInput dataInputStream;
-    private String class_name, superclassName;
+    private String className;
+    private String superclassName;
     private int accessFlags; // Access rights of parsed class
     private String[] interfaceNames; // Names of implemented interfaces
     private ConstantPool constantPool; // collection of constants
     private Annotations runtimeVisibleAnnotations; // 
"RuntimeVisibleAnnotations" attribute defined in the class
     private List<Annotations> runtimeVisibleFieldOrMethodAnnotations; // 
"RuntimeVisibleAnnotations" attribute defined elsewhere
-    private static final int BUFSIZE = 8192;
 
-    private static final String[] INTERFACES_EMPTY_ARRAY = new String[0];
+    private static final String[] INTERFACES_EMPTY_ARRAY = {};
 
     /**
      * Parses class from the given stream.
@@ -65,15 +60,13 @@ public final class ClassParser {
 
 
     /**
-     * Parses the given Java class file and return an object that represents
-     * the contained data, i.e., constants, methods, fields and commands.
-     * A <em>ClassFormatException</em> is raised, if the file is not a valid
-     * .class file. (This does not include verification of the byte code as it
-     * is performed by the java interpreter).
+     * Parses the given Java class file and return an object that represents 
the contained data, i.e., constants, methods,
+     * fields and commands. A <em>ClassFormatException</em> is raised, if the 
file is not a valid .class file. (This does
+     * not include verification of the byte code as it is performed by the 
java interpreter).
      *
      * @return Class object representing the parsed class file
-     * @throws  IOException If an I/O occurs reading the byte code
-     * @throws  ClassFormatException If the byte code is invalid
+     * @throws IOException if an I/O error occurs.
+     * @throws ClassFormatException if a class is malformed or cannot be 
interpreted as a class file
      */
     public JavaClass parse() throws IOException, ClassFormatException {
         /****************** Read headers ********************************/
@@ -97,8 +90,7 @@ public final class ClassParser {
         readAttributes(false);
 
         // Return the information we have gathered in a new object
-        return new JavaClass(class_name, superclassName,
-                accessFlags, constantPool, interfaceNames,
+        return new JavaClass(className, superclassName, accessFlags, 
constantPool, interfaceNames,
                 runtimeVisibleAnnotations, 
runtimeVisibleFieldOrMethodAnnotations);
     }
 
@@ -106,12 +98,12 @@ public final class ClassParser {
     /**
      * Reads information about the attributes of the class.
      * @param fieldOrMethod false if processing a class
-     * @throws  IOException if an I/O occurs reading the the .class file
-     * @throws  ClassFormatException If the .class file is not valid
+     * @throws IOException if an I/O error occurs.
+     * @throws ClassFormatException if a class is malformed or cannot be 
interpreted as a class file
      */
     private void readAttributes(boolean fieldOrMethod) throws IOException, 
ClassFormatException {
-        final int attributes_count = dataInputStream.readUnsignedShort();
-        for (int i = 0; i < attributes_count; i++) {
+        final int attributesCount = dataInputStream.readUnsignedShort();
+        for (int i = 0; i < attributesCount; i++) {
             ConstantUtf8 c;
             String name;
             int name_index;
@@ -147,24 +139,24 @@ public final class ClassParser {
 
     /**
      * Reads information about the class and its super class.
-     * @throws  IOException if an I/O occurs reading the the .class file
-     * @throws  ClassFormatException If the .class file is not valid
+     *
+     * @throws IOException if an I/O error occurs.
+     * @throws ClassFormatException if a class is malformed or cannot be 
interpreted as a class file
      */
     private void readClassInfo() throws IOException, ClassFormatException {
         accessFlags = dataInputStream.readUnsignedShort();
-        /* Interfaces are implicitly abstract, the flag should be set
-         * according to the JVM specification.
+        /*
+         * Interfaces are implicitly abstract, the flag should be set 
according to the JVM specification.
          */
         if ((accessFlags & Const.ACC_INTERFACE) != 0) {
             accessFlags |= Const.ACC_ABSTRACT;
         }
-        if ((accessFlags & Const.ACC_ABSTRACT) != 0
-                && (accessFlags & Const.ACC_FINAL) != 0) {
+        if ((accessFlags & Const.ACC_ABSTRACT) != 0 && (accessFlags & 
Const.ACC_FINAL) != 0) {
             throw new ClassFormatException("Class can't be both final and 
abstract");
         }
 
-        int class_name_index = dataInputStream.readUnsignedShort();
-        class_name = Utility.getClassName(constantPool, class_name_index);
+        int classNameIndex = dataInputStream.readUnsignedShort();
+        className = Utility.getClassName(constantPool, classNameIndex);
 
         int superclass_name_index = dataInputStream.readUnsignedShort();
         if (superclass_name_index > 0) {
@@ -178,8 +170,9 @@ public final class ClassParser {
 
     /**
      * Reads constant pool entries.
-     * @throws  IOException if an I/O occurs reading the the .class file
-     * @throws  ClassFormatException If the .class file is not valid
+     *
+     * @throws IOException if an I/O error occurs.
+     * @throws ClassFormatException if a class is malformed or cannot be 
interpreted as a class file
      */
     private void readConstantPool() throws IOException, ClassFormatException {
         constantPool = new ConstantPool(dataInputStream);
@@ -188,12 +181,13 @@ public final class ClassParser {
 
     /**
      * Reads information about the fields of the class, i.e., its variables.
-     * @throws  IOException if an I/O occurs reading the the .class file
-     * @throws  ClassFormatException If the .class file is not valid
+     *
+     * @throws IOException if an I/O error occurs.
+     * @throws ClassFormatException if a class is malformed or cannot be 
interpreted as a class file
      */
     private void readFields() throws IOException, ClassFormatException {
-        final int fields_count = dataInputStream.readUnsignedShort();
-        for (int i = 0; i < fields_count; i++) {
+        final int fieldsCount = dataInputStream.readUnsignedShort();
+        for (int i = 0; i < fieldsCount; i++) {
             // file.readUnsignedShort(); // Unused access flags
             // file.readUnsignedShort(); // name index
             // file.readUnsignedShort(); // signature index
@@ -206,13 +200,13 @@ public final class ClassParser {
 
     /******************** Private utility methods **********************/
     /**
-     * Checks whether the header of the file is ok.
-     * Of course, this has to be the first action on successive file reads.
-     * @throws  IOException if an I/O occurs reading the the .class file
-     * @throws  ClassFormatException If the .class file is not valid
+     * Checks whether the header of the file is ok. Of course, this has to be 
the first action on successive file reads.
+     *
+     * @throws IOException if an I/O error occurs.
+     * @throws ClassFormatException if a class is malformed or cannot be 
interpreted as a class file
      */
     private void readID() throws IOException, ClassFormatException {
-        if (dataInputStream.readInt() != MAGIC) {
+        if (dataInputStream.readInt() != Const.JVM_CLASSFILE_MAGIC) {
             throw new ClassFormatException("It is not a Java .class file");
         }
     }
@@ -220,14 +214,15 @@ public final class ClassParser {
 
     /**
      * Reads information about the interfaces implemented by this class.
-     * @throws  IOException if an I/O occurs reading the the .class file
-     * @throws  ClassFormatException If the .class file is not valid
+     *
+     * @throws IOException if an I/O error occurs.
+     * @throws ClassFormatException if a class is malformed or cannot be 
interpreted as a class file
      */
     private void readInterfaces() throws IOException, ClassFormatException {
-        final int interfaces_count = dataInputStream.readUnsignedShort();
-        if (interfaces_count > 0) {
-            interfaceNames = new String[interfaces_count];
-            for (int i = 0; i < interfaces_count; i++) {
+        final int interfacesCount = dataInputStream.readUnsignedShort();
+        if (interfacesCount > 0) {
+            interfaceNames = new String[interfacesCount];
+            for (int i = 0; i < interfacesCount; i++) {
                 int index = dataInputStream.readUnsignedShort();
                 interfaceNames[i] = Utility.getClassName(constantPool, index);
             }
@@ -239,12 +234,13 @@ public final class ClassParser {
 
     /**
      * Reads information about the methods of the class.
-     * @throws  IOException if an I/O occurs reading the the .class file
-     * @throws  ClassFormatException If the .class file is not valid
+     *
+     * @throws IOException if an I/O error occurs.
+     * @throws ClassFormatException if a class is malformed or cannot be 
interpreted as a class file
      */
     private void readMethods() throws IOException, ClassFormatException {
-        final int methods_count = dataInputStream.readUnsignedShort();
-        for (int i = 0; i < methods_count; i++) {
+        final int methodsCount = dataInputStream.readUnsignedShort();
+        for (int i = 0; i < methodsCount; i++) {
             // file.readUnsignedShort(); // Unused access flags
             // file.readUnsignedShort(); // name index
             // file.readUnsignedShort(); // signature index
@@ -257,8 +253,9 @@ public final class ClassParser {
 
     /**
      * Reads major and minor version of compiler which created the file.
-     * @throws  IOException if an I/O occurs reading the the .class file
-     * @throws  ClassFormatException If the .class file is not valid
+     *
+     * @throws IOException if an I/O error occurs.
+     * @throws ClassFormatException if a class is malformed or cannot be 
interpreted as a class file
      */
     private void readVersion() throws IOException, ClassFormatException {
         // file.readUnsignedShort(); // Unused minor
diff --git a/java/org/apache/tomcat/util/bcel/classfile/Constant.java 
b/java/org/apache/tomcat/util/bcel/classfile/Constant.java
index fd39e62e7a..875c1d83e0 100644
--- a/java/org/apache/tomcat/util/bcel/classfile/Constant.java
+++ b/java/org/apache/tomcat/util/bcel/classfile/Constant.java
@@ -1,19 +1,18 @@
 /*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 package org.apache.tomcat.util.bcel.classfile;
 
@@ -23,38 +22,13 @@ import java.io.IOException;
 import org.apache.tomcat.util.bcel.Const;
 
 /**
- * Abstract superclass for classes to represent the different constant types
- * in the constant pool of a class file. The classes keep closely to
- * the JVM specification.
- *
- * @author  <A HREF="mailto:m.d...@gmx.de";>M. Dahm</A>
+ * Abstract superclass for classes to represent the different constant types 
in the constant pool of a class file. The
+ * classes keep closely to the JVM specification.
  */
 public abstract class Constant {
 
-    /* In fact this tag is redundant since we can distinguish different
-     * `Constant' objects by their type, i.e., via `instanceof'. In some
-     * places we will use the tag for switch()es anyway.
-     *
-     * First, we want match the specification as closely as possible. Second we
-     * need the tag as an index to select the corresponding class name from the
-     * `CONSTANT_NAMES' array.
-     */
-    protected final byte tag;
-
-    Constant(final byte tag) {
-        this.tag = tag;
-    }
-
-    /**
-     * @return Tag of constant, i.e., its type. No setTag() method to avoid
-     * confusion.
-     */
-    public final byte getTag() {
-        return tag;
-    }
-
     /**
-     * Read one constant from the given input, the type depends on a tag byte.
+     * Reads one constant from the given input, the type depends on a tag byte.
      *
      * @param dataInput Input stream
      * @return Constant object
@@ -65,42 +39,62 @@ public abstract class Constant {
         final byte b = dataInput.readByte(); // Read tag byte
         int skipSize;
         switch (b) {
-            case Const.CONSTANT_Class:
-                return new ConstantClass(dataInput);
-            case Const.CONSTANT_Integer:
-                return new ConstantInteger(dataInput);
-            case Const.CONSTANT_Float:
-                return new ConstantFloat(dataInput);
-            case Const.CONSTANT_Long:
-                return new ConstantLong(dataInput);
-            case Const.CONSTANT_Double:
-                return new ConstantDouble(dataInput);
-            case Const.CONSTANT_Utf8:
-                return ConstantUtf8.getInstance(dataInput);
-            case Const.CONSTANT_String:
-            case Const.CONSTANT_MethodType:
-            case Const.CONSTANT_Module:
-            case Const.CONSTANT_Package:
-                skipSize = 2; // unsigned short
-                break;
-            case Const.CONSTANT_MethodHandle:
-                skipSize = 3; // unsigned byte, unsigned short
-                break;
-            case Const.CONSTANT_Fieldref:
-            case Const.CONSTANT_Methodref:
-            case Const.CONSTANT_InterfaceMethodref:
-            case Const.CONSTANT_NameAndType:
-            case Const.CONSTANT_Dynamic:
-            case Const.CONSTANT_InvokeDynamic:
-                skipSize = 4; // unsigned short, unsigned short
-                break;
-            default:
-                throw new ClassFormatException("Invalid byte tag in constant 
pool: " + b);
+        case Const.CONSTANT_Class:
+            return new ConstantClass(dataInput);
+        case Const.CONSTANT_Integer:
+            return new ConstantInteger(dataInput);
+        case Const.CONSTANT_Float:
+            return new ConstantFloat(dataInput);
+        case Const.CONSTANT_Long:
+            return new ConstantLong(dataInput);
+        case Const.CONSTANT_Double:
+            return new ConstantDouble(dataInput);
+        case Const.CONSTANT_Utf8:
+            return ConstantUtf8.getInstance(dataInput);
+        case Const.CONSTANT_String:
+        case Const.CONSTANT_MethodType:
+        case Const.CONSTANT_Module:
+        case Const.CONSTANT_Package:
+            skipSize = 2; // unsigned short
+            break;
+        case Const.CONSTANT_MethodHandle:
+            skipSize = 3; // unsigned byte, unsigned short
+            break;
+        case Const.CONSTANT_Fieldref:
+        case Const.CONSTANT_Methodref:
+        case Const.CONSTANT_InterfaceMethodref:
+        case Const.CONSTANT_NameAndType:
+        case Const.CONSTANT_Dynamic:
+        case Const.CONSTANT_InvokeDynamic:
+            skipSize = 4; // unsigned short, unsigned short
+            break;
+        default:
+            throw new ClassFormatException("Invalid byte tag in constant pool: 
" + b);
         }
         Utility.skipFully(dataInput, skipSize);
         return null;
     }
 
+    /*
+     * In fact this tag is redundant since we can distinguish different 
'Constant' objects by their type, i.e., via
+     * 'instanceof'. In some places we will use the tag for switch()es anyway.
+     *
+     * First, we want match the specification as closely as possible. Second 
we need the tag as an index to select the
+     * corresponding class name from the 'CONSTANT_NAMES' array.
+     */
+    private final byte tag;
+
+    Constant(final byte tag) {
+        this.tag = tag;
+    }
+
+    /**
+     * @return Tag of constant, i.e., its type. No setTag() method to avoid 
confusion.
+     */
+    public final byte getTag() {
+        return tag;
+    }
+
     @Override
     public String toString() {
         return "[" + tag + "]";
diff --git a/java/org/apache/tomcat/util/bcel/classfile/ConstantClass.java 
b/java/org/apache/tomcat/util/bcel/classfile/ConstantClass.java
index bc0a8614c4..9f62473294 100644
--- a/java/org/apache/tomcat/util/bcel/classfile/ConstantClass.java
+++ b/java/org/apache/tomcat/util/bcel/classfile/ConstantClass.java
@@ -1,19 +1,18 @@
 /*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 package org.apache.tomcat.util.bcel.classfile;
 
@@ -23,10 +22,9 @@ import java.io.IOException;
 import org.apache.tomcat.util.bcel.Const;
 
 /**
- * This class is derived from the abstract {@link Constant}
- * and represents a reference to a (external) class.
+ * This class is derived from the abstract {@link Constant} and represents a 
reference to a (external) class.
  *
- * @see     Constant
+ * @see Constant
  */
 public final class ConstantClass extends Constant {
 
diff --git a/java/org/apache/tomcat/util/bcel/classfile/ConstantDouble.java 
b/java/org/apache/tomcat/util/bcel/classfile/ConstantDouble.java
index 1c69a764e3..4641526c7e 100644
--- a/java/org/apache/tomcat/util/bcel/classfile/ConstantDouble.java
+++ b/java/org/apache/tomcat/util/bcel/classfile/ConstantDouble.java
@@ -1,19 +1,18 @@
 /*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 package org.apache.tomcat.util.bcel.classfile;
 
@@ -23,10 +22,9 @@ import java.io.IOException;
 import org.apache.tomcat.util.bcel.Const;
 
 /**
- * This class is derived from the abstract  {@link Constant}
- * and represents a reference to a Double object.
+ * This class is derived from the abstract {@link Constant} and represents a 
reference to a Double object.
  *
- * @see     Constant
+ * @see Constant
  */
 public final class ConstantDouble extends Constant {
 
@@ -37,8 +35,7 @@ public final class ConstantDouble extends Constant {
      * Initialize instance from file data.
      *
      * @param file Input stream
-     * @throws IOException If an I/O occurs reading from the provided
-     *         InoutStream
+     * @throws IOException if an I/O error occurs.
      */
     ConstantDouble(final DataInput file) throws IOException {
         super(Const.CONSTANT_Double);
diff --git a/java/org/apache/tomcat/util/bcel/classfile/ConstantFloat.java 
b/java/org/apache/tomcat/util/bcel/classfile/ConstantFloat.java
index 4a699b6837..69bfffdcb5 100644
--- a/java/org/apache/tomcat/util/bcel/classfile/ConstantFloat.java
+++ b/java/org/apache/tomcat/util/bcel/classfile/ConstantFloat.java
@@ -1,19 +1,18 @@
 /*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 package org.apache.tomcat.util.bcel.classfile;
 
@@ -23,10 +22,9 @@ import java.io.IOException;
 import org.apache.tomcat.util.bcel.Const;
 
 /**
- * This class is derived from the abstract {@link Constant}
- * and represents a reference to a float object.
+ * This class is derived from the abstract {@link Constant} and represents a 
reference to a float object.
  *
- * @see     Constant
+ * @see Constant
  */
 public final class ConstantFloat extends Constant {
 
@@ -37,8 +35,7 @@ public final class ConstantFloat extends Constant {
      * Initialize instance from file data.
      *
      * @param file Input stream
-     * @throws IOException If an I/O occurs reading from the provided
-     *         InoutStream
+     * @throws IOException if an I/O error occurs.
      */
     ConstantFloat(final DataInput file) throws IOException {
         super(Const.CONSTANT_Float);
diff --git a/java/org/apache/tomcat/util/bcel/classfile/ConstantInteger.java 
b/java/org/apache/tomcat/util/bcel/classfile/ConstantInteger.java
index c2960ac078..f3c4d2dde4 100644
--- a/java/org/apache/tomcat/util/bcel/classfile/ConstantInteger.java
+++ b/java/org/apache/tomcat/util/bcel/classfile/ConstantInteger.java
@@ -1,19 +1,18 @@
 /*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 package org.apache.tomcat.util.bcel.classfile;
 
@@ -23,10 +22,9 @@ import java.io.IOException;
 import org.apache.tomcat.util.bcel.Const;
 
 /**
- * This class is derived from the abstract {@link Constant}
- * and represents a reference to an int object.
+ * This class is derived from the abstract {@link Constant} and represents a 
reference to an int object.
  *
- * @see     Constant
+ * @see Constant
  */
 public final class ConstantInteger extends Constant {
 
@@ -37,8 +35,7 @@ public final class ConstantInteger extends Constant {
      * Initialize instance from file data.
      *
      * @param file Input stream
-     * @throws IOException If an I/O occurs reading from the provided
-     *         InoutStream
+     * @throws IOException if an I/O error occurs.
      */
     ConstantInteger(final DataInput file) throws IOException {
         super(Const.CONSTANT_Integer);
diff --git a/java/org/apache/tomcat/util/bcel/classfile/ConstantLong.java 
b/java/org/apache/tomcat/util/bcel/classfile/ConstantLong.java
index b6dc2c0f0d..6d0d609c0c 100644
--- a/java/org/apache/tomcat/util/bcel/classfile/ConstantLong.java
+++ b/java/org/apache/tomcat/util/bcel/classfile/ConstantLong.java
@@ -1,19 +1,18 @@
 /*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 package org.apache.tomcat.util.bcel.classfile;
 
@@ -23,10 +22,9 @@ import java.io.IOException;
 import org.apache.tomcat.util.bcel.Const;
 
 /**
- * This class is derived from the abstract {@link Constant}
- * and represents a reference to a long object.
+ * This class is derived from the abstract {@link Constant} and represents a 
reference to a long object.
  *
- * @see     Constant
+ * @see Constant
  */
 public final class ConstantLong extends Constant {
 
@@ -36,13 +34,12 @@ public final class ConstantLong extends Constant {
     /**
      * Initialize instance from file data.
      *
-     * @param input Input stream
-     * @throws IOException If an I/O occurs reading from the provided
-     *         InoutStream
+     * @param file Input stream
+     * @throws IOException if an I/O error occurs.
      */
-    ConstantLong(final DataInput input) throws IOException {
+    ConstantLong(final DataInput file) throws IOException {
         super(Const.CONSTANT_Long);
-        this.bytes = input.readLong();
+        this.bytes = file.readLong();
     }
 
 
diff --git a/java/org/apache/tomcat/util/bcel/classfile/ConstantPool.java 
b/java/org/apache/tomcat/util/bcel/classfile/ConstantPool.java
index ac36aa15b6..468314f097 100644
--- a/java/org/apache/tomcat/util/bcel/classfile/ConstantPool.java
+++ b/java/org/apache/tomcat/util/bcel/classfile/ConstantPool.java
@@ -1,19 +1,18 @@
 /*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 package org.apache.tomcat.util.bcel.classfile;
 
@@ -23,14 +22,11 @@ import java.io.IOException;
 import org.apache.tomcat.util.bcel.Const;
 
 /**
- * This class represents the constant pool, i.e., a table of constants, of
- * a parsed classfile. It may contain null references, due to the JVM
- * specification that skips an entry after an 8-byte constant (double,
- * long) entry.  Those interested in generating constant pools
- * programmatically should see <a href="../generic/ConstantPoolGen.html">
- * ConstantPoolGen</a>.
-
- * @see     Constant
+ * This class represents the constant pool, i.e., a table of constants, of a 
parsed classfile. It may contain null references, due to the JVM specification 
that
+ * skips an entry after an 8-byte constant (double, long) entry. Those 
interested in generating constant pools programmatically should see
+ * <a href="../generic/ConstantPoolGen.html"> ConstantPoolGen</a>.
+ *
+ * @see Constant
  */
 public class ConstantPool {
 
@@ -40,21 +36,20 @@ public class ConstantPool {
      * Reads constants from given input stream.
      *
      * @param input Input stream
-     * @throws  IOException if an I/O occurs reading the the InputStream
+     * @throws IOException if an I/O error occurs reading the the InputStream
      * @throws  ClassFormatException If the .class file is not valid
      */
     ConstantPool(final DataInput input) throws IOException, 
ClassFormatException {
-        final int constant_pool_count = input.readUnsignedShort();
-        constantPool = new Constant[constant_pool_count];
-        /* constantPool[0] is unused by the compiler and may be used freely
-         * by the implementation.
+        final int constantPoolCount = input.readUnsignedShort();
+        constantPool = new Constant[constantPoolCount];
+        /*
+         * constantPool[0] is unused by the compiler and may be used freely by 
the implementation.
          */
-        for (int i = 1; i < constant_pool_count; i++) {
+        for (int i = 1; i < constantPoolCount; i++) {
             constantPool[i] = Constant.readConstant(input);
-            /* Quote from the JVM specification:
-             * "All eight byte constants take up two spots in the constant 
pool.
-             * If this is the n'th byte in the constant pool, then the next 
item
-             * will be numbered n+2"
+            /*
+             * Quote from the JVM specification: "All eight byte constants 
take up two spots in the constant pool. If this is the n'th byte in the constant
+             * pool, then the next item will be numbered n+2"
              *
              * Thus we have to increment the index counter.
              */
@@ -70,38 +65,86 @@ public class ConstantPool {
     /**
      * Gets constant from constant pool.
      *
-     * @param  index Index in constant pool
+     * @param <T> A {@link Constant} subclass
+     * @param index Index in constant pool
      * @return Constant value
-     * @see    Constant
+     * @see Constant
+     * @throws ClassFormatException if index is invalid
      */
-    public Constant getConstant( final int index ) {
-        if (index >= constantPool.length || index < 0) {
-            throw new ClassFormatException("Invalid constant pool reference: " 
+ index
-                    + ". Constant pool size is: " + constantPool.length);
+    @SuppressWarnings("unchecked")
+    public <T extends Constant> T getConstant(final int index) throws 
ClassFormatException {
+        return (T) getConstant(index, Constant.class);
+    }
+
+    /**
+     * Gets constant from constant pool and check whether it has the expected 
type.
+     *
+     * @param <T> A {@link Constant} subclass
+     * @param index Index in constant pool
+     * @param tag   Tag of expected constant, i.e., its type
+     * @return Constant value
+     * @see Constant
+     * @throws ClassFormatException if constant type does not match tag
+     */
+    public <T extends Constant> T getConstant(final int index, final byte tag) 
throws ClassFormatException {
+        final T c = getConstant(index);
+        if (c.getTag() != tag) {
+            throw new ClassFormatException("Expected class '" + 
Const.getConstantName(tag) + "' at index " + index + " and got " + c);
         }
-        return constantPool[index];
+        return c;
     }
 
     /**
-     * Gets constant from constant pool and check whether it has the
-     * expected type.
+     * Gets constant from constant pool.
      *
-     * @param  index Index in constant pool
-     * @param  tag Tag of expected constant, i.e., its type
+     * @param <T> A {@link Constant} subclass
+     * @param index Index in constant pool
+     * @param castTo The {@link Constant} subclass to cast to.
      * @return Constant value
-     * @see    Constant
-     * @throws  ClassFormatException If the constant is not of the expected 
type
+     * @see Constant
+     * @throws ClassFormatException if index is invalid
      */
-    public Constant getConstant( final int index, final byte tag ) throws 
ClassFormatException {
-        Constant c;
-        c = getConstant(index);
-        if (c == null) {
-            throw new ClassFormatException("Constant pool at index " + index + 
" is null.");
+    public <T extends Constant> T getConstant(final int index, final Class<T> 
castTo) throws ClassFormatException {
+        if (index >= constantPool.length || index < 0) {
+            throw new ClassFormatException("Invalid constant pool reference 
using index: " + index + ". Constant pool size is: " + constantPool.length);
         }
-        if (c.getTag() != tag) {
-            throw new ClassFormatException("Expected class `" + 
Const.getConstantName(tag)
-                    + "' at index " + index + " and got " + c);
+        if (constantPool[index] != null && 
!castTo.isAssignableFrom(constantPool[index].getClass())) {
+            throw new ClassFormatException("Invalid constant pool reference at 
index: " + index +
+                    ". Expected " + castTo + " but was " + 
constantPool[index].getClass());
+        }
+        // Previous check ensures this won't throw a ClassCastException
+        final T c = castTo.cast(constantPool[index]);
+        // the 0th element is always null
+        if (c == null && index != 0) {
+            final Constant prev = constantPool[index - 1];
+            if (prev == null || prev.getTag() != Const.CONSTANT_Double && 
prev.getTag() != Const.CONSTANT_Long) {
+                throw new ClassFormatException("Constant pool at index " + 
index + " is null.");
+            }
         }
         return c;
     }
+
+    /**
+     * Gets constant from constant pool and check whether it has the expected 
type.
+     *
+     * @param index Index in constant pool
+     * @return ConstantInteger value
+     * @see ConstantInteger
+     * @throws ClassFormatException if constant type does not match tag
+     */
+    public ConstantInteger getConstantInteger(final int index) {
+        return getConstant(index, Const.CONSTANT_Integer);
+    }
+
+    /**
+     * Gets constant from constant pool and check whether it has the expected 
type.
+     *
+     * @param index Index in constant pool
+     * @return ConstantUtf8 value
+     * @see ConstantUtf8
+     * @throws ClassFormatException if constant type does not match tag
+     */
+    public ConstantUtf8 getConstantUtf8(final int index) throws 
ClassFormatException {
+        return getConstant(index, Const.CONSTANT_Utf8);
+    }
 }
diff --git a/java/org/apache/tomcat/util/bcel/classfile/ConstantUtf8.java 
b/java/org/apache/tomcat/util/bcel/classfile/ConstantUtf8.java
index 0e2e9650dd..0656931d67 100644
--- a/java/org/apache/tomcat/util/bcel/classfile/ConstantUtf8.java
+++ b/java/org/apache/tomcat/util/bcel/classfile/ConstantUtf8.java
@@ -1,56 +1,62 @@
 /*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 package org.apache.tomcat.util.bcel.classfile;
 
 import java.io.DataInput;
 import java.io.IOException;
+import java.util.Objects;
 
 import org.apache.tomcat.util.bcel.Const;
 
 /**
- * This class is derived from the abstract
- * <A HREF="org.apache.tomcat.util.bcel.classfile.Constant.html">Constant</A> 
class
- * and represents a reference to a Utf8 encoded string.
+ * Extends the abstract {@link Constant} to represent a reference to a UTF-8 
encoded string.
  *
- * @see     Constant
+ * @see Constant
  */
 public final class ConstantUtf8 extends Constant {
 
-    private final String bytes;
-
-    static ConstantUtf8 getInstance(final DataInput input) throws IOException {
-        return new ConstantUtf8(input.readUTF());
+    /**
+     * Gets a new or cached instance of the given value.
+     * <p>
+     * See {@link ConstantUtf8} class Javadoc for details.
+     * </p>
+     *
+     * @param dataInput the value.
+     * @return a new or cached instance of the given value.
+     * @throws IOException if an I/O error occurs.
+     */
+    static ConstantUtf8 getInstance(final DataInput dataInput) throws 
IOException {
+        return new ConstantUtf8(dataInput.readUTF());
     }
 
+    private final String value;
+
     /**
-     * @param bytes Data
+     * @param value Data
      */
-    private ConstantUtf8(final String bytes) {
+    private ConstantUtf8(final String value) {
         super(Const.CONSTANT_Utf8);
-        if (bytes == null) {
-            throw new IllegalArgumentException("bytes must not be null!");
-        }
-        this.bytes = bytes;
+        this.value = Objects.requireNonNull(value, "value");
     }
 
     /**
      * @return Data converted to string.
      */
     public final String getBytes() {
-        return bytes;
+        return value;
     }
 }
diff --git a/java/org/apache/tomcat/util/bcel/classfile/ElementValue.java 
b/java/org/apache/tomcat/util/bcel/classfile/ElementValue.java
index e9dd30df5f..c0a421a840 100644
--- a/java/org/apache/tomcat/util/bcel/classfile/ElementValue.java
+++ b/java/org/apache/tomcat/util/bcel/classfile/ElementValue.java
@@ -1,94 +1,144 @@
 /*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 package org.apache.tomcat.util.bcel.classfile;
 
 import java.io.DataInput;
 import java.io.IOException;
 
-public abstract class ElementValue
-{
-    private final int type;
+import org.apache.tomcat.util.bcel.Const;
 
-    private final ConstantPool cpool;
+/**
+ * The element_value structure is documented at 
https://docs.oracle.com/javase/specs/jvms/se11/html/jvms-4.html#jvms-4.7.16.1
+ *
+ * <pre>
+ * element_value {
+ *    u1 tag;
+ *    union {
+ *        u2 const_value_index;
+ *
+ *        {   u2 type_name_index;
+ *            u2 const_name_index;
+ *        } enum_const_value;
+ *
+ *        u2 class_info_index;
+ *
+ *        annotation annotation_value;
+ *
+ *        {   u2            num_values;
+ *            element_value values[num_values];
+ *        } array_value;
+ *    } value;
+ *}
+ *</pre>
+ */
+public abstract class ElementValue {
 
+    public static final byte STRING = 's';
+    public static final byte ENUM_CONSTANT = 'e';
+    public static final byte CLASS = 'c';
+    public static final byte ANNOTATION = '@';
+    public static final byte ARRAY = '[';
+    public static final byte PRIMITIVE_INT = 'I';
+    public static final byte PRIMITIVE_BYTE = 'B';
+    public static final byte PRIMITIVE_CHAR = 'C';
+    public static final byte PRIMITIVE_DOUBLE = 'D';
+    public static final byte PRIMITIVE_FLOAT = 'F';
+    public static final byte PRIMITIVE_LONG = 'J';
+    public static final byte PRIMITIVE_SHORT = 'S';
+    public static final byte PRIMITIVE_BOOLEAN = 'Z';
 
-    ElementValue(final int type, final ConstantPool cpool) {
-        this.type = type;
-        this.cpool = cpool;
+    /**
+     * Reads an {@code element_value} as an {@code ElementValue}.
+     *
+     * @param input Raw data input.
+     * @param cpool Constant pool.
+     * @return a new ElementValue.
+     * @throws IOException if an I/O error occurs.
+     */
+    public static ElementValue readElementValue(final DataInput input, final 
ConstantPool cpool) throws IOException {
+        return readElementValue(input, cpool, 0);
     }
 
-    public abstract String stringifyValue();
+    /**
+     * Reads an {@code element_value} as an {@code ElementValue}.
+     *
+     * @param input Raw data input.
+     * @param cpool Constant pool.
+     * @param arrayNesting level of current array nesting.
+     * @return a new ElementValue.
+     * @throws IOException if an I/O error occurs.
+     * @since 6.7.0
+     */
+    public static ElementValue readElementValue(final DataInput input, final 
ConstantPool cpool, int arrayNesting)
+            throws IOException {
+        final byte tag = input.readByte();
+        switch (tag) {
+        case PRIMITIVE_BYTE:
+        case PRIMITIVE_CHAR:
+        case PRIMITIVE_DOUBLE:
+        case PRIMITIVE_FLOAT:
+        case PRIMITIVE_INT:
+        case PRIMITIVE_LONG:
+        case PRIMITIVE_SHORT:
+        case PRIMITIVE_BOOLEAN:
+        case STRING:
+            return new SimpleElementValue(tag, input.readUnsignedShort(), 
cpool);
 
-    public static final byte STRING            = 's';
-    public static final byte ENUM_CONSTANT     = 'e';
-    public static final byte CLASS             = 'c';
-    public static final byte ANNOTATION        = '@';
-    public static final byte ARRAY             = '[';
-    public static final byte PRIMITIVE_INT     = 'I';
-    public static final byte PRIMITIVE_BYTE    = 'B';
-    public static final byte PRIMITIVE_CHAR    = 'C';
-    public static final byte PRIMITIVE_DOUBLE  = 'D';
-    public static final byte PRIMITIVE_FLOAT   = 'F';
-    public static final byte PRIMITIVE_LONG    = 'J';
-    public static final byte PRIMITIVE_SHORT   = 'S';
-    public static final byte PRIMITIVE_BOOLEAN = 'Z';
+        case ENUM_CONSTANT:
+            input.readUnsignedShort();    // Unused type_index
+            return new EnumElementValue(ENUM_CONSTANT, 
input.readUnsignedShort(), cpool);
+
+        case CLASS:
+            return new ClassElementValue(CLASS, input.readUnsignedShort(), 
cpool);
 
-    public static ElementValue readElementValue(final DataInput input, final 
ConstantPool cpool) throws IOException
-    {
-        final byte type = input.readByte();
-        switch (type)
-        {
-            case PRIMITIVE_BYTE:
-            case PRIMITIVE_CHAR:
-            case PRIMITIVE_DOUBLE:
-            case PRIMITIVE_FLOAT:
-            case PRIMITIVE_INT:
-            case PRIMITIVE_LONG:
-            case PRIMITIVE_SHORT:
-            case PRIMITIVE_BOOLEAN:
-            case STRING:
-                return new SimpleElementValue(type, input.readUnsignedShort(), 
cpool);
-
-            case ENUM_CONSTANT:
-                input.readUnsignedShort();    // Unused type_index
-                return new EnumElementValue(ENUM_CONSTANT, 
input.readUnsignedShort(), cpool);
-
-            case CLASS:
-                return new ClassElementValue(CLASS, input.readUnsignedShort(), 
cpool);
-
-            case ANNOTATION:
-                // TODO isRuntimeVisible
-                return new AnnotationElementValue(ANNOTATION, new 
AnnotationEntry(input, cpool), cpool);
-
-            case ARRAY:
-                final int numArrayVals = input.readUnsignedShort();
-                final ElementValue[] evalues = new ElementValue[numArrayVals];
-                for (int j = 0; j < numArrayVals; j++)
-                {
-                    evalues[j] = ElementValue.readElementValue(input, cpool);
-                }
-                return new ArrayElementValue(ARRAY, evalues, cpool);
-
-            default:
-                throw new IllegalArgumentException(
-                        "Unexpected element value kind in annotation: " + 
type);
+        case ANNOTATION:
+            // TODO isRuntimeVisible
+            return new AnnotationElementValue(ANNOTATION, new 
AnnotationEntry(input, cpool), cpool);
+
+        case ARRAY:
+            arrayNesting++;
+            if (arrayNesting > Const.MAX_ARRAY_DIMENSIONS) {
+                // JVM spec 4.4.1
+                throw new ClassFormatException(String.format("Arrays are only 
valid if they represent %,d or fewer dimensions.",
+                        Integer.valueOf(Const.MAX_ARRAY_DIMENSIONS)));
+            }
+            final int numArrayVals = input.readUnsignedShort();
+            final ElementValue[] evalues = new ElementValue[numArrayVals];
+            for (int j = 0; j < numArrayVals; j++) {
+                evalues[j] = ElementValue.readElementValue(input, cpool, 
arrayNesting);
+            }
+            return new ArrayElementValue(ARRAY, evalues, cpool);
+
+        default:
+            throw new ClassFormatException("Unexpected element value kind in 
annotation: " + tag);
         }
     }
 
+
+    private final int type;
+
+    private final ConstantPool cpool;
+
+
+    ElementValue(final int type, final ConstantPool cpool) {
+        this.type = type;
+        this.cpool = cpool;
+    }
+
     final ConstantPool getConstantPool() {
         return cpool;
     }
@@ -96,4 +146,6 @@ public abstract class ElementValue
     final int getType() {
         return type;
     }
+
+    public abstract String stringifyValue();
 }
diff --git a/java/org/apache/tomcat/util/bcel/classfile/ElementValuePair.java 
b/java/org/apache/tomcat/util/bcel/classfile/ElementValuePair.java
index 46e1a31aec..88e9efc204 100644
--- a/java/org/apache/tomcat/util/bcel/classfile/ElementValuePair.java
+++ b/java/org/apache/tomcat/util/bcel/classfile/ElementValuePair.java
@@ -1,19 +1,18 @@
 /*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 package org.apache.tomcat.util.bcel.classfile;
 
@@ -23,12 +22,11 @@ import java.io.IOException;
 import org.apache.tomcat.util.bcel.Const;
 
 /**
- * an annotation's element value pair
+ * An annotation's element value pair.
  *
  * @since 6.0
  */
-public class ElementValuePair
-{
+public class ElementValuePair {
     private final ElementValue elementValue;
 
     private final ConstantPool constantPool;
@@ -41,15 +39,12 @@ public class ElementValuePair
         this.elementValue = ElementValue.readElementValue(file, constantPool);
     }
 
-    public String getNameString()
-    {
-        final ConstantUtf8 c = (ConstantUtf8) constantPool.getConstant(
-                elementNameIndex, Const.CONSTANT_Utf8);
+    public String getNameString() {
+        final ConstantUtf8 c = (ConstantUtf8) 
constantPool.getConstant(elementNameIndex, Const.CONSTANT_Utf8);
         return c.getBytes();
     }
 
-    public final ElementValue getValue()
-    {
+    public final ElementValue getValue() {
         return elementValue;
     }
 }
diff --git a/java/org/apache/tomcat/util/bcel/classfile/EnumElementValue.java 
b/java/org/apache/tomcat/util/bcel/classfile/EnumElementValue.java
index 7e95a1eaa8..7a1d2a0473 100644
--- a/java/org/apache/tomcat/util/bcel/classfile/EnumElementValue.java
+++ b/java/org/apache/tomcat/util/bcel/classfile/EnumElementValue.java
@@ -1,42 +1,34 @@
 /*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 package org.apache.tomcat.util.bcel.classfile;
 
-import org.apache.tomcat.util.bcel.Const;
-
-public class EnumElementValue extends ElementValue
-{
+public class EnumElementValue extends ElementValue {
     private final int valueIdx;
 
     EnumElementValue(final int type, final int valueIdx, final ConstantPool 
cpool) {
         super(type, cpool);
         if (type != ENUM_CONSTANT) {
-            throw new IllegalArgumentException(
-                    "Only element values of type enum can be built with this 
ctor - type specified: " + type);
+            throw new ClassFormatException("Only element values of type enum 
can be built with this ctor - type specified: " + type);
         }
         this.valueIdx = valueIdx;
     }
 
     @Override
-    public String stringifyValue()
-    {
-        final ConstantUtf8 cu8 = (ConstantUtf8) 
super.getConstantPool().getConstant(valueIdx,
-                Const.CONSTANT_Utf8);
-        return cu8.getBytes();
+    public String stringifyValue() {
+        return super.getConstantPool().getConstantUtf8(valueIdx).getBytes();
     }
 }
diff --git a/java/org/apache/tomcat/util/bcel/classfile/JavaClass.java 
b/java/org/apache/tomcat/util/bcel/classfile/JavaClass.java
index 431df3abe2..259cd352d6 100644
--- a/java/org/apache/tomcat/util/bcel/classfile/JavaClass.java
+++ b/java/org/apache/tomcat/util/bcel/classfile/JavaClass.java
@@ -1,19 +1,18 @@
 /*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 package org.apache.tomcat.util.bcel.classfile;
 
@@ -21,12 +20,10 @@ import java.util.HashMap;
 import java.util.List;
 
 /**
- * Represents a Java class, i.e., the data structures, constant pool,
- * fields, methods and commands contained in a Java .class file.
- * See <a href="https://docs.oracle.com/javase/specs/";>JVM specification</a> 
for details.
- * The intent of this class is to represent a parsed or otherwise existing
- * class file.  Those interested in programmatically generating classes
- * should see the <a href="../generic/ClassGen.html">ClassGen</a> class.
+ * Represents a Java class, i.e., the data structures, constant pool, fields, 
methods and commands contained in a Java
+ * .class file. See <a href="https://docs.oracle.com/javase/specs/";>JVM 
specification</a> for details. The intent of
+ * this class is to represent a parsed or otherwise existing class file. Those 
interested in programmatically generating
+ * classes should see the <a href="../generic/ClassGen.html">ClassGen</a> 
class.
  */
 public class JavaClass {
 
@@ -43,13 +40,13 @@ public class JavaClass {
      * @param className Name of this class.
      * @param superclassName Name of this class's superclass.
      * @param accessFlags Access rights defined by bit flags
-     * @param constant_pool Array of constants
+     * @param constantPool Array of constants
      * @param interfaceNames Implemented interfaces
      * @param runtimeVisibleAnnotations "RuntimeVisibleAnnotations" attribute 
defined on the Class, or null
      * @param runtimeVisibleFieldOrMethodAnnotations 
"RuntimeVisibleAnnotations" attribute defined on the fields or methods, or null
      */
     JavaClass(final String className, final String superclassName,
-            final int accessFlags, final ConstantPool constant_pool, final 
String[] interfaceNames,
+            final int accessFlags, final ConstantPool constantPool, final 
String[] interfaceNames,
             final Annotations runtimeVisibleAnnotations, final 
List<Annotations> runtimeVisibleFieldOrMethodAnnotations) {
         this.accessFlags = accessFlags;
         this.runtimeVisibleAnnotations = runtimeVisibleAnnotations;
@@ -66,19 +63,6 @@ public class JavaClass {
         return accessFlags;
     }
 
-    /**
-     * Return annotations entries from "RuntimeVisibleAnnotations" attribute on
-     * the class, if there is any.
-     *
-     * @return An array of entries or {@code null}
-     */
-    public AnnotationEntry[] getAnnotationEntries() {
-        if (runtimeVisibleAnnotations != null) {
-            return runtimeVisibleAnnotations.getAnnotationEntries();
-        }
-        return null;
-    }
-
     /**
      * Return annotations entries from "RuntimeVisibleAnnotations" attribute on
      * the class, fields or methods if there is any.
@@ -93,7 +77,7 @@ public class JavaClass {
             }
         }
         if (runtimeVisibleFieldOrMethodAnnotations != null) {
-            for (Annotations annotations : 
runtimeVisibleFieldOrMethodAnnotations.toArray(new Annotations[0])) {
+            for (Annotations annotations : 
runtimeVisibleFieldOrMethodAnnotations.toArray(Annotations.EMPTY_ARRAY)) {
                 for (AnnotationEntry annotationEntry : 
annotations.getAnnotationEntries()) {
                     if 
(!annotationEntries.containsKey(annotationEntry.getAnnotationType())) {
                         
annotationEntries.put(annotationEntry.getAnnotationType(), annotationEntry);
@@ -104,10 +88,23 @@ public class JavaClass {
         if (annotationEntries.isEmpty()) {
             return null;
         } else {
-            return annotationEntries.values().toArray(new AnnotationEntry[0]);
+            return 
annotationEntries.values().toArray(AnnotationEntry.EMPTY_ARRAY);
         }
     }
 
+    /**
+     * Return annotations entries from "RuntimeVisibleAnnotations" attribute on
+     * the class, if there is any.
+     *
+     * @return An array of entries or {@code null}
+     */
+    public AnnotationEntry[] getAnnotationEntries() {
+        if (runtimeVisibleAnnotations != null) {
+            return runtimeVisibleAnnotations.getAnnotationEntries();
+        }
+        return null;
+    }
+
     /**
      * @return Class name.
      */
@@ -125,9 +122,8 @@ public class JavaClass {
 
 
     /**
-     * returns the super class name of this class. In the case that this class 
is
-     * java.lang.Object, it will return itself (java.lang.Object). This is 
probably incorrect
-     * but isn't fixed at this time to not break existing clients.
+     * returns the super class name of this class. In the case that this class 
is java.lang.Object, it will return itself
+     * (java.lang.Object). This is probably incorrect but isn't fixed at this 
time to not break existing clients.
      *
      * @return Superclass name.
      */
diff --git a/java/org/apache/tomcat/util/bcel/classfile/SimpleElementValue.java 
b/java/org/apache/tomcat/util/bcel/classfile/SimpleElementValue.java
index e450b675dc..295a8a9073 100644
--- a/java/org/apache/tomcat/util/bcel/classfile/SimpleElementValue.java
+++ b/java/org/apache/tomcat/util/bcel/classfile/SimpleElementValue.java
@@ -1,26 +1,24 @@
 /*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 package org.apache.tomcat.util.bcel.classfile;
 
 import org.apache.tomcat.util.bcel.Const;
 
-public class SimpleElementValue extends ElementValue
-{
+public class SimpleElementValue extends ElementValue {
     private final int index;
 
     SimpleElementValue(final int type, final int index, final ConstantPool 
cpool) {
@@ -31,61 +29,47 @@ public class SimpleElementValue extends ElementValue
     /**
      * @return Value entry index in the cpool
      */
-    public int getIndex()
-    {
+    public int getIndex() {
         return index;
     }
 
 
     // Whatever kind of value it is, return it as a string
     @Override
-    public String stringifyValue()
-    {
+    public String stringifyValue() {
         final ConstantPool cpool = super.getConstantPool();
-        final int _type = super.getType();
-        switch (_type)
-        {
+        final int type = super.getType();
+        switch (type) {
         case PRIMITIVE_INT:
-            final ConstantInteger c = (ConstantInteger) 
cpool.getConstant(getIndex(),
-                    Const.CONSTANT_Integer);
-            return Integer.toString(c.getBytes());
+            return 
Integer.toString(cpool.getConstantInteger(getIndex()).getBytes());
         case PRIMITIVE_LONG:
-            final ConstantLong j = (ConstantLong) cpool.getConstant(getIndex(),
-                    Const.CONSTANT_Long);
+            final ConstantLong j = cpool.getConstant(getIndex(), 
Const.CONSTANT_Long);
             return Long.toString(j.getBytes());
         case PRIMITIVE_DOUBLE:
-            final ConstantDouble d = (ConstantDouble) 
cpool.getConstant(getIndex(),
-                    Const.CONSTANT_Double);
+            final ConstantDouble d = cpool.getConstant(getIndex(), 
Const.CONSTANT_Double);
             return Double.toString(d.getBytes());
         case PRIMITIVE_FLOAT:
-            final ConstantFloat f = (ConstantFloat) 
cpool.getConstant(getIndex(),
-                    Const.CONSTANT_Float);
+            final ConstantFloat f = cpool.getConstant(getIndex(), 
Const.CONSTANT_Float);
             return Float.toString(f.getBytes());
         case PRIMITIVE_SHORT:
-            final ConstantInteger s = (ConstantInteger) 
cpool.getConstant(getIndex(),
-                    Const.CONSTANT_Integer);
+            final ConstantInteger s = cpool.getConstantInteger(getIndex());
             return Integer.toString(s.getBytes());
         case PRIMITIVE_BYTE:
-            final ConstantInteger b = (ConstantInteger) 
cpool.getConstant(getIndex(),
-                    Const.CONSTANT_Integer);
+            final ConstantInteger b = cpool.getConstantInteger(getIndex());
             return Integer.toString(b.getBytes());
         case PRIMITIVE_CHAR:
-            final ConstantInteger ch = (ConstantInteger) cpool.getConstant(
-                    getIndex(), Const.CONSTANT_Integer);
-            return String.valueOf((char)ch.getBytes());
+            final ConstantInteger ch = cpool.getConstantInteger(getIndex());
+            return String.valueOf((char) ch.getBytes());
         case PRIMITIVE_BOOLEAN:
-            final ConstantInteger bo = (ConstantInteger) cpool.getConstant(
-                    getIndex(), Const.CONSTANT_Integer);
+            final ConstantInteger bo = cpool.getConstantInteger(getIndex());
             if (bo.getBytes() == 0) {
                 return "false";
             }
             return "true";
         case STRING:
-            final ConstantUtf8 cu8 = (ConstantUtf8) 
cpool.getConstant(getIndex(),
-                    Const.CONSTANT_Utf8);
-            return cu8.getBytes();
+            return cpool.getConstantUtf8(getIndex()).getBytes();
         default:
-            throw new IllegalStateException("SimpleElementValue class does not 
know how to stringify type " + _type);
+            throw new IllegalStateException("SimpleElementValue class does not 
know how to stringify type " + type);
         }
     }
 }
diff --git a/java/org/apache/tomcat/util/bcel/classfile/Utility.java 
b/java/org/apache/tomcat/util/bcel/classfile/Utility.java
index dc0a09bbc1..4828fdff0e 100644
--- a/java/org/apache/tomcat/util/bcel/classfile/Utility.java
+++ b/java/org/apache/tomcat/util/bcel/classfile/Utility.java
@@ -1,18 +1,18 @@
 /*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 package org.apache.tomcat.util.bcel.classfile;
 
@@ -27,10 +27,6 @@ import org.apache.tomcat.util.bcel.Const;
  */
 final class Utility {
 
-    private Utility() {
-        // Hide default constructor
-    }
-
     /**
      * Shorten long class name <em>str</em>, i.e., chop off the 
<em>prefix</em>,
      * if the
@@ -41,7 +37,7 @@ final class Utility {
      * @return Compacted class name
      */
     static String compactClassName(final String str) {
-        return str.replace('/', '.'); // Is `/' on all systems, even DOS
+        return str.replace('/', '.'); // Is '/' on all systems, even DOS
     }
 
     static String getClassName(final ConstantPool constantPool, final int 
index) {
@@ -70,4 +66,8 @@ final class Utility {
         int length = file.readInt();
         skipFully(file, length);
     }
+
+    private Utility() {
+        // Hide default constructor
+    }
 }
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index edff7a999b..e2e1de26a0 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -144,6 +144,10 @@
         deprecated in Java 20 onwards, the reasons for deprecation are valid 
for
         all versions so move away from them now. (markt)
       </scode>
+      <add>
+        Update the internal fork of Apache Commons BCEL to b015e90 (2022-11-28,
+        6.7.0-RC1). (markt)
+      </add>
     </changelog>
   </subsection>
 </section>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to