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 Code attribute of a method produced by a {@link ClassWriter} is too
032 * large.
033 *
034 * @author Jason Zaugg
035 */
036public final class MethodTooLargeException extends IndexOutOfBoundsException {
037  private static final long serialVersionUID = 6807380416709738314L;
038
039  private final String className;
040  private final String methodName;
041  private final String descriptor;
042  private final int codeSize;
043
044  /**
045   * Constructs a new {@link MethodTooLargeException}.
046   *
047   * @param className the internal name of the owner class.
048   * @param methodName the name of the method.
049   * @param descriptor the descriptor of the method.
050   * @param codeSize the size of the method's Code attribute, in bytes.
051   */
052  public MethodTooLargeException(
053      final String className,
054      final String methodName,
055      final String descriptor,
056      final int codeSize) {
057    super("Method too large: " + className + "." + methodName + " " + descriptor);
058    this.className = className;
059    this.methodName = methodName;
060    this.descriptor = descriptor;
061    this.codeSize = codeSize;
062  }
063
064  /**
065   * Returns the internal name of the owner class.
066   *
067   * @return the internal name of the owner class.
068   */
069  public String getClassName() {
070    return className;
071  }
072
073  /**
074   * Returns the name of the method.
075   *
076   * @return the name of the method.
077   */
078  public String getMethodName() {
079    return methodName;
080  }
081
082  /**
083   * Returns the descriptor of the method.
084   *
085   * @return the descriptor of the method.
086   */
087  public String getDescriptor() {
088    return descriptor;
089  }
090
091  /**
092   * Returns the size of the method's Code attribute, in bytes.
093   *
094   * @return the size of the method's Code attribute, in bytes.
095   */
096  public int getCodeSize() {
097    return codeSize;
098  }
099}