From f6ea4fa6aaf2a1e10c8b4c6956352e33bff953ff Mon Sep 17 00:00:00 2001 From: Yuri Nesterenko Date: Wed, 1 Jun 2022 11:17:31 +0000 Subject: [PATCH] 8255035: Update BCEL to Version 6.5.0 Backport-of: 1a0ff28ea10aaba53c5fbeb59800d3bcb1d228bc --- .../sun/org/apache/bcel/internal/Const.java | 535 +++++++++--------- .../apache/bcel/internal/ExceptionConst.java | 23 +- .../internal/classfile/AnnotationDefault.java | 12 +- .../classfile/AnnotationElementValue.java | 2 +- .../internal/classfile/AnnotationEntry.java | 36 +- .../bcel/internal/classfile/Annotations.java | 40 +- .../internal/classfile/ArrayElementValue.java | 26 +- .../bcel/internal/classfile/Attribute.java | 4 +- .../internal/classfile/BootstrapMethod.java | 56 +- .../internal/classfile/BootstrapMethods.java | 38 +- .../bcel/internal/classfile/ClassParser.java | 86 +-- .../apache/bcel/internal/classfile/Code.java | 77 +-- .../internal/classfile/CodeException.java | 84 +-- .../bcel/internal/classfile/Constant.java | 4 +- .../internal/classfile/ConstantClass.java | 22 +- .../classfile/ConstantInvokeDynamic.java | 2 +- .../classfile/ConstantMethodHandle.java | 24 +- .../classfile/ConstantMethodType.java | 12 +- .../internal/classfile/ConstantModule.java | 22 +- .../classfile/ConstantNameAndType.java | 38 +- .../internal/classfile/ConstantPackage.java | 22 +- .../bcel/internal/classfile/ConstantPool.java | 58 +- .../internal/classfile/ConstantString.java | 22 +- .../internal/classfile/ConstantValue.java | 20 +- .../bcel/internal/classfile/ElementValue.java | 6 +- .../internal/classfile/EnumElementValue.java | 2 +- .../internal/classfile/ExceptionTable.java | 54 +- .../bcel/internal/classfile/InnerClass.java | 86 +-- .../bcel/internal/classfile/InnerClasses.java | 34 +- .../bcel/internal/classfile/JavaClass.java | 184 +++--- .../bcel/internal/classfile/LineNumber.java | 36 +- .../internal/classfile/LineNumberTable.java | 53 +- .../internal/classfile/LocalVariable.java | 114 ++-- .../classfile/LocalVariableTable.java | 46 +- .../classfile/LocalVariableTypeTable.java | 34 +- .../internal/classfile/MethodParameter.java | 32 +- .../internal/classfile/MethodParameters.java | 2 +- .../bcel/internal/classfile/Module.java | 135 ++--- .../internal/classfile/ModuleExports.java | 38 +- .../internal/classfile/ModuleMainClass.java | 36 +- .../bcel/internal/classfile/ModuleOpens.java | 38 +- .../internal/classfile/ModulePackages.java | 52 +- .../internal/classfile/ModuleProvides.java | 30 +- .../internal/classfile/ModuleRequires.java | 26 +- .../bcel/internal/classfile/NestHost.java | 30 +- .../bcel/internal/classfile/PMGClass.java | 50 +- .../classfile/ParameterAnnotationEntry.java | 12 +- .../classfile/ParameterAnnotations.java | 36 +- .../bcel/internal/classfile/Signature.java | 26 +- .../classfile/SimpleElementValue.java | 22 +- .../bcel/internal/classfile/SourceFile.java | 24 +- .../bcel/internal/classfile/StackMap.java | 4 +- .../internal/classfile/StackMapEntry.java | 278 ++++----- .../bcel/internal/classfile/StackMapType.java | 20 +- .../bcel/internal/classfile/Unknown.java | 10 +- .../bcel/internal/classfile/Utility.java | 59 +- .../generic/AnnotationElementValueGen.java | 4 +- .../generic/ArrayElementValueGen.java | 2 +- .../internal/generic/ArrayInstruction.java | 2 +- .../bcel/internal/generic/ArrayType.java | 18 +- .../bcel/internal/generic/ClassGen.java | 174 +++--- .../internal/generic/CodeExceptionGen.java | 78 +-- .../internal/generic/ConstantPoolGen.java | 80 +-- .../internal/generic/ElementValueGen.java | 8 +- .../internal/generic/ElementValuePairGen.java | 20 +- .../internal/generic/EnumElementValueGen.java | 2 +- .../bcel/internal/generic/FieldGen.java | 6 +- .../internal/generic/FieldGenOrMethodGen.java | 34 +- .../bcel/internal/generic/INVOKEDYNAMIC.java | 6 +- .../internal/generic/INVOKEINTERFACE.java | 2 +- .../bcel/internal/generic/INVOKESPECIAL.java | 2 +- .../bcel/internal/generic/INVOKESTATIC.java | 2 +- .../bcel/internal/generic/INVOKEVIRTUAL.java | 2 +- .../internal/generic/InstructionFactory.java | 84 ++- .../internal/generic/InstructionHandle.java | 8 +- .../internal/generic/InstructionList.java | 26 +- .../bcel/internal/generic/JsrInstruction.java | 2 +- .../org/apache/bcel/internal/generic/LDC.java | 8 +- .../apache/bcel/internal/generic/LDC2_W.java | 8 +- .../bcel/internal/generic/LineNumberGen.java | 21 +- .../internal/generic/LocalVariableGen.java | 26 +- .../generic/LocalVariableInstruction.java | 30 +- .../bcel/internal/generic/MethodGen.java | 360 ++++++------ .../bcel/internal/generic/ObjectType.java | 34 +- .../apache/bcel/internal/generic/SWITCH.java | 12 +- .../apache/bcel/internal/generic/Select.java | 6 +- .../generic/SimpleElementValueGen.java | 10 +- .../apache/bcel/internal/generic/Type.java | 6 +- .../bcel/internal/util/BCELFactory.java | 6 +- .../apache/bcel/internal/util/CodeHTML.java | 92 +-- .../bcel/internal/util/ConstantHTML.java | 74 +-- .../bcel/internal/util/InstructionFinder.java | 14 +- .../apache/bcel/internal/util/MethodHTML.java | 14 +- .../internal/util/SyntheticRepository.java | 8 +- src/java.xml/share/legal/bcel.md | 2 +- 95 files changed, 2116 insertions(+), 2051 deletions(-) diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/Const.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/Const.java index 9060a864ce0..e3c7099e454 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/Const.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/Const.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -26,14 +26,14 @@ * Constants for the project, mostly defined in the JVM specification. * * @since 6.0 (intended to replace the Constants interface) - * @LastModified: Jan 2020 + * @LastModified: May 2021 */ public final class Const { /** * Java class file format Magic number (0xCAFEBABE) * - * @see + * @see * The ClassFile Structure in The Java Virtual Machine Specification */ public static final int JVM_CLASSFILE_MAGIC = 0xCAFEBABE; @@ -211,13 +211,14 @@ public final class Const { public static final int MAX_BYTE = 255; // 2^8 - 1 /** One of the access flags for fields, methods, or classes. - * @see + * + * @see * Flag definitions for Classes in the Java Virtual Machine Specification (Java SE 9 Edition). - * @see + * @see * Flag definitions for Fields in the Java Virtual Machine Specification (Java SE 9 Edition). - * @see + * @see * Flag definitions for Methods in the Java Virtual Machine Specification (Java SE 9 Edition). - * @see + * @see * Flag definitions for Inner Classes in the Java Virtual Machine Specification (Java SE 9 Edition). */ public static final short ACC_PUBLIC = 0x0001; @@ -381,87 +382,87 @@ public static String getAccessName(final int index) { /** * Marks a constant pool entry as type UTF-8. - * @see + * @see * The Constant Pool in The Java Virtual Machine Specification */ public static final byte CONSTANT_Utf8 = 1; /** * Marks a constant pool entry as type Integer. - * @see + * @see * The Constant Pool in The Java Virtual Machine Specification */ public static final byte CONSTANT_Integer = 3; /** * Marks a constant pool entry as type Float. - * @see + * @see * The Constant Pool in The Java Virtual Machine Specification */ public static final byte CONSTANT_Float = 4; /** * Marks a constant pool entry as type Long. - * @see + * @see * The Constant Pool in The Java Virtual Machine Specification */ public static final byte CONSTANT_Long = 5; /** * Marks a constant pool entry as type Double. - * @see + * @see * The Constant Pool in The Java Virtual Machine Specification */ public static final byte CONSTANT_Double = 6; /** * Marks a constant pool entry as a Class - * @see + * @see * The Constant Pool in The Java Virtual Machine Specification */ public static final byte CONSTANT_Class = 7; /** * Marks a constant pool entry as a Field Reference. - * @see + * @see * The Constant Pool in The Java Virtual Machine Specification */ public static final byte CONSTANT_Fieldref = 9; /** * Marks a constant pool entry as type String - * @see + * @see * The Constant Pool in The Java Virtual Machine Specification */ public static final byte CONSTANT_String = 8; /** Marks a constant pool entry as a Method Reference. - * @see + * @see * The Constant Pool in The Java Virtual Machine Specification */ public static final byte CONSTANT_Methodref = 10; /** * Marks a constant pool entry as an Interface Method Reference. - * @see + * @see * The Constant Pool in The Java Virtual Machine Specification */ public static final byte CONSTANT_InterfaceMethodref = 11; /** Marks a constant pool entry as a name and type. - * @see + * @see * The Constant Pool in The Java Virtual Machine Specification */ public static final byte CONSTANT_NameAndType = 12; /** * Marks a constant pool entry as a Method Handle. - * @see + * @see * The Constant Pool in The Java Virtual Machine Specification */ public static final byte CONSTANT_MethodHandle = 15; /** * Marks a constant pool entry as a Method Type. - * @see + * @see * The Constant Pool in The Java Virtual Machine Specification */ public static final byte CONSTANT_MethodType = 16; @@ -476,7 +477,7 @@ public static String getAccessName(final int index) { /** * Marks a constant pool entry as an Invoke Dynamic - * @see + * @see * The Constant Pool in The Java Virtual Machine Specification */ public static final byte CONSTANT_InvokeDynamic = 18; @@ -546,7 +547,7 @@ public static Iterable getInterfacesImplementedByArrays() { /** * Maximum Constant Pool entries. * One of the limitations of the Java Virtual Machine. - * @see + * @see * The Java Virtual Machine Specification, Java SE 8 Edition, page 330, chapter 4.11. */ public static final int MAX_CP_ENTRIES = 65535; @@ -564,8 +565,8 @@ public static Iterable getInterfacesImplementedByArrays() { * The entry in the Limitations section has been removed from later versions of the spec; * it is not present in the Java SE 8 edition. * - * @see - * The Java Virtual Machine Specification, Java SE 8 Edition, page 104, chapter 4.7.3 + * @see + * The Java Virtual Machine Specification, Java SE 8 Edition, page 104, chapter 4.7. */ public static final int MAX_CODE_SIZE = 65536; //bytes @@ -573,1228 +574,1228 @@ public static Iterable getInterfacesImplementedByArrays() { * The maximum number of dimensions in an array ({@value}). * One of the limitations of the Java Virtual Machine. * - * @see + * @see * Field Descriptors in The Java Virtual Machine Specification */ public static final int MAX_ARRAY_DIMENSIONS = 255; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short NOP = 0; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short ACONST_NULL = 1; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short ICONST_M1 = 2; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short ICONST_0 = 3; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short ICONST_1 = 4; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short ICONST_2 = 5; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short ICONST_3 = 6; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short ICONST_4 = 7; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short ICONST_5 = 8; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short LCONST_0 = 9; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short LCONST_1 = 10; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short FCONST_0 = 11; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short FCONST_1 = 12; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short FCONST_2 = 13; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short DCONST_0 = 14; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short DCONST_1 = 15; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short BIPUSH = 16; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short SIPUSH = 17; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short LDC = 18; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short LDC_W = 19; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short LDC2_W = 20; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short ILOAD = 21; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short LLOAD = 22; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short FLOAD = 23; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short DLOAD = 24; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short ALOAD = 25; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short ILOAD_0 = 26; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short ILOAD_1 = 27; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short ILOAD_2 = 28; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short ILOAD_3 = 29; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short LLOAD_0 = 30; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short LLOAD_1 = 31; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short LLOAD_2 = 32; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short LLOAD_3 = 33; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short FLOAD_0 = 34; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short FLOAD_1 = 35; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short FLOAD_2 = 36; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short FLOAD_3 = 37; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short DLOAD_0 = 38; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short DLOAD_1 = 39; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short DLOAD_2 = 40; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short DLOAD_3 = 41; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short ALOAD_0 = 42; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short ALOAD_1 = 43; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short ALOAD_2 = 44; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short ALOAD_3 = 45; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short IALOAD = 46; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short LALOAD = 47; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short FALOAD = 48; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short DALOAD = 49; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short AALOAD = 50; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short BALOAD = 51; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short CALOAD = 52; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short SALOAD = 53; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short ISTORE = 54; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short LSTORE = 55; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short FSTORE = 56; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short DSTORE = 57; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short ASTORE = 58; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short ISTORE_0 = 59; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short ISTORE_1 = 60; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short ISTORE_2 = 61; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short ISTORE_3 = 62; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short LSTORE_0 = 63; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short LSTORE_1 = 64; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short LSTORE_2 = 65; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short LSTORE_3 = 66; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short FSTORE_0 = 67; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short FSTORE_1 = 68; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short FSTORE_2 = 69; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short FSTORE_3 = 70; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short DSTORE_0 = 71; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short DSTORE_1 = 72; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short DSTORE_2 = 73; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short DSTORE_3 = 74; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short ASTORE_0 = 75; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short ASTORE_1 = 76; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short ASTORE_2 = 77; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short ASTORE_3 = 78; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short IASTORE = 79; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short LASTORE = 80; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short FASTORE = 81; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short DASTORE = 82; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short AASTORE = 83; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short BASTORE = 84; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short CASTORE = 85; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short SASTORE = 86; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short POP = 87; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short POP2 = 88; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short DUP = 89; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short DUP_X1 = 90; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short DUP_X2 = 91; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short DUP2 = 92; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short DUP2_X1 = 93; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short DUP2_X2 = 94; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short SWAP = 95; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short IADD = 96; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short LADD = 97; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short FADD = 98; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short DADD = 99; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short ISUB = 100; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short LSUB = 101; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short FSUB = 102; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short DSUB = 103; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short IMUL = 104; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short LMUL = 105; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short FMUL = 106; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short DMUL = 107; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short IDIV = 108; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short LDIV = 109; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short FDIV = 110; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short DDIV = 111; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short IREM = 112; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short LREM = 113; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short FREM = 114; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short DREM = 115; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short INEG = 116; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short LNEG = 117; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short FNEG = 118; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short DNEG = 119; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short ISHL = 120; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short LSHL = 121; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short ISHR = 122; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short LSHR = 123; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short IUSHR = 124; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short LUSHR = 125; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short IAND = 126; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short LAND = 127; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short IOR = 128; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short LOR = 129; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short IXOR = 130; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short LXOR = 131; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short IINC = 132; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short I2L = 133; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short I2F = 134; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short I2D = 135; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short L2I = 136; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short L2F = 137; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short L2D = 138; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short F2I = 139; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short F2L = 140; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short F2D = 141; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short D2I = 142; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short D2L = 143; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short D2F = 144; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short I2B = 145; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short INT2BYTE = 145; // Old notation /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short I2C = 146; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short INT2CHAR = 146; // Old notation /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short I2S = 147; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short INT2SHORT = 147; // Old notation /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short LCMP = 148; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short FCMPL = 149; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short FCMPG = 150; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short DCMPL = 151; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short DCMPG = 152; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short IFEQ = 153; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short IFNE = 154; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short IFLT = 155; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short IFGE = 156; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short IFGT = 157; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short IFLE = 158; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short IF_ICMPEQ = 159; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short IF_ICMPNE = 160; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short IF_ICMPLT = 161; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short IF_ICMPGE = 162; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short IF_ICMPGT = 163; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short IF_ICMPLE = 164; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short IF_ACMPEQ = 165; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short IF_ACMPNE = 166; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short GOTO = 167; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short JSR = 168; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short RET = 169; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short TABLESWITCH = 170; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short LOOKUPSWITCH = 171; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short IRETURN = 172; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short LRETURN = 173; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short FRETURN = 174; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short DRETURN = 175; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short ARETURN = 176; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short RETURN = 177; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short GETSTATIC = 178; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short PUTSTATIC = 179; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short GETFIELD = 180; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short PUTFIELD = 181; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short INVOKEVIRTUAL = 182; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short INVOKESPECIAL = 183; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short INVOKENONVIRTUAL = 183; // Old name in JDK 1.0 /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short INVOKESTATIC = 184; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short INVOKEINTERFACE = 185; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short INVOKEDYNAMIC = 186; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short NEW = 187; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short NEWARRAY = 188; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short ANEWARRAY = 189; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short ARRAYLENGTH = 190; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short ATHROW = 191; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short CHECKCAST = 192; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short INSTANCEOF = 193; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short MONITORENTER = 194; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short MONITOREXIT = 195; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short WIDE = 196; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short MULTIANEWARRAY = 197; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short IFNULL = 198; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short IFNONNULL = 199; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short GOTO_W = 200; /** Java VM opcode. - * @see + * @see * Opcode definitions in The Java Virtual Machine Specification */ public static final short JSR_W = 201; /** JVM internal opcode. - * @see + * @see * Reserved opcodes in the Java Virtual Machine Specification */ public static final short BREAKPOINT = 202; /** JVM internal opcode. * @see * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) - * @see + * @see * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ public static final short LDC_QUICK = 203; /** JVM internal opcode. * @see * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) - * @see + * @see * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ public static final short LDC_W_QUICK = 204; /** JVM internal opcode. * @see * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) - * @see + * @see * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ public static final short LDC2_W_QUICK = 205; /** JVM internal opcode. * @see * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) - * @see + * @see * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ public static final short GETFIELD_QUICK = 206; /** JVM internal opcode. * @see * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) - * @see + * @see * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ public static final short PUTFIELD_QUICK = 207; /** JVM internal opcode. * @see * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) - * @see + * @see * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ public static final short GETFIELD2_QUICK = 208; /** JVM internal opcode. * @see * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) - * @see + * @see * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ public static final short PUTFIELD2_QUICK = 209; /** JVM internal opcode. * @see * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) - * @see + * @see * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ public static final short GETSTATIC_QUICK = 210; /** JVM internal opcode. * @see * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) - * @see + * @see * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ public static final short PUTSTATIC_QUICK = 211; /** JVM internal opcode. * @see * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) - * @see + * @see * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ public static final short GETSTATIC2_QUICK = 212; /** JVM internal opcode. * @see * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) - * @see + * @see * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ public static final short PUTSTATIC2_QUICK = 213; /** JVM internal opcode. * @see * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) - * @see + * @see * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ public static final short INVOKEVIRTUAL_QUICK = 214; /** JVM internal opcode. * @see * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) - * @see + * @see * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ public static final short INVOKENONVIRTUAL_QUICK = 215; /** JVM internal opcode. * @see * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) - * @see + * @see * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ public static final short INVOKESUPER_QUICK = 216; /** JVM internal opcode. * @see * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) - * @see + * @see * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ public static final short INVOKESTATIC_QUICK = 217; /** JVM internal opcode. * @see * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) - * @see + * @see * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ public static final short INVOKEINTERFACE_QUICK = 218; /** JVM internal opcode. * @see * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) - * @see + * @see * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ public static final short INVOKEVIRTUALOBJECT_QUICK = 219; /** JVM internal opcode. * @see * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) - * @see + * @see * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ public static final short NEW_QUICK = 221; /** JVM internal opcode. * @see * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) - * @see + * @see * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ public static final short ANEWARRAY_QUICK = 222; /** JVM internal opcode. * @see * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) - * @see + * @see * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ public static final short MULTIANEWARRAY_QUICK = 223; /** JVM internal opcode. * @see * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) - * @see + * @see * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ public static final short CHECKCAST_QUICK = 224; /** JVM internal opcode. * @see * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) - * @see + * @see * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ public static final short INSTANCEOF_QUICK = 225; /** JVM internal opcode. * @see * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) - * @see + * @see * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ public static final short INVOKEVIRTUAL_QUICK_W = 226; /** JVM internal opcode. * @see * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) - * @see + * @see * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ public static final short GETFIELD_QUICK_W = 227; /** JVM internal opcode. * @see * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) - * @see + * @see * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ public static final short PUTFIELD_QUICK_W = 228; /** JVM internal opcode. - * @see + * @see * Reserved opcodes in the Java Virtual Machine Specification */ public static final short IMPDEP1 = 254; /** JVM internal opcode. - * @see + * @see * Reserved opcodes in the Java Virtual Machine Specification */ public static final short IMPDEP2 = 255; @@ -1826,42 +1827,42 @@ public static Iterable getInterfacesImplementedByArrays() { public static final String ILLEGAL_TYPE = ""; /** Boolean data type. - * @see + * @see * Static Constraints in the Java Virtual Machine Specification */ public static final byte T_BOOLEAN = 4; /** Char data type. - * @see + * @see * Static Constraints in the Java Virtual Machine Specification */ public static final byte T_CHAR = 5; /** Float data type. - * @see + * @see * Static Constraints in the Java Virtual Machine Specification */ public static final byte T_FLOAT = 6; /** Double data type. - * @see + * @see * Static Constraints in the Java Virtual Machine Specification */ public static final byte T_DOUBLE = 7; /** Byte data type. - * @see + * @see * Static Constraints in the Java Virtual Machine Specification */ public static final byte T_BYTE = 8; /** Short data type. - * @see + * @see * Static Constraints in the Java Virtual Machine Specification */ public static final byte T_SHORT = 9; /** Int data type. - * @see + * @see * Static Constraints in the Java Virtual Machine Specification */ public static final byte T_INT = 10; /** Long data type. - * @see + * @see * Static Constraints in the Java Virtual Machine Specification */ public static final byte T_LONG = 11; diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/ExceptionConst.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/ExceptionConst.java index a5e69d4ab01..2da7e1248dc 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/ExceptionConst.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/ExceptionConst.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -23,20 +23,27 @@ /** * Exception constants. * @since 6.0 (intended to replace the InstructionConstant interface) - * @LastModified: Jan 2020 + * @LastModified: May 2021 */ public final class ExceptionConst { - /** The mother of all exceptions + /** + * The mother of all exceptions */ public static final Class THROWABLE = Throwable.class; - /** Super class of any run-time exception + + /** + * Super class of any run-time exception */ public static final Class RUNTIME_EXCEPTION = RuntimeException.class; - /** Super class of any linking exception (aka Linkage Error) + + /** + * Super class of any linking exception (aka Linkage Error) */ public static final Class LINKING_EXCEPTION = LinkageError.class; - /** Linking Exceptions + + /** + * Linking Exceptions */ public static final Class CLASS_CIRCULARITY_ERROR = ClassCircularityError.class; public static final Class CLASS_FORMAT_ERROR = ClassFormatError.class; @@ -52,7 +59,9 @@ public final class ExceptionConst { public static final Class VERIFY_ERROR = VerifyError.class; /* UnsupportedClassVersionError is new in JDK 1.2 */ // public static final Class UnsupportedClassVersionError = UnsupportedClassVersionError.class; - /** Run-Time Exceptions + + /** + * Run-Time Exceptions */ public static final Class NULL_POINTER_EXCEPTION = NullPointerException.class; public static final Class ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/AnnotationDefault.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/AnnotationDefault.java index fbdd548ad21..dc9c8ca47ba 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/AnnotationDefault.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/AnnotationDefault.java @@ -34,7 +34,7 @@ */ public class AnnotationDefault extends Attribute { - private ElementValue default_value; + private ElementValue defaultValue; /** * @param name_index Index pointing to the name Code @@ -44,7 +44,7 @@ public class AnnotationDefault extends Attribute { */ AnnotationDefault(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) throws IOException { this(name_index, length, (ElementValue) null, constant_pool); - default_value = ElementValue.readElementValue(input, constant_pool); + defaultValue = ElementValue.readElementValue(input, constant_pool); } /** @@ -55,7 +55,7 @@ public class AnnotationDefault extends Attribute { */ public AnnotationDefault(final int name_index, final int length, final ElementValue defaultValue, final ConstantPool constant_pool) { super(Const.ATTR_ANNOTATION_DEFAULT, name_index, length, constant_pool); - this.default_value = defaultValue; + this.defaultValue = defaultValue; } /** @@ -74,14 +74,14 @@ public void accept(final Visitor v) { * @param defaultValue the default value of this methodinfo's annotation */ public final void setDefaultValue(final ElementValue defaultValue) { - default_value = defaultValue; + this.defaultValue = defaultValue; } /** * @return the default value */ public final ElementValue getDefaultValue() { - return default_value; + return defaultValue; } @Override @@ -92,6 +92,6 @@ public Attribute copy(final ConstantPool _constant_pool) { @Override public final void dump(final DataOutputStream dos) throws IOException { super.dump(dos); - default_value.dump(dos); + defaultValue.dump(dos); } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/AnnotationElementValue.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/AnnotationElementValue.java index 5a5288cc317..79c7b25a266 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/AnnotationElementValue.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/AnnotationElementValue.java @@ -37,7 +37,7 @@ public AnnotationElementValue(final int type, final AnnotationEntry annotationEn { super(type, cpool); if (type != ANNOTATION) { - throw new RuntimeException( + throw new IllegalArgumentException( "Only element values of type annotation can be built with this ctor - type specified: " + type); } this.annotationEntry = annotationEntry; diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/AnnotationEntry.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/AnnotationEntry.java index ab5f165f0c6..8344048ab93 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/AnnotationEntry.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/AnnotationEntry.java @@ -37,17 +37,17 @@ */ public class AnnotationEntry implements Node { - private final int type_index; - private final ConstantPool constant_pool; + private final int typeIndex; + private final ConstantPool constantPool; private final boolean isRuntimeVisible; - private List element_value_pairs; + private List elementValuePairs; /* * Factory method to create an AnnotionEntry from a DataInput * * @param input - * @param constant_pool + * @param constantPool * @param isRuntimeVisible * @return the entry * @throws IOException @@ -56,9 +56,9 @@ public static AnnotationEntry read(final DataInput input, final ConstantPool con final AnnotationEntry annotationEntry = new AnnotationEntry(input.readUnsignedShort(), constant_pool, isRuntimeVisible); final int num_element_value_pairs = input.readUnsignedShort(); - annotationEntry.element_value_pairs = new ArrayList<>(); + annotationEntry.elementValuePairs = new ArrayList<>(); for (int i = 0; i < num_element_value_pairs; i++) { - annotationEntry.element_value_pairs.add( + annotationEntry.elementValuePairs.add( new ElementValuePair(input.readUnsignedShort(), ElementValue.readElementValue(input, constant_pool), constant_pool)); } @@ -66,17 +66,17 @@ public static AnnotationEntry read(final DataInput input, final ConstantPool con } public AnnotationEntry(final int type_index, final ConstantPool constant_pool, final boolean isRuntimeVisible) { - this.type_index = type_index; - this.constant_pool = constant_pool; + this.typeIndex = type_index; + this.constantPool = constant_pool; this.isRuntimeVisible = isRuntimeVisible; } public int getTypeIndex() { - return type_index; + return typeIndex; } public ConstantPool getConstantPool() { - return constant_pool; + return constantPool; } public boolean isRuntimeVisible() { @@ -98,7 +98,7 @@ public void accept(final Visitor v) { * @return the annotation type name */ public String getAnnotationType() { - final ConstantUtf8 c = (ConstantUtf8) constant_pool.getConstant(type_index, Const.CONSTANT_Utf8); + final ConstantUtf8 c = (ConstantUtf8) constantPool.getConstant(typeIndex, Const.CONSTANT_Utf8); return c.getBytes(); } @@ -106,14 +106,14 @@ public String getAnnotationType() { * @return the annotation type index */ public int getAnnotationTypeIndex() { - return type_index; + return typeIndex; } /** * @return the number of element value pairs in this annotation entry */ public final int getNumElementValuePairs() { - return element_value_pairs.size(); + return elementValuePairs.size(); } /** @@ -121,20 +121,20 @@ public final int getNumElementValuePairs() { */ public ElementValuePair[] getElementValuePairs() { // TODO return List - return element_value_pairs.toArray(new ElementValuePair[element_value_pairs.size()]); + return elementValuePairs.toArray(new ElementValuePair[elementValuePairs.size()]); } public void dump(final DataOutputStream dos) throws IOException { - dos.writeShort(type_index); // u2 index of type name in cpool - dos.writeShort(element_value_pairs.size()); // u2 element_value pair + dos.writeShort(typeIndex); // u2 index of type name in cpool + dos.writeShort(elementValuePairs.size()); // u2 element_value pair // count - for (final ElementValuePair envp : element_value_pairs) { + for (final ElementValuePair envp : elementValuePairs) { envp.dump(dos); } } public void addElementNameValuePair(final ElementValuePair elementNameValuePair) { - element_value_pairs.add(elementNameValuePair); + elementValuePairs.add(elementNameValuePair); } public String toShortString() { diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Annotations.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Annotations.java index e93792e8b34..5dc5f5cae77 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Annotations.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Annotations.java @@ -32,7 +32,7 @@ */ public abstract class Annotations extends Attribute { - private AnnotationEntry[] annotation_table; + private AnnotationEntry[] annotationTable; private final boolean isRuntimeVisible; /** @@ -46,23 +46,23 @@ public abstract class Annotations extends Attribute { final ConstantPool constant_pool, final boolean isRuntimeVisible) throws IOException { this(annotation_type, name_index, length, (AnnotationEntry[]) null, constant_pool, isRuntimeVisible); final int annotation_table_length = input.readUnsignedShort(); - annotation_table = new AnnotationEntry[annotation_table_length]; + annotationTable = new AnnotationEntry[annotation_table_length]; for (int i = 0; i < annotation_table_length; i++) { - annotation_table[i] = AnnotationEntry.read(input, constant_pool, isRuntimeVisible); + annotationTable[i] = AnnotationEntry.read(input, constant_pool, isRuntimeVisible); } } /** - * @param annotation_type the subclass type of the annotation - * @param name_index Index pointing to the name Code + * @param annotationType the subclass type of the annotation + * @param nameIndex Index pointing to the name Code * @param length Content length in bytes - * @param annotation_table the actual annotations - * @param constant_pool Array of constants + * @param annotationTable the actual annotations + * @param constantPool Array of constants */ - public Annotations(final byte annotation_type, final int name_index, final int length, final AnnotationEntry[] annotation_table, - final ConstantPool constant_pool, final boolean isRuntimeVisible) { - super(annotation_type, name_index, length, constant_pool); - this.annotation_table = annotation_table; + public Annotations(final byte annotationType, final int nameIndex, final int length, final AnnotationEntry[] annotationTable, + final ConstantPool constantPool, final boolean isRuntimeVisible) { + super(annotationType, nameIndex, length, constantPool); + this.annotationTable = annotationTable; this.isRuntimeVisible = isRuntimeVisible; } @@ -78,27 +78,27 @@ public void accept(final Visitor v) { } /** - * @param annotation_table the entries to set in this annotation + * @param annotationTable the entries to set in this annotation */ - public final void setAnnotationTable(final AnnotationEntry[] annotation_table) { - this.annotation_table = annotation_table; + public final void setAnnotationTable(final AnnotationEntry[] annotationTable) { + this.annotationTable = annotationTable; } /** * returns the array of annotation entries in this annotation */ public AnnotationEntry[] getAnnotationEntries() { - return annotation_table; + return annotationTable; } /** * @return the number of annotation entries in this annotation */ public final int getNumAnnotations() { - if (annotation_table == null) { + if (annotationTable == null) { return 0; } - return annotation_table.length; + return annotationTable.length; } public boolean isRuntimeVisible() { @@ -106,11 +106,11 @@ public boolean isRuntimeVisible() { } protected void writeAnnotations(final DataOutputStream dos) throws IOException { - if (annotation_table == null) { + if (annotationTable == null) { return; } - dos.writeShort(annotation_table.length); - for (final AnnotationEntry element : annotation_table) { + dos.writeShort(annotationTable.length); + for (final AnnotationEntry element : annotationTable) { element.dump(dos); } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ArrayElementValue.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ArrayElementValue.java index c4293ff3b2d..1e15d77049c 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ArrayElementValue.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ArrayElementValue.java @@ -30,17 +30,17 @@ public class ArrayElementValue extends ElementValue { // For array types, this is the array - private final ElementValue[] evalues; + private final ElementValue[] elementValues; @Override public String toString() { final StringBuilder sb = new StringBuilder(); sb.append("{"); - for (int i = 0; i < evalues.length; i++) + for (int i = 0; i < elementValues.length; i++) { - sb.append(evalues[i]); - if ((i + 1) < evalues.length) { + sb.append(elementValues[i]); + if ((i + 1) < elementValues.length) { sb.append(","); } } @@ -52,18 +52,18 @@ public ArrayElementValue(final int type, final ElementValue[] datums, final Cons { super(type, cpool); if (type != ARRAY) { - throw new RuntimeException( + throw new IllegalArgumentException( "Only element values of type array can be built with this ctor - type specified: " + type); } - this.evalues = datums; + this.elementValues = datums; } @Override public void dump(final DataOutputStream dos) throws IOException { dos.writeByte(super.getType()); // u1 type of value (ARRAY == '[') - dos.writeShort(evalues.length); - for (final ElementValue evalue : evalues) { + dos.writeShort(elementValues.length); + for (final ElementValue evalue : elementValues) { evalue.dump(dos); } } @@ -73,10 +73,10 @@ public String stringifyValue() { final StringBuilder sb = new StringBuilder(); sb.append("["); - for (int i = 0; i < evalues.length; i++) + for (int i = 0; i < elementValues.length; i++) { - sb.append(evalues[i].stringifyValue()); - if ((i + 1) < evalues.length) { + sb.append(elementValues[i].stringifyValue()); + if ((i + 1) < elementValues.length) { sb.append(","); } } @@ -86,11 +86,11 @@ public String stringifyValue() public ElementValue[] getElementValuesArray() { - return evalues; + return elementValues; } public int getElementValuesArraySize() { - return evalues.length; + return elementValues.length; } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Attribute.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Attribute.java index 2ec3e641519..4b21e9cdcc2 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Attribute.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Attribute.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -47,7 +47,7 @@ * @see Synthetic * @see Deprecated * @see Signature - * @LastModified: Jan 2020 + * @LastModified: May 2021 */ public abstract class Attribute implements Cloneable, Node { private static final boolean debug = false; diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/BootstrapMethod.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/BootstrapMethod.java index ef9b571b379..47e655e13c5 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/BootstrapMethod.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/BootstrapMethod.java @@ -33,17 +33,17 @@ * method ref, the number of bootstrap arguments and an array of the * bootstrap arguments. * - * @see + * @see * The class File Format : The BootstrapMethods Attribute * @since 6.0 */ public class BootstrapMethod implements Cloneable { /** Index of the CONSTANT_MethodHandle_info structure in the constant_pool table */ - private int bootstrap_method_ref; + private int bootstrapMethodRef; /** Array of references to the constant_pool table */ - private int[] bootstrap_arguments; + private int[] bootstrapArguments; /** @@ -62,8 +62,8 @@ public BootstrapMethod(final BootstrapMethod c) { BootstrapMethod(final DataInput input) throws IOException { this(input.readUnsignedShort(), input.readUnsignedShort()); - for (int i = 0; i < bootstrap_arguments.length; i++) { - bootstrap_arguments[i] = input.readUnsignedShort(); + for (int i = 0; i < bootstrapArguments.length; i++) { + bootstrapArguments[i] = input.readUnsignedShort(); } } @@ -73,47 +73,47 @@ private BootstrapMethod(final int bootstrap_method_ref, final int num_bootstrap_ } /** - * @param bootstrap_method_ref int index into constant_pool of CONSTANT_MethodHandle - * @param bootstrap_arguments int[] indices into constant_pool of CONSTANT_[type]_info + * @param bootstrapMethodRef int index into constant_pool of CONSTANT_MethodHandle + * @param bootstrapArguments int[] indices into constant_pool of CONSTANT_[type]_info */ - public BootstrapMethod(final int bootstrap_method_ref, final int[] bootstrap_arguments) { - this.bootstrap_method_ref = bootstrap_method_ref; - this.bootstrap_arguments = bootstrap_arguments; + public BootstrapMethod(final int bootstrapMethodRef, final int[] bootstrapArguments) { + this.bootstrapMethodRef = bootstrapMethodRef; + this.bootstrapArguments = bootstrapArguments; } /** * @return index into constant_pool of bootstrap_method */ public int getBootstrapMethodRef() { - return bootstrap_method_ref; + return bootstrapMethodRef; } /** - * @param bootstrap_method_ref int index into constant_pool of CONSTANT_MethodHandle + * @param bootstrapMethodRef int index into constant_pool of CONSTANT_MethodHandle */ - public void setBootstrapMethodRef(final int bootstrap_method_ref) { - this.bootstrap_method_ref = bootstrap_method_ref; + public void setBootstrapMethodRef(final int bootstrapMethodRef) { + this.bootstrapMethodRef = bootstrapMethodRef; } /** * @return int[] of bootstrap_method indices into constant_pool of CONSTANT_[type]_info */ public int[] getBootstrapArguments() { - return bootstrap_arguments; + return bootstrapArguments; } /** * @return count of number of boostrap arguments */ public int getNumBootstrapArguments() { - return bootstrap_arguments.length; + return bootstrapArguments.length; } /** - * @param bootstrap_arguments int[] indices into constant_pool of CONSTANT_[type]_info + * @param bootstrapArguments int[] indices into constant_pool of CONSTANT_[type]_info */ - public void setBootstrapArguments(final int[] bootstrap_arguments) { - this.bootstrap_arguments = bootstrap_arguments; + public void setBootstrapArguments(final int[] bootstrapArguments) { + this.bootstrapArguments = bootstrapArguments; } /** @@ -121,25 +121,25 @@ public void setBootstrapArguments(final int[] bootstrap_arguments) { */ @Override public final String toString() { - return "BootstrapMethod(" + bootstrap_method_ref + ", " + bootstrap_arguments.length + ", " - + Arrays.toString(bootstrap_arguments) + ")"; + return "BootstrapMethod(" + bootstrapMethodRef + ", " + bootstrapArguments.length + ", " + + Arrays.toString(bootstrapArguments) + ")"; } /** * @return Resolved string representation */ - public final String toString( final ConstantPool constant_pool ) { + public final String toString( final ConstantPool constantPool ) { final StringBuilder buf = new StringBuilder(); String bootstrap_method_name; - bootstrap_method_name = constant_pool.constantToString(bootstrap_method_ref, + bootstrap_method_name = constantPool.constantToString(bootstrapMethodRef, Const.CONSTANT_MethodHandle); buf.append(Utility.compactClassName(bootstrap_method_name, false)); - final int num_bootstrap_arguments = bootstrap_arguments.length; + final int num_bootstrap_arguments = bootstrapArguments.length; if (num_bootstrap_arguments > 0) { buf.append("\nMethod Arguments:"); for (int i = 0; i < num_bootstrap_arguments; i++) { buf.append("\n ").append(i).append(": "); - buf.append(constant_pool.constantToString(constant_pool.getConstant(bootstrap_arguments[i]))); + buf.append(constantPool.constantToString(constantPool.getConstant(bootstrapArguments[i]))); } } return buf.toString(); @@ -152,9 +152,9 @@ public final String toString( final ConstantPool constant_pool ) { * @throws IOException */ public final void dump(final DataOutputStream file) throws IOException { - file.writeShort(bootstrap_method_ref); - file.writeShort(bootstrap_arguments.length); - for (final int bootstrap_argument : bootstrap_arguments) { + file.writeShort(bootstrapMethodRef); + file.writeShort(bootstrapArguments.length); + for (final int bootstrap_argument : bootstrapArguments) { file.writeShort(bootstrap_argument); } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/BootstrapMethods.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/BootstrapMethods.java index 6042f38243e..1a55a725c9f 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/BootstrapMethods.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/BootstrapMethods.java @@ -30,13 +30,13 @@ /** * This class represents a BootstrapMethods attribute. * - * @see + * @see * The class File Format : The BootstrapMethods Attribute * @since 6.0 */ public class BootstrapMethods extends Attribute { - private BootstrapMethod[] bootstrap_methods; // TODO this could be made final (setter is not used) + private BootstrapMethod[] bootstrapMethods; // TODO this could be made final (setter is not used) /** * Initialize from another object. Note that both objects use the same @@ -50,12 +50,12 @@ public BootstrapMethods(final BootstrapMethods c) { /** * @param name_index Index in constant pool to CONSTANT_Utf8 * @param length Content length in bytes - * @param bootstrap_methods array of bootstrap methods + * @param bootstrapMethods array of bootstrap methods * @param constant_pool Array of constants */ - public BootstrapMethods(final int name_index, final int length, final BootstrapMethod[] bootstrap_methods, final ConstantPool constant_pool) { + public BootstrapMethods(final int name_index, final int length, final BootstrapMethod[] bootstrapMethods, final ConstantPool constant_pool) { super(Const.ATTR_BOOTSTRAP_METHODS, name_index, length, constant_pool); - this.bootstrap_methods = bootstrap_methods; + this.bootstrapMethods = bootstrapMethods; } /** @@ -71,9 +71,9 @@ public BootstrapMethods(final int name_index, final int length, final BootstrapM this(name_index, length, (BootstrapMethod[]) null, constant_pool); final int num_bootstrap_methods = input.readUnsignedShort(); - bootstrap_methods = new BootstrapMethod[num_bootstrap_methods]; + bootstrapMethods = new BootstrapMethod[num_bootstrap_methods]; for (int i = 0; i < num_bootstrap_methods; i++) { - bootstrap_methods[i] = new BootstrapMethod(input); + bootstrapMethods[i] = new BootstrapMethod(input); } } @@ -81,14 +81,14 @@ public BootstrapMethods(final int name_index, final int length, final BootstrapM * @return array of bootstrap method "records" */ public final BootstrapMethod[] getBootstrapMethods() { - return bootstrap_methods; + return bootstrapMethods; } /** - * @param bootstrap_methods the array of bootstrap methods + * @param bootstrapMethods the array of bootstrap methods */ - public final void setBootstrapMethods(final BootstrapMethod[] bootstrap_methods) { - this.bootstrap_methods = bootstrap_methods; + public final void setBootstrapMethods(final BootstrapMethod[] bootstrapMethods) { + this.bootstrapMethods = bootstrapMethods; } /** @@ -105,10 +105,10 @@ public void accept(final Visitor v) { @Override public BootstrapMethods copy(final ConstantPool _constant_pool) { final BootstrapMethods c = (BootstrapMethods) clone(); - c.bootstrap_methods = new BootstrapMethod[bootstrap_methods.length]; + c.bootstrapMethods = new BootstrapMethod[bootstrapMethods.length]; - for (int i = 0; i < bootstrap_methods.length; i++) { - c.bootstrap_methods[i] = bootstrap_methods[i].copy(); + for (int i = 0; i < bootstrapMethods.length; i++) { + c.bootstrapMethods[i] = bootstrapMethods[i].copy(); } c.setConstantPool(_constant_pool); return c; @@ -124,8 +124,8 @@ public BootstrapMethods copy(final ConstantPool _constant_pool) { public final void dump(final DataOutputStream file) throws IOException { super.dump(file); - file.writeShort(bootstrap_methods.length); - for (final BootstrapMethod bootstrap_method : bootstrap_methods) { + file.writeShort(bootstrapMethods.length); + for (final BootstrapMethod bootstrap_method : bootstrapMethods) { bootstrap_method.dump(file); } } @@ -137,14 +137,14 @@ public final void dump(final DataOutputStream file) throws IOException { public final String toString() { final StringBuilder buf = new StringBuilder(); buf.append("BootstrapMethods("); - buf.append(bootstrap_methods.length); + buf.append(bootstrapMethods.length); buf.append("):"); - for (int i = 0; i < bootstrap_methods.length; i++) { + for (int i = 0; i < bootstrapMethods.length; i++) { buf.append("\n"); final int start = buf.length(); buf.append(" ").append(i).append(": "); final int indent_count = buf.length() - start; - final String[] lines = (bootstrap_methods[i].toString(super.getConstantPool())).split("\\r?\\n"); + final String[] lines = (bootstrapMethods[i].toString(super.getConstantPool())).split("\\r?\\n"); buf.append(lines[0]); for (int j = 1; j < lines.length; j++) { buf.append("\n").append(" ".substring(0,indent_count)).append(lines[j]); diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ClassParser.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ClassParser.java index 4f26e4fe307..0ad2b781629 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ClassParser.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ClassParser.java @@ -48,19 +48,19 @@ public final class ClassParser { private DataInputStream dataInputStream; private final boolean fileOwned; - private final String file_name; - private String zip_file; - private int class_name_index; - private int superclass_name_index; + private final String fileName; + private String zipFile; + private int classNameIndex; + private int superclassNameIndex; private int major; // Compiler version private int minor; // Compiler version - private int access_flags; // Access rights of parsed class + private int accessFlags; // Access rights of parsed class private int[] interfaces; // Names of implemented interfaces - private ConstantPool constant_pool; // collection of constants + private ConstantPool constantPool; // collection of constants private Field[] fields; // class fields, i.e., its variables private Method[] methods; // methods defined in the class private Attribute[] attributes; // attributes defined in the class - private final boolean is_zip; // Loaded from zip file + private final boolean isZip; // Loaded from zip file private static final int BUFSIZE = 8192; @@ -68,13 +68,13 @@ public final class ClassParser { * Parses class from the given stream. * * @param inputStream Input stream - * @param file_name File name + * @param fileName File name */ - public ClassParser(final InputStream inputStream, final String file_name) { - this.file_name = file_name; + public ClassParser(final InputStream inputStream, final String fileName) { + this.fileName = fileName; fileOwned = false; final String clazz = inputStream.getClass().getName(); // Not a very clean solution ... - is_zip = clazz.startsWith("java.util.zip.") || clazz.startsWith("java.util.jar."); + isZip = clazz.startsWith("java.util.zip.") || clazz.startsWith("java.util.jar."); if (inputStream instanceof DataInputStream) { this.dataInputStream = (DataInputStream) inputStream; } else { @@ -85,25 +85,25 @@ public ClassParser(final InputStream inputStream, final String file_name) { /** Parses class from given .class file. * - * @param file_name file name + * @param fileName file name */ - public ClassParser(final String file_name) { - is_zip = false; - this.file_name = file_name; + public ClassParser(final String fileName) { + isZip = false; + this.fileName = fileName; fileOwned = true; } /** Parses class from given .class file in a ZIP-archive * - * @param zip_file zip file name - * @param file_name file name + * @param zipFile zip file name + * @param fileName file name */ - public ClassParser(final String zip_file, final String file_name) { - is_zip = true; + public ClassParser(final String zipFile, final String fileName) { + isZip = true; fileOwned = true; - this.zip_file = zip_file; - this.file_name = file_name; + this.zipFile = zipFile; + this.fileName = fileName; } @@ -122,19 +122,19 @@ public JavaClass parse() throws IOException, ClassFormatException { ZipFile zip = null; try { if (fileOwned) { - if (is_zip) { - zip = new ZipFile(zip_file); - final ZipEntry entry = zip.getEntry(file_name); + if (isZip) { + zip = new ZipFile(zipFile); + final ZipEntry entry = zip.getEntry(fileName); if (entry == null) { - throw new IOException("File " + file_name + " not found"); + throw new IOException("File " + fileName + " not found"); } dataInputStream = new DataInputStream(new BufferedInputStream(zip.getInputStream(entry), BUFSIZE)); } else { dataInputStream = new DataInputStream(new BufferedInputStream(new FileInputStream( - file_name), BUFSIZE)); + fileName), BUFSIZE)); } } /****************** Read headers ********************************/ @@ -165,8 +165,8 @@ public JavaClass parse() throws IOException, ClassFormatException { // int bytes = file.available(); // byte[] buf = new byte[bytes]; // file.read(buf); - // if(!(is_zip && (buf.length == 1))) { - // System.err.println("WARNING: Trailing garbage at end of " + file_name); + // if(!(isZip && (buf.length == 1))) { + // System.err.println("WARNING: Trailing garbage at end of " + fileName); // System.err.println(bytes + " extra bytes: " + Utility.toHexString(buf)); // } // } @@ -190,8 +190,8 @@ public JavaClass parse() throws IOException, ClassFormatException { } } // Return the information we have gathered in a new object - return new JavaClass(class_name_index, superclass_name_index, file_name, major, minor, - access_flags, constant_pool, interfaces, fields, methods, attributes, is_zip + return new JavaClass(classNameIndex, superclassNameIndex, fileName, major, minor, + accessFlags, constantPool, interfaces, fields, methods, attributes, isZip ? JavaClass.ZIP : JavaClass.FILE); } @@ -206,7 +206,7 @@ private void readAttributes() throws IOException, ClassFormatException { final int attributes_count = dataInputStream.readUnsignedShort(); attributes = new Attribute[attributes_count]; for (int i = 0; i < attributes_count; i++) { - attributes[i] = Attribute.readAttribute(dataInputStream, constant_pool); + attributes[i] = Attribute.readAttribute(dataInputStream, constantPool); } } @@ -217,19 +217,19 @@ private void readAttributes() throws IOException, ClassFormatException { * @throws ClassFormatException */ private void readClassInfo() throws IOException, ClassFormatException { - access_flags = dataInputStream.readUnsignedShort(); + accessFlags = dataInputStream.readUnsignedShort(); /* Interfaces are implicitely abstract, the flag should be set * according to the JVM specification. */ - if ((access_flags & Const.ACC_INTERFACE) != 0) { - access_flags |= Const.ACC_ABSTRACT; + if ((accessFlags & Const.ACC_INTERFACE) != 0) { + accessFlags |= Const.ACC_ABSTRACT; } - if (((access_flags & Const.ACC_ABSTRACT) != 0) - && ((access_flags & Const.ACC_FINAL) != 0)) { - throw new ClassFormatException("Class " + file_name + " can't be both final and abstract"); + if (((accessFlags & Const.ACC_ABSTRACT) != 0) + && ((accessFlags & Const.ACC_FINAL) != 0)) { + throw new ClassFormatException("Class " + fileName + " can't be both final and abstract"); } - class_name_index = dataInputStream.readUnsignedShort(); - superclass_name_index = dataInputStream.readUnsignedShort(); + classNameIndex = dataInputStream.readUnsignedShort(); + superclassNameIndex = dataInputStream.readUnsignedShort(); } @@ -239,7 +239,7 @@ private void readClassInfo() throws IOException, ClassFormatException { * @throws ClassFormatException */ private void readConstantPool() throws IOException, ClassFormatException { - constant_pool = new ConstantPool(dataInputStream); + constantPool = new ConstantPool(dataInputStream); } @@ -252,7 +252,7 @@ private void readFields() throws IOException, ClassFormatException { final int fields_count = dataInputStream.readUnsignedShort(); fields = new Field[fields_count]; for (int i = 0; i < fields_count; i++) { - fields[i] = new Field(dataInputStream, constant_pool); + fields[i] = new Field(dataInputStream, constantPool); } } @@ -266,7 +266,7 @@ private void readFields() throws IOException, ClassFormatException { */ private void readID() throws IOException, ClassFormatException { if (dataInputStream.readInt() != Const.JVM_CLASSFILE_MAGIC) { - throw new ClassFormatException(file_name + " is not a Java .class file"); + throw new ClassFormatException(fileName + " is not a Java .class file"); } } @@ -294,7 +294,7 @@ private void readMethods() throws IOException, ClassFormatException { final int methods_count = dataInputStream.readUnsignedShort(); methods = new Method[methods_count]; for (int i = 0; i < methods_count; i++) { - methods[i] = new Method(dataInputStream, constant_pool); + methods[i] = new Method(dataInputStream, constantPool); } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Code.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Code.java index 81a54ae506f..c486f2bb273 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Code.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Code.java @@ -46,10 +46,10 @@ */ public final class Code extends Attribute { - private int max_stack; // Maximum size of stack used by this method // TODO this could be made final (setter is not used) - private int max_locals; // Number of local variables // TODO this could be made final (setter is not used) + private int maxStack; // Maximum size of stack used by this method // TODO this could be made final (setter is not used) + private int maxLocals; // Number of local variables // TODO this could be made final (setter is not used) private byte[] code; // Actual byte code - private CodeException[] exception_table; // Table of handled exceptions + private CodeException[] exceptionTable; // Table of handled exceptions private Attribute[] attributes; // or LocalVariable @@ -81,9 +81,9 @@ public Code(final Code c) { * handler is active, i.e., a try { ... } catch() block. */ final int exception_table_length = file.readUnsignedShort(); - exception_table = new CodeException[exception_table_length]; + exceptionTable = new CodeException[exception_table_length]; for (int i = 0; i < exception_table_length; i++) { - exception_table[i] = new CodeException(file); + exceptionTable[i] = new CodeException(file); } /* Read all attributes, currently `LineNumberTable' and * `LocalVariableTable' @@ -104,20 +104,20 @@ public Code(final Code c) { /** * @param name_index Index pointing to the name Code * @param length Content length in bytes - * @param max_stack Maximum size of stack - * @param max_locals Number of local variables + * @param maxStack Maximum size of stack + * @param maxLocals Number of local variables * @param code Actual byte code - * @param exception_table Table of handled exceptions + * @param exceptionTable of handled exceptions * @param attributes Attributes of code: LineNumber or LocalVariable * @param constant_pool Array of constants */ - public Code(final int name_index, final int length, final int max_stack, final int max_locals, final byte[] code, - final CodeException[] exception_table, final Attribute[] attributes, final ConstantPool constant_pool) { + public Code(final int name_index, final int length, final int maxStack, final int maxLocals, final byte[] code, + final CodeException[] exceptionTable, final Attribute[] attributes, final ConstantPool constant_pool) { super(Const.ATTR_CODE, name_index, length, constant_pool); - this.max_stack = max_stack; - this.max_locals = max_locals; + this.maxStack = maxStack; + this.maxLocals = maxLocals; this.code = code != null ? code : new byte[0]; - this.exception_table = exception_table != null ? exception_table : new CodeException[0]; + this.exceptionTable = exceptionTable != null ? exceptionTable : new CodeException[0]; this.attributes = attributes != null ? attributes : new Attribute[0]; super.setLength(calculateLength()); // Adjust length } @@ -145,12 +145,12 @@ public void accept( final Visitor v ) { @Override public void dump( final DataOutputStream file ) throws IOException { super.dump(file); - file.writeShort(max_stack); - file.writeShort(max_locals); + file.writeShort(maxStack); + file.writeShort(maxLocals); file.writeInt(code.length); file.write(code, 0, code.length); - file.writeShort(exception_table.length); - for (final CodeException exception : exception_table) { + file.writeShort(exceptionTable.length); + for (final CodeException exception : exceptionTable) { exception.dump(file); } file.writeShort(attributes.length); @@ -208,7 +208,7 @@ public byte[] getCode() { * @see CodeException */ public CodeException[] getExceptionTable() { - return exception_table; + return exceptionTable; } @@ -216,7 +216,7 @@ public CodeException[] getExceptionTable() { * @return Number of local variables. */ public int getMaxLocals() { - return max_locals; + return maxLocals; } @@ -224,7 +224,7 @@ public int getMaxLocals() { * @return Maximum size of stack used by this method. */ public int getMaxStack() { - return max_stack; + return maxStack; } @@ -233,10 +233,10 @@ public int getMaxStack() { * and excluding all its attributes */ private int getInternalLength() { - return 2 /*max_stack*/+ 2 /*max_locals*/+ 4 /*code length*/ + return 2 /*maxStack*/+ 2 /*maxLocals*/+ 4 /*code length*/ + code.length /*byte-code*/ + 2 /*exception-table length*/ - + 8 * (exception_table == null ? 0 : exception_table.length) /* exception table */ + + 8 * (exceptionTable == null ? 0 : exceptionTable.length) /* exception table */ + 2 /* attributes count */; } @@ -275,27 +275,27 @@ public void setCode( final byte[] code ) { /** - * @param exception_table exception table + * @param exceptionTable exception table */ - public void setExceptionTable( final CodeException[] exception_table ) { - this.exception_table = exception_table != null ? exception_table : new CodeException[0]; + public void setExceptionTable( final CodeException[] exceptionTable ) { + this.exceptionTable = exceptionTable != null ? exceptionTable : new CodeException[0]; super.setLength(calculateLength()); // Adjust length } /** - * @param max_locals maximum number of local variables + * @param maxLocals maximum number of local variables */ - public void setMaxLocals( final int max_locals ) { - this.max_locals = max_locals; + public void setMaxLocals( final int maxLocals ) { + this.maxLocals = maxLocals; } /** - * @param max_stack maximum stack size + * @param maxStack maximum stack size */ - public void setMaxStack( final int max_stack ) { - this.max_stack = max_stack; + public void setMaxStack( final int maxStack ) { + this.maxStack = maxStack; } @@ -304,18 +304,19 @@ public void setMaxStack( final int max_stack ) { */ public String toString( final boolean verbose ) { final StringBuilder buf = new StringBuilder(100); // CHECKSTYLE IGNORE MagicNumber - buf.append("Code(max_stack = ").append(max_stack).append(", max_locals = ").append( - max_locals).append(", code_length = ").append(code.length).append(")\n").append( + buf.append("Code(maxStack = ").append(maxStack).append(", maxLocals = ").append( + maxLocals).append(", code_length = ").append(code.length).append(")\n").append( Utility.codeToString(code, super.getConstantPool(), 0, -1, verbose)); - if (exception_table.length > 0) { + if (exceptionTable.length > 0) { buf.append("\nException handler(s) = \n").append("From\tTo\tHandler\tType\n"); - for (final CodeException exception : exception_table) { + for (final CodeException exception : exceptionTable) { buf.append(exception.toString(super.getConstantPool(), verbose)).append("\n"); } } if (attributes.length > 0) { buf.append("\nAttribute(s) = "); for (final Attribute attribute : attributes) { + buf.append("\n").append(attribute.getName()).append(":"); buf.append("\n").append(attribute); } } @@ -345,9 +346,9 @@ public Attribute copy( final ConstantPool _constant_pool ) { System.arraycopy(code, 0, c.code, 0, code.length); } c.setConstantPool(_constant_pool); - c.exception_table = new CodeException[exception_table.length]; - for (int i = 0; i < exception_table.length; i++) { - c.exception_table[i] = exception_table[i].copy(); + c.exceptionTable = new CodeException[exceptionTable.length]; + for (int i = 0; i < exceptionTable.length; i++) { + c.exceptionTable[i] = exceptionTable[i].copy(); } c.attributes = new Attribute[attributes.length]; for (int i = 0; i < attributes.length; i++) { diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/CodeException.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/CodeException.java index 4512bd82db1..a1b8e46c825 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/CodeException.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/CodeException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -32,16 +32,16 @@ * particular exception handler is active. * * @see Code - * @LastModified: Jan 2020 + * @LastModified: May 2021 */ public final class CodeException implements Cloneable, Node { - private int start_pc; // Range in the code the exception handler is - private int end_pc; // active. start_pc is inclusive, end_pc exclusive - private int handler_pc; /* Starting address of exception handler, i.e., + private int startPc; // Range in the code the exception handler is + private int endPc; // active. startPc is inclusive, endPc exclusive + private int handlerPc; /* Starting address of exception handler, i.e., * an offset from start of code. */ - private int catch_type; /* If this is zero the handler catches any + private int catchType; /* If this is zero the handler catches any * exception, otherwise it points to the * exception class which is to be caught. */ @@ -67,20 +67,20 @@ public CodeException(final CodeException c) { /** - * @param start_pc Range in the code the exception handler is active, - * start_pc is inclusive while - * @param end_pc is exclusive - * @param handler_pc Starting address of exception handler, i.e., + * @param startPc Range in the code the exception handler is active, + * startPc is inclusive while + * @param endPc is exclusive + * @param handlerPc Starting address of exception handler, i.e., * an offset from start of code. - * @param catch_type If zero the handler catches any + * @param catchType If zero the handler catches any * exception, otherwise it points to the exception class which is * to be caught. */ - public CodeException(final int start_pc, final int end_pc, final int handler_pc, final int catch_type) { - this.start_pc = start_pc; - this.end_pc = end_pc; - this.handler_pc = handler_pc; - this.catch_type = catch_type; + public CodeException(final int startPc, final int endPc, final int handlerPc, final int catchType) { + this.startPc = startPc; + this.endPc = endPc; + this.handlerPc = handlerPc; + this.catchType = catchType; } @@ -104,10 +104,10 @@ public void accept( final Visitor v ) { * @throws IOException */ public void dump( final DataOutputStream file ) throws IOException { - file.writeShort(start_pc); - file.writeShort(end_pc); - file.writeShort(handler_pc); - file.writeShort(catch_type); + file.writeShort(startPc); + file.writeShort(endPc); + file.writeShort(handlerPc); + file.writeShort(catchType); } @@ -116,7 +116,7 @@ public void dump( final DataOutputStream file ) throws IOException { * the exception class which is to be caught. */ public int getCatchType() { - return catch_type; + return catchType; } @@ -124,7 +124,7 @@ public int getCatchType() { * @return Exclusive end index of the region where the handler is active. */ public int getEndPC() { - return end_pc; + return endPc; } @@ -132,7 +132,7 @@ public int getEndPC() { * @return Starting address of exception handler, relative to the code. */ public int getHandlerPC() { - return handler_pc; + return handlerPc; } @@ -140,39 +140,39 @@ public int getHandlerPC() { * @return Inclusive start index of the region where the handler is active. */ public int getStartPC() { - return start_pc; + return startPc; } /** - * @param catch_type the type of exception that is caught + * @param catchType the type of exception that is caught */ - public void setCatchType( final int catch_type ) { - this.catch_type = catch_type; + public void setCatchType( final int catchType ) { + this.catchType = catchType; } /** - * @param end_pc end of handled block + * @param endPc end of handled block */ - public void setEndPC( final int end_pc ) { - this.end_pc = end_pc; + public void setEndPC( final int endPc ) { + this.endPc = endPc; } /** - * @param handler_pc where the actual code is + * @param handlerPc where the actual code is */ - public void setHandlerPC( final int handler_pc ) { // TODO unused - this.handler_pc = handler_pc; + public void setHandlerPC( final int handlerPc ) { // TODO unused + this.handlerPc = handlerPc; } /** - * @param start_pc start of handled block + * @param startPc start of handled block */ - public void setStartPC( final int start_pc ) { // TODO unused - this.start_pc = start_pc; + public void setStartPC( final int startPc ) { // TODO unused + this.startPc = startPc; } @@ -181,8 +181,8 @@ public void setStartPC( final int start_pc ) { // TODO unused */ @Override public String toString() { - return "CodeException(start_pc = " + start_pc + ", end_pc = " + end_pc + ", handler_pc = " - + handler_pc + ", catch_type = " + catch_type + ")"; + return "CodeException(startPc = " + startPc + ", endPc = " + endPc + ", handlerPc = " + + handlerPc + ", catchType = " + catchType + ")"; } @@ -191,13 +191,13 @@ public String toString() { */ public String toString( final ConstantPool cp, final boolean verbose ) { String str; - if (catch_type == 0) { + if (catchType == 0) { str = "(0)"; } else { - str = Utility.compactClassName(cp.getConstantString(catch_type, Const.CONSTANT_Class), false) - + (verbose ? "(" + catch_type + ")" : ""); + str = Utility.compactClassName(cp.getConstantString(catchType, Const.CONSTANT_Class), false) + + (verbose ? "(" + catchType + ")" : ""); } - return start_pc + "\t" + end_pc + "\t" + handler_pc + "\t" + str; + return startPc + "\t" + endPc + "\t" + handlerPc + "\t" + str; } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Constant.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Constant.java index fa431a6a252..56ffb23cc83 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Constant.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Constant.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -32,7 +32,7 @@ * in the constant pool of a class file. The classes keep closely to * the JVM specification. * - * @LastModified: Jan 2020 + * @LastModified: May 2021 */ public abstract class Constant implements Cloneable, Node { diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantClass.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantClass.java index b33ce492b2f..ed64179834a 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantClass.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantClass.java @@ -35,7 +35,7 @@ */ public final class ConstantClass extends Constant implements ConstantObject { - private int name_index; // Identical to ConstantString except for the name + private int nameIndex; // Identical to ConstantString except for the name /** @@ -58,12 +58,12 @@ public ConstantClass(final ConstantClass c) { /** - * @param name_index Name index in constant pool. Should refer to a + * @param nameIndex Name index in constant pool. Should refer to a * ConstantUtf8. */ - public ConstantClass(final int name_index) { + public ConstantClass(final int nameIndex) { super(Const.CONSTANT_Class); - this.name_index = name_index; + this.nameIndex = nameIndex; } @@ -89,7 +89,7 @@ public void accept( final Visitor v ) { @Override public void dump( final DataOutputStream file ) throws IOException { file.writeByte(super.getTag()); - file.writeShort(name_index); + file.writeShort(nameIndex); } @@ -97,15 +97,15 @@ public void dump( final DataOutputStream file ) throws IOException { * @return Name index in constant pool of class name. */ public int getNameIndex() { - return name_index; + return nameIndex; } /** - * @param name_index the name index in the constant pool of this Constant Class + * @param nameIndex the name index in the constant pool of this Constant Class */ - public void setNameIndex( final int name_index ) { - this.name_index = name_index; + public void setNameIndex( final int nameIndex ) { + this.nameIndex = nameIndex; } @@ -113,7 +113,7 @@ public void setNameIndex( final int name_index ) { */ @Override public Object getConstantValue( final ConstantPool cp ) { - final Constant c = cp.getConstant(name_index, Const.CONSTANT_Utf8); + final Constant c = cp.getConstant(nameIndex, Const.CONSTANT_Utf8); return ((ConstantUtf8) c).getBytes(); } @@ -130,6 +130,6 @@ public String getBytes( final ConstantPool cp ) { */ @Override public String toString() { - return super.toString() + "(name_index = " + name_index + ")"; + return super.toString() + "(nameIndex = " + nameIndex + ")"; } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantInvokeDynamic.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantInvokeDynamic.java index 76039c68b85..7191c7ea207 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantInvokeDynamic.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantInvokeDynamic.java @@ -31,7 +31,7 @@ * and represents a reference to a invoke dynamic. * * @see Constant - * @see + * @see * The CONSTANT_InvokeDynamic_info Structure in The Java Virtual Machine Specification * @since 6.0 */ diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantMethodHandle.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantMethodHandle.java index 9e5ce843636..d516f1a609f 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantMethodHandle.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantMethodHandle.java @@ -36,8 +36,8 @@ */ public final class ConstantMethodHandle extends Constant { - private int reference_kind; - private int reference_index; + private int referenceKind; + private int referenceIndex; /** @@ -61,8 +61,8 @@ public ConstantMethodHandle(final ConstantMethodHandle c) { public ConstantMethodHandle(final int reference_kind, final int reference_index) { super(Const.CONSTANT_MethodHandle); - this.reference_kind = reference_kind; - this.reference_index = reference_index; + this.referenceKind = reference_kind; + this.referenceIndex = reference_index; } @@ -88,28 +88,28 @@ public void accept( final Visitor v ) { @Override public void dump( final DataOutputStream file ) throws IOException { file.writeByte(super.getTag()); - file.writeByte(reference_kind); - file.writeShort(reference_index); + file.writeByte(referenceKind); + file.writeShort(referenceIndex); } public int getReferenceKind() { - return reference_kind; + return referenceKind; } public void setReferenceKind(final int reference_kind) { - this.reference_kind = reference_kind; + this.referenceKind = reference_kind; } public int getReferenceIndex() { - return reference_index; + return referenceIndex; } public void setReferenceIndex(final int reference_index) { - this.reference_index = reference_index; + this.referenceIndex = reference_index; } @@ -118,7 +118,7 @@ public void setReferenceIndex(final int reference_index) { */ @Override public String toString() { - return super.toString() + "(reference_kind = " + reference_kind + - ", reference_index = " + reference_index + ")"; + return super.toString() + "(referenceKind = " + referenceKind + + ", referenceIndex = " + referenceIndex + ")"; } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantMethodType.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantMethodType.java index d9ea592bebc..08f894f0d4e 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantMethodType.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantMethodType.java @@ -36,7 +36,7 @@ */ public final class ConstantMethodType extends Constant { - private int descriptor_index; + private int descriptorIndex; /** @@ -60,7 +60,7 @@ public ConstantMethodType(final ConstantMethodType c) { public ConstantMethodType(final int descriptor_index) { super(Const.CONSTANT_MethodType); - this.descriptor_index = descriptor_index; + this.descriptorIndex = descriptor_index; } @@ -86,17 +86,17 @@ public void accept( final Visitor v ) { @Override public void dump( final DataOutputStream file ) throws IOException { file.writeByte(super.getTag()); - file.writeShort(descriptor_index); + file.writeShort(descriptorIndex); } public int getDescriptorIndex() { - return descriptor_index; + return descriptorIndex; } public void setDescriptorIndex(final int descriptor_index) { - this.descriptor_index = descriptor_index; + this.descriptorIndex = descriptor_index; } @@ -105,6 +105,6 @@ public void setDescriptorIndex(final int descriptor_index) { */ @Override public String toString() { - return super.toString() + "(descriptor_index = " + descriptor_index + ")"; + return super.toString() + "(descriptorIndex = " + descriptorIndex + ")"; } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantModule.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantModule.java index aee68918764..12c37069255 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantModule.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantModule.java @@ -38,7 +38,7 @@ */ public final class ConstantModule extends Constant implements ConstantObject { - private int name_index; + private int nameIndex; /** @@ -61,12 +61,12 @@ public ConstantModule(final ConstantModule c) { /** - * @param name_index Name index in constant pool. Should refer to a + * @param nameIndex Name index in constant pool. Should refer to a * ConstantUtf8. */ - public ConstantModule(final int name_index) { + public ConstantModule(final int nameIndex) { super(Const.CONSTANT_Module); - this.name_index = name_index; + this.nameIndex = nameIndex; } @@ -92,7 +92,7 @@ public void accept( final Visitor v ) { @Override public void dump( final DataOutputStream file ) throws IOException { file.writeByte(super.getTag()); - file.writeShort(name_index); + file.writeShort(nameIndex); } @@ -100,15 +100,15 @@ public void dump( final DataOutputStream file ) throws IOException { * @return Name index in constant pool of module name. */ public int getNameIndex() { - return name_index; + return nameIndex; } /** - * @param name_index the name index in the constant pool of this Constant Module + * @param nameIndex the name index in the constant pool of this Constant Module */ - public void setNameIndex( final int name_index ) { - this.name_index = name_index; + public void setNameIndex( final int nameIndex ) { + this.nameIndex = nameIndex; } @@ -116,7 +116,7 @@ public void setNameIndex( final int name_index ) { */ @Override public Object getConstantValue( final ConstantPool cp ) { - final Constant c = cp.getConstant(name_index, Const.CONSTANT_Utf8); + final Constant c = cp.getConstant(nameIndex, Const.CONSTANT_Utf8); return ((ConstantUtf8) c).getBytes(); } @@ -133,6 +133,6 @@ public String getBytes( final ConstantPool cp ) { */ @Override public String toString() { - return super.toString() + "(name_index = " + name_index + ")"; + return super.toString() + "(nameIndex = " + nameIndex + ")"; } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantNameAndType.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantNameAndType.java index 2f0494ab1ae..f1ce11948aa 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantNameAndType.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantNameAndType.java @@ -36,8 +36,8 @@ */ public final class ConstantNameAndType extends Constant { - private int name_index; // Name of field/method - private int signature_index; // and its signature. + private int nameIndex; // Name of field/method + private int signatureIndex; // and its signature. /** @@ -60,13 +60,13 @@ public ConstantNameAndType(final ConstantNameAndType c) { /** - * @param name_index Name of field/method - * @param signature_index and its signature + * @param nameIndex Name of field/method + * @param signatureIndex and its signature */ - public ConstantNameAndType(final int name_index, final int signature_index) { + public ConstantNameAndType(final int nameIndex, final int signatureIndex) { super(Const.CONSTANT_NameAndType); - this.name_index = name_index; - this.signature_index = signature_index; + this.nameIndex = nameIndex; + this.signatureIndex = signatureIndex; } @@ -92,8 +92,8 @@ public void accept( final Visitor v ) { @Override public void dump( final DataOutputStream file ) throws IOException { file.writeByte(super.getTag()); - file.writeShort(name_index); - file.writeShort(signature_index); + file.writeShort(nameIndex); + file.writeShort(signatureIndex); } @@ -101,7 +101,7 @@ public void dump( final DataOutputStream file ) throws IOException { * @return Name index in constant pool of field/method name. */ public int getNameIndex() { - return name_index; + return nameIndex; } @@ -116,7 +116,7 @@ public String getName( final ConstantPool cp ) { * @return Index in constant pool of field/method signature. */ public int getSignatureIndex() { - return signature_index; + return signatureIndex; } @@ -128,18 +128,18 @@ public String getSignature( final ConstantPool cp ) { /** - * @param name_index the name index of this constant + * @param nameIndex the name index of this constant */ - public void setNameIndex( final int name_index ) { - this.name_index = name_index; + public void setNameIndex( final int nameIndex ) { + this.nameIndex = nameIndex; } /** - * @param signature_index the signature index in the constant pool of this type + * @param signatureIndex the signature index in the constant pool of this type */ - public void setSignatureIndex( final int signature_index ) { - this.signature_index = signature_index; + public void setSignatureIndex( final int signatureIndex ) { + this.signatureIndex = signatureIndex; } @@ -148,7 +148,7 @@ public void setSignatureIndex( final int signature_index ) { */ @Override public String toString() { - return super.toString() + "(name_index = " + name_index + ", signature_index = " - + signature_index + ")"; + return super.toString() + "(nameIndex = " + nameIndex + ", signatureIndex = " + + signatureIndex + ")"; } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantPackage.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantPackage.java index d44d1996fde..2770f95b2a2 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantPackage.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantPackage.java @@ -38,7 +38,7 @@ */ public final class ConstantPackage extends Constant implements ConstantObject { - private int name_index; + private int nameIndex; /** @@ -61,12 +61,12 @@ public ConstantPackage(final ConstantPackage c) { /** - * @param name_index Name index in constant pool. Should refer to a + * @param nameIndex Name index in constant pool. Should refer to a * ConstantUtf8. */ - public ConstantPackage(final int name_index) { + public ConstantPackage(final int nameIndex) { super(Const.CONSTANT_Package); - this.name_index = name_index; + this.nameIndex = nameIndex; } @@ -92,7 +92,7 @@ public void accept( final Visitor v ) { @Override public void dump( final DataOutputStream file ) throws IOException { file.writeByte(super.getTag()); - file.writeShort(name_index); + file.writeShort(nameIndex); } @@ -100,15 +100,15 @@ public void dump( final DataOutputStream file ) throws IOException { * @return Name index in constant pool of package name. */ public int getNameIndex() { - return name_index; + return nameIndex; } /** - * @param name_index the name index in the constant pool of this Constant Package + * @param nameIndex the name index in the constant pool of this Constant Package */ - public void setNameIndex( final int name_index ) { - this.name_index = name_index; + public void setNameIndex( final int nameIndex ) { + this.nameIndex = nameIndex; } @@ -116,7 +116,7 @@ public void setNameIndex( final int name_index ) { */ @Override public Object getConstantValue( final ConstantPool cp ) { - final Constant c = cp.getConstant(name_index, Const.CONSTANT_Utf8); + final Constant c = cp.getConstant(nameIndex, Const.CONSTANT_Utf8); return ((ConstantUtf8) c).getBytes(); } @@ -133,6 +133,6 @@ public String getBytes( final ConstantPool cp ) { */ @Override public String toString() { - return super.toString() + "(name_index = " + name_index + ")"; + return super.toString() + "(nameIndex = " + nameIndex + ")"; } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantPool.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantPool.java index d294fde941e..303b2b8ad8d 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantPool.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantPool.java @@ -40,13 +40,13 @@ */ public class ConstantPool implements Cloneable, Node { - private Constant[] constant_pool; + private Constant[] constantPool; /** - * @param constant_pool Array of constants + * @param constantPool Array of constants */ - public ConstantPool(final Constant[] constant_pool) { - this.constant_pool = constant_pool; + public ConstantPool(final Constant[] constantPool) { + this.constantPool = constantPool; } /** @@ -59,12 +59,12 @@ public ConstantPool(final Constant[] constant_pool) { public ConstantPool(final DataInput input) throws IOException, ClassFormatException { byte tag; final int constant_pool_count = input.readUnsignedShort(); - constant_pool = new Constant[constant_pool_count]; - /* constant_pool[0] is unused by the compiler and may be used freely + constantPool = new Constant[constant_pool_count]; + /* constantPool[0] is unused by the compiler and may be used freely * by the implementation. */ for (int i = 1; i < constant_pool_count; i++) { - constant_pool[i] = Constant.readConstant(input); + 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 @@ -72,7 +72,7 @@ public ConstantPool(final DataInput input) throws IOException, ClassFormatExcept * * Thus we have to increment the index counter. */ - tag = constant_pool[i].getTag(); + tag = constantPool[i].getTag(); if ((tag == Const.CONSTANT_Double) || (tag == Const.CONSTANT_Long)) { i++; } @@ -169,7 +169,7 @@ public String constantToString( Constant c ) throws ClassFormatException { str = Utility.compactClassName(((ConstantUtf8) c).getBytes(), false); break; default: // Never reached - throw new RuntimeException("Unknown constant type " + tag); + throw new IllegalArgumentException("Unknown constant type " + tag); } return str; } @@ -222,10 +222,10 @@ public String constantToString( final int index, final byte tag ) throws ClassFo * @throws IOException */ public void dump( final DataOutputStream file ) throws IOException { - file.writeShort(constant_pool.length); - for (int i = 1; i < constant_pool.length; i++) { - if (constant_pool[i] != null) { - constant_pool[i].dump(file); + file.writeShort(constantPool.length); + for (int i = 1; i < constantPool.length; i++) { + if (constantPool[i] != null) { + constantPool[i].dump(file); } } } @@ -238,11 +238,11 @@ public void dump( final DataOutputStream file ) throws IOException { * @see Constant */ public Constant getConstant( final int index ) { - if (index >= constant_pool.length || index < 0) { + if (index >= constantPool.length || index < 0) { throw new ClassFormatException("Invalid constant pool reference: " + index - + ". Constant pool size is: " + constant_pool.length); + + ". Constant pool size is: " + constantPool.length); } - return constant_pool[index]; + return constantPool[index]; } /** @@ -273,7 +273,7 @@ public Constant getConstant( final int index, final byte tag ) throws ClassForma * @see Constant */ public Constant[] getConstantPool() { - return constant_pool; + return constantPool; } /** @@ -314,7 +314,7 @@ public String getConstantString( final int index, final byte tag ) throws ClassF i = ((ConstantPackage) c).getNameIndex(); break; default: - throw new RuntimeException("getConstantString called with illegal tag " + tag); + throw new IllegalArgumentException("getConstantString called with illegal tag " + tag); } // Finally get the string from the constant pool c = getConstant(i, Const.CONSTANT_Utf8); @@ -326,7 +326,7 @@ public String getConstantString( final int index, final byte tag ) throws ClassF * @return Length of constant pool. */ public int getLength() { - return constant_pool == null ? 0 : constant_pool.length; + return constantPool == null ? 0 : constantPool.length; } @@ -334,15 +334,15 @@ public int getLength() { * @param constant Constant to set */ public void setConstant( final int index, final Constant constant ) { - constant_pool[index] = constant; + constantPool[index] = constant; } /** - * @param constant_pool + * @param constantPool */ - public void setConstantPool( final Constant[] constant_pool ) { - this.constant_pool = constant_pool; + public void setConstantPool( final Constant[] constantPool ) { + this.constantPool = constantPool; } @@ -352,8 +352,8 @@ public void setConstantPool( final Constant[] constant_pool ) { @Override public String toString() { final StringBuilder buf = new StringBuilder(); - for (int i = 1; i < constant_pool.length; i++) { - buf.append(i).append(")").append(constant_pool[i]).append("\n"); + for (int i = 1; i < constantPool.length; i++) { + buf.append(i).append(")").append(constantPool[i]).append("\n"); } return buf.toString(); } @@ -366,10 +366,10 @@ public ConstantPool copy() { ConstantPool c = null; try { c = (ConstantPool) clone(); - c.constant_pool = new Constant[constant_pool.length]; - for (int i = 1; i < constant_pool.length; i++) { - if (constant_pool[i] != null) { - c.constant_pool[i] = constant_pool[i].copy(); + c.constantPool = new Constant[constantPool.length]; + for (int i = 1; i < constantPool.length; i++) { + if (constantPool[i] != null) { + c.constantPool[i] = constantPool[i].copy(); } } } catch (final CloneNotSupportedException e) { diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantString.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantString.java index e7ce0eab095..cdc2c0c5f9f 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantString.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantString.java @@ -35,7 +35,7 @@ */ public final class ConstantString extends Constant implements ConstantObject { - private int string_index; // Identical to ConstantClass except for this name + private int stringIndex; // Identical to ConstantClass except for this name /** @@ -58,11 +58,11 @@ public ConstantString(final ConstantString c) { /** - * @param string_index Index of Constant_Utf8 in constant pool + * @param stringIndex Index of Constant_Utf8 in constant pool */ - public ConstantString(final int string_index) { + public ConstantString(final int stringIndex) { super(Const.CONSTANT_String); - this.string_index = string_index; + this.stringIndex = stringIndex; } @@ -88,7 +88,7 @@ public void accept( final Visitor v ) { @Override public void dump( final DataOutputStream file ) throws IOException { file.writeByte(super.getTag()); - file.writeShort(string_index); + file.writeShort(stringIndex); } @@ -96,15 +96,15 @@ public void dump( final DataOutputStream file ) throws IOException { * @return Index in constant pool of the string (ConstantUtf8). */ public int getStringIndex() { - return string_index; + return stringIndex; } /** - * @param string_index the index into the constant of the string value + * @param stringIndex the index into the constant of the string value */ - public void setStringIndex( final int string_index ) { - this.string_index = string_index; + public void setStringIndex( final int stringIndex ) { + this.stringIndex = stringIndex; } @@ -113,7 +113,7 @@ public void setStringIndex( final int string_index ) { */ @Override public String toString() { - return super.toString() + "(string_index = " + string_index + ")"; + return super.toString() + "(stringIndex = " + stringIndex + ")"; } @@ -121,7 +121,7 @@ public String toString() { */ @Override public Object getConstantValue( final ConstantPool cp ) { - final Constant c = cp.getConstant(string_index, Const.CONSTANT_Utf8); + final Constant c = cp.getConstant(stringIndex, Const.CONSTANT_Utf8); return ((ConstantUtf8) c).getBytes(); } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantValue.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantValue.java index 6be8e237e1a..4b58ae8d40e 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantValue.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantValue.java @@ -36,7 +36,7 @@ */ public final class ConstantValue extends Attribute { - private int constantvalue_index; + private int constantValueIndex; /** @@ -65,13 +65,13 @@ public ConstantValue(final ConstantValue c) { /** * @param name_index Name index in constant pool * @param length Content length in bytes - * @param constantvalue_index Index in constant pool + * @param constantValueIndex Index in constant pool * @param constant_pool Array of constants */ - public ConstantValue(final int name_index, final int length, final int constantvalue_index, + public ConstantValue(final int name_index, final int length, final int constantValueIndex, final ConstantPool constant_pool) { super(Const.ATTR_CONSTANT_VALUE, name_index, length, constant_pool); - this.constantvalue_index = constantvalue_index; + this.constantValueIndex = constantValueIndex; } @@ -97,7 +97,7 @@ public void accept( final Visitor v ) { @Override public void dump( final DataOutputStream file ) throws IOException { super.dump(file); - file.writeShort(constantvalue_index); + file.writeShort(constantValueIndex); } @@ -105,15 +105,15 @@ public void dump( final DataOutputStream file ) throws IOException { * @return Index in constant pool of constant value. */ public int getConstantValueIndex() { - return constantvalue_index; + return constantValueIndex; } /** - * @param constantvalue_index the index info the constant pool of this constant value + * @param constantValueIndex the index info the constant pool of this constant value */ - public void setConstantValueIndex( final int constantvalue_index ) { - this.constantvalue_index = constantvalue_index; + public void setConstantValueIndex( final int constantValueIndex ) { + this.constantValueIndex = constantValueIndex; } @@ -122,7 +122,7 @@ public void setConstantValueIndex( final int constantvalue_index ) { */ @Override public String toString() { - Constant c = super.getConstantPool().getConstant(constantvalue_index); + Constant c = super.getConstantPool().getConstant(constantValueIndex); String buf; int i; // Print constant to string depending on its type diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ElementValue.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ElementValue.java index 738776d78be..d5967ffd531 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ElementValue.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ElementValue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -26,7 +26,7 @@ /** * @since 6.0 - * @LastModified: Jan 2020 + * @LastModified: May 2021 */ public abstract class ElementValue { @@ -105,7 +105,7 @@ public static ElementValue readElementValue(final DataInput input, final Constan return new ArrayElementValue(ARRAY, evalues, cpool); default: - throw new RuntimeException("Unexpected element value kind in annotation: " + type); + throw new IllegalArgumentException("Unexpected element value kind in annotation: " + type); } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/EnumElementValue.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/EnumElementValue.java index 8aff8396a22..ac8632ee223 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/EnumElementValue.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/EnumElementValue.java @@ -41,7 +41,7 @@ public EnumElementValue(final int type, final int typeIdx, final int valueIdx, { super(type, cpool); if (type != ENUM_CONSTANT) { - throw new RuntimeException( + throw new IllegalArgumentException( "Only element values of type enum can be built with this ctor - type specified: " + type); } this.typeIdx = typeIdx; diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ExceptionTable.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ExceptionTable.java index b851792dff9..cddae111923 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ExceptionTable.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ExceptionTable.java @@ -39,7 +39,7 @@ */ public final class ExceptionTable extends Attribute { - private int[] exception_index_table; // constant pool + private int[] exceptionIndexTable; // constant pool /** @@ -54,30 +54,30 @@ public ExceptionTable(final ExceptionTable c) { /** * @param name_index Index in constant pool * @param length Content length in bytes - * @param exception_index_table Table of indices in constant pool + * @param exceptionIndexTable Table of indices in constant pool * @param constant_pool Array of constants */ - public ExceptionTable(final int name_index, final int length, final int[] exception_index_table, + public ExceptionTable(final int name_index, final int length, final int[] exceptionIndexTable, final ConstantPool constant_pool) { super(Const.ATTR_EXCEPTIONS, name_index, length, constant_pool); - this.exception_index_table = exception_index_table != null ? exception_index_table : new int[0]; + this.exceptionIndexTable = exceptionIndexTable != null ? exceptionIndexTable : new int[0]; } /** * Construct object from input stream. - * @param name_index Index in constant pool + * @param nameIndex Index in constant pool * @param length Content length in bytes * @param input Input stream - * @param constant_pool Array of constants + * @param constantPool Array of constants * @throws IOException */ - ExceptionTable(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) throws IOException { - this(name_index, length, (int[]) null, constant_pool); + ExceptionTable(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, (int[]) null, constantPool); final int number_of_exceptions = input.readUnsignedShort(); - exception_index_table = new int[number_of_exceptions]; + exceptionIndexTable = new int[number_of_exceptions]; for (int i = 0; i < number_of_exceptions; i++) { - exception_index_table[i] = input.readUnsignedShort(); + exceptionIndexTable[i] = input.readUnsignedShort(); } } @@ -104,8 +104,8 @@ public void accept( final Visitor v ) { @Override public void dump( final DataOutputStream file ) throws IOException { super.dump(file); - file.writeShort(exception_index_table.length); - for (final int index : exception_index_table) { + file.writeShort(exceptionIndexTable.length); + for (final int index : exceptionIndexTable) { file.writeShort(index); } } @@ -115,7 +115,7 @@ public void dump( final DataOutputStream file ) throws IOException { * @return Array of indices into constant pool of thrown exceptions. */ public int[] getExceptionIndexTable() { - return exception_index_table; + return exceptionIndexTable; } @@ -123,7 +123,7 @@ public int[] getExceptionIndexTable() { * @return Length of exception table. */ public int getNumberOfExceptions() { - return exception_index_table == null ? 0 : exception_index_table.length; + return exceptionIndexTable == null ? 0 : exceptionIndexTable.length; } @@ -131,9 +131,9 @@ public int getNumberOfExceptions() { * @return class names of thrown exceptions */ public String[] getExceptionNames() { - final String[] names = new String[exception_index_table.length]; - for (int i = 0; i < exception_index_table.length; i++) { - names[i] = super.getConstantPool().getConstantString(exception_index_table[i], + final String[] names = new String[exceptionIndexTable.length]; + for (int i = 0; i < exceptionIndexTable.length; i++) { + names[i] = super.getConstantPool().getConstantString(exceptionIndexTable[i], Const.CONSTANT_Class).replace('/', '.'); } return names; @@ -141,11 +141,11 @@ public String[] getExceptionNames() { /** - * @param exception_index_table the list of exception indexes + * @param exceptionIndexTable the list of exception indexes * Also redefines number_of_exceptions according to table length. */ - public void setExceptionIndexTable( final int[] exception_index_table ) { - this.exception_index_table = exception_index_table != null ? exception_index_table : new int[0]; + public void setExceptionIndexTable( final int[] exceptionIndexTable ) { + this.exceptionIndexTable = exceptionIndexTable != null ? exceptionIndexTable : new int[0]; } @@ -157,10 +157,10 @@ public String toString() { final StringBuilder buf = new StringBuilder(); String str; buf.append("Exceptions: "); - for (int i = 0; i < exception_index_table.length; i++) { - str = super.getConstantPool().getConstantString(exception_index_table[i], Const.CONSTANT_Class); + for (int i = 0; i < exceptionIndexTable.length; i++) { + str = super.getConstantPool().getConstantString(exceptionIndexTable[i], Const.CONSTANT_Class); buf.append(Utility.compactClassName(str, false)); - if (i < exception_index_table.length - 1) { + if (i < exceptionIndexTable.length - 1) { buf.append(", "); } } @@ -174,10 +174,10 @@ public String toString() { @Override public Attribute copy( final ConstantPool _constant_pool ) { final ExceptionTable c = (ExceptionTable) clone(); - if (exception_index_table != null) { - c.exception_index_table = new int[exception_index_table.length]; - System.arraycopy(exception_index_table, 0, c.exception_index_table, 0, - exception_index_table.length); + if (exceptionIndexTable != null) { + c.exceptionIndexTable = new int[exceptionIndexTable.length]; + System.arraycopy(exceptionIndexTable, 0, c.exceptionIndexTable, 0, + exceptionIndexTable.length); } c.setConstantPool(_constant_pool); return c; diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/InnerClass.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/InnerClass.java index 6f2078d6285..e7fbbe02b0f 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/InnerClass.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/InnerClass.java @@ -36,10 +36,10 @@ */ public final class InnerClass implements Cloneable, Node { - private int inner_class_index; - private int outer_class_index; - private int inner_name_index; - private int inner_access_flags; + private int innerClassIndex; + private int outerClassIndex; + private int innerNameIndex; + private int innerAccessFlags; /** @@ -63,17 +63,17 @@ public InnerClass(final InnerClass c) { /** - * @param inner_class_index Class index in constant pool of inner class - * @param outer_class_index Class index in constant pool of outer class - * @param inner_name_index Name index in constant pool of inner class - * @param inner_access_flags Access flags of inner class + * @param innerClassIndex Class index in constant pool of inner class + * @param outerClassIndex Class index in constant pool of outer class + * @param innerNameIndex Name index in constant pool of inner class + * @param innerAccessFlags Access flags of inner class */ - public InnerClass(final int inner_class_index, final int outer_class_index, final int inner_name_index, - final int inner_access_flags) { - this.inner_class_index = inner_class_index; - this.outer_class_index = outer_class_index; - this.inner_name_index = inner_name_index; - this.inner_access_flags = inner_access_flags; + public InnerClass(final int innerClassIndex, final int outerClassIndex, final int innerNameIndex, + final int innerAccessFlags) { + this.innerClassIndex = innerClassIndex; + this.outerClassIndex = outerClassIndex; + this.innerNameIndex = innerNameIndex; + this.innerAccessFlags = innerAccessFlags; } @@ -97,10 +97,10 @@ public void accept( final Visitor v ) { * @throws IOException */ public void dump( final DataOutputStream file ) throws IOException { - file.writeShort(inner_class_index); - file.writeShort(outer_class_index); - file.writeShort(inner_name_index); - file.writeShort(inner_access_flags); + file.writeShort(innerClassIndex); + file.writeShort(outerClassIndex); + file.writeShort(innerNameIndex); + file.writeShort(innerAccessFlags); } @@ -108,7 +108,7 @@ public void dump( final DataOutputStream file ) throws IOException { * @return access flags of inner class. */ public int getInnerAccessFlags() { - return inner_access_flags; + return innerAccessFlags; } @@ -116,7 +116,7 @@ public int getInnerAccessFlags() { * @return class index of inner class. */ public int getInnerClassIndex() { - return inner_class_index; + return innerClassIndex; } @@ -124,7 +124,7 @@ public int getInnerClassIndex() { * @return name index of inner class. */ public int getInnerNameIndex() { - return inner_name_index; + return innerNameIndex; } @@ -132,39 +132,39 @@ public int getInnerNameIndex() { * @return class index of outer class. */ public int getOuterClassIndex() { - return outer_class_index; + return outerClassIndex; } /** - * @param inner_access_flags access flags for this inner class + * @param innerAccessFlags access flags for this inner class */ - public void setInnerAccessFlags( final int inner_access_flags ) { - this.inner_access_flags = inner_access_flags; + public void setInnerAccessFlags( final int innerAccessFlags ) { + this.innerAccessFlags = innerAccessFlags; } /** - * @param inner_class_index index into the constant pool for this class + * @param innerClassIndex index into the constant pool for this class */ - public void setInnerClassIndex( final int inner_class_index ) { - this.inner_class_index = inner_class_index; + public void setInnerClassIndex( final int innerClassIndex ) { + this.innerClassIndex = innerClassIndex; } /** - * @param inner_name_index index into the constant pool for this class's name + * @param innerNameIndex index into the constant pool for this class's name */ - public void setInnerNameIndex( final int inner_name_index ) { // TODO unused - this.inner_name_index = inner_name_index; + public void setInnerNameIndex( final int innerNameIndex ) { // TODO unused + this.innerNameIndex = innerNameIndex; } /** - * @param outer_class_index index into the constant pool for the owning class + * @param outerClassIndex index into the constant pool for the owning class */ - public void setOuterClassIndex( final int outer_class_index ) { // TODO unused - this.outer_class_index = outer_class_index; + public void setOuterClassIndex( final int outerClassIndex ) { // TODO unused + this.outerClassIndex = outerClassIndex; } @@ -173,34 +173,34 @@ public void setOuterClassIndex( final int outer_class_index ) { // TODO unused */ @Override public String toString() { - return "InnerClass(" + inner_class_index + ", " + outer_class_index + ", " - + inner_name_index + ", " + inner_access_flags + ")"; + return "InnerClass(" + innerClassIndex + ", " + outerClassIndex + ", " + + innerNameIndex + ", " + innerAccessFlags + ")"; } /** * @return Resolved string representation */ - public String toString( final ConstantPool constant_pool ) { + public String toString( final ConstantPool constantPool ) { String outer_class_name; String inner_name; - String inner_class_name = constant_pool.getConstantString(inner_class_index, + String inner_class_name = constantPool.getConstantString(innerClassIndex, Const.CONSTANT_Class); inner_class_name = Utility.compactClassName(inner_class_name, false); - if (outer_class_index != 0) { - outer_class_name = constant_pool.getConstantString(outer_class_index, + if (outerClassIndex != 0) { + outer_class_name = constantPool.getConstantString(outerClassIndex, Const.CONSTANT_Class); outer_class_name = " of class " + Utility.compactClassName(outer_class_name, false); } else { outer_class_name = ""; } - if (inner_name_index != 0) { - inner_name = ((ConstantUtf8) constant_pool.getConstant(inner_name_index, + if (innerNameIndex != 0) { + inner_name = ((ConstantUtf8) constantPool.getConstant(innerNameIndex, Const.CONSTANT_Utf8)).getBytes(); } else { inner_name = "(anonymous)"; } - String access = Utility.accessToString(inner_access_flags, true); + String access = Utility.accessToString(innerAccessFlags, true); access = access.isEmpty() ? "" : (access + " "); return " " + access + inner_name + "=class " + inner_class_name + outer_class_name; } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/InnerClasses.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/InnerClasses.java index 24cbb3f58c1..567972f0242 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/InnerClasses.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/InnerClasses.java @@ -37,7 +37,7 @@ */ public final class InnerClasses extends Attribute { - private InnerClass[] inner_classes; + private InnerClass[] innerClasses; /** @@ -52,13 +52,13 @@ public InnerClasses(final InnerClasses c) { /** * @param name_index Index in constant pool to CONSTANT_Utf8 * @param length Content length in bytes - * @param inner_classes array of inner classes attributes + * @param innerClasses array of inner classes attributes * @param constant_pool Array of constants */ - public InnerClasses(final int name_index, final int length, final InnerClass[] inner_classes, + public InnerClasses(final int name_index, final int length, final InnerClass[] innerClasses, final ConstantPool constant_pool) { super(Const.ATTR_INNER_CLASSES, name_index, length, constant_pool); - this.inner_classes = inner_classes != null ? inner_classes : new InnerClass[0]; + this.innerClasses = innerClasses != null ? innerClasses : new InnerClass[0]; } @@ -75,9 +75,9 @@ public InnerClasses(final int name_index, final int length, final InnerClass[] i throws IOException { this(name_index, length, (InnerClass[]) null, constant_pool); final int number_of_classes = input.readUnsignedShort(); - inner_classes = new InnerClass[number_of_classes]; + innerClasses = new InnerClass[number_of_classes]; for (int i = 0; i < number_of_classes; i++) { - inner_classes[i] = new InnerClass(input); + innerClasses[i] = new InnerClass(input); } } @@ -104,8 +104,8 @@ public void accept( final Visitor v ) { @Override public void dump( final DataOutputStream file ) throws IOException { super.dump(file); - file.writeShort(inner_classes.length); - for (final InnerClass inner_class : inner_classes) { + file.writeShort(innerClasses.length); + for (final InnerClass inner_class : innerClasses) { inner_class.dump(file); } } @@ -115,15 +115,15 @@ public void dump( final DataOutputStream file ) throws IOException { * @return array of inner class "records" */ public InnerClass[] getInnerClasses() { - return inner_classes; + return innerClasses; } /** - * @param inner_classes the array of inner classes + * @param innerClasses the array of inner classes */ - public void setInnerClasses( final InnerClass[] inner_classes ) { - this.inner_classes = inner_classes != null ? inner_classes : new InnerClass[0]; + public void setInnerClasses( final InnerClass[] innerClasses ) { + this.innerClasses = innerClasses != null ? innerClasses : new InnerClass[0]; } @@ -134,9 +134,9 @@ public void setInnerClasses( final InnerClass[] inner_classes ) { public String toString() { final StringBuilder buf = new StringBuilder(); buf.append("InnerClasses("); - buf.append(inner_classes.length); + buf.append(innerClasses.length); buf.append("):\n"); - for (final InnerClass inner_class : inner_classes) { + for (final InnerClass inner_class : innerClasses) { buf.append(inner_class.toString(super.getConstantPool())).append("\n"); } return buf.substring(0, buf.length()-1); // remove the last newline @@ -150,9 +150,9 @@ public String toString() { public Attribute copy( final ConstantPool _constant_pool ) { // TODO this could be recoded to use a lower level constructor after creating a copy of the inner classes final InnerClasses c = (InnerClasses) clone(); - c.inner_classes = new InnerClass[inner_classes.length]; - for (int i = 0; i < inner_classes.length; i++) { - c.inner_classes[i] = inner_classes[i].copy(); + c.innerClasses = new InnerClass[innerClasses.length]; + for (int i = 0; i < innerClasses.length; i++) { + c.innerClasses[i] = innerClasses[i].copy(); } c.setConstantPool(_constant_pool); return c; diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/JavaClass.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/JavaClass.java index f74aa6eabcb..052059fba0b 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/JavaClass.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/JavaClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -41,28 +41,28 @@ /** * Represents a Java class, i.e., the data structures, constant pool, * fields, methods and commands contained in a Java .class file. - * See JVM specification for details. + * See JVM specification for details. * The intent of this class is to represent a parsed or otherwise existing * class file. Those interested in programatically generating classes * should see the ClassGen class. * @see com.sun.org.apache.bcel.internal.generic.ClassGen - * @LastModified: Jan 2020 + * @LastModified: May 2021 */ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparable { - private String file_name; - private String package_name; - private String source_file_name = ""; - private int class_name_index; - private int superclass_name_index; - private String class_name; - private String superclass_name; + private String fileName; + private String packageName; + private String sourceFileName = ""; + private int classNameIndex; + private int superclassNameIndex; + private String className; + private String superclassName; private int major; private int minor; // Compiler version - private ConstantPool constant_pool; // Constant pool + private ConstantPool constantPool; // Constant pool private int[] interfaces; // implemented interfaces - private String[] interface_names; + private String[] interfaceNames; private Field[] fields; // Fields, i.e., variables of class private Method[] methods; // methods defined in the class private Attribute[] attributes; // attributes defined in the class @@ -104,24 +104,24 @@ public int hashCode( final Object o ) { /** * Constructor gets all contents as arguments. * - * @param class_name_index Index into constant pool referencing a + * @param classNameIndex Index into constant pool referencing a * ConstantClass that represents this class. - * @param superclass_name_index Index into constant pool referencing a + * @param superclassNameIndex Index into constant pool referencing a * ConstantClass that represents this class's superclass. - * @param file_name File name + * @param fileName File name * @param major Major compiler version * @param minor Minor compiler version * @param access_flags Access rights defined by bit flags - * @param constant_pool Array of constants + * @param constantPool Array of constants * @param interfaces Implemented interfaces * @param fields Class fields * @param methods Class methods * @param attributes Class attributes * @param source Read from file or generated in memory? */ - public JavaClass(final int class_name_index, final int superclass_name_index, - final String file_name, final int major, final int minor, final int access_flags, - final ConstantPool constant_pool, int[] interfaces, Field[] fields, + public JavaClass(final int classNameIndex, final int superclassNameIndex, + final String fileName, final int major, final int minor, final int access_flags, + final ConstantPool constantPool, int[] interfaces, Field[] fields, Method[] methods, Attribute[] attributes, final byte source) { super(access_flags); if (interfaces == null) { @@ -136,12 +136,12 @@ public JavaClass(final int class_name_index, final int superclass_name_index, if (methods == null) { methods = new Method[0]; } - this.class_name_index = class_name_index; - this.superclass_name_index = superclass_name_index; - this.file_name = file_name; + this.classNameIndex = classNameIndex; + this.superclassNameIndex = superclassNameIndex; + this.fileName = fileName; this.major = major; this.minor = minor; - this.constant_pool = constant_pool; + this.constantPool = constantPool; this.interfaces = interfaces; this.fields = fields; this.methods = methods; @@ -150,7 +150,7 @@ public JavaClass(final int class_name_index, final int superclass_name_index, // Get source file name if available for (final Attribute attribute : attributes) { if (attribute instanceof SourceFile) { - source_file_name = ((SourceFile) attribute).getSourceFileName(); + sourceFileName = ((SourceFile) attribute).getSourceFileName(); break; } } @@ -158,26 +158,26 @@ public JavaClass(final int class_name_index, final int superclass_name_index, * `ConstantClass' but we check that anyway via the * `ConstPool.getConstant' method. */ - class_name = constant_pool.getConstantString(class_name_index, Const.CONSTANT_Class); - class_name = Utility.compactClassName(class_name, false); - final int index = class_name.lastIndexOf('.'); + className = constantPool.getConstantString(classNameIndex, Const.CONSTANT_Class); + className = Utility.compactClassName(className, false); + final int index = className.lastIndexOf('.'); if (index < 0) { - package_name = ""; + packageName = ""; } else { - package_name = class_name.substring(0, index); + packageName = className.substring(0, index); } - if (superclass_name_index > 0) { + if (superclassNameIndex > 0) { // May be zero -> class is java.lang.Object - superclass_name = constant_pool.getConstantString(superclass_name_index, + superclassName = constantPool.getConstantString(superclassNameIndex, Const.CONSTANT_Class); - superclass_name = Utility.compactClassName(superclass_name, false); + superclassName = Utility.compactClassName(superclassName, false); } else { - superclass_name = "java.lang.Object"; + superclassName = "java.lang.Object"; } - interface_names = new String[interfaces.length]; + interfaceNames = new String[interfaces.length]; for (int i = 0; i < interfaces.length; i++) { - final String str = constant_pool.getConstantString(interfaces[i], Const.CONSTANT_Class); - interface_names[i] = Utility.compactClassName(str, false); + final String str = constantPool.getConstantString(interfaces[i], Const.CONSTANT_Class); + interfaceNames[i] = Utility.compactClassName(str, false); } } @@ -185,24 +185,24 @@ public JavaClass(final int class_name_index, final int superclass_name_index, /** * Constructor gets all contents as arguments. * - * @param class_name_index Class name - * @param superclass_name_index Superclass name - * @param file_name File name + * @param classNameIndex Class name + * @param superclassNameIndex Superclass name + * @param fileName File name * @param major Major compiler version * @param minor Minor compiler version * @param access_flags Access rights defined by bit flags - * @param constant_pool Array of constants + * @param constantPool Array of constants * @param interfaces Implemented interfaces * @param fields Class fields * @param methods Class methods * @param attributes Class attributes */ - public JavaClass(final int class_name_index, final int superclass_name_index, - final String file_name, final int major, final int minor, final int access_flags, - final ConstantPool constant_pool, final int[] interfaces, final Field[] fields, + public JavaClass(final int classNameIndex, final int superclassNameIndex, + final String fileName, final int major, final int minor, final int access_flags, + final ConstantPool constantPool, final int[] interfaces, final Field[] fields, final Method[] methods, final Attribute[] attributes) { - this(class_name_index, superclass_name_index, file_name, major, minor, access_flags, - constant_pool, interfaces, fields, methods, attributes, HEAP); + this(classNameIndex, superclassNameIndex, fileName, major, minor, access_flags, + constantPool, interfaces, fields, methods, attributes, HEAP); } @@ -251,7 +251,7 @@ public void dump(final File file) throws IOException { /** - * Dump class to a file named file_name. + * Dump class to a file named fileName. * * @param _file_name Output file name * @throws IOException @@ -303,10 +303,10 @@ public void dump( final DataOutputStream file ) throws IOException { file.writeInt(Const.JVM_CLASSFILE_MAGIC); file.writeShort(minor); file.writeShort(major); - constant_pool.dump(file); + constantPool.dump(file); file.writeShort(super.getAccessFlags()); - file.writeShort(class_name_index); - file.writeShort(superclass_name_index); + file.writeShort(classNameIndex); + file.writeShort(superclassNameIndex); file.writeShort(interfaces.length); for (final int interface1 : interfaces) { file.writeShort(interface1); @@ -354,7 +354,7 @@ public AnnotationEntry[] getAnnotationEntries() { * @return Class name. */ public String getClassName() { - return class_name; + return className; } @@ -362,7 +362,7 @@ public String getClassName() { * @return Package name. */ public String getPackageName() { - return package_name; + return packageName; } @@ -370,7 +370,7 @@ public String getPackageName() { * @return Class name index. */ public int getClassNameIndex() { - return class_name_index; + return classNameIndex; } @@ -378,7 +378,7 @@ public int getClassNameIndex() { * @return Constant pool. */ public ConstantPool getConstantPool() { - return constant_pool; + return constantPool; } @@ -396,7 +396,7 @@ public Field[] getFields() { * @return File name of class, aka SourceFile attribute value */ public String getFileName() { - return file_name; + return fileName; } @@ -404,7 +404,7 @@ public String getFileName() { * @return Names of implemented interfaces. */ public String[] getInterfaceNames() { - return interface_names; + return interfaceNames; } @@ -459,7 +459,7 @@ public int getMinor() { * @return sbsolute path to file where this class was read from */ public String getSourceFileName() { - return source_file_name; + return sourceFileName; } @@ -471,7 +471,7 @@ public String getSourceFileName() { * @return Superclass name. */ public String getSuperclassName() { - return superclass_name; + return superclassName; } @@ -479,7 +479,7 @@ public String getSuperclassName() { * @return Class name index. */ public int getSuperclassNameIndex() { - return superclass_name_index; + return superclassNameIndex; } /** @@ -491,26 +491,26 @@ public void setAttributes( final Attribute[] attributes ) { /** - * @param class_name . + * @param className . */ - public void setClassName( final String class_name ) { - this.class_name = class_name; + public void setClassName( final String className ) { + this.className = className; } /** - * @param class_name_index . + * @param classNameIndex . */ - public void setClassNameIndex( final int class_name_index ) { - this.class_name_index = class_name_index; + public void setClassNameIndex( final int classNameIndex ) { + this.classNameIndex = classNameIndex; } /** - * @param constant_pool . + * @param constantPool . */ - public void setConstantPool( final ConstantPool constant_pool ) { - this.constant_pool = constant_pool; + public void setConstantPool( final ConstantPool constantPool ) { + this.constantPool = constantPool; } @@ -525,16 +525,16 @@ public void setFields( final Field[] fields ) { /** * Set File name of class, aka SourceFile attribute value */ - public void setFileName( final String file_name ) { - this.file_name = file_name; + public void setFileName( final String fileName ) { + this.fileName = fileName; } /** - * @param interface_names . + * @param interfaceNames . */ - public void setInterfaceNames( final String[] interface_names ) { - this.interface_names = interface_names; + public void setInterfaceNames( final String[] interfaceNames ) { + this.interfaceNames = interfaceNames; } @@ -573,24 +573,24 @@ public void setMinor( final int minor ) { /** * Set absolute path to file this class was read from. */ - public void setSourceFileName( final String source_file_name ) { - this.source_file_name = source_file_name; + public void setSourceFileName( final String sourceFileName ) { + this.sourceFileName = sourceFileName; } /** - * @param superclass_name . + * @param superclassName . */ - public void setSuperclassName( final String superclass_name ) { - this.superclass_name = superclass_name; + public void setSuperclassName( final String superclassName ) { + this.superclassName = superclassName; } /** - * @param superclass_name_index . + * @param superclassNameIndex . */ - public void setSuperclassNameIndex( final int superclass_name_index ) { - this.superclass_name_index = superclass_name_index; + public void setSuperclassNameIndex( final int superclassNameIndex ) { + this.superclassNameIndex = superclassNameIndex; } @@ -603,24 +603,24 @@ public String toString() { access = access.isEmpty() ? "" : (access + " "); final StringBuilder buf = new StringBuilder(128); buf.append(access).append(Utility.classOrInterface(super.getAccessFlags())).append(" ").append( - class_name).append(" extends ").append( - Utility.compactClassName(superclass_name, false)).append('\n'); + className).append(" extends ").append( + Utility.compactClassName(superclassName, false)).append('\n'); final int size = interfaces.length; if (size > 0) { buf.append("implements\t\t"); for (int i = 0; i < size; i++) { - buf.append(interface_names[i]); + buf.append(interfaceNames[i]); if (i < size - 1) { buf.append(", "); } } buf.append('\n'); } - buf.append("file name\t\t").append(file_name).append('\n'); - buf.append("compiled from\t\t").append(source_file_name).append('\n'); + buf.append("file name\t\t").append(fileName).append('\n'); + buf.append("compiled from\t\t").append(sourceFileName).append('\n'); buf.append("compiler version\t").append(major).append(".").append(minor).append('\n'); buf.append("access flags\t\t").append(super.getAccessFlags()).append('\n'); - buf.append("constant pool\t\t").append(constant_pool.getLength()).append(" entries\n"); + buf.append("constant pool\t\t").append(constantPool.getLength()).append(" entries\n"); buf.append("ACC_SUPER flag\t\t").append(isSuper()).append("\n"); if (attributes.length > 0) { buf.append("\nAttribute(s):\n"); @@ -668,20 +668,20 @@ public JavaClass copy() { JavaClass c = null; try { c = (JavaClass) clone(); - c.constant_pool = constant_pool.copy(); + c.constantPool = constantPool.copy(); c.interfaces = interfaces.clone(); - c.interface_names = interface_names.clone(); + c.interfaceNames = interfaceNames.clone(); c.fields = new Field[fields.length]; for (int i = 0; i < fields.length; i++) { - c.fields[i] = fields[i].copy(c.constant_pool); + c.fields[i] = fields[i].copy(c.constantPool); } c.methods = new Method[methods.length]; for (int i = 0; i < methods.length; i++) { - c.methods[i] = methods[i].copy(c.constant_pool); + c.methods[i] = methods[i].copy(c.constantPool); } c.attributes = new Attribute[attributes.length]; for (int i = 0; i < attributes.length; i++) { - c.attributes[i] = attributes[i].copy(c.constant_pool); + c.attributes[i] = attributes[i].copy(c.constantPool); } } catch (final CloneNotSupportedException e) { // TODO should this throw? @@ -724,7 +724,7 @@ private void computeNestedTypeStatus() { final InnerClass[] innerClasses = ((InnerClasses) attribute).getInnerClasses(); for (final InnerClass innerClasse : innerClasses) { boolean innerClassAttributeRefersToMe = false; - String inner_class_name = constant_pool.getConstantString(innerClasse.getInnerClassIndex(), + String inner_class_name = constantPool.getConstantString(innerClasse.getInnerClassIndex(), Const.CONSTANT_Class); inner_class_name = Utility.compactClassName(inner_class_name, false); if (inner_class_name.equals(getClassName())) { diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LineNumber.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LineNumber.java index 266e04b2806..f90b88f1cce 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LineNumber.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LineNumber.java @@ -35,10 +35,10 @@ public final class LineNumber implements Cloneable, Node { /** Program Counter (PC) corresponds to line */ - private short start_pc; + private short startPc; /** number in source file */ - private short line_number; + private short lineNumber; /** * Initialize from another object. @@ -62,12 +62,12 @@ public LineNumber(final LineNumber c) { /** - * @param start_pc Program Counter (PC) corresponds to - * @param line_number line number in source file + * @param startPc Program Counter (PC) corresponds to + * @param lineNumber line number in source file */ - public LineNumber(final int start_pc, final int line_number) { - this.start_pc = (short) start_pc; - this.line_number = (short)line_number; + public LineNumber(final int startPc, final int lineNumber) { + this.startPc = (short) startPc; + this.lineNumber = (short)lineNumber; } @@ -91,8 +91,8 @@ public void accept( final Visitor v ) { * @throws IOException if an I/O Exception occurs in writeShort */ public void dump( final DataOutputStream file ) throws IOException { - file.writeShort(start_pc); - file.writeShort(line_number); + file.writeShort(startPc); + file.writeShort(lineNumber); } @@ -100,7 +100,7 @@ public void dump( final DataOutputStream file ) throws IOException { * @return Corresponding source line */ public int getLineNumber() { - return 0xffff & line_number; + return 0xffff & lineNumber; } @@ -108,23 +108,23 @@ public int getLineNumber() { * @return PC in code */ public int getStartPC() { - return 0xffff & start_pc; + return 0xffff & startPc; } /** - * @param line_number the source line number + * @param lineNumber the source line number */ - public void setLineNumber( final int line_number ) { - this.line_number = (short) line_number; + public void setLineNumber( final int lineNumber ) { + this.lineNumber = (short) lineNumber; } /** - * @param start_pc the pc for this line number + * @param startPc the pc for this line number */ - public void setStartPC( final int start_pc ) { - this.start_pc = (short) start_pc; + public void setStartPC( final int startPc ) { + this.startPc = (short) startPc; } @@ -133,7 +133,7 @@ public void setStartPC( final int start_pc ) { */ @Override public String toString() { - return "LineNumber(" + start_pc + ", " + line_number + ")"; + return "LineNumber(" + startPc + ", " + lineNumber + ")"; } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LineNumberTable.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LineNumberTable.java index 78a4fd97547..7bad272fff3 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LineNumberTable.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LineNumberTable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -32,12 +32,12 @@ * * @see Code * @see LineNumber - * @LastModified: Jan 2020 + * @LastModified: May 2021 */ public final class LineNumberTable extends Attribute { private static final int MAX_LINE_LENGTH = 72; - private LineNumber[] line_number_table; // Table of line/numbers pairs + private LineNumber[] lineNumberTable; // Table of line/numbers pairs /* @@ -52,13 +52,13 @@ public LineNumberTable(final LineNumberTable c) { /* * @param name_index Index of name * @param length Content length in bytes - * @param line_number_table Table of line/numbers pairs + * @param lineNumberTable Table of line/numbers pairs * @param constant_pool Array of constants */ public LineNumberTable(final int name_index, final int length, final LineNumber[] line_number_table, final ConstantPool constant_pool) { super(Const.ATTR_LINE_NUMBER_TABLE, name_index, length, constant_pool); - this.line_number_table = line_number_table; + this.lineNumberTable = line_number_table; } /** @@ -73,9 +73,9 @@ public LineNumberTable(final int name_index, final int length, final LineNumber[ throws IOException { this(name_index, length, (LineNumber[]) null, constant_pool); final int line_number_table_length = input.readUnsignedShort(); - line_number_table = new LineNumber[line_number_table_length]; + lineNumberTable = new LineNumber[line_number_table_length]; for (int i = 0; i < line_number_table_length; i++) { - line_number_table[i] = new LineNumber(input); + lineNumberTable[i] = new LineNumber(input); } } @@ -100,8 +100,8 @@ public void accept( final Visitor v ) { @Override public void dump( final DataOutputStream file ) throws IOException { super.dump(file); - file.writeShort(line_number_table.length); - for (final LineNumber lineNumber : line_number_table) { + file.writeShort(lineNumberTable.length); + for (final LineNumber lineNumber : lineNumberTable) { lineNumber.dump(file); } } @@ -110,14 +110,14 @@ public void dump( final DataOutputStream file ) throws IOException { * @return Array of (pc offset, line number) pairs. */ public LineNumber[] getLineNumberTable() { - return line_number_table; + return lineNumberTable; } /** - * @param line_number_table the line number entries for this table + * @param lineNumberTable the line number entries for this table */ - public void setLineNumberTable( final LineNumber[] line_number_table ) { - this.line_number_table = line_number_table; + public void setLineNumberTable( final LineNumber[] lineNumberTable ) { + this.lineNumberTable = lineNumberTable; } /** @@ -128,12 +128,12 @@ public String toString() { final StringBuilder buf = new StringBuilder(); final StringBuilder line = new StringBuilder(); - for (int i = 0; i < line_number_table.length; i++) { - line.append(line_number_table[i].toString()); - if (i < line_number_table.length - 1) { + for (int i = 0; i < lineNumberTable.length; i++) { + line.append(lineNumberTable[i].toString()); + if (i < lineNumberTable.length - 1) { line.append(", "); } - if ((line.length() > MAX_LINE_LENGTH) && (i < line_number_table.length - 1)) { + if ((line.length() > MAX_LINE_LENGTH) && (i < lineNumberTable.length - 1)) { line.append(SecuritySupport.NEWLINE); buf.append(line); line.setLength(0); @@ -151,7 +151,7 @@ public String toString() { */ public int getSourceLine( final int pos ) { int l = 0; - int r = line_number_table.length - 1; + int r = lineNumberTable.length - 1; if (r < 0) { return -1; } @@ -161,9 +161,9 @@ public int getSourceLine( final int pos ) { */ do { final int i = (l + r) >>> 1; - final int j = line_number_table[i].getStartPC(); + final int j = lineNumberTable[i].getStartPC(); if (j == pos) { - return line_number_table[i].getLineNumber(); + return lineNumberTable[i].getLineNumber(); } else if (pos < j) { r = i - 1; } else { @@ -184,7 +184,7 @@ public int getSourceLine( final int pos ) { if (min_index < 0) { return -1; } - return line_number_table[min_index].getLineNumber(); + return lineNumberTable[min_index].getLineNumber(); } /** @@ -193,17 +193,18 @@ public int getSourceLine( final int pos ) { @Override public Attribute copy( final ConstantPool _constant_pool ) { // TODO could use the lower level constructor and thereby allow - // line_number_table to be made final + // lineNumberTable to be made final final LineNumberTable c = (LineNumberTable) clone(); - c.line_number_table = new LineNumber[line_number_table.length]; - for (int i = 0; i < line_number_table.length; i++) { - c.line_number_table[i] = line_number_table[i].copy(); + c.lineNumberTable = new LineNumber[lineNumberTable.length]; + for (int i = 0; i < lineNumberTable.length; i++) { + c.lineNumberTable[i] = lineNumberTable[i].copy(); } c.setConstantPool(_constant_pool); return c; } + public int getTableLength() { - return line_number_table == null ? 0 : line_number_table.length; + return lineNumberTable == null ? 0 : lineNumberTable.length; } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LocalVariable.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LocalVariable.java index 7f1c4b59826..f0605cfebe6 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LocalVariable.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LocalVariable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -32,27 +32,27 @@ * to represent an element of the LocalVariableTable as well as an element * of the LocalVariableTypeTable. The nomenclature used here may be a bit confusing; * while the two items have the same layout in a class file, a LocalVariableTable - * attribute contains a descriptor_index, not a signature_index. The - * LocalVariableTypeTable attribute does have a signature_index. + * attribute contains a descriptor_index, not a signatureIndex. The + * LocalVariableTypeTable attribute does have a signatureIndex. * @see com.sun.org.apache.bcel.internal.classfile.Utility for more details on the difference. * * @see LocalVariableTable * @see LocalVariableTypeTable - * @LastModified: Jan 2020 + * @LastModified: May 2021 */ public final class LocalVariable implements Cloneable, Node { - private int start_pc; // Range in which the variable is valid + private int startPc; // Range in which the variable is valid private int length; - private int name_index; // Index in constant pool of variable name + private int nameIndex; // Index in constant pool of variable name // Technically, a decscriptor_index for a local variable table entry - // and a signature_index for a local variable type table entry. - private int signature_index; // Index of variable signature + // and a signatureIndex for a local variable type table entry. + private int signatureIndex; // Index of variable signature private int index; /* Variable is index'th local variable on * this method's frame. */ - private ConstantPool constant_pool; - private int orig_index; // never changes; used to match up with LocalVariableTypeTable entries + private ConstantPool constantPool; + private int origIndex; // never changes; used to match up with LocalVariableTypeTable entries /** @@ -64,7 +64,7 @@ public final class LocalVariable implements Cloneable, Node { public LocalVariable(final LocalVariable localVariable) { this(localVariable.getStartPC(), localVariable.getLength(), localVariable.getNameIndex(), localVariable.getSignatureIndex(), localVariable.getIndex(), localVariable.getConstantPool()); - this.orig_index = localVariable.getOrigIndex(); + this.origIndex = localVariable.getOrigIndex(); } /** @@ -79,43 +79,43 @@ public LocalVariable(final LocalVariable localVariable) { /** - * @param start_pc Range in which the variable + * @param startPc Range in which the variable * @param length ... is valid - * @param name_index Index in constant pool of variable name - * @param signature_index Index of variable's signature + * @param nameIndex Index in constant pool of variable name + * @param signatureIndex Index of variable's signature * @param index Variable is `index'th local variable on the method's frame - * @param constant_pool Array of constants + * @param constantPool Array of constants */ - public LocalVariable(final int start_pc, final int length, final int name_index, final int signature_index, final int index, - final ConstantPool constant_pool) { - this.start_pc = start_pc; + public LocalVariable(final int startPc, final int length, final int nameIndex, final int signatureIndex, final int index, + final ConstantPool constantPool) { + this.startPc = startPc; this.length = length; - this.name_index = name_index; - this.signature_index = signature_index; + this.nameIndex = nameIndex; + this.signatureIndex = signatureIndex; this.index = index; - this.constant_pool = constant_pool; - this.orig_index = index; + this.constantPool = constantPool; + this.origIndex = index; } /** - * @param start_pc Range in which the variable + * @param startPc Range in which the variable * @param length ... is valid - * @param name_index Index in constant pool of variable name - * @param signature_index Index of variable's signature + * @param nameIndex Index in constant pool of variable name + * @param signatureIndex Index of variable's signature * @param index Variable is `index'th local variable on the method's frame - * @param constant_pool Array of constants - * @param orig_index Variable is `index'th local variable on the method's frame prior to any changes + * @param constantPool Array of constants + * @param origIndex Variable is `index'th local variable on the method's frame prior to any changes */ - public LocalVariable(final int start_pc, final int length, final int name_index, final int signature_index, final int index, - final ConstantPool constant_pool, final int orig_index) { - this.start_pc = start_pc; + public LocalVariable(final int startPc, final int length, final int nameIndex, final int signatureIndex, final int index, + final ConstantPool constantPool, final int origIndex) { + this.startPc = startPc; this.length = length; - this.name_index = name_index; - this.signature_index = signature_index; + this.nameIndex = nameIndex; + this.signatureIndex = signatureIndex; this.index = index; - this.constant_pool = constant_pool; - this.orig_index = orig_index; + this.constantPool = constantPool; + this.origIndex = origIndex; } @@ -140,10 +140,10 @@ public void accept( final Visitor v ) { * @see java.io.FilterOutputStream#out */ public void dump(final DataOutputStream dataOutputStream) throws IOException { - dataOutputStream.writeShort(start_pc); + dataOutputStream.writeShort(startPc); dataOutputStream.writeShort(length); - dataOutputStream.writeShort(name_index); - dataOutputStream.writeShort(signature_index); + dataOutputStream.writeShort(nameIndex); + dataOutputStream.writeShort(signatureIndex); dataOutputStream.writeShort(index); } @@ -151,7 +151,7 @@ public void dump(final DataOutputStream dataOutputStream) throws IOException { * @return Constant pool used by this object. */ public ConstantPool getConstantPool() { - return constant_pool; + return constantPool; } @@ -168,7 +168,7 @@ public int getLength() { */ public String getName() { ConstantUtf8 c; - c = (ConstantUtf8) constant_pool.getConstant(name_index, Const.CONSTANT_Utf8); + c = (ConstantUtf8) constantPool.getConstant(nameIndex, Const.CONSTANT_Utf8); return c.getBytes(); } @@ -177,7 +177,7 @@ public String getName() { * @return Index in constant pool of variable name. */ public int getNameIndex() { - return name_index; + return nameIndex; } @@ -186,7 +186,7 @@ public int getNameIndex() { */ public String getSignature() { ConstantUtf8 c; - c = (ConstantUtf8) constant_pool.getConstant(signature_index, Const.CONSTANT_Utf8); + c = (ConstantUtf8) constantPool.getConstant(signatureIndex, Const.CONSTANT_Utf8); return c.getBytes(); } @@ -195,7 +195,7 @@ public String getSignature() { * @return Index in constant pool of variable signature. */ public int getSignatureIndex() { - return signature_index; + return signatureIndex; } @@ -211,7 +211,7 @@ public int getIndex() { * @return index of register where variable was originally stored */ public int getOrigIndex() { - return orig_index; + return origIndex; } @@ -219,7 +219,7 @@ public int getOrigIndex() { * @return Start of range where the variable is valid */ public int getStartPC() { - return start_pc; + return startPc; } @@ -230,16 +230,16 @@ String toStringShared( final boolean typeTable ) { final String name = getName(); final String signature = Utility.signatureToString(getSignature(), false); final String label = "LocalVariable" + (typeTable ? "Types" : "" ); - return label + "(start_pc = " + start_pc + ", length = " + length + ", index = " + return label + "(startPc = " + startPc + ", length = " + length + ", index = " + index + ":" + signature + " " + name + ")"; } /** - * @param constant_pool Constant pool to be used for this object. + * @param constantPool Constant pool to be used for this object. */ - public void setConstantPool( final ConstantPool constant_pool ) { - this.constant_pool = constant_pool; + public void setConstantPool( final ConstantPool constantPool ) { + this.constantPool = constantPool; } @@ -252,18 +252,18 @@ public void setLength( final int length ) { /** - * @param name_index the index into the constant pool for the name of this variable + * @param nameIndex the index into the constant pool for the name of this variable */ - public void setNameIndex( final int name_index ) { // TODO unused - this.name_index = name_index; + public void setNameIndex( final int nameIndex ) { // TODO unused + this.nameIndex = nameIndex; } /** - * @param signature_index the index into the constant pool for the signature of this variable + * @param signatureIndex the index into the constant pool for the signature of this variable */ - public void setSignatureIndex( final int signature_index ) { // TODO unused - this.signature_index = signature_index; + public void setSignatureIndex( final int signatureIndex ) { // TODO unused + this.signatureIndex = signatureIndex; } @@ -276,10 +276,10 @@ public void setIndex( final int index ) { // TODO unused /** - * @param start_pc Specify range where the local variable is valid. + * @param startPc Specify range where the local variable is valid. */ - public void setStartPC( final int start_pc ) { // TODO unused - this.start_pc = start_pc; + public void setStartPC( final int startPc ) { // TODO unused + this.startPc = startPc; } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LocalVariableTable.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LocalVariableTable.java index 27354789873..12bf71d2467 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LocalVariableTable.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LocalVariableTable.java @@ -36,7 +36,7 @@ */ public class LocalVariableTable extends Attribute { - private LocalVariable[] local_variable_table; // variables + private LocalVariable[] localVariableTable; // variables /** @@ -49,15 +49,15 @@ public LocalVariableTable(final LocalVariableTable c) { /** - * @param name_index Index in constant pool to `LocalVariableTable' + * @param nameIndex Index in constant pool to `LocalVariableTable' * @param length Content length in bytes - * @param local_variable_table Table of local variables - * @param constant_pool Array of constants + * @param localVariableTable Table of local variables + * @param constantPool Array of constants */ - public LocalVariableTable(final int name_index, final int length, final LocalVariable[] local_variable_table, - final ConstantPool constant_pool) { - super(Const.ATTR_LOCAL_VARIABLE_TABLE, name_index, length, constant_pool); - this.local_variable_table = local_variable_table; + public LocalVariableTable(final int nameIndex, final int length, final LocalVariable[] localVariableTable, + final ConstantPool constantPool) { + super(Const.ATTR_LOCAL_VARIABLE_TABLE, nameIndex, length, constantPool); + this.localVariableTable = localVariableTable; } @@ -73,9 +73,9 @@ public LocalVariableTable(final int name_index, final int length, final LocalVar throws IOException { this(name_index, length, (LocalVariable[]) null, constant_pool); final int local_variable_table_length = input.readUnsignedShort(); - local_variable_table = new LocalVariable[local_variable_table_length]; + localVariableTable = new LocalVariable[local_variable_table_length]; for (int i = 0; i < local_variable_table_length; i++) { - local_variable_table[i] = new LocalVariable(input, constant_pool); + localVariableTable[i] = new LocalVariable(input, constant_pool); } } @@ -102,8 +102,8 @@ public void accept( final Visitor v ) { @Override public final void dump( final DataOutputStream file ) throws IOException { super.dump(file); - file.writeShort(local_variable_table.length); - for (final LocalVariable variable : local_variable_table) { + file.writeShort(localVariableTable.length); + for (final LocalVariable variable : localVariableTable) { variable.dump(file); } } @@ -113,7 +113,7 @@ public final void dump( final DataOutputStream file ) throws IOException { * @return Array of local variables of method. */ public final LocalVariable[] getLocalVariableTable() { - return local_variable_table; + return localVariableTable; } @@ -128,7 +128,7 @@ public final LocalVariable[] getLocalVariableTable() { */ @java.lang.Deprecated public final LocalVariable getLocalVariable( final int index ) { - for (final LocalVariable variable : local_variable_table) { + for (final LocalVariable variable : localVariableTable) { if (variable.getIndex() == index) { return variable; } @@ -145,7 +145,7 @@ public final LocalVariable getLocalVariable( final int index ) { * @return the LocalVariable that matches or null if not found */ public final LocalVariable getLocalVariable( final int index, final int pc ) { - for (final LocalVariable variable : local_variable_table) { + for (final LocalVariable variable : localVariableTable) { if (variable.getIndex() == index) { final int start_pc = variable.getStartPC(); final int end_pc = start_pc + variable.getLength(); @@ -159,7 +159,7 @@ public final LocalVariable getLocalVariable( final int index, final int pc ) { public final void setLocalVariableTable( final LocalVariable[] local_variable_table ) { - this.local_variable_table = local_variable_table; + this.localVariableTable = local_variable_table; } @@ -169,9 +169,9 @@ public final void setLocalVariableTable( final LocalVariable[] local_variable_ta @Override public final String toString() { final StringBuilder buf = new StringBuilder(); - for (int i = 0; i < local_variable_table.length; i++) { - buf.append(local_variable_table[i]); - if (i < local_variable_table.length - 1) { + for (int i = 0; i < localVariableTable.length; i++) { + buf.append(localVariableTable[i]); + if (i < localVariableTable.length - 1) { buf.append('\n'); } } @@ -185,9 +185,9 @@ public final String toString() { @Override public Attribute copy( final ConstantPool _constant_pool ) { final LocalVariableTable c = (LocalVariableTable) clone(); - c.local_variable_table = new LocalVariable[local_variable_table.length]; - for (int i = 0; i < local_variable_table.length; i++) { - c.local_variable_table[i] = local_variable_table[i].copy(); + c.localVariableTable = new LocalVariable[localVariableTable.length]; + for (int i = 0; i < localVariableTable.length; i++) { + c.localVariableTable[i] = localVariableTable[i].copy(); } c.setConstantPool(_constant_pool); return c; @@ -195,6 +195,6 @@ public Attribute copy( final ConstantPool _constant_pool ) { public final int getTableLength() { - return local_variable_table == null ? 0 : local_variable_table.length; + return localVariableTable == null ? 0 : localVariableTable.length; } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LocalVariableTypeTable.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LocalVariableTypeTable.java index b0c781e7db6..bdd5d7a1bd1 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LocalVariableTypeTable.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LocalVariableTypeTable.java @@ -50,7 +50,7 @@ // u2 name_index; // u2 signature_index; // u2 index; -// } local_variable_type_table[local_variable_type_table_length]; +// } localVariableTypeTable[local_variable_type_table_length]; // } // J5TODO: Needs some testing ! @@ -59,7 +59,7 @@ */ public class LocalVariableTypeTable extends Attribute { - private LocalVariable[] local_variable_type_table; // variables + private LocalVariable[] localVariableTypeTable; // variables public LocalVariableTypeTable(final LocalVariableTypeTable c) { this(c.getNameIndex(), c.getLength(), c.getLocalVariableTypeTable(), c.getConstantPool()); @@ -67,17 +67,17 @@ public LocalVariableTypeTable(final LocalVariableTypeTable c) { public LocalVariableTypeTable(final int name_index, final int length, final LocalVariable[] local_variable_table, final ConstantPool constant_pool) { super(Const.ATTR_LOCAL_VARIABLE_TYPE_TABLE, name_index, length, constant_pool); - this.local_variable_type_table = local_variable_table; + this.localVariableTypeTable = local_variable_table; } LocalVariableTypeTable(final int nameIdx, final int len, final DataInput input, final ConstantPool cpool) throws IOException { this(nameIdx, len, (LocalVariable[]) null, cpool); final int local_variable_type_table_length = input.readUnsignedShort(); - local_variable_type_table = new LocalVariable[local_variable_type_table_length]; + localVariableTypeTable = new LocalVariable[local_variable_type_table_length]; for (int i = 0; i < local_variable_type_table_length; i++) { - local_variable_type_table[i] = new LocalVariable(input, cpool); + localVariableTypeTable[i] = new LocalVariable(input, cpool); } } @@ -89,18 +89,18 @@ public void accept(final Visitor v) { @Override public final void dump(final DataOutputStream file) throws IOException { super.dump(file); - file.writeShort(local_variable_type_table.length); - for (final LocalVariable variable : local_variable_type_table) { + file.writeShort(localVariableTypeTable.length); + for (final LocalVariable variable : localVariableTypeTable) { variable.dump(file); } } public final LocalVariable[] getLocalVariableTypeTable() { - return local_variable_type_table; + return localVariableTypeTable; } public final LocalVariable getLocalVariable(final int index) { - for (final LocalVariable variable : local_variable_type_table) { + for (final LocalVariable variable : localVariableTypeTable) { if (variable.getIndex() == index) { return variable; } @@ -110,7 +110,7 @@ public final LocalVariable getLocalVariable(final int index) { } public final void setLocalVariableTable(final LocalVariable[] local_variable_table) { - this.local_variable_type_table = local_variable_table; + this.localVariableTypeTable = local_variable_table; } /** @@ -120,10 +120,10 @@ public final void setLocalVariableTable(final LocalVariable[] local_variable_tab public final String toString() { final StringBuilder buf = new StringBuilder(); - for (int i = 0; i < local_variable_type_table.length; i++) { - buf.append(local_variable_type_table[i].toStringShared(true)); + for (int i = 0; i < localVariableTypeTable.length; i++) { + buf.append(localVariableTypeTable[i].toStringShared(true)); - if (i < local_variable_type_table.length - 1) { + if (i < localVariableTypeTable.length - 1) { buf.append('\n'); } } @@ -138,9 +138,9 @@ public final String toString() { public Attribute copy(final ConstantPool constant_pool) { final LocalVariableTypeTable c = (LocalVariableTypeTable) clone(); - c.local_variable_type_table = new LocalVariable[local_variable_type_table.length]; - for (int i = 0; i < local_variable_type_table.length; i++) { - c.local_variable_type_table[i] = local_variable_type_table[i].copy(); + c.localVariableTypeTable = new LocalVariable[localVariableTypeTable.length]; + for (int i = 0; i < localVariableTypeTable.length; i++) { + c.localVariableTypeTable[i] = localVariableTypeTable[i].copy(); } c.setConstantPool(constant_pool); @@ -148,6 +148,6 @@ public Attribute copy(final ConstantPool constant_pool) { } public final int getTableLength() { - return local_variable_type_table == null ? 0 : local_variable_type_table.length; + return localVariableTypeTable == null ? 0 : localVariableTypeTable.length; } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/MethodParameter.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/MethodParameter.java index 1d0bc160662..86155336302 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/MethodParameter.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/MethodParameter.java @@ -30,17 +30,17 @@ /** * Entry of the parameters table. * - * @see + * @see * The class File Format : The MethodParameters Attribute * @since 6.0 */ public class MethodParameter implements Cloneable { /** Index of the CONSTANT_Utf8_info structure in the constant_pool table representing the name of the parameter */ - private int name_index; + private int nameIndex; /** The access flags */ - private int access_flags; + private int accessFlags; public MethodParameter() { } @@ -53,46 +53,46 @@ public MethodParameter() { * @throws ClassFormatException */ MethodParameter(final DataInput input) throws IOException { - name_index = input.readUnsignedShort(); - access_flags = input.readUnsignedShort(); + nameIndex = input.readUnsignedShort(); + accessFlags = input.readUnsignedShort(); } public int getNameIndex() { - return name_index; + return nameIndex; } public void setNameIndex(final int name_index) { - this.name_index = name_index; + this.nameIndex = name_index; } /** * Returns the name of the parameter. */ public String getParameterName(final ConstantPool constant_pool) { - if (name_index == 0) { + if (nameIndex == 0) { return null; } - return ((ConstantUtf8) constant_pool.getConstant(name_index, Const.CONSTANT_Utf8)).getBytes(); + return ((ConstantUtf8) constant_pool.getConstant(nameIndex, Const.CONSTANT_Utf8)).getBytes(); } public int getAccessFlags() { - return access_flags; + return accessFlags; } public void setAccessFlags(final int access_flags) { - this.access_flags = access_flags; + this.accessFlags = access_flags; } public boolean isFinal() { - return (access_flags & Const.ACC_FINAL) != 0; + return (accessFlags & Const.ACC_FINAL) != 0; } public boolean isSynthetic() { - return (access_flags & Const.ACC_SYNTHETIC) != 0; + return (accessFlags & Const.ACC_SYNTHETIC) != 0; } public boolean isMandated() { - return (access_flags & Const.ACC_MANDATED) != 0; + return (accessFlags & Const.ACC_MANDATED) != 0; } public void accept(final Visitor v) { @@ -106,8 +106,8 @@ public void accept(final Visitor v) { * @throws IOException */ public final void dump(final DataOutputStream file) throws IOException { - file.writeShort(name_index); - file.writeShort(access_flags); + file.writeShort(nameIndex); + file.writeShort(accessFlags); } /** diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/MethodParameters.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/MethodParameters.java index 0bab2b0b2c6..0ee75fb6355 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/MethodParameters.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/MethodParameters.java @@ -30,7 +30,7 @@ /** * This class represents a MethodParameters attribute. * - * @see + * @see * The class File Format : The MethodParameters Attribute * @since 6.0 */ diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Module.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Module.java index ff4dfe338f8..ffb87b1123b 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Module.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Module.java @@ -28,7 +28,8 @@ import com.sun.org.apache.bcel.internal.Const; /** - * This class is derived from Attribute and represents the list of modules required, exported, opened or provided by a module. + * This class is derived from Attribute and represents the list of + * modules required, exported, opened or provided by a module. * There may be at most one Module attribute in a ClassFile structure. * * @see Attribute @@ -36,16 +37,16 @@ */ public final class Module extends Attribute { - private final int module_name_index; - private final int module_flags; - private final int module_version_index; + private final int moduleNameIndex; + private final int moduleFlags; + private final int moduleVersionIndex; - private ModuleRequires[] requires_table; - private ModuleExports[] exports_table; - private ModuleOpens[] opens_table; - private final int uses_count; - private final int[] uses_index; - private ModuleProvides[] provides_table; + private ModuleRequires[] requiresTable; + private ModuleExports[] exportsTable; + private ModuleOpens[] opensTable; + private final int usesCount; + private final int[] usesIndex; + private ModuleProvides[] providesTable; /** * Construct object from input stream. @@ -58,38 +59,38 @@ public final class Module extends Attribute { Module(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) throws IOException { super(Const.ATTR_MODULE, name_index, length, constant_pool); - module_name_index = input.readUnsignedShort(); - module_flags = input.readUnsignedShort(); - module_version_index = input.readUnsignedShort(); + moduleNameIndex = input.readUnsignedShort(); + moduleFlags = input.readUnsignedShort(); + moduleVersionIndex = input.readUnsignedShort(); final int requires_count = input.readUnsignedShort(); - requires_table = new ModuleRequires[requires_count]; + requiresTable = new ModuleRequires[requires_count]; for (int i = 0; i < requires_count; i++) { - requires_table[i] = new ModuleRequires(input); + requiresTable[i] = new ModuleRequires(input); } final int exports_count = input.readUnsignedShort(); - exports_table = new ModuleExports[exports_count]; + exportsTable = new ModuleExports[exports_count]; for (int i = 0; i < exports_count; i++) { - exports_table[i] = new ModuleExports(input); + exportsTable[i] = new ModuleExports(input); } final int opens_count = input.readUnsignedShort(); - opens_table = new ModuleOpens[opens_count]; + opensTable = new ModuleOpens[opens_count]; for (int i = 0; i < opens_count; i++) { - opens_table[i] = new ModuleOpens(input); + opensTable[i] = new ModuleOpens(input); } - uses_count = input.readUnsignedShort(); - uses_index = new int[uses_count]; - for (int i = 0; i < uses_count; i++) { - uses_index[i] = input.readUnsignedShort(); + usesCount = input.readUnsignedShort(); + usesIndex = new int[usesCount]; + for (int i = 0; i < usesCount; i++) { + usesIndex[i] = input.readUnsignedShort(); } final int provides_count = input.readUnsignedShort(); - provides_table = new ModuleProvides[provides_count]; + providesTable = new ModuleProvides[provides_count]; for (int i = 0; i < provides_count; i++) { - provides_table[i] = new ModuleProvides(input); + providesTable[i] = new ModuleProvides(input); } } @@ -113,7 +114,7 @@ public void accept( final Visitor v ) { * @see ModuleRequires */ public ModuleRequires[] getRequiresTable() { - return requires_table; + return requiresTable; } @@ -122,7 +123,7 @@ public ModuleRequires[] getRequiresTable() { * @see ModuleExports */ public ModuleExports[] getExportsTable() { - return exports_table; + return exportsTable; } @@ -131,7 +132,7 @@ public ModuleExports[] getExportsTable() { * @see ModuleOpens */ public ModuleOpens[] getOpensTable() { - return opens_table; + return opensTable; } @@ -140,7 +141,7 @@ public ModuleOpens[] getOpensTable() { * @see ModuleProvides */ public ModuleProvides[] getProvidesTable() { - return provides_table; + return providesTable; } @@ -154,32 +155,32 @@ public ModuleProvides[] getProvidesTable() { public void dump( final DataOutputStream file ) throws IOException { super.dump(file); - file.writeShort(module_name_index); - file.writeShort(module_flags); - file.writeShort(module_version_index); + file.writeShort(moduleNameIndex); + file.writeShort(moduleFlags); + file.writeShort(moduleVersionIndex); - file.writeShort(requires_table.length); - for (final ModuleRequires entry : requires_table) { + file.writeShort(requiresTable.length); + for (final ModuleRequires entry : requiresTable) { entry.dump(file); } - file.writeShort(exports_table.length); - for (final ModuleExports entry : exports_table) { + file.writeShort(exportsTable.length); + for (final ModuleExports entry : exportsTable) { entry.dump(file); } - file.writeShort(opens_table.length); - for (final ModuleOpens entry : opens_table) { + file.writeShort(opensTable.length); + for (final ModuleOpens entry : opensTable) { entry.dump(file); } - file.writeShort(uses_index.length); - for (final int entry : uses_index) { + file.writeShort(usesIndex.length); + for (final int entry : usesIndex) { file.writeShort(entry); } - file.writeShort(provides_table.length); - for (final ModuleProvides entry : provides_table) { + file.writeShort(providesTable.length); + for (final ModuleProvides entry : providesTable) { entry.dump(file); } } @@ -193,34 +194,34 @@ public String toString() { final ConstantPool cp = super.getConstantPool(); final StringBuilder buf = new StringBuilder(); buf.append("Module:\n"); - buf.append(" name: ") .append(cp.getConstantString(module_name_index, Const.CONSTANT_Module).replace('/', '.')).append("\n"); - buf.append(" flags: ") .append(String.format("%04x", module_flags)).append("\n"); - final String version = module_version_index == 0 ? "0" : cp.getConstantString(module_version_index, Const.CONSTANT_Utf8); + buf.append(" name: ") .append(cp.getConstantString(moduleNameIndex, Const.CONSTANT_Module).replace('/', '.')).append("\n"); + buf.append(" flags: ") .append(String.format("%04x", moduleFlags)).append("\n"); + final String version = moduleVersionIndex == 0 ? "0" : cp.getConstantString(moduleVersionIndex, Const.CONSTANT_Utf8); buf.append(" version: ") .append(version).append("\n"); - buf.append(" requires(").append(requires_table.length).append("):\n"); - for (final ModuleRequires module : requires_table) { + buf.append(" requires(").append(requiresTable.length).append("):\n"); + for (final ModuleRequires module : requiresTable) { buf.append(" ").append(module.toString(cp)).append("\n"); } - buf.append(" exports(").append(exports_table.length).append("):\n"); - for (final ModuleExports module : exports_table) { + buf.append(" exports(").append(exportsTable.length).append("):\n"); + for (final ModuleExports module : exportsTable) { buf.append(" ").append(module.toString(cp)).append("\n"); } - buf.append(" opens(").append(opens_table.length).append("):\n"); - for (final ModuleOpens module : opens_table) { + buf.append(" opens(").append(opensTable.length).append("):\n"); + for (final ModuleOpens module : opensTable) { buf.append(" ").append(module.toString(cp)).append("\n"); } - buf.append(" uses(").append(uses_index.length).append("):\n"); - for (final int index : uses_index) { + buf.append(" uses(").append(usesIndex.length).append("):\n"); + for (final int index : usesIndex) { final String class_name = cp.getConstantString(index, Const.CONSTANT_Class); buf.append(" ").append(Utility.compactClassName(class_name, false)).append("\n"); } - buf.append(" provides(").append(provides_table.length).append("):\n"); - for (final ModuleProvides module : provides_table) { + buf.append(" provides(").append(providesTable.length).append("):\n"); + for (final ModuleProvides module : providesTable) { buf.append(" ").append(module.toString(cp)).append("\n"); } @@ -235,24 +236,24 @@ public String toString() { public Attribute copy( final ConstantPool _constant_pool ) { final Module c = (Module) clone(); - c.requires_table = new ModuleRequires[requires_table.length]; - for (int i = 0; i < requires_table.length; i++) { - c.requires_table[i] = requires_table[i].copy(); + c.requiresTable = new ModuleRequires[requiresTable.length]; + for (int i = 0; i < requiresTable.length; i++) { + c.requiresTable[i] = requiresTable[i].copy(); } - c.exports_table = new ModuleExports[exports_table.length]; - for (int i = 0; i < exports_table.length; i++) { - c.exports_table[i] = exports_table[i].copy(); + c.exportsTable = new ModuleExports[exportsTable.length]; + for (int i = 0; i < exportsTable.length; i++) { + c.exportsTable[i] = exportsTable[i].copy(); } - c.opens_table = new ModuleOpens[opens_table.length]; - for (int i = 0; i < opens_table.length; i++) { - c.opens_table[i] = opens_table[i].copy(); + c.opensTable = new ModuleOpens[opensTable.length]; + for (int i = 0; i < opensTable.length; i++) { + c.opensTable[i] = opensTable[i].copy(); } - c.provides_table = new ModuleProvides[provides_table.length]; - for (int i = 0; i < provides_table.length; i++) { - c.provides_table[i] = provides_table[i].copy(); + c.providesTable = new ModuleProvides[providesTable.length]; + for (int i = 0; i < providesTable.length; i++) { + c.providesTable[i] = providesTable[i].copy(); } c.setConstantPool(_constant_pool); diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleExports.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleExports.java index 441c08b47aa..ec581c8baf1 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleExports.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleExports.java @@ -36,10 +36,10 @@ */ public final class ModuleExports implements Cloneable, Node { - private final int exports_index; // points to CONSTANT_Package_info - private final int exports_flags; - private final int exports_to_count; - private final int[] exports_to_index; // points to CONSTANT_Module_info + private final int exportsIndex; // points to CONSTANT_Package_info + private final int exportsFlags; + private final int exportsToCount; + private final int[] exportsToIndex; // points to CONSTANT_Module_info /** @@ -49,12 +49,12 @@ public final class ModuleExports implements Cloneable, Node { * @throws IOException if an I/O Exception occurs in readUnsignedShort */ ModuleExports(final DataInput file) throws IOException { - exports_index = file.readUnsignedShort(); - exports_flags = file.readUnsignedShort(); - exports_to_count = file.readUnsignedShort(); - exports_to_index = new int[exports_to_count]; - for (int i = 0; i < exports_to_count; i++) { - exports_to_index[i] = file.readUnsignedShort(); + exportsIndex = file.readUnsignedShort(); + exportsFlags = file.readUnsignedShort(); + exportsToCount = file.readUnsignedShort(); + exportsToIndex = new int[exportsToCount]; + for (int i = 0; i < exportsToCount; i++) { + exportsToIndex[i] = file.readUnsignedShort(); } } @@ -80,10 +80,10 @@ public void accept( final Visitor v ) { * @throws IOException if an I/O Exception occurs in writeShort */ public void dump( final DataOutputStream file ) throws IOException { - file.writeShort(exports_index); - file.writeShort(exports_flags); - file.writeShort(exports_to_count); - for (final int entry : exports_to_index) { + file.writeShort(exportsIndex); + file.writeShort(exportsFlags); + file.writeShort(exportsToCount); + for (final int entry : exportsToIndex) { file.writeShort(entry); } } @@ -94,7 +94,7 @@ public void dump( final DataOutputStream file ) throws IOException { */ @Override public String toString() { - return "exports(" + exports_index + ", " + exports_flags + ", " + exports_to_count + ", ...)"; + return "exports(" + exportsIndex + ", " + exportsFlags + ", " + exportsToCount + ", ...)"; } @@ -103,11 +103,11 @@ public String toString() { */ public String toString( final ConstantPool constant_pool ) { final StringBuilder buf = new StringBuilder(); - final String package_name = constant_pool.constantToString(exports_index, Const.CONSTANT_Package); + final String package_name = constant_pool.constantToString(exportsIndex, Const.CONSTANT_Package); buf.append(Utility.compactClassName(package_name, false)); - buf.append(", ").append(String.format("%04x", exports_flags)); - buf.append(", to(").append(exports_to_count).append("):\n"); - for (final int index : exports_to_index) { + buf.append(", ").append(String.format("%04x", exportsFlags)); + buf.append(", to(").append(exportsToCount).append("):\n"); + for (final int index : exportsToIndex) { final String module_name = constant_pool.getConstantString(index, Const.CONSTANT_Module); buf.append(" ").append(Utility.compactClassName(module_name, false)).append("\n"); } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleMainClass.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleMainClass.java index 2924df18001..7b6d89ed69a 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleMainClass.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleMainClass.java @@ -35,7 +35,7 @@ */ public final class ModuleMainClass extends Attribute { - private int main_class_index; + private int mainClassIndex; /** @@ -50,27 +50,27 @@ public ModuleMainClass(final ModuleMainClass c) { /** * @param name_index Index in constant pool * @param length Content length in bytes - * @param main_class_index Host class index - * @param constant_pool Array of constants + * @param mainClassIndex Host class index + * @param constantPool Array of constants */ - public ModuleMainClass(final int name_index, final int length, final int main_class_index, - final ConstantPool constant_pool) { - super(Const.ATTR_NEST_MEMBERS, name_index, length, constant_pool); - this.main_class_index = main_class_index; + public ModuleMainClass(final int name_index, final int length, final int mainClassIndex, + final ConstantPool constantPool) { + super(Const.ATTR_NEST_MEMBERS, name_index, length, constantPool); + this.mainClassIndex = mainClassIndex; } /** * Construct object from input stream. - * @param name_index Index in constant pool + * @param nameIndex Index in constant pool * @param length Content length in bytes * @param input Input stream - * @param constant_pool Array of constants + * @param constantPool Array of constants * @throws IOException */ - ModuleMainClass(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) throws IOException { - this(name_index, length, 0, constant_pool); - main_class_index = input.readUnsignedShort(); + ModuleMainClass(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, 0, constantPool); + mainClassIndex = input.readUnsignedShort(); } @@ -96,7 +96,7 @@ public void accept( final Visitor v ) { @Override public void dump( final DataOutputStream file ) throws IOException { super.dump(file); - file.writeShort(main_class_index); + file.writeShort(mainClassIndex); } @@ -104,15 +104,15 @@ public void dump( final DataOutputStream file ) throws IOException { * @return index into constant pool of host class name. */ public int getHostClassIndex() { - return main_class_index; + return mainClassIndex; } /** - * @param main_class_index the host class index + * @param mainClassIndex the host class index */ - public void setHostClassIndex( final int main_class_index ) { - this.main_class_index = main_class_index; + public void setHostClassIndex( final int mainClassIndex ) { + this.mainClassIndex = mainClassIndex; } @@ -123,7 +123,7 @@ public void setHostClassIndex( final int main_class_index ) { public String toString() { final StringBuilder buf = new StringBuilder(); buf.append("ModuleMainClass: "); - final String class_name = super.getConstantPool().getConstantString(main_class_index, Const.CONSTANT_Class); + final String class_name = super.getConstantPool().getConstantString(mainClassIndex, Const.CONSTANT_Class); buf.append(Utility.compactClassName(class_name, false)); return buf.toString(); } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleOpens.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleOpens.java index 81d4eb2cd2a..341228ea3a3 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleOpens.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleOpens.java @@ -36,10 +36,10 @@ */ public final class ModuleOpens implements Cloneable, Node { - private final int opens_index; // points to CONSTANT_Package_info - private final int opens_flags; - private final int opens_to_count; - private final int[] opens_to_index; // points to CONSTANT_Module_info + private final int opensIndex; // points to CONSTANT_Package_info + private final int opensFlags; + private final int opensToCount; + private final int[] opensToIndex; // points to CONSTANT_Module_info /** @@ -49,12 +49,12 @@ public final class ModuleOpens implements Cloneable, Node { * @throws IOException if an I/O Exception occurs in readUnsignedShort */ ModuleOpens(final DataInput file) throws IOException { - opens_index = file.readUnsignedShort(); - opens_flags = file.readUnsignedShort(); - opens_to_count = file.readUnsignedShort(); - opens_to_index = new int[opens_to_count]; - for (int i = 0; i < opens_to_count; i++) { - opens_to_index[i] = file.readUnsignedShort(); + opensIndex = file.readUnsignedShort(); + opensFlags = file.readUnsignedShort(); + opensToCount = file.readUnsignedShort(); + opensToIndex = new int[opensToCount]; + for (int i = 0; i < opensToCount; i++) { + opensToIndex[i] = file.readUnsignedShort(); } } @@ -80,10 +80,10 @@ public void accept( final Visitor v ) { * @throws IOException if an I/O Exception occurs in writeShort */ public void dump( final DataOutputStream file ) throws IOException { - file.writeShort(opens_index); - file.writeShort(opens_flags); - file.writeShort(opens_to_count); - for (final int entry : opens_to_index) { + file.writeShort(opensIndex); + file.writeShort(opensFlags); + file.writeShort(opensToCount); + for (final int entry : opensToIndex) { file.writeShort(entry); } } @@ -94,7 +94,7 @@ public void dump( final DataOutputStream file ) throws IOException { */ @Override public String toString() { - return "opens(" + opens_index + ", " + opens_flags + ", " + opens_to_count + ", ...)"; + return "opens(" + opensIndex + ", " + opensFlags + ", " + opensToCount + ", ...)"; } @@ -103,11 +103,11 @@ public String toString() { */ public String toString( final ConstantPool constant_pool ) { final StringBuilder buf = new StringBuilder(); - final String package_name = constant_pool.constantToString(opens_index, Const.CONSTANT_Package); + final String package_name = constant_pool.constantToString(opensIndex, Const.CONSTANT_Package); buf.append(Utility.compactClassName(package_name, false)); - buf.append(", ").append(String.format("%04x", opens_flags)); - buf.append(", to(").append(opens_to_count).append("):\n"); - for (final int index : opens_to_index) { + buf.append(", ").append(String.format("%04x", opensFlags)); + buf.append(", to(").append(opensToCount).append("):\n"); + for (final int index : opensToIndex) { final String module_name = constant_pool.getConstantString(index, Const.CONSTANT_Module); buf.append(" ").append(Utility.compactClassName(module_name, false)).append("\n"); } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModulePackages.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModulePackages.java index f946bd0b3a1..1e1cb98731d 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModulePackages.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModulePackages.java @@ -35,7 +35,7 @@ */ public final class ModulePackages extends Attribute { - private int[] package_index_table; + private int[] packageIndexTable; /** @@ -48,15 +48,15 @@ public ModulePackages(final ModulePackages c) { /** - * @param name_index Index in constant pool + * @param nameIndex Index in constant pool * @param length Content length in bytes - * @param package_index_table Table of indices in constant pool - * @param constant_pool Array of constants + * @param packageIndexTable Table of indices in constant pool + * @param constantPool Array of constants */ - public ModulePackages(final int name_index, final int length, final int[] package_index_table, - final ConstantPool constant_pool) { - super(Const.ATTR_MODULE_PACKAGES, name_index, length, constant_pool); - this.package_index_table = package_index_table != null ? package_index_table : new int[0]; + public ModulePackages(final int nameIndex, final int length, final int[] packageIndexTable, + final ConstantPool constantPool) { + super(Const.ATTR_MODULE_PACKAGES, nameIndex, length, constantPool); + this.packageIndexTable = packageIndexTable != null ? packageIndexTable : new int[0]; } @@ -71,9 +71,9 @@ public ModulePackages(final int name_index, final int length, final int[] packag ModulePackages(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) throws IOException { this(name_index, length, (int[]) null, constant_pool); final int number_of_packages = input.readUnsignedShort(); - package_index_table = new int[number_of_packages]; + packageIndexTable = new int[number_of_packages]; for (int i = 0; i < number_of_packages; i++) { - package_index_table[i] = input.readUnsignedShort(); + packageIndexTable[i] = input.readUnsignedShort(); } } @@ -100,8 +100,8 @@ public void accept( final Visitor v ) { @Override public void dump( final DataOutputStream file ) throws IOException { super.dump(file); - file.writeShort(package_index_table.length); - for (final int index : package_index_table) { + file.writeShort(packageIndexTable.length); + for (final int index : packageIndexTable) { file.writeShort(index); } } @@ -111,7 +111,7 @@ public void dump( final DataOutputStream file ) throws IOException { * @return array of indices into constant pool of package names. */ public int[] getPackageIndexTable() { - return package_index_table; + return packageIndexTable; } @@ -119,7 +119,7 @@ public int[] getPackageIndexTable() { * @return Length of package table. */ public int getNumberOfPackages() { - return package_index_table == null ? 0 : package_index_table.length; + return packageIndexTable == null ? 0 : packageIndexTable.length; } @@ -127,9 +127,9 @@ public int getNumberOfPackages() { * @return string array of package names */ public String[] getPackageNames() { - final String[] names = new String[package_index_table.length]; - for (int i = 0; i < package_index_table.length; i++) { - names[i] = super.getConstantPool().getConstantString(package_index_table[i], + final String[] names = new String[packageIndexTable.length]; + for (int i = 0; i < packageIndexTable.length; i++) { + names[i] = super.getConstantPool().getConstantString(packageIndexTable[i], Const.CONSTANT_Package).replace('/', '.'); } return names; @@ -137,11 +137,11 @@ public String[] getPackageNames() { /** - * @param package_index_table the list of package indexes + * @param packageIndexTable the list of package indexes * Also redefines number_of_packages according to table length. */ - public void setPackageIndexTable( final int[] package_index_table ) { - this.package_index_table = package_index_table != null ? package_index_table : new int[0]; + public void setPackageIndexTable( final int[] packageIndexTable ) { + this.packageIndexTable = packageIndexTable != null ? packageIndexTable : new int[0]; } @@ -152,9 +152,9 @@ public void setPackageIndexTable( final int[] package_index_table ) { public String toString() { final StringBuilder buf = new StringBuilder(); buf.append("ModulePackages("); - buf.append(package_index_table.length); + buf.append(packageIndexTable.length); buf.append("):\n"); - for (final int index : package_index_table) { + for (final int index : packageIndexTable) { final String package_name = super.getConstantPool().getConstantString(index, Const.CONSTANT_Package); buf.append(" ").append(Utility.compactClassName(package_name, false)).append("\n"); } @@ -168,10 +168,10 @@ public String toString() { @Override public Attribute copy( final ConstantPool _constant_pool ) { final ModulePackages c = (ModulePackages) clone(); - if (package_index_table != null) { - c.package_index_table = new int[package_index_table.length]; - System.arraycopy(package_index_table, 0, c.package_index_table, 0, - package_index_table.length); + if (packageIndexTable != null) { + c.packageIndexTable = new int[packageIndexTable.length]; + System.arraycopy(packageIndexTable, 0, c.packageIndexTable, 0, + packageIndexTable.length); } c.setConstantPool(_constant_pool); return c; diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleProvides.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleProvides.java index 90c10599652..8cbeecc3f26 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleProvides.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleProvides.java @@ -36,9 +36,9 @@ */ public final class ModuleProvides implements Cloneable, Node { - private final int provides_index; // points to CONSTANT_Class_info - private final int provides_with_count; - private final int[] provides_with_index; // points to CONSTANT_Class_info + private final int providesIndex; // points to CONSTANT_Class_info + private final int providesWithCount; + private final int[] providesWithIndex; // points to CONSTANT_Class_info /** @@ -48,11 +48,11 @@ public final class ModuleProvides implements Cloneable, Node { * @throws IOException if an I/O Exception occurs in readUnsignedShort */ ModuleProvides(final DataInput file) throws IOException { - provides_index = file.readUnsignedShort(); - provides_with_count = file.readUnsignedShort(); - provides_with_index = new int[provides_with_count]; - for (int i = 0; i < provides_with_count; i++) { - provides_with_index[i] = file.readUnsignedShort(); + providesIndex = file.readUnsignedShort(); + providesWithCount = file.readUnsignedShort(); + providesWithIndex = new int[providesWithCount]; + for (int i = 0; i < providesWithCount; i++) { + providesWithIndex[i] = file.readUnsignedShort(); } } @@ -78,9 +78,9 @@ public void accept( final Visitor v ) { * @throws IOException if an I/O Exception occurs in writeShort */ public void dump( final DataOutputStream file ) throws IOException { - file.writeShort(provides_index); - file.writeShort(provides_with_count); - for (final int entry : provides_with_index) { + file.writeShort(providesIndex); + file.writeShort(providesWithCount); + for (final int entry : providesWithIndex) { file.writeShort(entry); } } @@ -91,7 +91,7 @@ public void dump( final DataOutputStream file ) throws IOException { */ @Override public String toString() { - return "provides(" + provides_index + ", " + provides_with_count + ", ...)"; + return "provides(" + providesIndex + ", " + providesWithCount + ", ...)"; } @@ -100,10 +100,10 @@ public String toString() { */ public String toString( final ConstantPool constant_pool ) { final StringBuilder buf = new StringBuilder(); - final String interface_name = constant_pool.constantToString(provides_index, Const.CONSTANT_Class); + final String interface_name = constant_pool.constantToString(providesIndex, Const.CONSTANT_Class); buf.append(Utility.compactClassName(interface_name, false)); - buf.append(", with(").append(provides_with_count).append("):\n"); - for (final int index : provides_with_index) { + buf.append(", with(").append(providesWithCount).append("):\n"); + for (final int index : providesWithIndex) { final String class_name = constant_pool.getConstantString(index, Const.CONSTANT_Class); buf.append(" ").append(Utility.compactClassName(class_name, false)).append("\n"); } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleRequires.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleRequires.java index d860a866bc1..a368197220d 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleRequires.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleRequires.java @@ -36,9 +36,9 @@ */ public final class ModuleRequires implements Cloneable, Node { - private final int requires_index; // points to CONSTANT_Module_info - private final int requires_flags; - private final int requires_version_index; // either 0 or points to CONSTANT_Utf8_info + private final int requiresIndex; // points to CONSTANT_Module_info + private final int requiresFlags; + private final int requiresVersionIndex; // either 0 or points to CONSTANT_Utf8_info /** @@ -48,9 +48,9 @@ public final class ModuleRequires implements Cloneable, Node { * @throws IOException if an I/O Exception occurs in readUnsignedShort */ ModuleRequires(final DataInput file) throws IOException { - requires_index = file.readUnsignedShort(); - requires_flags = file.readUnsignedShort(); - requires_version_index = file.readUnsignedShort(); + requiresIndex = file.readUnsignedShort(); + requiresFlags = file.readUnsignedShort(); + requiresVersionIndex = file.readUnsignedShort(); } @@ -75,9 +75,9 @@ public void accept( final Visitor v ) { * @throws IOException if an I/O Exception occurs in writeShort */ public void dump( final DataOutputStream file ) throws IOException { - file.writeShort(requires_index); - file.writeShort(requires_flags); - file.writeShort(requires_version_index); + file.writeShort(requiresIndex); + file.writeShort(requiresFlags); + file.writeShort(requiresVersionIndex); } @@ -86,7 +86,7 @@ public void dump( final DataOutputStream file ) throws IOException { */ @Override public String toString() { - return "requires(" + requires_index + ", " + String.format("%04x", requires_flags) + ", " + requires_version_index + ")"; + return "requires(" + requiresIndex + ", " + String.format("%04x", requiresFlags) + ", " + requiresVersionIndex + ")"; } @@ -95,10 +95,10 @@ public String toString() { */ public String toString( final ConstantPool constant_pool ) { final StringBuilder buf = new StringBuilder(); - final String module_name = constant_pool.constantToString(requires_index, Const.CONSTANT_Module); + final String module_name = constant_pool.constantToString(requiresIndex, Const.CONSTANT_Module); buf.append(Utility.compactClassName(module_name, false)); - buf.append(", ").append(String.format("%04x", requires_flags)); - final String version = requires_version_index == 0 ? "0" : constant_pool.getConstantString(requires_version_index, Const.CONSTANT_Utf8); + buf.append(", ").append(String.format("%04x", requiresFlags)); + final String version = requiresVersionIndex == 0 ? "0" : constant_pool.getConstantString(requiresVersionIndex, Const.CONSTANT_Utf8); buf.append(", ").append(version); return buf.toString(); } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/NestHost.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/NestHost.java index c71b28e9851..b9a0a1d68a4 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/NestHost.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/NestHost.java @@ -36,7 +36,7 @@ */ public final class NestHost extends Attribute { - private int host_class_index; + private int hostClassIndex; /** @@ -49,15 +49,15 @@ public NestHost(final NestHost c) { /** - * @param name_index Index in constant pool + * @param nameIndex Index in constant pool * @param length Content length in bytes - * @param host_class_index Host class index - * @param constant_pool Array of constants + * @param hostClassIndex Host class index + * @param constantPool Array of constants */ - public NestHost(final int name_index, final int length, final int host_class_index, - final ConstantPool constant_pool) { - super(Const.ATTR_NEST_MEMBERS, name_index, length, constant_pool); - this.host_class_index = host_class_index; + public NestHost(final int nameIndex, final int length, final int hostClassIndex, + final ConstantPool constantPool) { + super(Const.ATTR_NEST_MEMBERS, nameIndex, length, constantPool); + this.hostClassIndex = hostClassIndex; } @@ -71,7 +71,7 @@ public NestHost(final int name_index, final int length, final int host_class_ind */ NestHost(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) throws IOException { this(name_index, length, 0, constant_pool); - host_class_index = input.readUnsignedShort(); + hostClassIndex = input.readUnsignedShort(); } @@ -97,7 +97,7 @@ public void accept( final Visitor v ) { @Override public void dump( final DataOutputStream file ) throws IOException { super.dump(file); - file.writeShort(host_class_index); + file.writeShort(hostClassIndex); } @@ -105,15 +105,15 @@ public void dump( final DataOutputStream file ) throws IOException { * @return index into constant pool of host class name. */ public int getHostClassIndex() { - return host_class_index; + return hostClassIndex; } /** - * @param host_class_index the host class index + * @param hostClassIndex the host class index */ - public void setHostClassIndex( final int host_class_index ) { - this.host_class_index = host_class_index; + public void setHostClassIndex( final int hostClassIndex ) { + this.hostClassIndex = hostClassIndex; } @@ -124,7 +124,7 @@ public void setHostClassIndex( final int host_class_index ) { public String toString() { final StringBuilder buf = new StringBuilder(); buf.append("NestHost: "); - final String class_name = super.getConstantPool().getConstantString(host_class_index, Const.CONSTANT_Class); + final String class_name = super.getConstantPool().getConstantString(hostClassIndex, Const.CONSTANT_Class); buf.append(Utility.compactClassName(class_name, false)); return buf.toString(); } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/PMGClass.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/PMGClass.java index 4d87c1873c7..fed7464e779 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/PMGClass.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/PMGClass.java @@ -35,17 +35,17 @@ */ public final class PMGClass extends Attribute { - private int pmg_class_index; - private int pmg_index; + private int pmgClassIndex; + private int pmgIndex; /** * Initialize from another object. Note that both objects use the same * references (shallow copy). Use copy() for a physical copy. */ - public PMGClass(final PMGClass c) { - this(c.getNameIndex(), c.getLength(), c.getPMGIndex(), c.getPMGClassIndex(), c - .getConstantPool()); + public PMGClass(final PMGClass pgmClass) { + this(pgmClass.getNameIndex(), pgmClass.getLength(), pgmClass.getPMGIndex(), pgmClass.getPMGClassIndex(), + pgmClass.getConstantPool()); } @@ -66,15 +66,15 @@ public PMGClass(final PMGClass c) { /** * @param name_index Index in constant pool to CONSTANT_Utf8 * @param length Content length in bytes - * @param pmg_index index in constant pool for source file name - * @param pmg_class_index Index in constant pool to CONSTANT_Utf8 - * @param constant_pool Array of constants + * @param pmgIndex index in constant pool for source file name + * @param pmgClassIndex Index in constant pool to CONSTANT_Utf8 + * @param constantPool Array of constants */ - public PMGClass(final int name_index, final int length, final int pmg_index, final int pmg_class_index, - final ConstantPool constant_pool) { - super(Const.ATTR_PMG, name_index, length, constant_pool); - this.pmg_index = pmg_index; - this.pmg_class_index = pmg_class_index; + public PMGClass(final int name_index, final int length, final int pmgIndex, final int pmgClassIndex, + final ConstantPool constantPool) { + super(Const.ATTR_PMG, name_index, length, constantPool); + this.pmgIndex = pmgIndex; + this.pmgClassIndex = pmgClassIndex; } @@ -100,8 +100,8 @@ public void accept( final Visitor v ) { @Override public void dump( final DataOutputStream file ) throws IOException { super.dump(file); - file.writeShort(pmg_index); - file.writeShort(pmg_class_index); + file.writeShort(pmgIndex); + file.writeShort(pmgClassIndex); } @@ -109,15 +109,15 @@ public void dump( final DataOutputStream file ) throws IOException { * @return Index in constant pool of source file name. */ public int getPMGClassIndex() { - return pmg_class_index; + return pmgClassIndex; } /** - * @param pmg_class_index + * @param pmgClassIndex */ - public void setPMGClassIndex( final int pmg_class_index ) { - this.pmg_class_index = pmg_class_index; + public void setPMGClassIndex( final int pmgClassIndex ) { + this.pmgClassIndex = pmgClassIndex; } @@ -125,15 +125,15 @@ public void setPMGClassIndex( final int pmg_class_index ) { * @return Index in constant pool of source file name. */ public int getPMGIndex() { - return pmg_index; + return pmgIndex; } /** - * @param pmg_index + * @param pmgIndex */ - public void setPMGIndex( final int pmg_index ) { - this.pmg_index = pmg_index; + public void setPMGIndex( final int pmgIndex ) { + this.pmgIndex = pmgIndex; } @@ -141,7 +141,7 @@ public void setPMGIndex( final int pmg_index ) { * @return PMG name. */ public String getPMGName() { - final ConstantUtf8 c = (ConstantUtf8) super.getConstantPool().getConstant(pmg_index, + final ConstantUtf8 c = (ConstantUtf8) super.getConstantPool().getConstant(pmgIndex, Const.CONSTANT_Utf8); return c.getBytes(); } @@ -151,7 +151,7 @@ public String getPMGName() { * @return PMG class name. */ public String getPMGClassName() { - final ConstantUtf8 c = (ConstantUtf8) super.getConstantPool().getConstant(pmg_class_index, + final ConstantUtf8 c = (ConstantUtf8) super.getConstantPool().getConstant(pmgClassIndex, Const.CONSTANT_Utf8); return c.getBytes(); } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ParameterAnnotationEntry.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ParameterAnnotationEntry.java index cf676e51df0..f652ad7ca11 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ParameterAnnotationEntry.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ParameterAnnotationEntry.java @@ -35,7 +35,7 @@ */ public class ParameterAnnotationEntry implements Node { - private final AnnotationEntry[] annotation_table; + private final AnnotationEntry[] annotationTable; /** @@ -46,10 +46,10 @@ public class ParameterAnnotationEntry implements Node { */ ParameterAnnotationEntry(final DataInput input, final ConstantPool constant_pool) throws IOException { final int annotation_table_length = input.readUnsignedShort(); - annotation_table = new AnnotationEntry[annotation_table_length]; + annotationTable = new AnnotationEntry[annotation_table_length]; for (int i = 0; i < annotation_table_length; i++) { // TODO isRuntimeVisible - annotation_table[i] = AnnotationEntry.read(input, constant_pool, false); + annotationTable[i] = AnnotationEntry.read(input, constant_pool, false); } } @@ -70,12 +70,12 @@ public void accept( final Visitor v ) { * returns the array of annotation entries in this annotation */ public AnnotationEntry[] getAnnotationEntries() { - return annotation_table; + return annotationTable; } public void dump(final DataOutputStream dos) throws IOException { - dos.writeShort(annotation_table.length); - for (final AnnotationEntry entry : annotation_table) { + dos.writeShort(annotationTable.length); + for (final AnnotationEntry entry : annotationTable) { entry.dump(dos); } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ParameterAnnotations.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ParameterAnnotations.java index 9ad197a8151..2370ed76aff 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ParameterAnnotations.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ParameterAnnotations.java @@ -33,7 +33,7 @@ public abstract class ParameterAnnotations extends Attribute { /** Table of parameter annotations */ - private ParameterAnnotationEntry[] parameter_annotation_table; + private ParameterAnnotationEntry[] parameterAnnotationTable; /** * @param parameter_annotation_type the subclass type of the parameter annotation @@ -47,24 +47,24 @@ public abstract class ParameterAnnotations extends Attribute { this(parameter_annotation_type, name_index, length, (ParameterAnnotationEntry[]) null, constant_pool); final int num_parameters = input.readUnsignedByte(); - parameter_annotation_table = new ParameterAnnotationEntry[num_parameters]; + parameterAnnotationTable = new ParameterAnnotationEntry[num_parameters]; for (int i = 0; i < num_parameters; i++) { - parameter_annotation_table[i] = new ParameterAnnotationEntry(input, constant_pool); + parameterAnnotationTable[i] = new ParameterAnnotationEntry(input, constant_pool); } } /** - * @param parameter_annotation_type the subclass type of the parameter annotation - * @param name_index Index pointing to the name Code + * @param parameterAnnotationType the subclass type of the parameter annotation + * @param nameIndex Index pointing to the name Code * @param length Content length in bytes - * @param parameter_annotation_table the actual parameter annotations - * @param constant_pool Array of constants + * @param parameterAnnotationTable the actual parameter annotations + * @param constantPool Array of constants */ - public ParameterAnnotations(final byte parameter_annotation_type, final int name_index, final int length, - final ParameterAnnotationEntry[] parameter_annotation_table, final ConstantPool constant_pool) { - super(parameter_annotation_type, name_index, length, constant_pool); - this.parameter_annotation_table = parameter_annotation_table; + public ParameterAnnotations(final byte parameterAnnotationType, final int nameIndex, final int length, + final ParameterAnnotationEntry[] parameterAnnotationTable, final ConstantPool constantPool) { + super(parameterAnnotationType, nameIndex, length, constantPool); + this.parameterAnnotationTable = parameterAnnotationTable; } @@ -82,10 +82,10 @@ public void accept( final Visitor v ) { /** - * @param parameter_annotation_table the entries to set in this parameter annotation + * @param parameterAnnotationTable the entries to set in this parameter annotation */ - public final void setParameterAnnotationTable(final ParameterAnnotationEntry[] parameter_annotation_table ) { - this.parameter_annotation_table = parameter_annotation_table; + public final void setParameterAnnotationTable(final ParameterAnnotationEntry[] parameterAnnotationTable ) { + this.parameterAnnotationTable = parameterAnnotationTable; } @@ -93,7 +93,7 @@ public final void setParameterAnnotationTable(final ParameterAnnotationEntry[] p * @return the parameter annotation entry table */ public final ParameterAnnotationEntry[] getParameterAnnotationTable() { - return parameter_annotation_table; + return parameterAnnotationTable; } @@ -101,16 +101,16 @@ public final ParameterAnnotationEntry[] getParameterAnnotationTable() { * returns the array of parameter annotation entries in this parameter annotation */ public ParameterAnnotationEntry[] getParameterAnnotationEntries() { - return parameter_annotation_table; + return parameterAnnotationTable; } @Override public void dump(final DataOutputStream dos) throws IOException { super.dump(dos); - dos.writeByte(parameter_annotation_table.length); + dos.writeByte(parameterAnnotationTable.length); - for (final ParameterAnnotationEntry element : parameter_annotation_table) { + for (final ParameterAnnotationEntry element : parameterAnnotationTable) { element.dump(dos); } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Signature.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Signature.java index a64760269af..45c138c6ad0 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Signature.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Signature.java @@ -36,7 +36,7 @@ */ public final class Signature extends Attribute { - private int signature_index; + private int signatureIndex; /** @@ -65,12 +65,12 @@ public Signature(final Signature c) { /** * @param name_index Index in constant pool to CONSTANT_Utf8 * @param length Content length in bytes - * @param signature_index Index in constant pool to CONSTANT_Utf8 + * @param signatureIndex Index in constant pool to CONSTANT_Utf8 * @param constant_pool Array of constants */ - public Signature(final int name_index, final int length, final int signature_index, final ConstantPool constant_pool) { + public Signature(final int name_index, final int length, final int signatureIndex, final ConstantPool constant_pool) { super(Const.ATTR_SIGNATURE, name_index, length, constant_pool); - this.signature_index = signature_index; + this.signatureIndex = signatureIndex; } @@ -97,7 +97,7 @@ public void accept( final Visitor v ) { @Override public void dump( final DataOutputStream file ) throws IOException { super.dump(file); - file.writeShort(signature_index); + file.writeShort(signatureIndex); } @@ -105,15 +105,15 @@ public void dump( final DataOutputStream file ) throws IOException { * @return Index in constant pool of source file name. */ public int getSignatureIndex() { - return signature_index; + return signatureIndex; } /** - * @param signature_index the index info the constant pool of this signature + * @param signatureIndex the index info the constant pool of this signature */ - public void setSignatureIndex( final int signature_index ) { - this.signature_index = signature_index; + public void setSignatureIndex( final int signatureIndex ) { + this.signatureIndex = signatureIndex; } @@ -121,7 +121,7 @@ public void setSignatureIndex( final int signature_index ) { * @return GJ signature. */ public String getSignature() { - final ConstantUtf8 c = (ConstantUtf8) super.getConstantPool().getConstant(signature_index, + final ConstantUtf8 c = (ConstantUtf8) super.getConstantPool().getConstant(signatureIndex, Const.CONSTANT_Utf8); return c.getBytes(); } @@ -157,7 +157,7 @@ private static boolean identStart( final int ch ) { private static void matchIdent( final MyByteArrayInputStream in, final StringBuilder buf ) { int ch; if ((ch = in.read()) == -1) { - throw new RuntimeException("Illegal signature: " + in.getData() + throw new IllegalArgumentException("Illegal signature: " + in.getData() + " no ident, reaching EOF"); } //System.out.println("return from ident:" + (char)ch); @@ -207,7 +207,7 @@ private static void matchGJIdent( final MyByteArrayInputStream in, final StringB matchGJIdent(in, buf); while (((ch = in.read()) != '>') && (ch != ')')) { // List of parameters if (ch == -1) { - throw new RuntimeException("Illegal signature: " + in.getData() + throw new IllegalArgumentException("Illegal signature: " + in.getData() + " reaching EOF"); } //System.out.println("Still no >"); @@ -228,7 +228,7 @@ private static void matchGJIdent( final MyByteArrayInputStream in, final StringB in.unread(); return; } else if (ch != ';') { - throw new RuntimeException("Illegal signature: " + in.getData() + " read " + (char) ch); + throw new IllegalArgumentException("Illegal signature: " + in.getData() + " read " + (char) ch); } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/SimpleElementValue.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/SimpleElementValue.java index 24efbc34d95..7b3050ea427 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/SimpleElementValue.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/SimpleElementValue.java @@ -55,7 +55,7 @@ public void setIndex(final int index) public String getValueString() { if (super.getType() != STRING) { - throw new RuntimeException( + throw new IllegalStateException( "Dont call getValueString() on a non STRING ElementValue"); } final ConstantUtf8 c = (ConstantUtf8) super.getConstantPool().getConstant(getIndex(), @@ -66,7 +66,7 @@ public String getValueString() public int getValueInt() { if (super.getType() != PRIMITIVE_INT) { - throw new RuntimeException( + throw new IllegalStateException( "Dont call getValueString() on a non STRING ElementValue"); } final ConstantInteger c = (ConstantInteger) super.getConstantPool().getConstant(getIndex(), @@ -77,7 +77,7 @@ public int getValueInt() public byte getValueByte() { if (super.getType() != PRIMITIVE_BYTE) { - throw new RuntimeException( + throw new IllegalStateException( "Dont call getValueByte() on a non BYTE ElementValue"); } final ConstantInteger c = (ConstantInteger) super.getConstantPool().getConstant(getIndex(), @@ -88,7 +88,7 @@ public byte getValueByte() public char getValueChar() { if (super.getType() != PRIMITIVE_CHAR) { - throw new RuntimeException( + throw new IllegalStateException( "Dont call getValueChar() on a non CHAR ElementValue"); } final ConstantInteger c = (ConstantInteger) super.getConstantPool().getConstant(getIndex(), @@ -99,7 +99,7 @@ public char getValueChar() public long getValueLong() { if (super.getType() != PRIMITIVE_LONG) { - throw new RuntimeException( + throw new IllegalStateException( "Dont call getValueLong() on a non LONG ElementValue"); } final ConstantLong j = (ConstantLong) super.getConstantPool().getConstant(getIndex()); @@ -109,7 +109,7 @@ public long getValueLong() public float getValueFloat() { if (super.getType() != PRIMITIVE_FLOAT) { - throw new RuntimeException( + throw new IllegalStateException( "Dont call getValueFloat() on a non FLOAT ElementValue"); } final ConstantFloat f = (ConstantFloat) super.getConstantPool().getConstant(getIndex()); @@ -119,7 +119,7 @@ public float getValueFloat() public double getValueDouble() { if (super.getType() != PRIMITIVE_DOUBLE) { - throw new RuntimeException( + throw new IllegalStateException( "Dont call getValueDouble() on a non DOUBLE ElementValue"); } final ConstantDouble d = (ConstantDouble) super.getConstantPool().getConstant(getIndex()); @@ -129,7 +129,7 @@ public double getValueDouble() public boolean getValueBoolean() { if (super.getType() != PRIMITIVE_BOOLEAN) { - throw new RuntimeException( + throw new IllegalStateException( "Dont call getValueBoolean() on a non BOOLEAN ElementValue"); } final ConstantInteger bo = (ConstantInteger) super.getConstantPool().getConstant(getIndex()); @@ -139,7 +139,7 @@ public boolean getValueBoolean() public short getValueShort() { if (super.getType() != PRIMITIVE_SHORT) { - throw new RuntimeException( + throw new IllegalStateException( "Dont call getValueShort() on a non SHORT ElementValue"); } final ConstantInteger s = (ConstantInteger) super.getConstantPool().getConstant(getIndex()); @@ -200,7 +200,7 @@ public String stringifyValue() Const.CONSTANT_Utf8); return cu8.getBytes(); default: - throw new RuntimeException("SimpleElementValue class does not know how to stringify type " + _type); + throw new IllegalStateException("SimpleElementValue class does not know how to stringify type " + _type); } } @@ -223,7 +223,7 @@ public void dump(final DataOutputStream dos) throws IOException dos.writeShort(getIndex()); break; default: - throw new RuntimeException("SimpleElementValue doesnt know how to write out type " + _type); + throw new IllegalStateException("SimpleElementValue doesnt know how to write out type " + _type); } } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/SourceFile.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/SourceFile.java index 2ed8ddf3cd8..dc030f5b226 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/SourceFile.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/SourceFile.java @@ -37,7 +37,7 @@ */ public final class SourceFile extends Attribute { - private int sourcefile_index; + private int sourceFileIndex; /** @@ -67,18 +67,18 @@ public SourceFile(final SourceFile c) { * @param name_index Index in constant pool to CONSTANT_Utf8, which * should represent the string "SourceFile". * @param length Content length in bytes, the value should be 2. - * @param constant_pool The constant pool that this attribute is + * @param constantPool The constant pool that this attribute is * associated with. - * @param sourcefile_index Index in constant pool to CONSTANT_Utf8. This + * @param sourceFileIndex Index in constant pool to CONSTANT_Utf8. This * string will be interpreted as the name of the file from which this * class was compiled. It will not be interpreted as indicating the name * of the directory contqining the file or an absolute path; this * information has to be supplied the consumer of this attribute - in * many cases, the JVM. */ - public SourceFile(final int name_index, final int length, final int sourcefile_index, final ConstantPool constant_pool) { - super(Const.ATTR_SOURCE_FILE, name_index, length, constant_pool); - this.sourcefile_index = sourcefile_index; + public SourceFile(final int name_index, final int length, final int sourceFileIndex, final ConstantPool constantPool) { + super(Const.ATTR_SOURCE_FILE, name_index, length, constantPool); + this.sourceFileIndex = sourceFileIndex; } @@ -104,7 +104,7 @@ public void accept( final Visitor v ) { @Override public void dump( final DataOutputStream file ) throws IOException { super.dump(file); - file.writeShort(sourcefile_index); + file.writeShort(sourceFileIndex); } @@ -112,15 +112,15 @@ public void dump( final DataOutputStream file ) throws IOException { * @return Index in constant pool of source file name. */ public int getSourceFileIndex() { - return sourcefile_index; + return sourceFileIndex; } /** - * @param sourcefile_index + * @param sourceFileIndex */ - public void setSourceFileIndex( final int sourcefile_index ) { - this.sourcefile_index = sourcefile_index; + public void setSourceFileIndex( final int sourceFileIndex ) { + this.sourceFileIndex = sourceFileIndex; } @@ -128,7 +128,7 @@ public void setSourceFileIndex( final int sourcefile_index ) { * @return Source file name. */ public String getSourceFileName() { - final ConstantUtf8 c = (ConstantUtf8) super.getConstantPool().getConstant(sourcefile_index, + final ConstantUtf8 c = (ConstantUtf8) super.getConstantPool().getConstant(sourceFileIndex, Const.CONSTANT_Utf8); return c.getBytes(); } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMap.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMap.java index 987fcfe95fd..e5f4b8c69b7 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMap.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMap.java @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -39,6 +38,7 @@ * @see Code * @see StackMapEntry * @see StackMapType + * @LastModified: Oct 2020 */ public final class StackMap extends Attribute { diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMapEntry.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMapEntry.java index e9abad0dc2e..eaf233a079b 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMapEntry.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMapEntry.java @@ -37,11 +37,11 @@ public final class StackMapEntry implements Node, Cloneable { - private int frame_type; - private int byte_code_offset; - private StackMapType[] types_of_locals; - private StackMapType[] types_of_stack_items; - private ConstantPool constant_pool; + private int frameType; + private int byteCodeOffset; + private StackMapType[] typesOfLocals; + private StackMapType[] typesOfStackItems; + private ConstantPool constantPool; /** @@ -53,43 +53,43 @@ public final class StackMapEntry implements Node, Cloneable StackMapEntry(final DataInput input, final ConstantPool constantPool) throws IOException { this(input.readByte() & 0xFF, -1, null, null, constantPool); - if (frame_type >= Const.SAME_FRAME && frame_type <= Const.SAME_FRAME_MAX) { - byte_code_offset = frame_type - Const.SAME_FRAME; - } else if (frame_type >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME && - frame_type <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) { - byte_code_offset = frame_type - Const.SAME_LOCALS_1_STACK_ITEM_FRAME; - types_of_stack_items = new StackMapType[1]; - types_of_stack_items[0] = new StackMapType(input, constantPool); - } else if (frame_type == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) { - byte_code_offset = input.readShort(); - types_of_stack_items = new StackMapType[1]; - types_of_stack_items[0] = new StackMapType(input, constantPool); - } else if (frame_type >= Const.CHOP_FRAME && frame_type <= Const.CHOP_FRAME_MAX) { - byte_code_offset = input.readShort(); - } else if (frame_type == Const.SAME_FRAME_EXTENDED) { - byte_code_offset = input.readShort(); - } else if (frame_type >= Const.APPEND_FRAME && frame_type <= Const.APPEND_FRAME_MAX) { - byte_code_offset = input.readShort(); - final int number_of_locals = frame_type - 251; - types_of_locals = new StackMapType[number_of_locals]; + if (frameType >= Const.SAME_FRAME && frameType <= Const.SAME_FRAME_MAX) { + byteCodeOffset = frameType - Const.SAME_FRAME; + } else if (frameType >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME && + frameType <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) { + byteCodeOffset = frameType - Const.SAME_LOCALS_1_STACK_ITEM_FRAME; + typesOfStackItems = new StackMapType[1]; + typesOfStackItems[0] = new StackMapType(input, constantPool); + } else if (frameType == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) { + byteCodeOffset = input.readShort(); + typesOfStackItems = new StackMapType[1]; + typesOfStackItems[0] = new StackMapType(input, constantPool); + } else if (frameType >= Const.CHOP_FRAME && frameType <= Const.CHOP_FRAME_MAX) { + byteCodeOffset = input.readShort(); + } else if (frameType == Const.SAME_FRAME_EXTENDED) { + byteCodeOffset = input.readShort(); + } else if (frameType >= Const.APPEND_FRAME && frameType <= Const.APPEND_FRAME_MAX) { + byteCodeOffset = input.readShort(); + final int number_of_locals = frameType - 251; + typesOfLocals = new StackMapType[number_of_locals]; for (int i = 0; i < number_of_locals; i++) { - types_of_locals[i] = new StackMapType(input, constantPool); + typesOfLocals[i] = new StackMapType(input, constantPool); } - } else if (frame_type == Const.FULL_FRAME) { - byte_code_offset = input.readShort(); + } else if (frameType == Const.FULL_FRAME) { + byteCodeOffset = input.readShort(); final int number_of_locals = input.readShort(); - types_of_locals = new StackMapType[number_of_locals]; + typesOfLocals = new StackMapType[number_of_locals]; for (int i = 0; i < number_of_locals; i++) { - types_of_locals[i] = new StackMapType(input, constantPool); + typesOfLocals[i] = new StackMapType(input, constantPool); } final int number_of_stack_items = input.readShort(); - types_of_stack_items = new StackMapType[number_of_stack_items]; + typesOfStackItems = new StackMapType[number_of_stack_items]; for (int i = 0; i < number_of_stack_items; i++) { - types_of_stack_items[i] = new StackMapType(input, constantPool); + typesOfStackItems[i] = new StackMapType(input, constantPool); } } else { /* Can't happen */ - throw new ClassFormatException ("Invalid frame type found while parsing stack map table: " + frame_type); + throw new ClassFormatException ("Invalid frame type found while parsing stack map table: " + frameType); } } @@ -109,16 +109,16 @@ public final class StackMapEntry implements Node, Cloneable public StackMapEntry(final int byteCodeOffset, final int numberOfLocals, final StackMapType[] typesOfLocals, final int numberOfStackItems, final StackMapType[] typesOfStackItems, final ConstantPool constantPool) { - this.byte_code_offset = byteCodeOffset; - this.types_of_locals = typesOfLocals != null ? typesOfLocals : new StackMapType[0]; - this.types_of_stack_items = typesOfStackItems != null ? typesOfStackItems : new StackMapType[0]; - this.constant_pool = constantPool; + this.byteCodeOffset = byteCodeOffset; + this.typesOfLocals = typesOfLocals != null ? typesOfLocals : new StackMapType[0]; + this.typesOfStackItems = typesOfStackItems != null ? typesOfStackItems : new StackMapType[0]; + this.constantPool = constantPool; } /** * Create an instance * - * @param tag the frame_type to use + * @param tag the frameType to use * @param byteCodeOffset * @param typesOfLocals array of {@link StackMapType}s of locals * @param typesOfStackItems array ot {@link StackMapType}s of stack items @@ -127,11 +127,11 @@ public StackMapEntry(final int byteCodeOffset, final int numberOfLocals, public StackMapEntry(final int tag, final int byteCodeOffset, final StackMapType[] typesOfLocals, final StackMapType[] typesOfStackItems, final ConstantPool constantPool) { - this.frame_type = tag; - this.byte_code_offset = byteCodeOffset; - this.types_of_locals = typesOfLocals != null ? typesOfLocals : new StackMapType[0]; - this.types_of_stack_items = typesOfStackItems != null ? typesOfStackItems : new StackMapType[0]; - this.constant_pool = constantPool; + this.frameType = tag; + this.byteCodeOffset = byteCodeOffset; + this.typesOfLocals = typesOfLocals != null ? typesOfLocals : new StackMapType[0]; + this.typesOfStackItems = typesOfStackItems != null ? typesOfStackItems : new StackMapType[0]; + this.constantPool = constantPool; } @@ -142,37 +142,37 @@ public StackMapEntry(final int tag, final int byteCodeOffset, * @throws IOException */ public void dump( final DataOutputStream file ) throws IOException { - file.write(frame_type); - if (frame_type >= Const.SAME_FRAME && frame_type <= Const.SAME_FRAME_MAX) { + file.write(frameType); + if (frameType >= Const.SAME_FRAME && frameType <= Const.SAME_FRAME_MAX) { // nothing to be done - } else if (frame_type >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME && - frame_type <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) { - types_of_stack_items[0].dump(file); - } else if (frame_type == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) { - file.writeShort(byte_code_offset); - types_of_stack_items[0].dump(file); - } else if (frame_type >= Const.CHOP_FRAME && frame_type <= Const.CHOP_FRAME_MAX) { - file.writeShort(byte_code_offset); - } else if (frame_type == Const.SAME_FRAME_EXTENDED) { - file.writeShort(byte_code_offset); - } else if (frame_type >= Const.APPEND_FRAME && frame_type <= Const.APPEND_FRAME_MAX) { - file.writeShort(byte_code_offset); - for (final StackMapType type : types_of_locals) { + } else if (frameType >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME && + frameType <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) { + typesOfStackItems[0].dump(file); + } else if (frameType == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) { + file.writeShort(byteCodeOffset); + typesOfStackItems[0].dump(file); + } else if (frameType >= Const.CHOP_FRAME && frameType <= Const.CHOP_FRAME_MAX) { + file.writeShort(byteCodeOffset); + } else if (frameType == Const.SAME_FRAME_EXTENDED) { + file.writeShort(byteCodeOffset); + } else if (frameType >= Const.APPEND_FRAME && frameType <= Const.APPEND_FRAME_MAX) { + file.writeShort(byteCodeOffset); + for (final StackMapType type : typesOfLocals) { type.dump(file); } - } else if (frame_type == Const.FULL_FRAME) { - file.writeShort(byte_code_offset); - file.writeShort(types_of_locals.length); - for (final StackMapType type : types_of_locals) { + } else if (frameType == Const.FULL_FRAME) { + file.writeShort(byteCodeOffset); + file.writeShort(typesOfLocals.length); + for (final StackMapType type : typesOfLocals) { type.dump(file); } - file.writeShort(types_of_stack_items.length); - for (final StackMapType type : types_of_stack_items) { + file.writeShort(typesOfStackItems.length); + for (final StackMapType type : typesOfStackItems) { type.dump(file); } } else { /* Can't happen */ - throw new ClassFormatException ("Invalid Stack map table tag: " + frame_type); + throw new ClassFormatException ("Invalid Stack map table tag: " + frameType); } } @@ -184,40 +184,40 @@ public void dump( final DataOutputStream file ) throws IOException { public String toString() { final StringBuilder buf = new StringBuilder(64); buf.append("("); - if (frame_type >= Const.SAME_FRAME && frame_type <= Const.SAME_FRAME_MAX) { + if (frameType >= Const.SAME_FRAME && frameType <= Const.SAME_FRAME_MAX) { buf.append("SAME"); - } else if (frame_type >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME && - frame_type <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) { + } else if (frameType >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME && + frameType <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) { buf.append("SAME_LOCALS_1_STACK"); - } else if (frame_type == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) { + } else if (frameType == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) { buf.append("SAME_LOCALS_1_STACK_EXTENDED"); - } else if (frame_type >= Const.CHOP_FRAME && frame_type <= Const.CHOP_FRAME_MAX) { - buf.append("CHOP ").append(String.valueOf(251-frame_type)); - } else if (frame_type == Const.SAME_FRAME_EXTENDED) { + } else if (frameType >= Const.CHOP_FRAME && frameType <= Const.CHOP_FRAME_MAX) { + buf.append("CHOP ").append(String.valueOf(251-frameType)); + } else if (frameType == Const.SAME_FRAME_EXTENDED) { buf.append("SAME_EXTENDED"); - } else if (frame_type >= Const.APPEND_FRAME && frame_type <= Const.APPEND_FRAME_MAX) { - buf.append("APPEND ").append(String.valueOf(frame_type-251)); - } else if (frame_type == Const.FULL_FRAME) { + } else if (frameType >= Const.APPEND_FRAME && frameType <= Const.APPEND_FRAME_MAX) { + buf.append("APPEND ").append(String.valueOf(frameType-251)); + } else if (frameType == Const.FULL_FRAME) { buf.append("FULL"); } else { - buf.append("UNKNOWN (").append(frame_type).append(")"); + buf.append("UNKNOWN (").append(frameType).append(")"); } - buf.append(", offset delta=").append(byte_code_offset); - if (types_of_locals.length > 0) { + buf.append(", offset delta=").append(byteCodeOffset); + if (typesOfLocals.length > 0) { buf.append(", locals={"); - for (int i = 0; i < types_of_locals.length; i++) { - buf.append(types_of_locals[i]); - if (i < types_of_locals.length - 1) { + for (int i = 0; i < typesOfLocals.length; i++) { + buf.append(typesOfLocals[i]); + if (i < typesOfLocals.length - 1) { buf.append(", "); } } buf.append("}"); } - if (types_of_stack_items.length > 0) { + if (typesOfStackItems.length > 0) { buf.append(", stack items={"); - for (int i = 0; i < types_of_stack_items.length; i++) { - buf.append(types_of_stack_items[i]); - if (i < types_of_stack_items.length - 1) { + for (int i = 0; i < typesOfStackItems.length; i++) { + buf.append(typesOfStackItems[i]); + if (i < typesOfStackItems.length - 1) { buf.append(", "); } } @@ -233,91 +233,91 @@ public String toString() { * */ int getMapEntrySize() { - if (frame_type >= Const.SAME_FRAME && frame_type <= Const.SAME_FRAME_MAX) { + if (frameType >= Const.SAME_FRAME && frameType <= Const.SAME_FRAME_MAX) { return 1; - } else if (frame_type >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME && - frame_type <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) { - return 1 + (types_of_stack_items[0].hasIndex() ? 3 : 1); - } else if (frame_type == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) { - return 3 + (types_of_stack_items[0].hasIndex() ? 3 : 1); - } else if (frame_type >= Const.CHOP_FRAME && frame_type <= Const.CHOP_FRAME_MAX) { + } else if (frameType >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME && + frameType <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) { + return 1 + (typesOfStackItems[0].hasIndex() ? 3 : 1); + } else if (frameType == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) { + return 3 + (typesOfStackItems[0].hasIndex() ? 3 : 1); + } else if (frameType >= Const.CHOP_FRAME && frameType <= Const.CHOP_FRAME_MAX) { return 3; - } else if (frame_type == Const.SAME_FRAME_EXTENDED) { + } else if (frameType == Const.SAME_FRAME_EXTENDED) { return 3; - } else if (frame_type >= Const.APPEND_FRAME && frame_type <= Const.APPEND_FRAME_MAX) { + } else if (frameType >= Const.APPEND_FRAME && frameType <= Const.APPEND_FRAME_MAX) { int len = 3; - for (final StackMapType types_of_local : types_of_locals) { + for (final StackMapType types_of_local : typesOfLocals) { len += types_of_local.hasIndex() ? 3 : 1; } return len; - } else if (frame_type == Const.FULL_FRAME) { + } else if (frameType == Const.FULL_FRAME) { int len = 7; - for (final StackMapType types_of_local : types_of_locals) { + for (final StackMapType types_of_local : typesOfLocals) { len += types_of_local.hasIndex() ? 3 : 1; } - for (final StackMapType types_of_stack_item : types_of_stack_items) { + for (final StackMapType types_of_stack_item : typesOfStackItems) { len += types_of_stack_item.hasIndex() ? 3 : 1; } return len; } else { - throw new RuntimeException("Invalid StackMap frame_type: " + frame_type); + throw new IllegalStateException("Invalid StackMap frameType: " + frameType); } } public void setFrameType( final int f ) { if (f >= Const.SAME_FRAME && f <= Const.SAME_FRAME_MAX) { - byte_code_offset = f - Const.SAME_FRAME; + byteCodeOffset = f - Const.SAME_FRAME; } else if (f >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME && f <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) { - byte_code_offset = f - Const.SAME_LOCALS_1_STACK_ITEM_FRAME; + byteCodeOffset = f - Const.SAME_LOCALS_1_STACK_ITEM_FRAME; } else if (f == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) { // CHECKSTYLE IGNORE EmptyBlock } else if (f >= Const.CHOP_FRAME && f <= Const.CHOP_FRAME_MAX) { // CHECKSTYLE IGNORE EmptyBlock } else if (f == Const.SAME_FRAME_EXTENDED) { // CHECKSTYLE IGNORE EmptyBlock } else if (f >= Const.APPEND_FRAME && f <= Const.APPEND_FRAME_MAX) { // CHECKSTYLE IGNORE EmptyBlock } else if (f == Const.FULL_FRAME) { // CHECKSTYLE IGNORE EmptyBlock } else { - throw new RuntimeException("Invalid StackMap frame_type"); + throw new IllegalArgumentException("Invalid StackMap frameType"); } - frame_type = f; + frameType = f; } public int getFrameType() { - return frame_type; + return frameType; } public void setByteCodeOffset( final int new_offset ) { if (new_offset < 0 || new_offset > 32767) { - throw new RuntimeException("Invalid StackMap offset: " + new_offset); + throw new IllegalArgumentException("Invalid StackMap offset: " + new_offset); } - if (frame_type >= Const.SAME_FRAME && - frame_type <= Const.SAME_FRAME_MAX) { + if (frameType >= Const.SAME_FRAME && + frameType <= Const.SAME_FRAME_MAX) { if (new_offset > Const.SAME_FRAME_MAX) { - frame_type = Const.SAME_FRAME_EXTENDED; + frameType = Const.SAME_FRAME_EXTENDED; } else { - frame_type = new_offset; + frameType = new_offset; } - } else if (frame_type >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME && - frame_type <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) { + } else if (frameType >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME && + frameType <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) { if (new_offset > Const.SAME_FRAME_MAX) { - frame_type = Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED; + frameType = Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED; } else { - frame_type = Const.SAME_LOCALS_1_STACK_ITEM_FRAME + new_offset; + frameType = Const.SAME_LOCALS_1_STACK_ITEM_FRAME + new_offset; } - } else if (frame_type == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) { // CHECKSTYLE IGNORE EmptyBlock - } else if (frame_type >= Const.CHOP_FRAME && - frame_type <= Const.CHOP_FRAME_MAX) { // CHECKSTYLE IGNORE EmptyBlock - } else if (frame_type == Const.SAME_FRAME_EXTENDED) { // CHECKSTYLE IGNORE EmptyBlock - } else if (frame_type >= Const.APPEND_FRAME && - frame_type <= Const.APPEND_FRAME_MAX) { // CHECKSTYLE IGNORE EmptyBlock - } else if (frame_type == Const.FULL_FRAME) { // CHECKSTYLE IGNORE EmptyBlock + } else if (frameType == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) { // CHECKSTYLE IGNORE EmptyBlock + } else if (frameType >= Const.CHOP_FRAME && + frameType <= Const.CHOP_FRAME_MAX) { // CHECKSTYLE IGNORE EmptyBlock + } else if (frameType == Const.SAME_FRAME_EXTENDED) { // CHECKSTYLE IGNORE EmptyBlock + } else if (frameType >= Const.APPEND_FRAME && + frameType <= Const.APPEND_FRAME_MAX) { // CHECKSTYLE IGNORE EmptyBlock + } else if (frameType == Const.FULL_FRAME) { // CHECKSTYLE IGNORE EmptyBlock } else { - throw new RuntimeException("Invalid StackMap frame_type: " + frame_type); + throw new IllegalStateException("Invalid StackMap frameType: " + frameType); } - byte_code_offset = new_offset; + byteCodeOffset = new_offset; } @@ -329,12 +329,12 @@ public void setByteCodeOffset( final int new_offset ) { * @param delta offset delta */ public void updateByteCodeOffset(final int delta) { - setByteCodeOffset(byte_code_offset + delta); + setByteCodeOffset(byteCodeOffset + delta); } public int getByteCodeOffset() { - return byte_code_offset; + return byteCodeOffset; } @@ -348,17 +348,17 @@ public void setNumberOfLocals( final int n ) { // TODO unused public int getNumberOfLocals() { - return types_of_locals.length; + return typesOfLocals.length; } public void setTypesOfLocals( final StackMapType[] types ) { - types_of_locals = types != null ? types : new StackMapType[0]; + typesOfLocals = types != null ? types : new StackMapType[0]; } public StackMapType[] getTypesOfLocals() { - return types_of_locals; + return typesOfLocals; } @@ -372,17 +372,17 @@ public void setNumberOfStackItems( final int n ) { // TODO unused public int getNumberOfStackItems() { - return types_of_stack_items.length; + return typesOfStackItems.length; } public void setTypesOfStackItems( final StackMapType[] types ) { - types_of_stack_items = types != null ? types : new StackMapType[0]; + typesOfStackItems = types != null ? types : new StackMapType[0]; } public StackMapType[] getTypesOfStackItems() { - return types_of_stack_items; + return typesOfStackItems; } @@ -397,13 +397,13 @@ public StackMapEntry copy() { throw new Error("Clone Not Supported"); } - e.types_of_locals = new StackMapType[types_of_locals.length]; - for (int i = 0; i < types_of_locals.length; i++) { - e.types_of_locals[i] = types_of_locals[i].copy(); + e.typesOfLocals = new StackMapType[typesOfLocals.length]; + for (int i = 0; i < typesOfLocals.length; i++) { + e.typesOfLocals[i] = typesOfLocals[i].copy(); } - e.types_of_stack_items = new StackMapType[types_of_stack_items.length]; - for (int i = 0; i < types_of_stack_items.length; i++) { - e.types_of_stack_items[i] = types_of_stack_items[i].copy(); + e.typesOfStackItems = new StackMapType[typesOfStackItems.length]; + for (int i = 0; i < typesOfStackItems.length; i++) { + e.typesOfStackItems[i] = typesOfStackItems[i].copy(); } return e; } @@ -426,14 +426,14 @@ public void accept( final Visitor v ) { * @return Constant pool used by this object. */ public ConstantPool getConstantPool() { - return constant_pool; + return constantPool; } /** - * @param constant_pool Constant pool to be used for this object. + * @param constantPool Constant pool to be used for this object. */ - public void setConstantPool( final ConstantPool constant_pool ) { - this.constant_pool = constant_pool; + public void setConstantPool( final ConstantPool constantPool ) { + this.constantPool = constantPool; } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMapType.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMapType.java index bf0f7493f49..8d7c3871a09 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMapType.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMapType.java @@ -39,7 +39,7 @@ public final class StackMapType implements Cloneable { private byte type; private int index = -1; // Index to CONSTANT_Class or offset - private ConstantPool constant_pool; + private ConstantPool constantPool; /** @@ -52,7 +52,7 @@ public final class StackMapType implements Cloneable { if (hasIndex()) { this.index = file.readShort(); } - this.constant_pool = constant_pool; + this.constantPool = constant_pool; } @@ -62,17 +62,17 @@ public final class StackMapType implements Cloneable { */ public StackMapType(final byte type, final int index, final ConstantPool constant_pool) { if ((type < Const.ITEM_Bogus) || (type > Const.ITEM_NewObject)) { - throw new RuntimeException("Illegal type for StackMapType: " + type); + throw new IllegalArgumentException("Illegal type for StackMapType: " + type); } this.type = type; this.index = index; - this.constant_pool = constant_pool; + this.constantPool = constant_pool; } public void setType( final byte t ) { if ((t < Const.ITEM_Bogus) || (t > Const.ITEM_NewObject)) { - throw new RuntimeException("Illegal type for StackMapType: " + t); + throw new IllegalArgumentException("Illegal type for StackMapType: " + t); } type = t; } @@ -122,7 +122,7 @@ private String printIndex() { if (index < 0) { return ", class="; } - return ", class=" + constant_pool.constantToString(index, Const.CONSTANT_Class); + return ", class=" + constantPool.constantToString(index, Const.CONSTANT_Class); } else if (type == Const.ITEM_NewObject) { return ", offset=" + index; } else { @@ -157,14 +157,14 @@ public StackMapType copy() { * @return Constant pool used by this object. */ public ConstantPool getConstantPool() { - return constant_pool; + return constantPool; } /** - * @param constant_pool Constant pool to be used for this object. + * @param constantPool Constant pool to be used for this object. */ - public void setConstantPool( final ConstantPool constant_pool ) { - this.constant_pool = constant_pool; + public void setConstantPool( final ConstantPool constantPool ) { + this.constantPool = constantPool; } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Unknown.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Unknown.java index b12cb280f55..9b93a91e0c9 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Unknown.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Unknown.java @@ -45,15 +45,15 @@ public final class Unknown extends Attribute { private byte[] bytes; private final String name; - private static final Map unknown_attributes = new HashMap<>(); + private static final Map unknownAttributes = new HashMap<>(); /** @return array of unknown attributes, but just one for each kind. */ static Unknown[] getUnknownAttributes() { - final Unknown[] unknowns = new Unknown[unknown_attributes.size()]; - unknown_attributes.values().toArray(unknowns); - unknown_attributes.clear(); + final Unknown[] unknowns = new Unknown[unknownAttributes.size()]; + unknownAttributes.values().toArray(unknowns); + unknownAttributes.clear(); return unknowns; } @@ -80,7 +80,7 @@ public Unknown(final int name_index, final int length, final byte[] bytes, final this.bytes = bytes; name = ((ConstantUtf8) constant_pool.getConstant(name_index, Const.CONSTANT_Utf8)) .getBytes(); - unknown_attributes.put(name, this); + unknownAttributes.put(name, this); } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Utility.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Utility.java index a1f23d42801..8577bdff728 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Utility.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Utility.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -42,7 +42,7 @@ /** * Utility functions that do not really belong to any class in particular. * - * @LastModified: Jan 2020 + * @LastModified: May 2021 */ // @since 6.0 methods are no longer final public abstract class Utility { @@ -772,10 +772,10 @@ public static String replace( String str, final String old, final String new_ ) * There is some nomenclature confusion through much of the BCEL code base with * respect to the terms Descriptor and Signature. For the offical definitions see: * - * @see + * @see * Descriptors in The Java Virtual Machine Specification * - * @see + * @see * Signatures in The Java Virtual Machine Specification * * In brief, a descriptor is a string representing the type of a field or method. @@ -835,30 +835,29 @@ public static String signatureToString( final String signature, final boolean ch index += unwrap(consumed_chars); // update position // ignore any throws information in the signature return type; - } else { - // Could be Class or Type... - type = typeSignatureToString(signature.substring(index), chopit); + } + // Could be Class or Type... + type = typeSignatureToString(signature.substring(index), chopit); + index += unwrap(consumed_chars); // update position + if ((typeParams.length() == 0) && (index == signature.length())) { + // We have a Type signature. + return type; + } + // We have a Class signature. + final StringBuilder typeClass = new StringBuilder(typeParams); + typeClass.append(" extends "); + typeClass.append(type); + if (index < signature.length()) { + typeClass.append(" implements "); + typeClass.append(typeSignatureToString(signature.substring(index), chopit)); + index += unwrap(consumed_chars); // update position + } + while (index < signature.length()) { + typeClass.append(", "); + typeClass.append(typeSignatureToString(signature.substring(index), chopit)); index += unwrap(consumed_chars); // update position - if ((typeParams.length() == 0) && (index == signature.length())) { - // We have a Type signature. - return type; - } - // We have a Class signature. - final StringBuilder typeClass = new StringBuilder(typeParams); - typeClass.append(" extends "); - typeClass.append(type); - if (index < signature.length()) { - typeClass.append(" implements "); - typeClass.append(typeSignatureToString(signature.substring(index), chopit)); - index += unwrap(consumed_chars); // update position - } - while (index < signature.length()) { - typeClass.append(", "); - typeClass.append(typeSignatureToString(signature.substring(index), chopit)); - index += unwrap(consumed_chars); // update position - } - return typeClass.toString(); } + return typeClass.toString(); } @@ -1149,7 +1148,7 @@ public static String getSignature( String type ) { break; case '[': if (!char_found) { - throw new RuntimeException("Illegal type: " + type); + throw new IllegalArgumentException("Illegal type: " + type); } index = i; break loop; @@ -1191,13 +1190,13 @@ private static int countBrackets( final String brackets ) { switch (c) { case '[': if (open) { - throw new RuntimeException("Illegally nested brackets:" + brackets); + throw new IllegalArgumentException("Illegally nested brackets:" + brackets); } open = true; break; case ']': if (!open) { - throw new RuntimeException("Illegally nested brackets:" + brackets); + throw new IllegalArgumentException("Illegally nested brackets:" + brackets); } open = false; count++; @@ -1208,7 +1207,7 @@ private static int countBrackets( final String brackets ) { } } if (open) { - throw new RuntimeException("Illegally nested brackets:" + brackets); + throw new IllegalArgumentException("Illegally nested brackets:" + brackets); } return count; } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/AnnotationElementValueGen.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/AnnotationElementValueGen.java index 61c08bbe894..e58f6006969 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/AnnotationElementValueGen.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/AnnotationElementValueGen.java @@ -46,7 +46,7 @@ public AnnotationElementValueGen(final int type, final AnnotationEntryGen annota { super(type, cpool); if (type != ANNOTATION) { - throw new RuntimeException( + throw new IllegalArgumentException( "Only element values of type annotation can be built with this ctor - type specified: " + type); } this.a = annotation; @@ -69,7 +69,7 @@ public void dump(final DataOutputStream dos) throws IOException @Override public String stringifyValue() { - throw new RuntimeException("Not implemented yet"); + throw new UnsupportedOperationException("Not implemented yet"); } /** diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ArrayElementValueGen.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ArrayElementValueGen.java index 699b6560cb6..b20f6ba848b 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ArrayElementValueGen.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ArrayElementValueGen.java @@ -49,7 +49,7 @@ public ArrayElementValueGen(final int type, final ElementValue[] datums, { super(type, cpool); if (type != ARRAY) { - throw new RuntimeException( + throw new IllegalArgumentException( "Only element values of type array can be built with this ctor - type specified: " + type); } this.evalues = new ArrayList<>(); diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ArrayInstruction.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ArrayInstruction.java index f38e6bb0d12..50b0dbff7ce 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ArrayInstruction.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ArrayInstruction.java @@ -83,7 +83,7 @@ public Type getType( final ConstantPoolGen cp ) { case com.sun.org.apache.bcel.internal.Const.AASTORE: return Type.OBJECT; default: - throw new ClassGenException("Oops: unknown case in switch" + _opcode); + throw new ClassGenException("Unknown case in switch" + _opcode); } } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ArrayType.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ArrayType.java index 68de2f36da0..3b20c7336e8 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ArrayType.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ArrayType.java @@ -29,7 +29,7 @@ public final class ArrayType extends ReferenceType { private int dimensions; - private Type basic_type; + private Type basicType; /** @@ -66,20 +66,20 @@ public ArrayType(final Type type, final int dimensions) { case Const.T_ARRAY: final ArrayType array = (ArrayType) type; this.dimensions = dimensions + array.dimensions; - basic_type = array.basic_type; + basicType = array.basicType; break; case Const.T_VOID: throw new ClassGenException("Invalid type: void[]"); default: // Basic type or reference this.dimensions = dimensions; - basic_type = type; + basicType = type; break; } final StringBuilder buf = new StringBuilder(); for (int i = 0; i < this.dimensions; i++) { buf.append('['); } - buf.append(basic_type.getSignature()); + buf.append(basicType.getSignature()); super.setSignature(buf.toString()); } @@ -88,7 +88,7 @@ public ArrayType(final Type type, final int dimensions) { * @return basic type of array, i.e., for int[][][] the basic type is int */ public Type getBasicType() { - return basic_type; + return basicType; } @@ -97,9 +97,9 @@ public Type getBasicType() { */ public Type getElementType() { if (dimensions == 1) { - return basic_type; + return basicType; } - return new ArrayType(basic_type, dimensions - 1); + return new ArrayType(basicType, dimensions - 1); } @@ -114,7 +114,7 @@ public int getDimensions() { */ @Override public int hashCode() { - return basic_type.hashCode() ^ dimensions; + return basicType.hashCode() ^ dimensions; } @@ -124,7 +124,7 @@ public int hashCode() { public boolean equals( final Object _type ) { if (_type instanceof ArrayType) { final ArrayType array = (ArrayType) _type; - return (array.dimensions == dimensions) && array.basic_type.equals(basic_type); + return (array.dimensions == dimensions) && array.basicType.equals(basicType); } return false; } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ClassGen.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ClassGen.java index cd3de5a3228..04be4be622a 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ClassGen.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ClassGen.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -42,28 +42,28 @@ * existing java class (file). * * @see JavaClass - * @LastModified: Jan 2020 + * @LastModified: May 2021 */ public class ClassGen extends AccessFlags implements Cloneable { /* Corresponds to the fields found in a JavaClass object. */ - private String class_name; - private String super_class_name; - private final String file_name; - private int class_name_index = -1; + private String className; + private String superClassName; + private final String fileName; + private int classNameIndex = -1; private int superclass_name_index = -1; - private int major = Const.MAJOR; - private int minor = Const.MINOR; + private int major = Const.MAJOR_1_1; + private int minor = Const.MINOR_1_1; private ConstantPoolGen cp; // Template for building up constant pool // ArrayLists instead of arrays to gather fields, methods, etc. - private final List field_vec = new ArrayList<>(); - private final List method_vec = new ArrayList<>(); - private final List attribute_vec = new ArrayList<>(); - private final List interface_vec = new ArrayList<>(); - private final List annotation_vec = new ArrayList<>(); + private final List fieldList = new ArrayList<>(); + private final List methodList = new ArrayList<>(); + private final List attributeList = new ArrayList<>(); + private final List interfaceList = new ArrayList<>(); + private final List annotationList = new ArrayList<>(); - private static BCELComparator _cmp = new BCELComparator() { + private static BCELComparator bcelComparator = new BCELComparator() { @Override public boolean equals( final Object o1, final Object o2 ) { @@ -83,27 +83,27 @@ public int hashCode( final Object o ) { /** Convenience constructor to set up some important values initially. * - * @param class_name fully qualified class name - * @param super_class_name fully qualified superclass name - * @param file_name source file name - * @param access_flags access qualifiers + * @param className fully qualified class name + * @param superClassName fully qualified superclass name + * @param fileName source file name + * @param accessFlags access qualifiers * @param interfaces implemented interfaces * @param cp constant pool to use */ - public ClassGen(final String class_name, final String super_class_name, final String file_name, final int access_flags, + public ClassGen(final String className, final String superClassName, final String fileName, final int accessFlags, final String[] interfaces, final ConstantPoolGen cp) { - super(access_flags); - this.class_name = class_name; - this.super_class_name = super_class_name; - this.file_name = file_name; + super(accessFlags); + this.className = className; + this.superClassName = superClassName; + this.fileName = fileName; this.cp = cp; // Put everything needed by default into the constant pool and the vectors - if (file_name != null) { - addAttribute(new SourceFile(cp.addUtf8("SourceFile"), 2, cp.addUtf8(file_name), cp + if (fileName != null) { + addAttribute(new SourceFile(cp.addUtf8("SourceFile"), 2, cp.addUtf8(fileName), cp .getConstantPool())); } - class_name_index = cp.addClass(class_name); - superclass_name_index = cp.addClass(super_class_name); + classNameIndex = cp.addClass(className); + superclass_name_index = cp.addClass(superClassName); if (interfaces != null) { for (final String interface1 : interfaces) { addInterface(interface1); @@ -114,15 +114,15 @@ public ClassGen(final String class_name, final String super_class_name, final St /** Convenience constructor to set up some important values initially. * - * @param class_name fully qualified class name - * @param super_class_name fully qualified superclass name - * @param file_name source file name - * @param access_flags access qualifiers + * @param className fully qualified class name + * @param superClassName fully qualified superclass name + * @param fileName source file name + * @param accessFlags access qualifiers * @param interfaces implemented interfaces */ - public ClassGen(final String class_name, final String super_class_name, final String file_name, final int access_flags, + public ClassGen(final String className, final String superClassName, final String fileName, final int accessFlags, final String[] interfaces) { - this(class_name, super_class_name, file_name, access_flags, interfaces, + this(className, superClassName, fileName, accessFlags, interfaces, new ConstantPoolGen()); } @@ -133,11 +133,11 @@ public ClassGen(final String class_name, final String super_class_name, final St */ public ClassGen(final JavaClass clazz) { super(clazz.getAccessFlags()); - class_name_index = clazz.getClassNameIndex(); + classNameIndex = clazz.getClassNameIndex(); superclass_name_index = clazz.getSuperclassNameIndex(); - class_name = clazz.getClassName(); - super_class_name = clazz.getSuperclassName(); - file_name = clazz.getSourceFileName(); + className = clazz.getClassName(); + superClassName = clazz.getSuperclassName(); + fileName = clazz.getSourceFileName(); cp = new ConstantPoolGen(clazz.getConstantPool()); major = clazz.getMajor(); minor = clazz.getMinor(); @@ -205,18 +205,18 @@ public JavaClass getJavaClass() { final Field[] fields = getFields(); final Method[] methods = getMethods(); Attribute[] attributes = null; - if (annotation_vec.isEmpty()) { + if (annotationList.isEmpty()) { attributes = getAttributes(); } else { // TODO: Sometime later, trash any attributes called 'RuntimeVisibleAnnotations' or 'RuntimeInvisibleAnnotations' final Attribute[] annAttributes = AnnotationEntryGen.getAnnotationAttributes(cp, getAnnotationEntries()); - attributes = new Attribute[attribute_vec.size()+annAttributes.length]; - attribute_vec.toArray(attributes); - System.arraycopy(annAttributes,0,attributes,attribute_vec.size(),annAttributes.length); + attributes = new Attribute[attributeList.size()+annAttributes.length]; + attributeList.toArray(attributes); + System.arraycopy(annAttributes,0,attributes,attributeList.size(),annAttributes.length); } // Must be last since the above calls may still add something to it final ConstantPool _cp = this.cp.getFinalConstantPool(); - return new JavaClass(class_name_index, superclass_name_index, file_name, major, minor, + return new JavaClass(classNameIndex, superclass_name_index, fileName, major, minor, super.getAccessFlags(), _cp, interfaces, fields, methods, attributes); } @@ -226,7 +226,7 @@ public JavaClass getJavaClass() { * @param name interface to implement (fully qualified class name) */ public void addInterface( final String name ) { - interface_vec.add(name); + interfaceList.add(name); } @@ -235,7 +235,7 @@ public void addInterface( final String name ) { * @param name interface to remove (fully qualified name) */ public void removeInterface( final String name ) { - interface_vec.remove(name); + interfaceList.remove(name); } @@ -275,11 +275,11 @@ public int getMinor() { * @param a attribute to add */ public void addAttribute( final Attribute a ) { - attribute_vec.add(a); + attributeList.add(a); } public void addAnnotationEntry(final AnnotationEntryGen a) { - annotation_vec.add(a); + annotationList.add(a); } @@ -288,7 +288,7 @@ public void addAnnotationEntry(final AnnotationEntryGen a) { * @param m method to add */ public void addMethod( final Method m ) { - method_vec.add(m); + methodList.add(m); } @@ -301,10 +301,10 @@ public void addMethod( final Method m ) { public void addEmptyConstructor( final int access_flags ) { final InstructionList il = new InstructionList(); il.append(InstructionConst.THIS); // Push `this' - il.append(new INVOKESPECIAL(cp.addMethodref(super_class_name, "", "()V"))); + il.append(new INVOKESPECIAL(cp.addMethodref(superClassName, "", "()V"))); il.append(InstructionConst.RETURN); final MethodGen mg = new MethodGen(access_flags, Type.VOID, Type.NO_ARGS, null, "", - class_name, il, cp); + className, il, cp); mg.setMaxStack(1); addMethod(mg.getMethod()); } @@ -315,19 +315,19 @@ public void addEmptyConstructor( final int access_flags ) { * @param f field to add */ public void addField( final Field f ) { - field_vec.add(f); + fieldList.add(f); } public boolean containsField( final Field f ) { - return field_vec.contains(f); + return fieldList.contains(f); } /** @return field object with given name, or null */ public Field containsField( final String name ) { - for (final Field f : field_vec) { + for (final Field f : fieldList) { if (f.getName().equals(name)) { return f; } @@ -339,7 +339,7 @@ public Field containsField( final String name ) { /** @return method object with given name and signature, or null */ public Method containsMethod( final String name, final String signature ) { - for (final Method m : method_vec) { + for (final Method m : methodList) { if (m.getName().equals(name) && m.getSignature().equals(signature)) { return m; } @@ -353,7 +353,7 @@ public Method containsMethod( final String name, final String signature ) { * @param a attribute to remove */ public void removeAttribute( final Attribute a ) { - attribute_vec.remove(a); + attributeList.remove(a); } @@ -362,7 +362,7 @@ public void removeAttribute( final Attribute a ) { * @param m method to remove */ public void removeMethod( final Method m ) { - method_vec.remove(m); + methodList.remove(m); } @@ -373,11 +373,11 @@ public void replaceMethod( final Method old, final Method new_ ) { if (new_ == null) { throw new ClassGenException("Replacement method must not be null"); } - final int i = method_vec.indexOf(old); + final int i = methodList.indexOf(old); if (i < 0) { - method_vec.add(new_); + methodList.add(new_); } else { - method_vec.set(i, new_); + methodList.set(i, new_); } } @@ -389,11 +389,11 @@ public void replaceField( final Field old, final Field new_ ) { if (new_ == null) { throw new ClassGenException("Replacement method must not be null"); } - final int i = field_vec.indexOf(old); + final int i = fieldList.indexOf(old); if (i < 0) { - field_vec.add(new_); + fieldList.add(new_); } else { - field_vec.set(i, new_); + fieldList.set(i, new_); } } @@ -403,44 +403,44 @@ public void replaceField( final Field old, final Field new_ ) { * @param f field to remove */ public void removeField( final Field f ) { - field_vec.remove(f); + fieldList.remove(f); } public String getClassName() { - return class_name; + return className; } public String getSuperclassName() { - return super_class_name; + return superClassName; } public String getFileName() { - return file_name; + return fileName; } public void setClassName( final String name ) { - class_name = name.replace('/', '.'); - class_name_index = cp.addClass(name); + className = name.replace('/', '.'); + classNameIndex = cp.addClass(name); } public void setSuperclassName( final String name ) { - super_class_name = name.replace('/', '.'); + superClassName = name.replace('/', '.'); superclass_name_index = cp.addClass(name); } public Method[] getMethods() { - return method_vec.toArray(new Method[method_vec.size()]); + return methodList.toArray(new Method[methodList.size()]); } public void setMethods( final Method[] methods ) { - method_vec.clear(); + methodList.clear(); for (final Method method : methods) { addMethod(method); } @@ -448,45 +448,45 @@ public void setMethods( final Method[] methods ) { public void setMethodAt( final Method method, final int pos ) { - method_vec.set(pos, method); + methodList.set(pos, method); } public Method getMethodAt( final int pos ) { - return method_vec.get(pos); + return methodList.get(pos); } public String[] getInterfaceNames() { - final int size = interface_vec.size(); + final int size = interfaceList.size(); final String[] interfaces = new String[size]; - interface_vec.toArray(interfaces); + interfaceList.toArray(interfaces); return interfaces; } public int[] getInterfaces() { - final int size = interface_vec.size(); + final int size = interfaceList.size(); final int[] interfaces = new int[size]; for (int i = 0; i < size; i++) { - interfaces[i] = cp.addClass(interface_vec.get(i)); + interfaces[i] = cp.addClass(interfaceList.get(i)); } return interfaces; } public Field[] getFields() { - return field_vec.toArray(new Field[field_vec.size()]); + return fieldList.toArray(new Field[fieldList.size()]); } public Attribute[] getAttributes() { - return attribute_vec.toArray(new Attribute[attribute_vec.size()]); + return attributeList.toArray(new Attribute[attributeList.size()]); } // J5TODO: Should we make calling unpackAnnotations() lazy and put it in here? public AnnotationEntryGen[] getAnnotationEntries() { - return annotation_vec.toArray(new AnnotationEntryGen[annotation_vec.size()]); + return annotationList.toArray(new AnnotationEntryGen[annotationList.size()]); } @@ -501,15 +501,15 @@ public void setConstantPool( final ConstantPoolGen constant_pool ) { public void setClassNameIndex( final int class_name_index ) { - this.class_name_index = class_name_index; - class_name = cp.getConstantPool().getConstantString(class_name_index, + this.classNameIndex = class_name_index; + className = cp.getConstantPool().getConstantString(class_name_index, Const.CONSTANT_Class).replace('/', '.'); } public void setSuperclassNameIndex( final int superclass_name_index ) { this.superclass_name_index = superclass_name_index; - super_class_name = cp.getConstantPool().getConstantString(superclass_name_index, + superClassName = cp.getConstantPool().getConstantString(superclass_name_index, Const.CONSTANT_Class).replace('/', '.'); } @@ -520,7 +520,7 @@ public int getSuperclassNameIndex() { public int getClassNameIndex() { - return class_name_index; + return classNameIndex; } private List observers; @@ -572,7 +572,7 @@ public Object clone() { * @return Comparison strategy object */ public static BCELComparator getComparator() { - return _cmp; + return bcelComparator; } @@ -580,7 +580,7 @@ public static BCELComparator getComparator() { * @param comparator Comparison strategy object */ public static void setComparator( final BCELComparator comparator ) { - _cmp = comparator; + bcelComparator = comparator; } @@ -593,7 +593,7 @@ public static void setComparator( final BCELComparator comparator ) { */ @Override public boolean equals( final Object obj ) { - return _cmp.equals(this, obj); + return bcelComparator.equals(this, obj); } @@ -605,6 +605,6 @@ public boolean equals( final Object obj ) { */ @Override public int hashCode() { - return _cmp.hashCode(this); + return bcelComparator.hashCode(this); } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/CodeExceptionGen.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/CodeExceptionGen.java index 1915d9274c5..de1a31dd125 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/CodeExceptionGen.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/CodeExceptionGen.java @@ -37,27 +37,27 @@ */ public final class CodeExceptionGen implements InstructionTargeter, Cloneable { - private InstructionHandle start_pc; - private InstructionHandle end_pc; - private InstructionHandle handler_pc; - private ObjectType catch_type; + private InstructionHandle startPc; + private InstructionHandle endPc; + private InstructionHandle handlerPc; + private ObjectType catchType; /** * Add an exception handler, i.e., specify region where a handler is active and an * instruction where the actual handling is done. * - * @param start_pc Start of handled region (inclusive) - * @param end_pc End of handled region (inclusive) - * @param handler_pc Where handling is done - * @param catch_type which exception is handled, null for ANY + * @param startPc Start of handled region (inclusive) + * @param endPc End of handled region (inclusive) + * @param handlerPc Where handling is done + * @param catchType which exception is handled, null for ANY */ - public CodeExceptionGen(final InstructionHandle start_pc, final InstructionHandle end_pc, - final InstructionHandle handler_pc, final ObjectType catch_type) { - setStartPC(start_pc); - setEndPC(end_pc); - setHandlerPC(handler_pc); - this.catch_type = catch_type; + public CodeExceptionGen(final InstructionHandle startPc, final InstructionHandle endPc, + final InstructionHandle handlerPc, final ObjectType catchType) { + setStartPC(startPc); + setEndPC(endPc); + setHandlerPC(handlerPc); + this.catchType = catchType; } @@ -71,36 +71,36 @@ public CodeExceptionGen(final InstructionHandle start_pc, final InstructionHandl * @param cp constant pool */ public CodeException getCodeException( final ConstantPoolGen cp ) { - return new CodeException(start_pc.getPosition(), end_pc.getPosition() - + end_pc.getInstruction().getLength(), handler_pc.getPosition(), - (catch_type == null) ? 0 : cp.addClass(catch_type)); + return new CodeException(startPc.getPosition(), endPc.getPosition() + + endPc.getInstruction().getLength(), handlerPc.getPosition(), + (catchType == null) ? 0 : cp.addClass(catchType)); } /* Set start of handler - * @param start_pc Start of handled region (inclusive) + * @param startPc Start of handled region (inclusive) */ public void setStartPC( final InstructionHandle start_pc ) { // TODO could be package-protected? - BranchInstruction.notifyTarget(this.start_pc, start_pc, this); - this.start_pc = start_pc; + BranchInstruction.notifyTarget(this.startPc, start_pc, this); + this.startPc = start_pc; } /* Set end of handler - * @param end_pc End of handled region (inclusive) + * @param endPc End of handled region (inclusive) */ public void setEndPC( final InstructionHandle end_pc ) { // TODO could be package-protected? - BranchInstruction.notifyTarget(this.end_pc, end_pc, this); - this.end_pc = end_pc; + BranchInstruction.notifyTarget(this.endPc, end_pc, this); + this.endPc = end_pc; } /* Set handler code - * @param handler_pc Start of handler + * @param handlerPc Start of handler */ public void setHandlerPC( final InstructionHandle handler_pc ) { // TODO could be package-protected? - BranchInstruction.notifyTarget(this.handler_pc, handler_pc, this); - this.handler_pc = handler_pc; + BranchInstruction.notifyTarget(this.handlerPc, handler_pc, this); + this.handlerPc = handler_pc; } @@ -111,21 +111,21 @@ public void setHandlerPC( final InstructionHandle handler_pc ) { // TODO could b @Override public void updateTarget( final InstructionHandle old_ih, final InstructionHandle new_ih ) { boolean targeted = false; - if (start_pc == old_ih) { + if (startPc == old_ih) { targeted = true; setStartPC(new_ih); } - if (end_pc == old_ih) { + if (endPc == old_ih) { targeted = true; setEndPC(new_ih); } - if (handler_pc == old_ih) { + if (handlerPc == old_ih) { targeted = true; setHandlerPC(new_ih); } if (!targeted) { - throw new ClassGenException("Not targeting " + old_ih + ", but {" + start_pc + ", " - + end_pc + ", " + handler_pc + "}"); + throw new ClassGenException("Not targeting " + old_ih + ", but {" + startPc + ", " + + endPc + ", " + handlerPc + "}"); } } @@ -135,46 +135,46 @@ public void updateTarget( final InstructionHandle old_ih, final InstructionHandl */ @Override public boolean containsTarget( final InstructionHandle ih ) { - return (start_pc == ih) || (end_pc == ih) || (handler_pc == ih); + return (startPc == ih) || (endPc == ih) || (handlerPc == ih); } /** Sets the type of the Exception to catch. Set 'null' for ANY. */ - public void setCatchType( final ObjectType catch_type ) { - this.catch_type = catch_type; + public void setCatchType( final ObjectType catchType ) { + this.catchType = catchType; } /** Gets the type of the Exception to catch, 'null' for ANY. */ public ObjectType getCatchType() { - return catch_type; + return catchType; } /** @return start of handled region (inclusive) */ public InstructionHandle getStartPC() { - return start_pc; + return startPc; } /** @return end of handled region (inclusive) */ public InstructionHandle getEndPC() { - return end_pc; + return endPc; } /** @return start of handler */ public InstructionHandle getHandlerPC() { - return handler_pc; + return handlerPc; } @Override public String toString() { - return "CodeExceptionGen(" + start_pc + ", " + end_pc + ", " + handler_pc + ")"; + return "CodeExceptionGen(" + startPc + ", " + endPc + ", " + handlerPc + ")"; } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ConstantPoolGen.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ConstantPoolGen.java index b430b6e2c4e..a1dadbfc4b6 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ConstantPoolGen.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ConstantPoolGen.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -50,7 +50,7 @@ * JVM and that Double and Long constants need two slots. * * @see Constant - * @LastModified: Jan 2020 + * @LastModified: May 2021 */ public class ConstantPoolGen { @@ -98,15 +98,15 @@ public ConstantPoolGen(final Constant[] cs) { final ConstantString s = (ConstantString) c; final ConstantUtf8 u8 = (ConstantUtf8) constants[s.getStringIndex()]; final String key = u8.getBytes(); - if (!string_table.containsKey(key)) { - string_table.put(key, new Index(i)); + if (!stringTable.containsKey(key)) { + stringTable.put(key, new Index(i)); } } else if (c instanceof ConstantClass) { final ConstantClass s = (ConstantClass) c; final ConstantUtf8 u8 = (ConstantUtf8) constants[s.getNameIndex()]; final String key = u8.getBytes(); - if (!class_table.containsKey(key)) { - class_table.put(key, new Index(i)); + if (!classTable.containsKey(key)) { + classTable.put(key, new Index(i)); } } else if (c instanceof ConstantNameAndType) { final ConstantNameAndType n = (ConstantNameAndType) c; @@ -119,14 +119,14 @@ public ConstantPoolGen(final Constant[] cs) { final String key = sb.toString(); sb.delete(0, sb.length()); - if (!n_a_t_table.containsKey(key)) { - n_a_t_table.put(key, new Index(i)); + if (!natTable.containsKey(key)) { + natTable.put(key, new Index(i)); } } else if (c instanceof ConstantUtf8) { final ConstantUtf8 u = (ConstantUtf8) c; final String key = u.getBytes(); - if (!utf8_table.containsKey(key)) { - utf8_table.put(key, new Index(i)); + if (!utf8Table.containsKey(key)) { + utf8Table.put(key, new Index(i)); } } else if (c instanceof ConstantCP) { final ConstantCP m = (ConstantCP) c; @@ -164,8 +164,8 @@ public ConstantPoolGen(final Constant[] cs) { final String key = sb.toString(); sb.delete(0, sb.length()); - if (!cp_table.containsKey(key)) { - cp_table.put(key, new Index(i)); + if (!cpTable.containsKey(key)) { + cpTable.put(key, new Index(i)); } } else if (c == null) { // entries may be null // nothing to do @@ -220,7 +220,7 @@ protected void adjustSize() { } } - private final Map string_table = new HashMap<>(); + private final Map stringTable = new HashMap<>(); /** @@ -230,7 +230,7 @@ protected void adjustSize() { * @return index on success, -1 otherwise */ public int lookupString( final String str ) { - final Index index = string_table.get(str); + final Index index = stringTable.get(str); return (index != null) ? index.index : -1; } @@ -251,13 +251,13 @@ public int addString( final String str ) { final ConstantString s = new ConstantString(utf8); ret = index; constants[index++] = s; - if (!string_table.containsKey(str)) { - string_table.put(str, new Index(ret)); + if (!stringTable.containsKey(str)) { + stringTable.put(str, new Index(ret)); } return ret; } - private final Map class_table = new HashMap<>(); + private final Map classTable = new HashMap<>(); /** @@ -267,7 +267,7 @@ public int addString( final String str ) { * @return index on success, -1 otherwise */ public int lookupClass( final String str ) { - final Index index = class_table.get(str.replace('.', '/')); + final Index index = classTable.get(str.replace('.', '/')); return (index != null) ? index.index : -1; } @@ -281,8 +281,8 @@ private int addClass_( final String clazz ) { final ConstantClass c = new ConstantClass(addUtf8(clazz)); ret = index; constants[index++] = c; - if (!class_table.containsKey(clazz)) { - class_table.put(clazz, new Index(ret)); + if (!classTable.containsKey(clazz)) { + classTable.put(clazz, new Index(ret)); } return ret; } @@ -396,7 +396,7 @@ public int addFloat( final float n ) { return ret; } - private final Map utf8_table = new HashMap<>(); + private final Map utf8Table = new HashMap<>(); /** @@ -406,7 +406,7 @@ public int addFloat( final float n ) { * @return index on success, -1 otherwise */ public int lookupUtf8( final String n ) { - final Index index = utf8_table.get(n); + final Index index = utf8Table.get(n); return (index != null) ? index.index : -1; } @@ -425,8 +425,8 @@ public int addUtf8( final String n ) { adjustSize(); ret = index; constants[index++] = new ConstantUtf8(n); - if (!utf8_table.containsKey(n)) { - utf8_table.put(n, new Index(ret)); + if (!utf8Table.containsKey(n)) { + utf8Table.put(n, new Index(ret)); } return ret; } @@ -508,7 +508,7 @@ public int addDouble( final double n ) { return ret; } - private final Map n_a_t_table = new HashMap<>(); + private final Map natTable = new HashMap<>(); /** @@ -519,7 +519,7 @@ public int addDouble( final double n ) { * @return index on success, -1 otherwise */ public int lookupNameAndType( final String name, final String signature ) { - final Index _index = n_a_t_table.get(name + NAT_DELIM + signature); + final Index _index = natTable.get(name + NAT_DELIM + signature); return (_index != null) ? _index.index : -1; } @@ -545,13 +545,13 @@ public int addNameAndType( final String name, final String signature ) { ret = index; constants[index++] = new ConstantNameAndType(name_index, signature_index); final String key = name + NAT_DELIM + signature; - if (!n_a_t_table.containsKey(key)) { - n_a_t_table.put(key, new Index(ret)); + if (!natTable.containsKey(key)) { + natTable.put(key, new Index(ret)); } return ret; } - private final Map cp_table = new HashMap<>(); + private final Map cpTable = new HashMap<>(); /** @@ -563,7 +563,7 @@ public int addNameAndType( final String name, final String signature ) { * @return index on success, -1 otherwise */ public int lookupMethodref( final String class_name, final String method_name, final String signature ) { - final Index index = cp_table.get(class_name + METHODREF_DELIM + method_name + final Index index = cpTable.get(class_name + METHODREF_DELIM + method_name + METHODREF_DELIM + signature); return (index != null) ? index.index : -1; } @@ -596,8 +596,8 @@ public int addMethodref( final String class_name, final String method_name, fina ret = index; constants[index++] = new ConstantMethodref(class_index, name_and_type_index); final String key = class_name + METHODREF_DELIM + method_name + METHODREF_DELIM + signature; - if (!cp_table.containsKey(key)) { - cp_table.put(key, new Index(ret)); + if (!cpTable.containsKey(key)) { + cpTable.put(key, new Index(ret)); } return ret; } @@ -617,7 +617,7 @@ public int addMethodref( final MethodGen method ) { * @return index on success, -1 otherwise */ public int lookupInterfaceMethodref( final String class_name, final String method_name, final String signature ) { - final Index index = cp_table.get(class_name + IMETHODREF_DELIM + method_name + final Index index = cpTable.get(class_name + IMETHODREF_DELIM + method_name + IMETHODREF_DELIM + signature); return (index != null) ? index.index : -1; } @@ -651,8 +651,8 @@ public int addInterfaceMethodref( final String class_name, final String method_n ret = index; constants[index++] = new ConstantInterfaceMethodref(class_index, name_and_type_index); final String key = class_name + IMETHODREF_DELIM + method_name + IMETHODREF_DELIM + signature; - if (!cp_table.containsKey(key)) { - cp_table.put(key, new Index(ret)); + if (!cpTable.containsKey(key)) { + cpTable.put(key, new Index(ret)); } return ret; } @@ -672,7 +672,7 @@ public int addInterfaceMethodref( final MethodGen method ) { * @return index on success, -1 otherwise */ public int lookupFieldref( final String class_name, final String field_name, final String signature ) { - final Index index = cp_table.get(class_name + FIELDREF_DELIM + field_name + final Index index = cpTable.get(class_name + FIELDREF_DELIM + field_name + FIELDREF_DELIM + signature); return (index != null) ? index.index : -1; } @@ -700,8 +700,8 @@ public int addFieldref( final String class_name, final String field_name, final ret = index; constants[index++] = new ConstantFieldref(class_index, name_and_type_index); final String key = class_name + FIELDREF_DELIM + field_name + FIELDREF_DELIM + signature; - if (!cp_table.containsKey(key)) { - cp_table.put(key, new Index(ret)); + if (!cpTable.containsKey(key)) { + cpTable.put(key, new Index(ret)); } return ret; } @@ -817,11 +817,11 @@ public int addConstant( final Constant c, final ConstantPoolGen cp ) { case Const.CONSTANT_Fieldref: return addFieldref(class_name, name, signature); default: // Never reached - throw new RuntimeException("Unknown constant type " + c); + throw new IllegalArgumentException("Unknown constant type " + c); } } default: // Never reached - throw new RuntimeException("Unknown constant type " + c); + throw new IllegalArgumentException("Unknown constant type " + c); } } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ElementValueGen.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ElementValueGen.java index 0e730e6b66b..cebc7c45bd2 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ElementValueGen.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ElementValueGen.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -34,7 +34,7 @@ /** * @since 6.0 - * @LastModified: Jan 2020 + * @LastModified: May 2021 */ public abstract class ElementValueGen { @@ -141,7 +141,7 @@ public static ElementValueGen readElementValue(final DataInput dis, } return new ArrayElementValueGen(ARRAY, evalues, cpGen); default: - throw new RuntimeException("Unexpected element value kind in annotation: " + type); + throw new IllegalArgumentException("Unexpected element value kind in annotation: " + type); } } @@ -183,7 +183,7 @@ public static ElementValueGen copy(final ElementValue value, return new ClassElementValueGen((ClassElementValue) value, cpool, copyPoolEntries); default: - throw new RuntimeException("Not implemented yet! (" + value.getElementValueType() + ")"); + throw new UnsupportedOperationException("Not implemented yet! (" + value.getElementValueType() + ")"); } } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ElementValuePairGen.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ElementValuePairGen.java index 5a928375174..218ea89cae0 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ElementValuePairGen.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ElementValuePairGen.java @@ -37,19 +37,19 @@ public class ElementValuePairGen private final ElementValueGen value; - private final ConstantPoolGen cpool; + private final ConstantPoolGen constantPoolGen; public ElementValuePairGen(final ElementValuePair nvp, final ConstantPoolGen cpool, final boolean copyPoolEntries) { - this.cpool = cpool; + this.constantPoolGen = cpool; // J5ASSERT: // Could assert nvp.getNameString() points to the same thing as - // cpool.getConstant(nvp.getNameIndex()) + // constantPoolGen.getConstant(nvp.getNameIndex()) // if - // (!nvp.getNameString().equals(((ConstantUtf8)cpool.getConstant(nvp.getNameIndex())).getBytes())) + // (!nvp.getNameString().equals(((ConstantUtf8)constantPoolGen.getConstant(nvp.getNameIndex())).getBytes())) // { - // throw new RuntimeException("envp buggered"); + // throw new IllegalArgumentException("envp buggered"); // } if (copyPoolEntries) { @@ -68,7 +68,7 @@ public ElementValuePairGen(final ElementValuePair nvp, final ConstantPoolGen cpo public ElementValuePair getElementNameValuePair() { final ElementValue immutableValue = value.getElementValue(); - return new ElementValuePair(nameIdx, immutableValue, cpool + return new ElementValuePair(nameIdx, immutableValue, constantPoolGen .getConstantPool()); } @@ -77,7 +77,7 @@ protected ElementValuePairGen(final int idx, final ElementValueGen value, { this.nameIdx = idx; this.value = value; - this.cpool = cpool; + this.constantPoolGen = cpool; } public ElementValuePairGen(final String name, final ElementValueGen value, @@ -85,7 +85,7 @@ public ElementValuePairGen(final String name, final ElementValueGen value, { this.nameIdx = cpool.addUtf8(name); this.value = value; - this.cpool = cpool; + this.constantPoolGen = cpool; } protected void dump(final DataOutputStream dos) throws IOException @@ -101,8 +101,8 @@ public int getNameIndex() public final String getNameString() { - // ConstantString cu8 = (ConstantString)cpool.getConstant(nameIdx); - return ((ConstantUtf8) cpool.getConstant(nameIdx)).getBytes(); + // ConstantString cu8 = (ConstantString)constantPoolGen.getConstant(nameIdx); + return ((ConstantUtf8) constantPoolGen.getConstant(nameIdx)).getBytes(); } public final ElementValueGen getValue() diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/EnumElementValueGen.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/EnumElementValueGen.java index ae2746e2d53..13958521398 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/EnumElementValueGen.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/EnumElementValueGen.java @@ -48,7 +48,7 @@ protected EnumElementValueGen(final int typeIdx, final int valueIdx, { super(ElementValueGen.ENUM_CONSTANT, cpool); if (super.getElementValueType() != ENUM_CONSTANT) { - throw new RuntimeException( + throw new IllegalArgumentException( "Only element values of type enum can be built with this ctor - type specified: " + super.getElementValueType()); } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FieldGen.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FieldGen.java index 1e5e861efa6..78af8b698e0 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FieldGen.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FieldGen.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -41,7 +41,7 @@ * course be compatible with to the declared type). * * @see Field - * @LastModified: Jan 2020 + * @LastModified: May 2021 */ public class FieldGen extends FieldGenOrMethodGen { @@ -255,7 +255,7 @@ private int addConstant() { case Const.T_REFERENCE: return super.getConstantPool().addString((String) value); default: - throw new RuntimeException("Oops: Unhandled : " + super.getType().getType()); // sic + throw new IllegalStateException("Unhandled : " + super.getType().getType()); // sic } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FieldGenOrMethodGen.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FieldGenOrMethodGen.java index e0e07eeffd4..1c2e37f7d8b 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FieldGenOrMethodGen.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FieldGenOrMethodGen.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -30,7 +30,7 @@ * Super class for FieldGen and MethodGen objects, since they have * some methods in common! * - * @LastModified: Jun 2020 + * @LastModified: May 2021 */ public abstract class FieldGenOrMethodGen extends AccessFlags implements NamedAndTyped, Cloneable { @@ -38,10 +38,10 @@ public abstract class FieldGenOrMethodGen extends AccessFlags implements NamedAn private Type type; private ConstantPoolGen cp; - private final List attribute_vec = new ArrayList<>(); + private final List attributeList = new ArrayList<>(); // @since 6.0 - private final List annotation_vec= new ArrayList<>(); + private final List annotationList = new ArrayList<>(); protected FieldGenOrMethodGen() { @@ -103,15 +103,15 @@ public void setConstantPool( final ConstantPoolGen cp ) { // TODO could be packa * @param a attribute to be added */ public void addAttribute( final Attribute a ) { - attribute_vec.add(a); + attributeList.add(a); } /** * @since 6.0 */ - protected void addAnnotationEntry(final AnnotationEntryGen ag) // TODO could this be package protected? + public void addAnnotationEntry(final AnnotationEntryGen ag) { - annotation_vec.add(ag); + annotationList.add(ag); } @@ -119,15 +119,15 @@ protected void addAnnotationEntry(final AnnotationEntryGen ag) // TODO could thi * Remove an attribute. */ public void removeAttribute( final Attribute a ) { - attribute_vec.remove(a); + attributeList.remove(a); } /** * @since 6.0 */ - protected void removeAnnotationEntry(final AnnotationEntryGen ag) // TODO could this be package protected? + public void removeAnnotationEntry(final AnnotationEntryGen ag) { - annotation_vec.remove(ag); + annotationList.remove(ag); } @@ -135,15 +135,15 @@ protected void removeAnnotationEntry(final AnnotationEntryGen ag) // TODO could * Remove all attributes. */ public void removeAttributes() { - attribute_vec.clear(); + attributeList.clear(); } /** * @since 6.0 */ - protected void removeAnnotationEntries() // TODO could this be package protected? + public void removeAnnotationEntries() { - annotation_vec.clear(); + annotationList.clear(); } @@ -151,15 +151,11 @@ protected void removeAnnotationEntries() // TODO could this be package protected * @return all attributes of this method. */ public Attribute[] getAttributes() { - final Attribute[] attributes = new Attribute[attribute_vec.size()]; - attribute_vec.toArray(attributes); - return attributes; + return attributeList.toArray(new Attribute[0]); } public AnnotationEntryGen[] getAnnotationEntries() { - final AnnotationEntryGen[] annotations = new AnnotationEntryGen[annotation_vec.size()]; - annotation_vec.toArray(annotations); - return annotations; + return annotationList.toArray(new AnnotationEntryGen[0]); } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKEDYNAMIC.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKEDYNAMIC.java index 46f026cffee..d6bac98f036 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKEDYNAMIC.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKEDYNAMIC.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -36,10 +36,10 @@ * mechanism entirely. * * @see - * + * * The invokedynamic instruction in The Java Virtual Machine Specification * @since 6.0 - * @LastModified: Jan 2020 + * @LastModified: May 2021 */ public class INVOKEDYNAMIC extends InvokeInstruction { diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKEINTERFACE.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKEINTERFACE.java index 6f1736c3707..4953abda34b 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKEINTERFACE.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKEINTERFACE.java @@ -34,7 +34,7 @@ *
Stack: ..., objectref, [arg1, [arg2 ...]] -> ...
* * @see - * + * * The invokeinterface instruction in The Java Virtual Machine Specification */ public final class INVOKEINTERFACE extends InvokeInstruction { diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKESPECIAL.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKESPECIAL.java index d3eed22dae5..ce27d07fd20 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKESPECIAL.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKESPECIAL.java @@ -34,7 +34,7 @@ *
Stack: ..., objectref, [arg1, [arg2 ...]] -> ...
* * @see - * + * * The invokespecial instruction in The Java Virtual Machine Specification */ public class INVOKESPECIAL extends InvokeInstruction { diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKESTATIC.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKESTATIC.java index 356e13133e7..a89702514a2 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKESTATIC.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKESTATIC.java @@ -33,7 +33,7 @@ *
Stack: ..., [arg1, [arg2 ...]] -> ...
* * @see - * + * * The invokestatic instruction in The Java Virtual Machine Specification */ public class INVOKESTATIC extends InvokeInstruction { diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKEVIRTUAL.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKEVIRTUAL.java index a9652fd3403..bd5a2b5fd07 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKEVIRTUAL.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKEVIRTUAL.java @@ -33,7 +33,7 @@ *
Stack: ..., objectref, [arg1, [arg2 ...]] -> ...
* * @see - * + * * The invokevirtual instruction in The Java Virtual Machine Specification */ public class INVOKEVIRTUAL extends InvokeInstruction { diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionFactory.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionFactory.java index bb78cb97ff5..d2ec08ed678 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionFactory.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -32,7 +32,7 @@ * * @see Const * @see InstructionConst - * @LastModified: Jan 2020 + * @LastModified: May 2021 */ public class InstructionFactory { @@ -76,30 +76,52 @@ public InstructionFactory(final ConstantPoolGen cp) { */ public InvokeInstruction createInvoke( final String class_name, final String name, final Type ret_type, final Type[] arg_types, final short kind ) { + return createInvoke(class_name, name, ret_type, arg_types, kind, kind == Const.INVOKEINTERFACE); + } + + /** + * Creates an invoke instruction. (Except for invokedynamic.) + * + * @param class_name name of the called class + * @param name name of the called method + * @param ret_type return type of method + * @param arg_types argument types of method + * @param kind how to invoke: INVOKEINTERFACE, INVOKESTATIC, INVOKEVIRTUAL, or INVOKESPECIAL + * @param use_interface force use of InterfaceMethodref + * @return A new InvokeInstruction. + * @since 6.5.0 + */ + public InvokeInstruction createInvoke( final String class_name, final String name, final Type ret_type, + final Type[] arg_types, final short kind, final boolean use_interface) { + if (kind != Const.INVOKESPECIAL && kind != Const.INVOKEVIRTUAL && kind != Const.INVOKESTATIC + && kind != Const.INVOKEINTERFACE && kind != Const.INVOKEDYNAMIC) { + throw new IllegalArgumentException("Unknown invoke kind: " + kind); + } int index; int nargs = 0; final String signature = Type.getMethodSignature(ret_type, arg_types); for (final Type arg_type : arg_types) { nargs += arg_type.getSize(); } - if (kind == Const.INVOKEINTERFACE) { + if (use_interface) { index = cp.addInterfaceMethodref(class_name, name, signature); } else { index = cp.addMethodref(class_name, name, signature); } switch (kind) { - case Const.INVOKESPECIAL: - return new INVOKESPECIAL(index); - case Const.INVOKEVIRTUAL: - return new INVOKEVIRTUAL(index); - case Const.INVOKESTATIC: - return new INVOKESTATIC(index); - case Const.INVOKEINTERFACE: - return new INVOKEINTERFACE(index, nargs + 1); - case Const.INVOKEDYNAMIC: - return new INVOKEDYNAMIC(index); - default: - throw new RuntimeException("Oops: Unknown invoke kind: " + kind); + case Const.INVOKESPECIAL: + return new INVOKESPECIAL(index); + case Const.INVOKEVIRTUAL: + return new INVOKEVIRTUAL(index); + case Const.INVOKESTATIC: + return new INVOKESTATIC(index); + case Const.INVOKEINTERFACE: + return new INVOKEINTERFACE(index, nargs + 1); + case Const.INVOKEDYNAMIC: + return new INVOKEDYNAMIC(index); + default: + // Can't happen + throw new IllegalStateException("Unknown invoke kind: " + kind); } } @@ -248,7 +270,7 @@ public Instruction createAppend( final Type type ) { case Const.T_OBJECT: return createInvoke(append_mos[1], Const.INVOKEVIRTUAL); default: - throw new RuntimeException("Oops: No append for this type? " + type); + throw new IllegalArgumentException("No append for this type? " + type); } } @@ -276,7 +298,7 @@ public FieldInstruction createFieldAccess( final String class_name, case Const.PUTSTATIC: return new PUTSTATIC(index); default: - throw new RuntimeException("Oops: Unknown getfield kind:" + kind); + throw new IllegalArgumentException("Unknown getfield kind:" + kind); } } @@ -310,7 +332,7 @@ public static ReturnInstruction createReturn( final Type type ) { case Const.T_VOID: return InstructionConst.RETURN; default: - throw new RuntimeException("Invalid type: " + type); + throw new IllegalArgumentException("Invalid type: " + type); } } @@ -338,7 +360,7 @@ private static ArithmeticInstruction createBinaryIntOp( final char first, final case '>': return op.equals(">>>") ? InstructionConst.IUSHR : InstructionConst.ISHR; default: - throw new RuntimeException("Invalid operand " + op); + throw new IllegalArgumentException("Invalid operand " + op); } } @@ -366,7 +388,7 @@ private static ArithmeticInstruction createBinaryLongOp( final char first, final case '>': return op.equals(">>>") ? InstructionConst.LUSHR : InstructionConst.LSHR; default: - throw new RuntimeException("Invalid operand " + op); + throw new IllegalArgumentException("Invalid operand " + op); } } @@ -384,7 +406,7 @@ private static ArithmeticInstruction createBinaryFloatOp( final char op ) { case '%': return InstructionConst.FREM; default: - throw new RuntimeException("Invalid operand " + op); + throw new IllegalArgumentException("Invalid operand " + op); } } @@ -402,7 +424,7 @@ private static ArithmeticInstruction createBinaryDoubleOp( final char op ) { case '%': return InstructionConst.DREM; default: - throw new RuntimeException("Invalid operand " + op); + throw new IllegalArgumentException("Invalid operand " + op); } } @@ -427,7 +449,7 @@ public static ArithmeticInstruction createBinaryOperation( final String op, fina case Const.T_DOUBLE: return createBinaryDoubleOp(first); default: - throw new RuntimeException("Invalid type " + type); + throw new IllegalArgumentException("Invalid type " + type); } } @@ -485,7 +507,7 @@ public static LocalVariableInstruction createStore( final Type type, final int i case Const.T_OBJECT: return new ASTORE(index); default: - throw new RuntimeException("Invalid type " + type); + throw new IllegalArgumentException("Invalid type " + type); } } @@ -511,7 +533,7 @@ public static LocalVariableInstruction createLoad( final Type type, final int in case Const.T_OBJECT: return new ALOAD(index); default: - throw new RuntimeException("Invalid type " + type); + throw new IllegalArgumentException("Invalid type " + type); } } @@ -540,7 +562,7 @@ public static ArrayInstruction createArrayLoad( final Type type ) { case Const.T_OBJECT: return InstructionConst.AALOAD; default: - throw new RuntimeException("Invalid type " + type); + throw new IllegalArgumentException("Invalid type " + type); } } @@ -569,7 +591,7 @@ public static ArrayInstruction createArrayStore( final Type type ) { case Const.T_OBJECT: return InstructionConst.AASTORE; default: - throw new RuntimeException("Invalid type " + type); + throw new IllegalArgumentException("Invalid type " + type); } } @@ -592,7 +614,7 @@ public Instruction createCast( final Type src_type, final Type dest_type ) { try { i = (Instruction) java.lang.Class.forName(name).getDeclaredConstructor().newInstance(); } catch (final Exception e) { - throw new RuntimeException("Could not find instruction: " + name, e); + throw new IllegalArgumentException("Could not find instruction: " + name, e); } return i; } else if ((src_type instanceof ReferenceType) && (dest_type instanceof ReferenceType)) { @@ -601,7 +623,7 @@ public Instruction createCast( final Type src_type, final Type dest_type ) { } return new CHECKCAST(cp.addClass(((ObjectType) dest_type).getClassName())); } else { - throw new RuntimeException("Can not cast " + src_type + " to " + dest_type); + throw new IllegalArgumentException("Cannot cast " + src_type + " to " + dest_type); } } @@ -699,7 +721,7 @@ public static Instruction createNull( final Type type ) { case Const.T_VOID: return InstructionConst.NOP; default: - throw new RuntimeException("Invalid type: " + type); + throw new IllegalArgumentException("Invalid type: " + type); } } @@ -751,7 +773,7 @@ public static BranchInstruction createBranchInstruction( final short opcode, case Const.JSR_W: return new JSR_W(target); default: - throw new RuntimeException("Invalid opcode: " + opcode); + throw new IllegalArgumentException("Invalid opcode: " + opcode); } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionHandle.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionHandle.java index 25008e69d78..bdf78029537 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionHandle.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionHandle.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -42,7 +42,7 @@ * @see Instruction * @see BranchHandle * @see InstructionList - * @LastModified: Jan 2020 + * @LastModified: May 2021 */ public class InstructionHandle { @@ -295,7 +295,7 @@ public void accept( final Visitor v ) { /** * @param next the next to set - * @ since 6.0 + * @since 6.0 */ final InstructionHandle setNext(final InstructionHandle next) { this.next = next; @@ -305,7 +305,7 @@ final InstructionHandle setNext(final InstructionHandle next) { /** * @param prev the prev to set - * @ since 6.0 + * @since 6.0 */ final InstructionHandle setPrev(final InstructionHandle prev) { this.prev = prev; diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionList.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionList.java index 0e90723c530..28c53220444 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionList.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionList.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -47,14 +47,14 @@ * @see Instruction * @see InstructionHandle * @see BranchHandle - * @LastModified: Jan 2020 + * @LastModified: May 2021 */ public class InstructionList implements Iterable { private InstructionHandle start = null; private InstructionHandle end = null; private int length = 0; // number of elements in list - private int[] byte_positions; // byte code offsets corresponding to instructions + private int[] bytePositions; // byte code offsets corresponding to instructions /** * Create (empty) instruction list. @@ -145,7 +145,7 @@ public static InstructionHandle findHandle(final InstructionHandle[] ihs, * @return target position's instruction handle if available */ public InstructionHandle findHandle(final int pos) { - final int[] positions = byte_positions; + final int[] positions = bytePositions; InstructionHandle ih = start; for (int i = 0; i < length; i++) { if (positions[i] == pos) { @@ -193,8 +193,8 @@ public InstructionList(final byte[] code) { } catch (final IOException e) { throw new ClassGenException(e.toString(), e); } - byte_positions = new int[count]; // Trim to proper size - System.arraycopy(pos, 0, byte_positions, 0, count); + bytePositions = new int[count]; // Trim to proper size + System.arraycopy(pos, 0, bytePositions, 0, count); /* * Pass 2: Look for BranchInstruction and update their targets, i.e., convert offsets to instruction handles. */ @@ -204,7 +204,7 @@ public InstructionList(final byte[] code) { int target = bi.getPosition() + bi.getIndex(); /* * Byte code position: relative -> absolute. - */ + */ // Search for target position InstructionHandle ih = findHandle(ihs, pos, count, target); if (ih == null) { @@ -797,10 +797,8 @@ public void delete(final InstructionHandle from, final InstructionHandle to) thr } /** - * Remove instructions from instruction `from' to instruction `to' contained - * in this list. The user must ensure that `from' is an instruction before - * `to', or risk havoc. The corresponding Instruction handles must not be - * reused! + * Remove instructions from instruction `from' to instruction `to' contained in this list. The user must ensure that `from' is an instruction before `to', + * or risk havoc. The corresponding Instruction handles must not be reused! * * @param from * where to start deleting (inclusive) @@ -960,8 +958,8 @@ public void setPositions(final boolean check) { // called by code in other packa pos[count++] = index; index += i.getLength(); } - byte_positions = new int[count]; // Trim to proper size - System.arraycopy(pos, 0, byte_positions, 0, count); + bytePositions = new int[count]; // Trim to proper size + System.arraycopy(pos, 0, bytePositions, 0, count); } /** @@ -1074,7 +1072,7 @@ public InstructionHandle[] getInstructionHandles() { * @return array containing all instruction's offset in byte code */ public int[] getInstructionPositions() { - return byte_positions; + return bytePositions; } /** diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/JsrInstruction.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/JsrInstruction.java index b679d6bb115..f999d5ce76b 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/JsrInstruction.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/JsrInstruction.java @@ -74,7 +74,7 @@ public InstructionHandle physicalSuccessor() { while (ih != null) { ih = ih.getNext(); if ((ih != null) && (ih.getInstruction() == this)) { - throw new RuntimeException("physicalSuccessor() called on a shared JsrInstruction."); + throw new IllegalStateException("physicalSuccessor() called on a shared JsrInstruction."); } } // Return the physical successor diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LDC.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LDC.java index 3b7ceec2f91..92c490a43b4 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LDC.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LDC.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -31,7 +31,7 @@ * *
Stack: ... -> ..., item
* - * @LastModified: Jan 2020 + * @LastModified: May 2021 */ public class LDC extends CPInstruction implements PushInstruction, ExceptionThrower { @@ -112,7 +112,7 @@ public Object getValue( final ConstantPoolGen cpg ) { c = cpg.getConstantPool().getConstant(nameIndex); return new ObjectType(((com.sun.org.apache.bcel.internal.classfile.ConstantUtf8) c).getBytes()); default: // Never reached - throw new RuntimeException("Unknown or invalid constant type at " + super.getIndex()); + throw new IllegalArgumentException("Unknown or invalid constant type at " + super.getIndex()); } } @@ -129,7 +129,7 @@ public Type getType( final ConstantPoolGen cpg ) { case com.sun.org.apache.bcel.internal.Const.CONSTANT_Class: return Type.CLASS; default: // Never reached - throw new RuntimeException("Unknown or invalid constant type at " + super.getIndex()); + throw new IllegalArgumentException("Unknown or invalid constant type at " + super.getIndex()); } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LDC2_W.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LDC2_W.java index 544b879647c..ade9b29cd84 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LDC2_W.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LDC2_W.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -25,7 +25,7 @@ * *
Stack: ... -> ..., item.word1, item.word2
* - * @LastModified: Jan 2020 + * @LastModified: May 2021 */ public class LDC2_W extends CPInstruction implements PushInstruction { @@ -50,7 +50,7 @@ public Type getType( final ConstantPoolGen cpg ) { case com.sun.org.apache.bcel.internal.Const.CONSTANT_Double: return Type.DOUBLE; default: // Never reached - throw new RuntimeException("Unknown constant type " + super.getOpcode()); + throw new IllegalArgumentException("Unknown constant type " + super.getOpcode()); } } @@ -63,7 +63,7 @@ public Number getValue( final ConstantPoolGen cpg ) { case com.sun.org.apache.bcel.internal.Const.CONSTANT_Double: return ((com.sun.org.apache.bcel.internal.classfile.ConstantDouble) c).getBytes(); default: // Never reached - throw new RuntimeException("Unknown or invalid constant type at " + super.getIndex()); + throw new IllegalArgumentException("Unknown or invalid constant type at " + super.getIndex()); } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LineNumberGen.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LineNumberGen.java index a9ab4a8012e..b5ac6cda812 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LineNumberGen.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LineNumberGen.java @@ -21,6 +21,8 @@ package com.sun.org.apache.bcel.internal.generic; +import java.util.Objects; + import com.sun.org.apache.bcel.internal.classfile.LineNumber; /** @@ -33,8 +35,7 @@ public class LineNumberGen implements InstructionTargeter, Cloneable { private InstructionHandle ih; - private int src_line; - + private int srcLine; /** * Create a line number. @@ -76,16 +77,14 @@ public void updateTarget( final InstructionHandle old_ih, final InstructionHandl * or that the `setPositions' methods has been called for the instruction list. */ public LineNumber getLineNumber() { - return new LineNumber(ih.getPosition(), src_line); + return new LineNumber(ih.getPosition(), srcLine); } - public void setInstruction( final InstructionHandle ih ) { // TODO could be package-protected? - if (ih == null) { - throw new NullPointerException("InstructionHandle may not be null"); - } - BranchInstruction.notifyTarget(this.ih, ih, this); - this.ih = ih; + public void setInstruction( final InstructionHandle instructionHandle ) { // TODO could be package-protected? + Objects.requireNonNull(instructionHandle, "instructionHandle"); + BranchInstruction.notifyTarget(this.ih, instructionHandle, this); + this.ih = instructionHandle; } @@ -105,11 +104,11 @@ public InstructionHandle getInstruction() { public void setSourceLine( final int src_line ) { // TODO could be package-protected? - this.src_line = src_line; + this.srcLine = src_line; } public int getSourceLine() { - return src_line; + return srcLine; } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LocalVariableGen.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LocalVariableGen.java index 57961f346dc..4693af780e7 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LocalVariableGen.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LocalVariableGen.java @@ -39,8 +39,8 @@ public class LocalVariableGen implements InstructionTargeter, NamedAndTyped, Clo private Type type; private InstructionHandle start; private InstructionHandle end; - private int orig_index; // never changes; used to match up with LocalVariableTypeTable entries - private boolean live_to_end; + private int origIndex; // never changes; used to match up with LocalVariableTypeTable entries + private boolean liveToEnd; /** @@ -63,8 +63,8 @@ public LocalVariableGen(final int index, final String name, final Type type, fin this.index = index; setStart(start); setEnd(end); - this.orig_index = index; - this.live_to_end = end == null; + this.origIndex = index; + this.liveToEnd = end == null; } @@ -77,12 +77,12 @@ public LocalVariableGen(final int index, final String name, final Type type, fin * @param type its type * @param start from where the instruction is valid (null means from the start) * @param end until where the instruction is valid (null means to the end) - * @param orig_index index of local variable prior to any changes to index + * @param origIndex index of local variable prior to any changes to index */ public LocalVariableGen(final int index, final String name, final Type type, final InstructionHandle start, - final InstructionHandle end, final int orig_index) { + final InstructionHandle end, final int origIndex) { this(index, name, type, start, end); - this.orig_index = orig_index; + this.origIndex = origIndex; } @@ -95,7 +95,7 @@ public LocalVariableGen(final int index, final String name, final Type type, fin * Note that due to the conversion from byte code offset to InstructionHandle, * it is impossible to tell the difference between a live range that ends BEFORE * the last insturction of the method or a live range that ends AFTER the last - * instruction of the method. Hence the live_to_end flag to differentiate + * instruction of the method. Hence the liveToEnd flag to differentiate * between these two cases. * * @param cp constant pool @@ -106,14 +106,14 @@ public LocalVariable getLocalVariable( final ConstantPoolGen cp ) { if ((start != null) && (end != null)) { start_pc = start.getPosition(); length = end.getPosition() - start_pc; - if ((end.getNext() == null) && live_to_end) { + if ((end.getNext() == null) && liveToEnd) { length += end.getInstruction().getLength(); } } final int name_index = cp.addUtf8(name); final int signature_index = cp.addUtf8(type.getSignature()); return new LocalVariable(start_pc, length, name_index, signature_index, index, cp - .getConstantPool(), orig_index); + .getConstantPool(), origIndex); } @@ -128,17 +128,17 @@ public int getIndex() { public int getOrigIndex() { - return orig_index; + return origIndex; } public void setLiveToEnd( final boolean live_to_end) { - this.live_to_end = live_to_end; + this.liveToEnd = live_to_end; } public boolean getLiveToEnd() { - return live_to_end; + return liveToEnd; } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LocalVariableInstruction.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LocalVariableInstruction.java index 5f009b2ade0..fb4d7545478 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LocalVariableInstruction.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LocalVariableInstruction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -28,14 +28,14 @@ /** * Abstract super class for instructions dealing with local variables. * - * @LastModified: Jan 2020 + * @LastModified: May 2021 */ public abstract class LocalVariableInstruction extends Instruction implements TypedInstruction, IndexedInstruction { private int n = -1; // index of referenced variable - private short c_tag = -1; // compact version, such as ILOAD_0 - private short canon_tag = -1; // canonical tag such as ILOAD + private short cTag = -1; // compact version, such as ILOAD_0 + private short canonTag = -1; // canonical tag such as ILOAD private boolean wide() { @@ -50,8 +50,8 @@ private boolean wide() { */ LocalVariableInstruction(final short canon_tag, final short c_tag) { super(); - this.canon_tag = canon_tag; - this.c_tag = c_tag; + this.canonTag = canon_tag; + this.cTag = c_tag; } @@ -65,13 +65,13 @@ private boolean wide() { /** * @param opcode Instruction opcode - * @param c_tag Instruction number for compact version, ALOAD_0, e.g. + * @param cTag Instruction number for compact version, ALOAD_0, e.g. * @param n local variable index (unsigned short) */ - protected LocalVariableInstruction(final short opcode, final short c_tag, final int n) { + protected LocalVariableInstruction(final short opcode, final short cTag, final int n) { super(opcode, (short) 2); - this.c_tag = c_tag; - canon_tag = opcode; + this.cTag = cTag; + canonTag = opcode; setIndex(n); } @@ -167,10 +167,10 @@ public void setIndex( final int n ) { // TODO could be package-protected? this.n = n; // Cannot be < 0 as this is checked above if (n <= 3) { // Use more compact instruction xLOAD_n - super.setOpcode((short) (c_tag + n)); + super.setOpcode((short) (cTag + n)); super.setLength(1); } else { - super.setOpcode(canon_tag); + super.setOpcode(canonTag); if (wide()) { super.setLength(4); } else { @@ -183,7 +183,7 @@ public void setIndex( final int n ) { // TODO could be package-protected? /** @return canonical tag for instruction, e.g., ALOAD for ALOAD_0 */ public short getCanonicalTag() { - return canon_tag; + return canonTag; } @@ -197,7 +197,7 @@ public short getCanonicalTag() { */ @Override public Type getType( final ConstantPoolGen cp ) { - switch (canon_tag) { + switch (canonTag) { case Const.ILOAD: case Const.ISTORE: return Type.INT; @@ -214,7 +214,7 @@ public Type getType( final ConstantPoolGen cp ) { case Const.ASTORE: return Type.OBJECT; default: - throw new ClassGenException("Oops: unknown case in switch" + canon_tag); + throw new ClassGenException("Unknown case in switch" + canonTag); } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/MethodGen.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/MethodGen.java index 478082cc13f..f787b44b08d 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/MethodGen.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/MethodGen.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -57,25 +57,25 @@ * * @see InstructionList * @see Method - * @LastModified: Jan 2020 + * @LastModified: May 2021 */ public class MethodGen extends FieldGenOrMethodGen { - private String class_name; - private Type[] arg_types; - private String[] arg_names; - private int max_locals; - private int max_stack; + private String className; + private Type[] argTypes; + private String[] argNames; + private int maxLocals; + private int maxStack; private InstructionList il; - private boolean strip_attributes; - private LocalVariableTypeTable local_variable_type_table = null; - private final List variable_vec = new ArrayList<>(); - private final List line_number_vec = new ArrayList<>(); - private final List exception_vec = new ArrayList<>(); - private final List throws_vec = new ArrayList<>(); - private final List code_attrs_vec = new ArrayList<>(); - - private List[] param_annotations; // Array of lists containing AnnotationGen objects + private boolean stripAttributes; + private LocalVariableTypeTable localVariableTypeTable = null; + private final List variableList = new ArrayList<>(); + private final List lineNumberList = new ArrayList<>(); + private final List exceptionList = new ArrayList<>(); + private final List throwsList = new ArrayList<>(); + private final List codeAttrsList = new ArrayList<>(); + + private List[] paramAnnotations; // Array of lists containing AnnotationGen objects private boolean hasParameterAnnotations = false; private boolean haveUnpackedParameterAnnotations = false; @@ -111,23 +111,23 @@ public int hashCode( final Object o ) { * * @param access_flags access qualifiers * @param return_type method type - * @param arg_types argument types - * @param arg_names argument names (if this is null, default names will be provided + * @param argTypes argument types + * @param argNames argument names (if this is null, default names will be provided * for them) * @param method_name name of method - * @param class_name class name containing this method (may be null, if you don't care) + * @param className class name containing this method (may be null, if you don't care) * @param il instruction list associated with this method, may be null only for * abstract or native methods * @param cp constant pool */ - public MethodGen(final int access_flags, final Type return_type, final Type[] arg_types, String[] arg_names, - final String method_name, final String class_name, final InstructionList il, final ConstantPoolGen cp) { + public MethodGen(final int access_flags, final Type return_type, final Type[] argTypes, String[] argNames, + final String method_name, final String className, final InstructionList il, final ConstantPoolGen cp) { super(access_flags); setType(return_type); - setArgumentTypes(arg_types); - setArgumentNames(arg_names); + setArgumentTypes(argTypes); + setArgumentNames(argNames); setName(method_name); - setClassName(class_name); + setClassName(className); setInstructionList(il); setConstantPool(cp); final boolean abstract_ = isAbstract() || isNative(); @@ -138,32 +138,32 @@ public MethodGen(final int access_flags, final Type return_type, final Type[] ar // end == null => live to end of method /* Add local variables, namely the implicit `this' and the arguments */ - if (!isStatic() && (class_name != null)) { // Instance method -> `this' is local var 0 - addLocalVariable("this", ObjectType.getInstance(class_name), start, end); + if (!isStatic() && (className != null)) { // Instance method -> `this' is local var 0 + addLocalVariable("this", ObjectType.getInstance(className), start, end); } } - if (arg_types != null) { - final int size = arg_types.length; - for (final Type arg_type : arg_types) { + if (argTypes != null) { + final int size = argTypes.length; + for (final Type arg_type : argTypes) { if (Type.VOID == arg_type) { throw new ClassGenException("'void' is an illegal argument type for a method"); } } - if (arg_names != null) { // Names for variables provided? - if (size != arg_names.length) { + if (argNames != null) { // Names for variables provided? + if (size != argNames.length) { throw new ClassGenException("Mismatch in argument array lengths: " + size - + " vs. " + arg_names.length); + + " vs. " + argNames.length); } } else { // Give them dummy names - arg_names = new String[size]; + argNames = new String[size]; for (int i = 0; i < size; i++) { - arg_names[i] = "arg" + i; + argNames[i] = "arg" + i; } - setArgumentNames(arg_names); + setArgumentNames(argNames); } if (!abstract_) { for (int i = 0; i < size; i++) { - addLocalVariable(arg_names[i], arg_types[i], start, end); + addLocalVariable(argNames[i], argTypes[i], start, end); } } } @@ -173,18 +173,19 @@ public MethodGen(final int access_flags, final Type return_type, final Type[] ar /** * Instantiate from existing method. * - * @param m method - * @param class_name class name containing this method + * @param method method + * @param className class name containing this method * @param cp constant pool */ - public MethodGen(final Method m, final String class_name, final ConstantPoolGen cp) { - this(m.getAccessFlags(), Type.getReturnType(m.getSignature()), Type.getArgumentTypes(m - .getSignature()), null /* may be overridden anyway */ - , m.getName(), class_name, - ((m.getAccessFlags() & (Const.ACC_ABSTRACT | Const.ACC_NATIVE)) == 0) - ? new InstructionList(m.getCode().getCode()) - : null, cp); - final Attribute[] attributes = m.getAttributes(); + public MethodGen(final Method method, final String className, final ConstantPoolGen cp) { + this(method.getAccessFlags(), Type.getReturnType(method.getSignature()), + Type.getArgumentTypes(method.getSignature()), null /* may be overridden anyway */ + , method.getName(), className, + ((method.getAccessFlags() & (Const.ACC_ABSTRACT | Const.ACC_NATIVE)) == 0) + ? new InstructionList(getByteCodes(method)) + : null, + cp); + final Attribute[] attributes = method.getAttributes(); for (final Attribute attribute : attributes) { Attribute a = attribute; if (a instanceof Code) { @@ -197,12 +198,12 @@ public MethodGen(final Method m, final String class_name, final ConstantPoolGen final int type = ce.getCatchType(); ObjectType c_type = null; if (type > 0) { - final String cen = m.getConstantPool().getConstantString(type, + final String cen = method.getConstantPool().getConstantString(type, Const.CONSTANT_Class); c_type = ObjectType.getInstance(cen); } final int end_pc = ce.getEndPC(); - final int length = m.getCode().getCode().length; + final int length = getByteCodes(method).length; InstructionHandle end; if (length == end_pc) { // May happen, because end_pc is exclusive end = il.getEnd(); @@ -210,8 +211,8 @@ public MethodGen(final Method m, final String class_name, final ConstantPoolGen end = il.findHandle(end_pc); end = end.getPrev(); // Make it inclusive } - addExceptionHandler(il.findHandle(ce.getStartPC()), end, il.findHandle(ce - .getHandlerPC()), c_type); + addExceptionHandler(il.findHandle(ce.getStartPC()), end, + il.findHandle(ce.getHandlerPC()), c_type); } } final Attribute[] c_attributes = c.getAttributes(); @@ -228,7 +229,7 @@ public MethodGen(final Method m, final String class_name, final ConstantPoolGen } else if (a instanceof LocalVariableTable) { updateLocalVariableTable((LocalVariableTable) a); } else if (a instanceof LocalVariableTypeTable) { - this.local_variable_type_table = (LocalVariableTypeTable) a.copy(cp.getConstantPool()); + this.localVariableTypeTable = (LocalVariableTypeTable) a.copy(cp.getConstantPool()); } else { addCodeAttribute(a); } @@ -250,6 +251,15 @@ public MethodGen(final Method m, final String class_name, final ConstantPoolGen } } + + private static byte[] getByteCodes(final Method method) { + final Code code = method.getCode(); + if (code == null) { + throw new IllegalStateException(String.format("The method '%s' has no code.", method)); + } + return code.getCode(); + } + /** * Adds a local variable to this method. * @@ -268,15 +278,15 @@ public LocalVariableGen addLocalVariable( final String name, final Type type, fi final byte t = type.getType(); if (t != Const.T_ADDRESS) { final int add = type.getSize(); - if (slot + add > max_locals) { - max_locals = slot + add; + if (slot + add > maxLocals) { + maxLocals = slot + add; } final LocalVariableGen l = new LocalVariableGen(slot, name, type, start, end, orig_index); int i; - if ((i = variable_vec.indexOf(l)) >= 0) { - variable_vec.set(i, l); + if ((i = variableList.indexOf(l)) >= 0) { + variableList.set(i, l); } else { - variable_vec.add(l); + variableList.add(l); } return l; } @@ -316,7 +326,7 @@ public LocalVariableGen addLocalVariable( final String name, final Type type, fi */ public LocalVariableGen addLocalVariable( final String name, final Type type, final InstructionHandle start, final InstructionHandle end ) { - return addLocalVariable(name, type, max_locals, start, end); + return addLocalVariable(name, type, maxLocals, start, end); } @@ -325,7 +335,7 @@ public LocalVariableGen addLocalVariable( final String name, final Type type, fi * addLocalVariable with an explicit index argument. */ public void removeLocalVariable(final LocalVariableGen l) { - variable_vec.remove(l); + variableList.remove(l); } @@ -333,7 +343,7 @@ public void removeLocalVariable(final LocalVariableGen l) { * Remove all local variables. */ public void removeLocalVariables() { - variable_vec.clear(); + variableList.clear(); } @@ -344,9 +354,9 @@ public void removeLocalVariables() { * @return array of declared local variables sorted by index */ public LocalVariableGen[] getLocalVariables() { - final int size = variable_vec.size(); + final int size = variableList.size(); final LocalVariableGen[] lg = new LocalVariableGen[size]; - variable_vec.toArray(lg); + variableList.toArray(lg); for (int i = 0; i < size; i++) { if ((lg[i].getStart() == null) && (il != null)) { lg[i].setStart(il.getStart()); @@ -380,7 +390,7 @@ public LocalVariableTable getLocalVariableTable( final ConstantPoolGen cp ) { * @return `LocalVariableTypeTable' attribute of this method. */ public LocalVariableTypeTable getLocalVariableTypeTable() { - return local_variable_type_table; + return localVariableTypeTable; } /** @@ -390,9 +400,9 @@ public LocalVariableTypeTable getLocalVariableTypeTable() { * @return new line number object * @see LineNumber */ - public LineNumberGen addLineNumber( final InstructionHandle ih, final int src_line ) { - final LineNumberGen l = new LineNumberGen(ih, src_line); - line_number_vec.add(l); + public LineNumberGen addLineNumber( final InstructionHandle ih, final int srcLine ) { + final LineNumberGen l = new LineNumberGen(ih, srcLine); + lineNumberList.add(l); return l; } @@ -401,7 +411,7 @@ public LineNumberGen addLineNumber( final InstructionHandle ih, final int src_li * Remove a line number. */ public void removeLineNumber( final LineNumberGen l ) { - line_number_vec.remove(l); + lineNumberList.remove(l); } @@ -409,7 +419,7 @@ public void removeLineNumber( final LineNumberGen l ) { * Remove all line numbers. */ public void removeLineNumbers() { - line_number_vec.clear(); + lineNumberList.clear(); } @@ -417,8 +427,8 @@ public void removeLineNumbers() { * @return array of line numbers */ public LineNumberGen[] getLineNumbers() { - final LineNumberGen[] lg = new LineNumberGen[line_number_vec.size()]; - line_number_vec.toArray(lg); + final LineNumberGen[] lg = new LineNumberGen[lineNumberList.size()]; + lineNumberList.toArray(lg); return lg; } @@ -427,10 +437,10 @@ public LineNumberGen[] getLineNumbers() { * @return `LineNumberTable' attribute of all the local variables of this method. */ public LineNumberTable getLineNumberTable( final ConstantPoolGen cp ) { - final int size = line_number_vec.size(); + final int size = lineNumberList.size(); final LineNumber[] ln = new LineNumber[size]; for (int i = 0; i < size; i++) { - ln[i] = line_number_vec.get(i).getLineNumber(); + ln[i] = lineNumberList.get(i).getLineNumber(); } return new LineNumberTable(cp.addUtf8("LineNumberTable"), 2 + ln.length * 4, ln, cp .getConstantPool()); @@ -454,7 +464,7 @@ public CodeExceptionGen addExceptionHandler( final InstructionHandle start_pc, throw new ClassGenException("Exception handler target is null instruction"); } final CodeExceptionGen c = new CodeExceptionGen(start_pc, end_pc, handler_pc, catch_type); - exception_vec.add(c); + exceptionList.add(c); return c; } @@ -463,7 +473,7 @@ public CodeExceptionGen addExceptionHandler( final InstructionHandle start_pc, * Remove an exception handler. */ public void removeExceptionHandler( final CodeExceptionGen c ) { - exception_vec.remove(c); + exceptionList.remove(c); } @@ -471,7 +481,7 @@ public void removeExceptionHandler( final CodeExceptionGen c ) { * Remove all line numbers. */ public void removeExceptionHandlers() { - exception_vec.clear(); + exceptionList.clear(); } @@ -479,8 +489,8 @@ public void removeExceptionHandlers() { * @return array of declared exception handlers */ public CodeExceptionGen[] getExceptionHandlers() { - final CodeExceptionGen[] cg = new CodeExceptionGen[exception_vec.size()]; - exception_vec.toArray(cg); + final CodeExceptionGen[] cg = new CodeExceptionGen[exceptionList.size()]; + exceptionList.toArray(cg); return cg; } @@ -489,10 +499,10 @@ public CodeExceptionGen[] getExceptionHandlers() { * @return code exceptions for `Code' attribute */ private CodeException[] getCodeExceptions() { - final int size = exception_vec.size(); + final int size = exceptionList.size(); final CodeException[] c_exc = new CodeException[size]; for (int i = 0; i < size; i++) { - final CodeExceptionGen c = exception_vec.get(i); + final CodeExceptionGen c = exceptionList.get(i); c_exc[i] = c.getCodeException(super.getConstantPool()); } return c_exc; @@ -502,10 +512,10 @@ private CodeException[] getCodeExceptions() { /** * Add an exception possibly thrown by this method. * - * @param class_name (fully qualified) name of exception + * @param className (fully qualified) name of exception */ - public void addException( final String class_name ) { - throws_vec.add(class_name); + public void addException( final String className ) { + throwsList.add(className); } @@ -513,7 +523,7 @@ public void addException( final String class_name ) { * Remove an exception. */ public void removeException( final String c ) { - throws_vec.remove(c); + throwsList.remove(c); } @@ -521,7 +531,7 @@ public void removeException( final String c ) { * Remove all exceptions. */ public void removeExceptions() { - throws_vec.clear(); + throwsList.clear(); } @@ -529,9 +539,7 @@ public void removeExceptions() { * @return array of thrown exceptions */ public String[] getExceptions() { - final String[] e = new String[throws_vec.size()]; - throws_vec.toArray(e); - return e; + return throwsList.toArray(new String[0]); } @@ -539,10 +547,10 @@ public String[] getExceptions() { * @return `Exceptions' attribute of all the exceptions thrown by this method. */ private ExceptionTable getExceptionTable( final ConstantPoolGen cp ) { - final int size = throws_vec.size(); + final int size = throwsList.size(); final int[] ex = new int[size]; for (int i = 0; i < size; i++) { - ex[i] = cp.addClass(throws_vec.get(i)); + ex[i] = cp.addClass(throwsList.get(i)); } return new ExceptionTable(cp.addUtf8("Exceptions"), 2 + 2 * size, ex, cp.getConstantPool()); } @@ -558,7 +566,7 @@ private ExceptionTable getExceptionTable( final ConstantPoolGen cp ) { * @param a attribute to be added */ public void addCodeAttribute( final Attribute a ) { - code_attrs_vec.add(a); + codeAttrsList.add(a); } @@ -566,14 +574,14 @@ public void addCodeAttribute( final Attribute a ) { * Remove the LocalVariableTypeTable */ public void removeLocalVariableTypeTable( ) { - local_variable_type_table = null; + localVariableTypeTable = null; } /** * Remove a code attribute. */ public void removeCodeAttribute( final Attribute a ) { - code_attrs_vec.remove(a); + codeAttrsList.remove(a); } @@ -581,8 +589,8 @@ public void removeCodeAttribute( final Attribute a ) { * Remove all code attributes. */ public void removeCodeAttributes() { - local_variable_type_table = null; - code_attrs_vec.clear(); + localVariableTypeTable = null; + codeAttrsList.clear(); } @@ -590,35 +598,63 @@ public void removeCodeAttributes() { * @return all attributes of this method. */ public Attribute[] getCodeAttributes() { - final Attribute[] attributes = new Attribute[code_attrs_vec.size()]; - code_attrs_vec.toArray(attributes); - return attributes; + return codeAttrsList.toArray(new Attribute[0]); } /** * @since 6.0 */ public void addAnnotationsAsAttribute(final ConstantPoolGen cp) { - final Attribute[] attrs = AnnotationEntryGen.getAnnotationAttributes(cp, super.getAnnotationEntries()); + final Attribute[] attrs = AnnotationEntryGen.getAnnotationAttributes(cp, super.getAnnotationEntries()); for (final Attribute attr : attrs) { addAttribute(attr); } - } + } /** * @since 6.0 */ - public void addParameterAnnotationsAsAttribute(final ConstantPoolGen cp) { - if (!hasParameterAnnotations) { - return; - } - final Attribute[] attrs = AnnotationEntryGen.getParameterAnnotationAttributes(cp,param_annotations); - if (attrs != null) { - for (final Attribute attr : attrs) { - addAttribute(attr); - } - } - } + public void addParameterAnnotationsAsAttribute(final ConstantPoolGen cp) { + if (!hasParameterAnnotations) { + return; + } + final Attribute[] attrs = AnnotationEntryGen.getParameterAnnotationAttributes(cp, paramAnnotations); + if (attrs != null) { + for (final Attribute attr : attrs) { + addAttribute(attr); + } + } + } + + private Attribute[] addRuntimeAnnotationsAsAttribute(final ConstantPoolGen cp) { + final Attribute[] attrs = AnnotationEntryGen.getAnnotationAttributes(cp, super.getAnnotationEntries()); + for (final Attribute attr : attrs) { + addAttribute(attr); + } + return attrs; + } + + private Attribute[] addRuntimeParameterAnnotationsAsAttribute(final ConstantPoolGen cp) { + if (!hasParameterAnnotations) { + return new Attribute[0]; + } + final Attribute[] attrs = AnnotationEntryGen.getParameterAnnotationAttributes(cp, paramAnnotations); + for (final Attribute attr : attrs) { + addAttribute(attr); + } + return attrs; + } + + /** + * Would prefer to make this private, but need a way to test if client is + * using BCEL version 6.5.0 or later that contains fix for BCEL-329. + * @since 6.5.0 + */ + public void removeRuntimeAttributes(final Attribute[] attrs) { + for (final Attribute attr : attrs) { + removeAttribute(attr); + } + } /** @@ -642,18 +678,18 @@ public Method getMethod() { LocalVariableTable lvt = null; /* Create LocalVariableTable and LineNumberTable attributes (for debuggers, e.g.) */ - if ((variable_vec.size() > 0) && !strip_attributes) { + if ((variableList.size() > 0) && !stripAttributes) { updateLocalVariableTable(getLocalVariableTable(_cp)); addCodeAttribute(lvt = getLocalVariableTable(_cp)); } - if (local_variable_type_table != null) { + if (localVariableTypeTable != null) { // LocalVariable length in LocalVariableTypeTable is not updated automatically. It's a difference with LocalVariableTable. if (lvt != null) { adjustLocalVariableTypeTable(lvt); } - addCodeAttribute(local_variable_type_table); + addCodeAttribute(localVariableTypeTable); } - if ((line_number_vec.size() > 0) && !strip_attributes) { + if ((lineNumberList.size() > 0) && !stripAttributes) { addCodeAttribute(lnt = getLineNumberTable(_cp)); } final Attribute[] code_attrs = getCodeAttributes(); @@ -677,13 +713,13 @@ public Method getMethod() { code = new Code(_cp.addUtf8("Code"), 8 + byte_code.length + // prologue byte code 2 + exc_len + // exceptions 2 + attrs_len, // attributes - max_stack, max_locals, byte_code, c_exc, code_attrs, _cp.getConstantPool()); + maxStack, maxLocals, byte_code, c_exc, code_attrs, _cp.getConstantPool()); addAttribute(code); } - addAnnotationsAsAttribute(_cp); - addParameterAnnotationsAsAttribute(_cp); + final Attribute[] annotations = addRuntimeAnnotationsAsAttribute(_cp); + final Attribute[] parameterAnnotations = addRuntimeParameterAnnotationsAsAttribute(_cp); ExceptionTable et = null; - if (throws_vec.size() > 0) { + if (throwsList.size() > 0) { addAttribute(et = getExceptionTable(_cp)); // Add `Exceptions' if there are "throws" clauses } @@ -693,8 +729,8 @@ public Method getMethod() { if (lvt != null) { removeCodeAttribute(lvt); } - if (local_variable_type_table != null) { - removeCodeAttribute(local_variable_type_table); + if (localVariableTypeTable != null) { + removeCodeAttribute(localVariableTypeTable); } if (lnt != null) { removeCodeAttribute(lnt); @@ -705,6 +741,8 @@ public Method getMethod() { if (et != null) { removeAttribute(et); } + removeRuntimeAttributes(annotations); + removeRuntimeAttributes(parameterAnnotations); return m; } @@ -728,7 +766,7 @@ private void updateLocalVariableTable(final LocalVariableTable a) { private void adjustLocalVariableTypeTable(final LocalVariableTable lvt) { final LocalVariable[] lv = lvt.getLocalVariableTable(); - final LocalVariable[] lvg = local_variable_type_table.getLocalVariableTypeTable(); + final LocalVariable[] lvg = localVariableTypeTable.getLocalVariableTypeTable(); for (final LocalVariable element : lvg) { for (final LocalVariable l : lv) { @@ -775,12 +813,12 @@ public void removeNOPs() { * Set maximum number of local variables. */ public void setMaxLocals( final int m ) { - max_locals = m; + maxLocals = m; } public int getMaxLocals() { - return max_locals; + return maxLocals; } @@ -788,24 +826,24 @@ public int getMaxLocals() { * Set maximum stack size for this method. */ public void setMaxStack( final int m ) { // TODO could be package-protected? - max_stack = m; + maxStack = m; } public int getMaxStack() { - return max_stack; + return maxStack; } /** @return class that contains this method */ public String getClassName() { - return class_name; + return className; } public void setClassName( final String class_name ) { // TODO could be package-protected? - this.class_name = class_name; + this.className = class_name; } @@ -820,42 +858,42 @@ public Type getReturnType() { public void setArgumentTypes( final Type[] arg_types ) { - this.arg_types = arg_types; + this.argTypes = arg_types; } public Type[] getArgumentTypes() { - return arg_types.clone(); + return argTypes.clone(); } public void setArgumentType( final int i, final Type type ) { - arg_types[i] = type; + argTypes[i] = type; } public Type getArgumentType( final int i ) { - return arg_types[i]; + return argTypes[i]; } public void setArgumentNames( final String[] arg_names ) { - this.arg_names = arg_names; + this.argNames = arg_names; } public String[] getArgumentNames() { - return arg_names.clone(); + return argNames.clone(); } public void setArgumentName( final int i, final String name ) { - arg_names[i] = name; + argNames[i] = name; } public String getArgumentName( final int i ) { - return arg_names[i]; + return argNames[i]; } @@ -871,7 +909,7 @@ public void setInstructionList( final InstructionList il ) { // TODO could be pa @Override public String getSignature() { - return Type.getMethodSignature(super.getType(), arg_types); + return Type.getMethodSignature(super.getType(), argTypes); } @@ -880,9 +918,9 @@ public String getSignature() { */ public void setMaxStack() { // TODO could be package-protected? (some tests would need repackaging) if (il != null) { - max_stack = getMaxStack(super.getConstantPool(), il, getExceptionHandlers()); + maxStack = getMaxStack(super.getConstantPool(), il, getExceptionHandlers()); } else { - max_stack = 0; + maxStack = 0; } } @@ -893,8 +931,8 @@ public void setMaxStack() { // TODO could be package-protected? (some tests woul public void setMaxLocals() { // TODO could be package-protected? (some tests would need repackaging) if (il != null) { int max = isStatic() ? 0 : 1; - if (arg_types != null) { - for (final Type arg_type : arg_types) { + if (argTypes != null) { + for (final Type arg_type : argTypes) { max += arg_type.getSize(); } } @@ -909,9 +947,9 @@ public void setMaxLocals() { // TODO could be package-protected? (some tests wou } } } - max_locals = max; + maxLocals = max; } else { - max_locals = 0; + maxLocals = 0; } } @@ -920,7 +958,7 @@ public void setMaxLocals() { // TODO could be package-protected? (some tests wou * LocalVariableTable, like javac -O */ public void stripAttributes( final boolean flag ) { - strip_attributes = flag; + stripAttributes = flag; } static final class BranchTarget { @@ -1091,7 +1129,7 @@ public void update() { @Override public final String toString() { final String access = Utility.accessToString(super.getAccessFlags()); - String signature = Type.getMethodSignature(super.getType(), arg_types); + String signature = Type.getMethodSignature(super.getType(), argTypes); signature = Utility.methodSignatureToString(signature, super.getName(), access, true, getLocalVariableTable(super.getConstantPool())); final StringBuilder buf = new StringBuilder(signature); @@ -1101,8 +1139,8 @@ public final String toString() { } } - if (throws_vec.size() > 0) { - for (final String throwsDescriptor : throws_vec) { + if (throwsList.size() > 0) { + for (final String throwsDescriptor : throwsList) { buf.append("\n\t\tthrows ").append(throwsDescriptor); } } @@ -1112,9 +1150,9 @@ public final String toString() { /** @return deep copy of this method */ - public MethodGen copy( final String class_name, final ConstantPoolGen cp ) { + public MethodGen copy( final String className, final ConstantPoolGen cp ) { final Method m = ((MethodGen) clone()).getMethod(); - final MethodGen mg = new MethodGen(m, class_name, super.getConstantPool()); + final MethodGen mg = new MethodGen(m, className, super.getConstantPool()); if (super.getConstantPool() != cp) { mg.setConstantPool(cp); mg.getInstructionList().replaceConstantPool(super.getConstantPool(), cp); @@ -1122,7 +1160,7 @@ public MethodGen copy( final String class_name, final ConstantPoolGen cp ) { return mg; } - //J5TODO: Should param_annotations be an array of arrays? Rather than an array of lists, this + //J5TODO: Should paramAnnotations be an array of arrays? Rather than an array of lists, this // is more likely to suggest to the caller it is readonly (which a List does not). /** * Return a list of AnnotationGen objects representing parameter annotations @@ -1130,10 +1168,10 @@ public MethodGen copy( final String class_name, final ConstantPoolGen cp ) { */ public List getAnnotationsOnParameter(final int i) { ensureExistingParameterAnnotationsUnpacked(); - if (!hasParameterAnnotations || i > arg_types.length) { + if (!hasParameterAnnotations || i > argTypes.length) { return null; } - return param_annotations[i]; + return paramAnnotations[i]; } /** @@ -1156,14 +1194,14 @@ private void ensureExistingParameterAnnotationsUnpacked() for (final Attribute attribute : attrs) { if (attribute instanceof ParameterAnnotations) { - // Initialize param_annotations + // Initialize paramAnnotations if (!hasParameterAnnotations) { - @SuppressWarnings({"rawtypes", "unchecked"}) - final List[] parmList = new List[arg_types.length]; - param_annotations = parmList; - for (int j = 0; j < arg_types.length; j++) { - param_annotations[j] = new ArrayList<>(); + @SuppressWarnings({"rawtypes", "unchecked"}) // OK + final List[] parmList = new List[argTypes.length]; + paramAnnotations = parmList; + for (int j = 0; j < argTypes.length; j++) { + paramAnnotations[j] = new ArrayList<>(); } } hasParameterAnnotations = true; @@ -1181,7 +1219,7 @@ private void ensureExistingParameterAnnotationsUnpacked() // ... which needs transforming into an AnnotationGen[] ... final List mutable = makeMutableVersion(immutableArray.getAnnotationEntries()); // ... then add these to any we already know about - param_annotations[j].addAll(mutable); + paramAnnotations[j].addAll(mutable); } } } @@ -1211,11 +1249,11 @@ public void addParameterAnnotation(final int parameterIndex, if (!hasParameterAnnotations) { @SuppressWarnings({"rawtypes", "unchecked"}) - final List[] parmList = new List[arg_types.length]; - param_annotations = parmList; + final List[] parmList = new List[argTypes.length]; + paramAnnotations = parmList; hasParameterAnnotations = true; } - final List existingAnnotations = param_annotations[parameterIndex]; + final List existingAnnotations = paramAnnotations[parameterIndex]; if (existingAnnotations != null) { existingAnnotations.add(annotation); @@ -1224,7 +1262,7 @@ public void addParameterAnnotation(final int parameterIndex, { final List l = new ArrayList<>(); l.add(annotation); - param_annotations[parameterIndex] = l; + paramAnnotations[parameterIndex] = l; } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ObjectType.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ObjectType.java index bca11994303..13cb8eaa346 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ObjectType.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ObjectType.java @@ -31,28 +31,28 @@ */ public class ObjectType extends ReferenceType { - private final String class_name; // Class name of type + private final String className; // Class name of type /** * @since 6.0 */ - public static ObjectType getInstance(final String class_name) { - return new ObjectType(class_name); + public static ObjectType getInstance(final String className) { + return new ObjectType(className); } /** - * @param class_name fully qualified class name, e.g. java.lang.String + * @param className fully qualified class name, e.g. java.lang.String */ - public ObjectType(final String class_name) { - super(Const.T_REFERENCE, "L" + class_name.replace('.', '/') + ";"); - this.class_name = class_name.replace('/', '.'); + public ObjectType(final String className) { + super(Const.T_REFERENCE, "L" + className.replace('.', '/') + ";"); + this.className = className.replace('/', '.'); } /** @return name of referenced class */ public String getClassName() { - return class_name; + return className; } @@ -60,7 +60,7 @@ public String getClassName() { */ @Override public int hashCode() { - return class_name.hashCode(); + return className.hashCode(); } @@ -69,7 +69,7 @@ public int hashCode() { @Override public boolean equals( final Object type ) { return (type instanceof ObjectType) - ? ((ObjectType) type).class_name.equals(class_name) + ? ((ObjectType) type).className.equals(className) : false; } @@ -84,7 +84,7 @@ public boolean equals( final Object type ) { @Deprecated public boolean referencesClass() { try { - final JavaClass jc = Repository.lookupClass(class_name); + final JavaClass jc = Repository.lookupClass(className); return jc.isClass(); } catch (final ClassNotFoundException e) { return false; @@ -102,7 +102,7 @@ public boolean referencesClass() { @Deprecated public boolean referencesInterface() { try { - final JavaClass jc = Repository.lookupClass(class_name); + final JavaClass jc = Repository.lookupClass(className); return !jc.isClass(); } catch (final ClassNotFoundException e) { return false; @@ -119,7 +119,7 @@ public boolean referencesInterface() { * referenced by this type can't be found */ public boolean referencesClassExact() throws ClassNotFoundException { - final JavaClass jc = Repository.lookupClass(class_name); + final JavaClass jc = Repository.lookupClass(className); return jc.isClass(); } @@ -133,7 +133,7 @@ public boolean referencesClassExact() throws ClassNotFoundException { * referenced by this type can't be found */ public boolean referencesInterfaceExact() throws ClassNotFoundException { - final JavaClass jc = Repository.lookupClass(class_name); + final JavaClass jc = Repository.lookupClass(className); return !jc.isClass(); } @@ -147,7 +147,7 @@ public boolean subclassOf( final ObjectType superclass ) throws ClassNotFoundExc if (this.referencesInterfaceExact() || superclass.referencesInterfaceExact()) { return false; } - return Repository.instanceOf(this.class_name, superclass.class_name); + return Repository.instanceOf(this.className, superclass.className); } @@ -157,11 +157,11 @@ public boolean subclassOf( final ObjectType superclass ) throws ClassNotFoundExc * can't be found */ public boolean accessibleTo( final ObjectType accessor ) throws ClassNotFoundException { - final JavaClass jc = Repository.lookupClass(class_name); + final JavaClass jc = Repository.lookupClass(className); if (jc.isPublic()) { return true; } - final JavaClass acc = Repository.lookupClass(accessor.class_name); + final JavaClass acc = Repository.lookupClass(accessor.className); return acc.getPackageName().equals(jc.getPackageName()); } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/SWITCH.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/SWITCH.java index 6f7c7a88a12..bd2f25413c8 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/SWITCH.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/SWITCH.java @@ -32,7 +32,7 @@ public final class SWITCH implements CompoundInstruction { private int[] match; private InstructionHandle[] targets; private Select instruction; - private int match_length; + private int matchLength; /** @@ -53,10 +53,10 @@ public final class SWITCH implements CompoundInstruction { public SWITCH(final int[] match, final InstructionHandle[] targets, final InstructionHandle target, final int max_gap) { this.match = match.clone(); this.targets = targets.clone(); - if ((match_length = match.length) < 2) { + if ((matchLength = match.length) < 2) { instruction = new TABLESWITCH(match, targets, target); } else { - sort(0, match_length - 1); + sort(0, matchLength - 1); if (matchIsOrdered(max_gap)) { fillup(max_gap, target); instruction = new TABLESWITCH(this.match, this.targets, target); @@ -73,13 +73,13 @@ public SWITCH(final int[] match, final InstructionHandle[] targets, final Instru private void fillup( final int max_gap, final InstructionHandle target ) { - final int max_size = match_length + match_length * max_gap; + final int max_size = matchLength + matchLength * max_gap; final int[] m_vec = new int[max_size]; final InstructionHandle[] t_vec = new InstructionHandle[max_size]; int count = 1; m_vec[0] = match[0]; t_vec[0] = targets[0]; - for (int i = 1; i < match_length; i++) { + for (int i = 1; i < matchLength; i++) { final int prev = match[i - 1]; final int gap = match[i] - prev; for (int j = 1; j < gap; j++) { @@ -138,7 +138,7 @@ private void sort( final int l, final int r ) { * @return match is sorted in ascending order with no gap bigger than max_gap? */ private boolean matchIsOrdered( final int max_gap ) { - for (int i = 1; i < match_length; i++) { + for (int i = 1; i < matchLength; i++) { if (match[i] - match[i - 1] > max_gap) { return false; } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/Select.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/Select.java index 244507a8853..a9dc01e2600 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/Select.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/Select.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -27,12 +27,12 @@ /** * Select - Abstract super class for LOOKUPSWITCH and TABLESWITCH instructions. * - *

We use our super's target property as the default target. + *

We use our super's {@code target} property as the default target. * * @see LOOKUPSWITCH * @see TABLESWITCH * @see InstructionList - * @LastModified: Jan 2020 + * @LastModified: May 2021 */ public abstract class Select extends BranchInstruction implements VariableLengthInstruction, StackConsumer /* @since 6.0 */, StackProducer { diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/SimpleElementValueGen.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/SimpleElementValueGen.java index 946d962fcf3..bccb59cabaf 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/SimpleElementValueGen.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/SimpleElementValueGen.java @@ -166,7 +166,7 @@ public SimpleElementValueGen(final SimpleElementValue value, idx = cpool.addInteger(value.getValueShort()); break; default: - throw new RuntimeException( + throw new IllegalArgumentException( "SimpleElementValueGen class does not know how to copy this type " + super.getElementValueType()); } } @@ -189,7 +189,7 @@ public int getIndex() public String getValueString() { if (super.getElementValueType() != STRING) { - throw new RuntimeException( + throw new IllegalStateException( "Dont call getValueString() on a non STRING ElementValue"); } final ConstantUtf8 c = (ConstantUtf8) getConstantPool().getConstant(idx); @@ -199,7 +199,7 @@ public String getValueString() public int getValueInt() { if (super.getElementValueType() != PRIMITIVE_INT) { - throw new RuntimeException( + throw new IllegalStateException( "Dont call getValueString() on a non STRING ElementValue"); } final ConstantInteger c = (ConstantInteger) getConstantPool().getConstant(idx); @@ -243,7 +243,7 @@ public String stringifyValue() final ConstantUtf8 cu8 = (ConstantUtf8) getConstantPool().getConstant(idx); return cu8.getBytes(); default: - throw new RuntimeException( + throw new IllegalStateException( "SimpleElementValueGen class does not know how to stringify type " + super.getElementValueType()); } } @@ -266,7 +266,7 @@ public void dump(final DataOutputStream dos) throws IOException dos.writeShort(idx); break; default: - throw new RuntimeException( + throw new IllegalStateException( "SimpleElementValueGen doesnt know how to write out type " + super.getElementValueType()); } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/Type.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/Type.java index ced2f1832e8..2e366dfc8d9 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/Type.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/Type.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -30,7 +30,7 @@ * Abstract super class for all possible java types, namely basic types * such as int, object types like String and array types, e.g. int[] * - * @LastModified: Jan 2020 + * @LastModified: May 2021 */ public abstract class Type { @@ -295,7 +295,7 @@ public static Type getType( final java.lang.Class cl ) { } else if (cl == Character.TYPE) { return CHAR; } else { - throw new IllegalStateException("Ooops, what primitive type is " + cl); + throw new IllegalStateException("Unknown primitive type " + cl); } } else { // "Real" class return ObjectType.getInstance(cl.getName()); diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/BCELFactory.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/BCELFactory.java index 18f9d5a5d08..ae7f74099e9 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/BCELFactory.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/BCELFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -64,7 +64,7 @@ * A helper class for BCELifier. * * @see BCELifier - * @LastModified: Jan 2020 + * @LastModified: May 2021 */ class BCELFactory extends EmptyVisitor { @@ -201,7 +201,7 @@ public void visitAllocationInstruction( final AllocationInstruction i ) { + ", (short) " + dim + "));"); break; default: - throw new RuntimeException("Oops: " + opcode); + throw new IllegalArgumentException("Unhandled opcode: " + opcode); } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/CodeHTML.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/CodeHTML.java index 0ed26e4cf1c..fe8e9388391 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/CodeHTML.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/CodeHTML.java @@ -48,21 +48,21 @@ */ final class CodeHTML { - private final String class_name; // name of current class + private final String className; // name of current class // private Method[] methods; // Methods to print private final PrintWriter file; // file to write to - private BitSet goto_set; - private final ConstantPool constant_pool; - private final ConstantHTML constant_html; + private BitSet gotoSet; + private final ConstantPool constantPool; + private final ConstantHTML constantHtml; private static boolean wide = false; CodeHTML(final String dir, final String class_name, final Method[] methods, final ConstantPool constant_pool, final ConstantHTML constant_html) throws IOException { - this.class_name = class_name; + this.className = class_name; // this.methods = methods; - this.constant_pool = constant_pool; - this.constant_html = constant_html; + this.constantPool = constant_pool; + this.constantHtml = constant_html; file = new PrintWriter(new FileOutputStream(dir + class_name + "_code.html")); file.println(""); for (int i = 0; i < methods.length; i++) { @@ -231,19 +231,19 @@ private String codeToHTML( final ByteSequence bytes, final int method_number ) t case Const.PUTFIELD: case Const.PUTSTATIC: index = bytes.readShort(); - final ConstantFieldref c1 = (ConstantFieldref) constant_pool.getConstant(index, + final ConstantFieldref c1 = (ConstantFieldref) constantPool.getConstant(index, Const.CONSTANT_Fieldref); class_index = c1.getClassIndex(); - name = constant_pool.getConstantString(class_index, Const.CONSTANT_Class); + name = constantPool.getConstantString(class_index, Const.CONSTANT_Class); name = Utility.compactClassName(name, false); index = c1.getNameAndTypeIndex(); - final String field_name = constant_pool.constantToString(index, Const.CONSTANT_NameAndType); - if (name.equals(class_name)) { // Local field - buf.append("").append(field_name) .append("\n"); } else { - buf.append(constant_html.referenceConstant(class_index)).append(".").append( + buf.append(constantHtml.referenceConstant(class_index)).append(".").append( field_name); } break; @@ -253,7 +253,7 @@ private String codeToHTML( final ByteSequence bytes, final int method_number ) t case Const.INSTANCEOF: case Const.NEW: index = bytes.readShort(); - buf.append(constant_html.referenceConstant(index)); + buf.append(constantHtml.referenceConstant(index)); break; /* Operands are references to methods in constant pool */ @@ -269,7 +269,7 @@ private String codeToHTML( final ByteSequence bytes, final int method_number ) t bytes.readUnsignedByte(); // Reserved // int nargs = bytes.readUnsignedByte(); // Redundant // int reserved = bytes.readUnsignedByte(); // Reserved - final ConstantInterfaceMethodref c = (ConstantInterfaceMethodref) constant_pool + final ConstantInterfaceMethodref c = (ConstantInterfaceMethodref) constantPool .getConstant(m_index, Const.CONSTANT_InterfaceMethodref); class_index = c.getClassIndex(); index = c.getNameAndTypeIndex(); @@ -277,7 +277,7 @@ private String codeToHTML( final ByteSequence bytes, final int method_number ) t } else if (opcode == Const.INVOKEDYNAMIC) { // Special treatment needed bytes.readUnsignedByte(); // Reserved bytes.readUnsignedByte(); // Reserved - final ConstantInvokeDynamic c = (ConstantInvokeDynamic) constant_pool + final ConstantInvokeDynamic c = (ConstantInvokeDynamic) constantPool .getConstant(m_index, Const.CONSTANT_InvokeDynamic); index = c.getNameAndTypeIndex(); name = "#" + c.getBootstrapMethodAttrIndex(); @@ -285,21 +285,21 @@ private String codeToHTML( final ByteSequence bytes, final int method_number ) t // UNDONE: Java8 now allows INVOKESPECIAL and INVOKESTATIC to // reference EITHER a Methodref OR an InterfaceMethodref. // Not sure if that affects this code or not. (markro) - final ConstantMethodref c = (ConstantMethodref) constant_pool.getConstant(m_index, + final ConstantMethodref c = (ConstantMethodref) constantPool.getConstant(m_index, Const.CONSTANT_Methodref); class_index = c.getClassIndex(); index = c.getNameAndTypeIndex(); name = Class2HTML.referenceClass(class_index); } - str = Class2HTML.toHTML(constant_pool.constantToString(constant_pool.getConstant( + str = Class2HTML.toHTML(constantPool.constantToString(constantPool.getConstant( index, Const.CONSTANT_NameAndType))); // Get signature, i.e., types - final ConstantNameAndType c2 = (ConstantNameAndType) constant_pool.getConstant(index, + final ConstantNameAndType c2 = (ConstantNameAndType) constantPool.getConstant(index, Const.CONSTANT_NameAndType); - signature = constant_pool.constantToString(c2.getSignatureIndex(), Const.CONSTANT_Utf8); + signature = constantPool.constantToString(c2.getSignatureIndex(), Const.CONSTANT_Utf8); final String[] args = Utility.methodSignatureArgumentTypes(signature, false); final String type = Utility.methodSignatureReturnType(signature, false); - buf.append(name).append(".").append(str).append( "").append("("); // List arguments @@ -317,30 +317,30 @@ private String codeToHTML( final ByteSequence bytes, final int method_number ) t case Const.LDC_W: case Const.LDC2_W: index = bytes.readShort(); - buf.append("").append( - Class2HTML.toHTML(constant_pool.constantToString(index, - constant_pool.getConstant(index).getTag()))).append(""); + Class2HTML.toHTML(constantPool.constantToString(index, + constantPool.getConstant(index).getTag()))).append(""); break; case Const.LDC: index = bytes.readUnsignedByte(); - buf.append("").append( - Class2HTML.toHTML(constant_pool.constantToString(index, - constant_pool.getConstant(index).getTag()))).append(""); + Class2HTML.toHTML(constantPool.constantToString(index, + constantPool.getConstant(index).getTag()))).append(""); break; /* Array of references. */ case Const.ANEWARRAY: index = bytes.readShort(); - buf.append(constant_html.referenceConstant(index)); + buf.append(constantHtml.referenceConstant(index)); break; /* Multidimensional array of references. */ case Const.MULTIANEWARRAY: index = bytes.readShort(); final int dimensions = bytes.readByte(); - buf.append(constant_html.referenceConstant(index)).append(":").append(dimensions) + buf.append(constantHtml.referenceConstant(index)).append(":").append(dimensions) .append("-dimensional"); break; /* Increment local variable. @@ -389,7 +389,7 @@ private String codeToHTML( final ByteSequence bytes, final int method_number ) t */ private void findGotos( final ByteSequence bytes, final Code code ) throws IOException { int index; - goto_set = new BitSet(bytes.available()); + gotoSet = new BitSet(bytes.available()); int opcode; /* First get Code attribute from method and the exceptions handled * (try .. catch) in this method. We only need the line number here. @@ -397,9 +397,9 @@ private void findGotos( final ByteSequence bytes, final Code code ) throws IOExc if (code != null) { final CodeException[] ce = code.getExceptionTable(); for (final CodeException cex : ce) { - goto_set.set(cex.getStartPC()); - goto_set.set(cex.getEndPC()); - goto_set.set(cex.getHandlerPC()); + gotoSet.set(cex.getStartPC()); + gotoSet.set(cex.getEndPC()); + gotoSet.set(cex.getHandlerPC()); } // Look for local variables and their range final Attribute[] attributes = code.getAttributes(); @@ -410,8 +410,8 @@ private void findGotos( final ByteSequence bytes, final Code code ) throws IOExc for (final LocalVariable var : vars) { final int start = var.getStartPC(); final int end = start + var.getLength(); - goto_set.set(start); - goto_set.set(end); + gotoSet.set(start); + gotoSet.set(end); } break; } @@ -439,21 +439,21 @@ private void findGotos( final ByteSequence bytes, final Code code ) throws IOExc final int high = bytes.readInt(); offset = bytes.getIndex() - 12 - no_pad_bytes - 1; default_offset += offset; - goto_set.set(default_offset); + gotoSet.set(default_offset); for (int j = 0; j < (high - low + 1); j++) { index = offset + bytes.readInt(); - goto_set.set(index); + gotoSet.set(index); } } else { // LOOKUPSWITCH final int npairs = bytes.readInt(); offset = bytes.getIndex() - 8 - no_pad_bytes - 1; default_offset += offset; - goto_set.set(default_offset); + gotoSet.set(default_offset); for (int j = 0; j < npairs; j++) { // int match = bytes.readInt(); bytes.readInt(); index = offset + bytes.readInt(); - goto_set.set(index); + gotoSet.set(index); } } break; @@ -477,13 +477,13 @@ private void findGotos( final ByteSequence bytes, final Code code ) throws IOExc case Const.JSR: //bytes.readByte(); // Skip already read byte index = bytes.getIndex() + bytes.readShort() - 1; - goto_set.set(index); + gotoSet.set(index); break; case Const.GOTO_W: case Const.JSR_W: //bytes.readByte(); // Skip already read byte index = bytes.getIndex() + bytes.readInt() - 1; - goto_set.set(index); + gotoSet.set(index); break; default: bytes.unreadByte(); @@ -513,7 +513,7 @@ private void writeMethod( final Method method, final int method_number ) throws final Attribute[] attributes = method.getAttributes(); file.print("

" + access + " " + "" + Class2HTML.referenceType(type) + " " + + className + "_methods.html#method" + method_number + "\" TARGET=Methods>" + html_name + "("); for (int i = 0; i < args.length; i++) { file.print(Class2HTML.referenceType(args[i])); @@ -529,7 +529,7 @@ private void writeMethod( final Method method, final int method_number ) throws for (int i = 0; i < attributes.length; i++) { byte tag = attributes[i].getTag(); if (tag != Const.ATTR_UNKNOWN) { - file.print("

  • " + Const.getAttributeName(tag) + "
  • \n"); } else { @@ -542,7 +542,7 @@ private void writeMethod( final Method method, final int method_number ) throws file.print("
      "); for (int j = 0; j < attributes2.length; j++) { tag = attributes2[j].getTag(); - file.print("
    • " + Const.getAttributeName(tag) + "
    • \n"); } @@ -552,7 +552,7 @@ private void writeMethod( final Method method, final int method_number ) throws file.println("
    "); } if (code != null) { // No code, an abstract method, e.g. - //System.out.println(name + "\n" + Utility.codeToString(code, constant_pool, 0, -1)); + //System.out.println(name + "\n" + Utility.codeToString(code, constantPool, 0, -1)); // Print the byte code try (ByteSequence stream = new ByteSequence(code)) { stream.mark(stream.available()); @@ -568,7 +568,7 @@ private void writeMethod( final Method method, final int method_number ) throws * Set an anchor mark if this line is targetted by a goto, jsr, etc. Defining an anchor for every * line is very inefficient! */ - if (goto_set.get(offset)) { + if (gotoSet.get(offset)) { anchor = ""; } String anchor2; diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ConstantHTML.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ConstantHTML.java index eeafbcfaff8..e2d5b4b5103 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ConstantHTML.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ConstantHTML.java @@ -44,25 +44,25 @@ */ final class ConstantHTML { - private final String class_name; // name of current class - private final String class_package; // name of package - private final ConstantPool constant_pool; // reference to constant pool + private final String className; // name of current class + private final String classPackage; // name of package + private final ConstantPool constantPool; // reference to constant pool private final PrintWriter file; // file to write to - private final String[] constant_ref; // String to return for cp[i] + private final String[] constantRef; // String to return for cp[i] private final Constant[] constants; // The constants in the cp private final Method[] methods; ConstantHTML(final String dir, final String class_name, final String class_package, final Method[] methods, final ConstantPool constant_pool) throws IOException { - this.class_name = class_name; - this.class_package = class_package; - this.constant_pool = constant_pool; + this.className = class_name; + this.classPackage = class_package; + this.constantPool = constant_pool; this.methods = methods; constants = constant_pool.getConstantPool(); file = new PrintWriter(new FileOutputStream(dir + class_name + "_cp.html")); - constant_ref = new String[constants.length]; - constant_ref[0] = "<unknown>"; + constantRef = new String[constants.length]; + constantRef[0] = "<unknown>"; file.println(""); // Loop through constants, constants[0] is reserved for (int i = 1; i < constants.length; i++) { @@ -82,7 +82,7 @@ final class ConstantHTML { String referenceConstant( final int index ) { - return constant_ref[index]; + return constantRef[index]; } @@ -101,29 +101,29 @@ private void writeConstant( final int index ) { case Const.CONSTANT_Methodref: // Get class_index and name_and_type_index, depending on type if (tag == Const.CONSTANT_Methodref) { - final ConstantMethodref c = (ConstantMethodref) constant_pool.getConstant(index, + final ConstantMethodref c = (ConstantMethodref) constantPool.getConstant(index, Const.CONSTANT_Methodref); class_index = c.getClassIndex(); name_index = c.getNameAndTypeIndex(); } else { - final ConstantInterfaceMethodref c1 = (ConstantInterfaceMethodref) constant_pool + final ConstantInterfaceMethodref c1 = (ConstantInterfaceMethodref) constantPool .getConstant(index, Const.CONSTANT_InterfaceMethodref); class_index = c1.getClassIndex(); name_index = c1.getNameAndTypeIndex(); } // Get method name and its class - final String method_name = constant_pool.constantToString(name_index, + final String method_name = constantPool.constantToString(name_index, Const.CONSTANT_NameAndType); final String html_method_name = Class2HTML.toHTML(method_name); // Partially compacted class name, i.e., / -> . - final String method_class = constant_pool.constantToString(class_index, Const.CONSTANT_Class); + final String method_class = constantPool.constantToString(class_index, Const.CONSTANT_Class); String short_method_class = Utility.compactClassName(method_class); // I.e., remove java.lang. - short_method_class = Utility.compactClassName(short_method_class, class_package + short_method_class = Utility.compactClassName(short_method_class, classPackage + ".", true); // Remove class package prefix // Get method signature - final ConstantNameAndType c2 = (ConstantNameAndType) constant_pool.getConstant( + final ConstantNameAndType c2 = (ConstantNameAndType) constantPool.getConstant( name_index, Const.CONSTANT_NameAndType); - final String signature = constant_pool.constantToString(c2.getSignatureIndex(), + final String signature = constantPool.constantToString(c2.getSignatureIndex(), Const.CONSTANT_Utf8); // Get array of strings containing the argument types final String[] args = Utility.methodSignatureArgumentTypes(signature, false); @@ -139,17 +139,17 @@ private void writeConstant( final int index ) { } buf.append(")"); final String arg_types = buf.toString(); - if (method_class.equals(class_name)) { - ref = "" + html_method_name + ""; } else { ref = "" + short_method_class + "." + html_method_name; } - constant_ref[index] = ret_type + " " + short_method_class - + ".." + html_method_name + " " + arg_types; file.println("

    " + ret_type + " " + ref + arg_types + " \n

      " + "
    • " + field_name + ""; } else { ref = "" + short_field_class + "." + field_name + "\n"; } - constant_ref[index] = "" + short_field_class + "." + + className + "_cp.html#cp" + index + "\" TARGET=ConstantPool>" + field_name + ""; file.println("

      " + ref + "
      \n" + "

      "); break; case Const.CONSTANT_Class: - final ConstantClass c4 = (ConstantClass) constant_pool.getConstant(index, Const.CONSTANT_Class); + final ConstantClass c4 = (ConstantClass) constantPool.getConstant(index, Const.CONSTANT_Class); name_index = c4.getNameIndex(); - final String class_name2 = constant_pool.constantToString(index, tag); // / -> . + final String class_name2 = constantPool.constantToString(index, tag); // / -> . String short_class_name = Utility.compactClassName(class_name2); // I.e., remove java.lang. - short_class_name = Utility.compactClassName(short_class_name, class_package + ".", + short_class_name = Utility.compactClassName(short_class_name, classPackage + ".", true); // Remove class package prefix ref = "" + short_class_name + ""; - constant_ref[index] = "" + short_class_name + ""; file.println("

      " + ref + "

      \n"); break; case Const.CONSTANT_String: - final ConstantString c5 = (ConstantString) constant_pool.getConstant(index, + final ConstantString c5 = (ConstantString) constantPool.getConstant(index, Const.CONSTANT_String); name_index = c5.getStringIndex(); - final String str = Class2HTML.toHTML(constant_pool.constantToString(index, tag)); + final String str = Class2HTML.toHTML(constantPool.constantToString(index, tag)); file.println("

      " + str + "

      \n"); break; case Const.CONSTANT_NameAndType: - final ConstantNameAndType c6 = (ConstantNameAndType) constant_pool.getConstant(index, + final ConstantNameAndType c6 = (ConstantNameAndType) constantPool.getConstant(index, Const.CONSTANT_NameAndType); name_index = c6.getNameIndex(); final int signature_index = c6.getSignatureIndex(); file.println("

      " - + Class2HTML.toHTML(constant_pool.constantToString(index, tag)) + + Class2HTML.toHTML(constantPool.constantToString(index, tag)) + "

      \n"); break; default: - file.println("

      " + Class2HTML.toHTML(constant_pool.constantToString(index, tag)) + "\n"); + file.println("

      " + Class2HTML.toHTML(constantPool.constantToString(index, tag)) + "\n"); } // switch } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/InstructionFinder.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/InstructionFinder.java index b9b4815311c..46d22379524 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/InstructionFinder.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/InstructionFinder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -64,7 +64,7 @@ * * @see com.sun.org.apache.bcel.internal.generic.Instruction * @see InstructionList - * @LastModified: Jan 2020 + * @LastModified: May 2021 */ public class InstructionFinder { @@ -72,7 +72,7 @@ public class InstructionFinder { private static final int NO_OPCODES = 256; // Potential number, some are not used private static final Map map = new HashMap<>(); private final InstructionList il; - private String il_string; // instruction list as string + private String ilString; // instruction list as string private InstructionHandle[] handles; // map instruction @@ -99,7 +99,7 @@ public final void reread() { for (int i = 0; i < size; i++) { buf[i] = makeChar(handles[i].getInstruction().getOpcode()); } - il_string = new String(buf); + ilString = new String(buf); } @@ -120,7 +120,7 @@ private static String mapName( final String pattern ) { return "" + makeChar(i); } } - throw new RuntimeException("Instruction unknown: " + pattern); + throw new IllegalArgumentException("Instruction unknown: " + pattern); } @@ -221,8 +221,8 @@ public final Iterator search( final String pattern, } final Pattern regex = Pattern.compile(search); final List matches = new ArrayList<>(); - final Matcher matcher = regex.matcher(il_string); - while (start < il_string.length() && matcher.find(start)) { + final Matcher matcher = regex.matcher(ilString); + while (start < ilString.length() && matcher.find(start)) { final int startExpr = matcher.start(); final int endExpr = matcher.end(); final int lenExpr = endExpr - startExpr; diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/MethodHTML.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/MethodHTML.java index 26210d77c6f..05f25ed775e 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/MethodHTML.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/MethodHTML.java @@ -41,17 +41,17 @@ */ final class MethodHTML { - private final String class_name; // name of current class + private final String className; // name of current class private final PrintWriter file; // file to write to - private final ConstantHTML constant_html; + private final ConstantHTML constantHtml; private final AttributeHTML attribute_html; MethodHTML(final String dir, final String class_name, final Method[] methods, final Field[] fields, final ConstantHTML constant_html, final AttributeHTML attribute_html) throws IOException { - this.class_name = class_name; + this.className = class_name; this.attribute_html = attribute_html; - this.constant_html = constant_html; + this.constantHtml = constant_html; file = new PrintWriter(new FileOutputStream(dir + class_name + "_methods.html")); file.println("

    "); file.println("" @@ -95,7 +95,7 @@ private void writeField( final Field field ) throws IOException { if (attributes[i].getTag() == Const.ATTR_CONSTANT_VALUE) { // Default value final String str = ((ConstantValue) attributes[i]).toString(); // Reference attribute in _attributes.html - file.print("\n"); break; } @@ -125,7 +125,7 @@ private void writeMethod( final Method method, final int method_number ) { html_name = Class2HTML.toHTML(name); file.print(""); - file.print("\n
    Access flagsType= = " + str + "
    " + access + "" + Class2HTML.referenceType(type) + "" + "" + Class2HTML.referenceType(type) + "" + "" + html_name + "("); for (int i = 0; i < args.length; i++) { @@ -144,7 +144,7 @@ private void writeMethod( final Method method, final int method_number ) { file.print("
    throws"); final int[] exceptions = ((ExceptionTable) attributes[i]).getExceptionIndexTable(); for (int j = 0; j < exceptions.length; j++) { - file.print(constant_html.referenceConstant(exceptions[j])); + file.print(constantHtml.referenceConstant(exceptions[j])); if (j < exceptions.length - 1) { file.print(", "); } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/SyntheticRepository.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/SyntheticRepository.java index 19eaa7ff3b7..c0c708235ec 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/SyntheticRepository.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/SyntheticRepository.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -39,7 +39,7 @@ * * @see com.sun.org.apache.bcel.internal.Repository * - * @LastModified: Jan 2020 + * @LastModified: May 2021 */ public class SyntheticRepository implements Repository { @@ -60,7 +60,7 @@ public static SyntheticRepository getInstance() { public void storeClass(final JavaClass clazz) { loadedClasses.put(clazz.getClassName(), new SoftReference<>(clazz)); clazz.setRepository(this); - } + } /** * Remove class from repository @@ -78,7 +78,7 @@ public JavaClass findClass(final String className) { final SoftReference ref = loadedClasses.get(className); if (ref == null) { return null; - } +} return ref.get(); } diff --git a/src/java.xml/share/legal/bcel.md b/src/java.xml/share/legal/bcel.md index 5e461303d73..aca04ab4a8d 100644 --- a/src/java.xml/share/legal/bcel.md +++ b/src/java.xml/share/legal/bcel.md @@ -1,4 +1,4 @@ -## Apache Commons Byte Code Engineering Library (BCEL) Version 6.4.1 +## Apache Commons Byte Code Engineering Library (BCEL) Version 6.5.0 ### Apache Commons BCEL Notice