Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Commit

Permalink
8255035: Update BCEL to Version 6.5.0
Browse files Browse the repository at this point in the history
Backport-of: 1a0ff28ea10aaba53c5fbeb59800d3bcb1d228bc
  • Loading branch information
Yuri Nesterenko committed Jun 1, 2022
1 parent 087abc1 commit f6ea4fa
Show file tree
Hide file tree
Showing 95 changed files with 2,116 additions and 2,051 deletions.
535 changes: 268 additions & 267 deletions src/java.xml/share/classes/com/sun/org/apache/bcel/internal/Const.java

Large diffs are not rendered by default.

@@ -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
Expand All @@ -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 = Throwable.class;
/** Super class of any run-time exception

/**
* Super class of any run-time exception
*/
public static final Class<RuntimeException> 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<LinkageError> LINKING_EXCEPTION = LinkageError.class;
/** Linking Exceptions

/**
* Linking Exceptions
*/
public static final Class<ClassCircularityError> CLASS_CIRCULARITY_ERROR = ClassCircularityError.class;
public static final Class<ClassFormatError> CLASS_FORMAT_ERROR = ClassFormatError.class;
Expand All @@ -52,7 +59,9 @@ public final class ExceptionConst {
public static final Class<VerifyError> 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<NullPointerException> NULL_POINTER_EXCEPTION = NullPointerException.class;
public static final Class<ArrayIndexOutOfBoundsException> ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION
Expand Down
Expand Up @@ -34,7 +34,7 @@
*/
public class AnnotationDefault extends Attribute {

private ElementValue default_value;
private ElementValue defaultValue;

/**
* @param name_index Index pointing to the name <em>Code</em>
Expand All @@ -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);
}

/**
Expand All @@ -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;
}

/**
Expand All @@ -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
Expand All @@ -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);
}
}
Expand Up @@ -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;
Expand Down
Expand Up @@ -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<ElementValuePair> element_value_pairs;
private List<ElementValuePair> elementValuePairs;

/*
* Factory method to create an AnnotionEntry from a DataInput
*
* @param input
* @param constant_pool
* @param constantPool
* @param isRuntimeVisible
* @return the entry
* @throws IOException
Expand All @@ -56,27 +56,27 @@ 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));
}
return annotationEntry;
}

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() {
Expand All @@ -98,43 +98,43 @@ 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();
}

/**
* @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();
}

/**
* @return the element value pairs in this annotation entry
*/
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() {
Expand Down
Expand Up @@ -32,7 +32,7 @@
*/
public abstract class Annotations extends Attribute {

private AnnotationEntry[] annotation_table;
private AnnotationEntry[] annotationTable;
private final boolean isRuntimeVisible;

/**
Expand All @@ -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 <em>Code</em>
* @param annotationType the subclass type of the annotation
* @param nameIndex Index pointing to the name <em>Code</em>
* @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;
}

Expand All @@ -78,39 +78,39 @@ 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() {
return 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);
}
}
Expand Down
Expand Up @@ -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(",");
}
}
Expand All @@ -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);
}
}
Expand All @@ -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(",");
}
}
Expand All @@ -86,11 +86,11 @@ public String stringifyValue()

public ElementValue[] getElementValuesArray()
{
return evalues;
return elementValues;
}

public int getElementValuesArraySize()
{
return evalues.length;
return elementValues.length;
}
}

1 comment on commit f6ea4fa

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.