org.apache.tomcat.util.bcel.classfile

## Class JavaClass

- java.lang.Object
- - org.apache.tomcat.util.bcel.classfile.AccessFlags
  - - org.apache.tomcat.util.bcel.classfile.JavaClass

All Implemented Interfaces:
  Serializable, Cloneable, Comparable<JavaClass>

    public class JavaClass
    extends AccessFlags
    implements Cloneable, Comparable<JavaClass>

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. 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.

Author:
  M. Dahm
See Also:
  Serialized Form

### Field Summary

### Fields inherited from class org.apache.tomcat.util.bcel.classfile.AccessFlags

`access_flags`

### Constructor Summary

Constructors
Constructor and Description
`JavaClass(int class_name_index, int superclass_name_index, String file_name, int major, int minor, int access_flags, ConstantPool constant_pool, int[] interfaces, Field[] fields, Method[] methods, Attribute[] attributes)` Constructor gets all contents as arguments.

### Method Summary

Methods
`int` `compareTo(JavaClass obj)` Return the natural ordering of two JavaClasses.
`boolean` `equals(Object obj)` Return value as defined by given BCELComparator strategy.
`AnnotationEntry[]` `getAnnotationEntries()`
`Attribute[]` `getAttributes()`
`String` `getClassName()`
`String[]` `getInterfaceNames()`
`String` `getSuperclassName()` returns the super class name of this class.
`int` `hashCode()` Return value as defined by given BCELComparator strategy.
`boolean` `isSuper()`
`String` `toString()`

### Methods inherited from class org.apache.tomcat.util.bcel.classfile.AccessFlags

`getAccessFlags`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### JavaClass

    public JavaClass(int class_name_index,
             int superclass_name_index,
             String file_name,
             int major,
             int minor,
             int access_flags,
             ConstantPool constant_pool,
             int[] interfaces,
             Field[] fields,
             Method[] methods,
             Attribute[] attributes)

Constructor gets all contents as arguments.

Parameters:
  `class_name_index` - Index into constant pool referencing a ConstantClass that represents this class.
  `superclass_name_index` - Index into constant pool referencing a ConstantClass that represents this class's superclass.
  `file_name` - File name
  `major` - Major compiler version
  `minor` - Minor compiler version
  `access_flags` - Access rights defined by bit flags
  `constant_pool` - Array of constants
  `interfaces` - Implemented interfaces
  `fields` - Class fields
  `methods` - Class methods
  `attributes` - Class attributes

### Method Detail

#### getAttributes

    public Attribute[] getAttributes()

Returns:
  Attributes of the class.

#### getAnnotationEntries

    public AnnotationEntry[] getAnnotationEntries()

#### getClassName

    public String getClassName()

Returns:
  Class name.

#### getInterfaceNames

    public String[] getInterfaceNames()

Returns:
  Names of implemented interfaces.

#### getSuperclassName

    public String getSuperclassName()

returns the super class name of this class. In the case that this class is java.lang.Object, it will return itself (java.lang.Object). This is probably incorrect but isn't fixed at this time to not break existing clients.

Returns:
  Superclass name.

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`
Returns:
  String representing class contents.

#### isSuper

    public final boolean isSuper()

#### equals

    public boolean equals(Object obj)

Return value as defined by given BCELComparator strategy. By default two JavaClass objects are said to be equal when their class names are equal.

Overrides:
  `equals` in class `Object`
See Also:
  `Object.equals(java.lang.Object)`

#### compareTo

    public int compareTo(JavaClass obj)

Return the natural ordering of two JavaClasses. This ordering is based on the class name

Specified by:
  `compareTo` in interface `Comparable<JavaClass>`

#### hashCode

    public int hashCode()

Return value as defined by given BCELComparator strategy. By default return the hashcode of the class name.

Overrides:
  `hashCode` in class `Object`
See Also:
  `Object.hashCode()`