001// ASM: a very small and fast Java bytecode manipulation framework
002// Copyright (c) 2000-2011 INRIA, France Telecom
003// All rights reserved.
004//
005// Redistribution and use in source and binary forms, with or without
006// modification, are permitted provided that the following conditions
007// are met:
008// 1. Redistributions of source code must retain the above copyright
009//    notice, this list of conditions and the following disclaimer.
010// 2. Redistributions in binary form must reproduce the above copyright
011//    notice, this list of conditions and the following disclaimer in the
012//    documentation and/or other materials provided with the distribution.
013// 3. Neither the name of the copyright holders nor the names of its
014//    contributors may be used to endorse or promote products derived from
015//    this software without specific prior written permission.
016//
017// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
018// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
019// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
020// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
021// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
022// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
023// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
024// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
025// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
026// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
027// THE POSSIBILITY OF SUCH DAMAGE.
028package org.springframework.asm;
029
030/**
031 * Exception thrown when the constant pool of a class produced by a {@link ClassWriter} is too
032 * large.
033 *
034 * @author Jason Zaugg
035 */
036public final class ClassTooLargeException extends IndexOutOfBoundsException {
037  private static final long serialVersionUID = 160715609518896765L;
038
039  private final String className;
040  private final int constantPoolCount;
041
042  /**
043   * Constructs a new {@link ClassTooLargeException}.
044   *
045   * @param className the internal name of the class.
046   * @param constantPoolCount the number of constant pool items of the class.
047   */
048  public ClassTooLargeException(final String className, final int constantPoolCount) {
049    super("Class too large: " + className);
050    this.className = className;
051    this.constantPoolCount = constantPoolCount;
052  }
053
054  /**
055   * Returns the internal name of the class.
056   *
057   * @return the internal name of the class.
058   */
059  public String getClassName() {
060    return className;
061  }
062
063  /**
064   * Returns the number of constant pool items of the class.
065   *
066   * @return the number of constant pool items of the class.
067   */
068  public int getConstantPoolCount() {
069    return constantPoolCount;
070  }
071}