< prev index next >
src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Constant.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
@@ -30,12 +30,11 @@
/**
* Abstract superclass for classes to represent the different constant types
* in the constant pool of a class file. The classes keep closely to
* the JVM specification.
*
- * @version $Id$
- * @LastModified: Jun 2019
+ * @LastModified: Jan 2020
*/
public abstract class Constant implements Cloneable, Node {
private static BCELComparator bcelComparator = new BCELComparator() {
@@ -62,48 +61,42 @@
* need the tag as an index to select the corresponding class name from the
* `CONSTANT_NAMES' array.
*/
private byte tag;
-
Constant(final byte tag) {
this.tag = tag;
}
-
/**
* Called by objects that are traversing the nodes of the tree implicitely
* defined by the contents of a Java class. I.e., the hierarchy of methods,
* fields, attributes, etc. spawns a tree of objects.
*
* @param v Visitor object
*/
@Override
public abstract void accept( Visitor v );
-
public abstract void dump( DataOutputStream file ) throws IOException;
-
/**
* @return Tag of constant, i.e., its type. No setTag() method to avoid
* confusion.
*/
public final byte getTag() {
return tag;
}
-
/**
* @return String representation.
*/
@Override
public String toString() {
return Const.getConstantName(tag) + "[" + tag + "]";
}
-
/**
* @return deep copy of this constant
*/
public Constant copy() {
try {
@@ -112,23 +105,21 @@
// TODO should this throw?
}
return null;
}
-
@Override
public Object clone() {
try {
return super.clone();
} catch (final CloneNotSupportedException e) {
throw new Error("Clone Not Supported"); // never happens
}
}
-
/**
- * Read one constant from the given input, the type depends on a tag byte.
+ * Reads one constant from the given input, the type depends on a tag byte.
*
* @param dataInput Input stream
* @return Constant object
* @throws IOException if an I/O error occurs reading from the given {@code dataInput}.
* @throws ClassFormatException if the next byte is not recognized
@@ -181,34 +172,31 @@
*/
public static BCELComparator getComparator() {
return bcelComparator;
}
-
/**
* @param comparator Comparison strategy object
*/
public static void setComparator( final BCELComparator comparator ) {
bcelComparator = comparator;
}
-
/**
- * Return value as defined by given BCELComparator strategy.
+ * Returns value as defined by given BCELComparator strategy.
* By default two Constant objects are said to be equal when
* the result of toString() is equal.
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals( final Object obj ) {
return bcelComparator.equals(this, obj);
}
-
/**
- * Return value as defined by given BCELComparator strategy.
+ * Returns value as defined by given BCELComparator strategy.
* By default return the hashcode of the result of toString().
*
* @see java.lang.Object#hashCode()
*/
@Override
< prev index next >