View Javadoc

    1   /*
    2    * Copyright  2000-2004 The Apache Software Foundation
    3    *
    4    *  Licensed under the Apache License, Version 2.0 (the "License");
    5    *  you may not use this file except in compliance with the License.
    6    *  You may obtain a copy of the License at
    7    *
    8    *      http://www.apache.org/licenses/LICENSE-2.0
    9    *
    10   *  Unless required by applicable law or agreed to in writing, software
    11   *  distributed under the License is distributed on an "AS IS" BASIS,
    12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   *  See the License for the specific language governing permissions and
    14   *  limitations under the License.
    15   *
    16   */
    17  package org.apache.bcel.verifier.exc;
    18
    19
    20  /***
    21   * Instances of this class are thrown by BCEL's class file verifier "JustIce"
    22   * whenever
    23   * verification proves that some constraint of a class file (as stated in the
    24   * Java Virtual Machine Specification, Edition 2) is violated.
    25   * This is roughly equivalent to the VerifyError the JVM-internal verifiers
    26   * throw.
    27   *
    28   * @version $Id: VerifierConstraintViolatedException.java 386056 2006-03-15 11:31:56Z tcurdt $
    29   * @author Enver Haase
    30   */
    31  public abstract class VerifierConstraintViolatedException extends RuntimeException{
    32  	// /*** The name of the offending class that did not pass the verifier. */
    33  	// String name_of_offending_class;
    34
    35  	/*** The specified error message. */
    36  	private String detailMessage;
    37  	/***
    38  	 * Constructs a new VerifierConstraintViolatedException with null as its error message string.
    39  	 */
    40  	VerifierConstraintViolatedException(){
    41  		super();
    42  	}
    43  	/***
    44  	 * Constructs a new VerifierConstraintViolatedException with the specified error message.
    45  	 */
    46  	VerifierConstraintViolatedException(String message){
    47  		super(message); // Not that important
    48  		detailMessage = message;
    49  	}
    50
    51
    52  	/*** Extends the error message with a string before ("pre") and after ("post") the
    53  	    'old' error message. All of these three strings are allowed to be null, and null
    54  	    is always replaced by the empty string (""). In particular, after invoking this
    55  	    method, the error message of this object can no longer be null.
    56  	*/
    57  	public void extendMessage(String pre, String post){
    58  		if (pre  == null) {
    59              pre="";
    60          }
    61  		if (detailMessage == null) {
    62              detailMessage="";
    63          }
    64  		if (post == null) {
    65              post="";
    66          }
    67  		detailMessage = pre+detailMessage+post;
    68  	}
    69  	/***
    70  	 * Returns the error message string of this VerifierConstraintViolatedException object.
    71  	 * @return the error message string of this VerifierConstraintViolatedException.
    72  	 */
    73  	public String getMessage(){
    74  		return detailMessage;
    75  	}
    76  }