diff options
author | Jason van Zyl <jvanzyl@apache.org> | 2001-10-29 19:59:54 +0000 |
---|---|---|
committer | Jason van Zyl <jvanzyl@apache.org> | 2001-10-29 19:59:54 +0000 |
commit | 96ac0670cf9944d4912ab25ec885a4bea651443d (patch) | |
tree | 485cb3c3d889d1e3db129b44e60f6714924314c7 /src/java/org/apache/bcel/verifier/exc | |
parent | 32e0972903c55452f01defb3322dc0ce9ef0dd58 (diff) | |
download | apache-commons-bcel-96ac0670cf9944d4912ab25ec885a4bea651443d.tar.gz |
Initial revision
git-svn-id: https://svn.apache.org/repos/asf/jakarta/bcel/trunk@152690 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/bcel/verifier/exc')
15 files changed, 1173 insertions, 0 deletions
diff --git a/src/java/org/apache/bcel/verifier/exc/AssertionViolatedException.java b/src/java/org/apache/bcel/verifier/exc/AssertionViolatedException.java new file mode 100644 index 00000000..91b8c6b7 --- /dev/null +++ b/src/java/org/apache/bcel/verifier/exc/AssertionViolatedException.java @@ -0,0 +1,115 @@ +package org.apache.bcel.verifier.exc; + +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" and + * "Apache BCEL" must not be used to endorse or promote products + * derived from this software without prior written permission. For + * written permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * "Apache BCEL", nor may "Apache" appear in their name, without + * prior written permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/** + * Instances of this class should never be thrown. When such an instance is thrown, + * this is due to an INTERNAL ERROR of BCEL's class file verifier "JustIce". + * + * @version $Id$ + * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> + */ +public final class AssertionViolatedException extends RuntimeException{ + /** The error message. */ + private String detailMessage; + /** Constructs a new AssertionViolatedException with null as its error message string. */ + public AssertionViolatedException(){ + super(); + } + /** + * Constructs a new AssertionViolatedException with the specified error message preceded + * by "INTERNAL ERROR: ". + */ + public AssertionViolatedException(String message){ + super(message = "INTERNAL ERROR: "+message); // Thanks to Java, the constructor call here must be first. + detailMessage=message; + } + /** Extends the error message with a string before ("pre") and after ("post") the + 'old' error message. All of these three strings are allowed to be null, and null + is always replaced by the empty string (""). In particular, after invoking this + method, the error message of this object can no longer be null. + */ + public void extendMessage(String pre, String post){ + if (pre == null) pre=""; + if (detailMessage == null) detailMessage=""; + if (post == null) post=""; + detailMessage = pre+detailMessage+post; + } + /** + * Returns the error message string of this AssertionViolatedException object. + * @return the error message string of this AssertionViolatedException. + */ + public String getMessage(){ + return detailMessage; + } + + /** + * DO NOT USE. It's for experimental testing during development only. + */ + public static void main(String[] args){ + AssertionViolatedException ave = new AssertionViolatedException("Oops!"); + ave.extendMessage("\nFOUND:\n\t","\nExiting!!\n"); + throw ave; + } + + /** + * Returns the backtrace of this AssertionViolatedException as a String. + * @return The backtrace of this AssertionViolatedException as a String. + */ + public String getStackTrace(){ + return Utility.getStackTrace(this); + } + +} diff --git a/src/java/org/apache/bcel/verifier/exc/ClassConstraintException.java b/src/java/org/apache/bcel/verifier/exc/ClassConstraintException.java new file mode 100644 index 00000000..11b67f24 --- /dev/null +++ b/src/java/org/apache/bcel/verifier/exc/ClassConstraintException.java @@ -0,0 +1,83 @@ +package org.apache.bcel.verifier.exc; + +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" and + * "Apache BCEL" must not be used to endorse or promote products + * derived from this software without prior written permission. For + * written permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * "Apache BCEL", nor may "Apache" appear in their name, without + * prior written permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/** + * Instances of this class are thrown by BCEL's class file verifier "JustIce" + * when a class file to verify does not pass the verification pass 2 as described + * in the Java Virtual Machine specification, 2nd edition. + * + * @version $Id$ + * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> + */ +public class ClassConstraintException extends VerificationException{ + /** The specified error message. */ + private String detailMessage; + + /** + * Constructs a new ClassConstraintException with null as its error message string. + */ + public ClassConstraintException(){ + super(); + } + + /** + * Constructs a new ClassConstraintException with the specified error message. + */ + public ClassConstraintException(String message){ + super (message); + detailMessage = message; + } +} diff --git a/src/java/org/apache/bcel/verifier/exc/CodeConstraintException.java b/src/java/org/apache/bcel/verifier/exc/CodeConstraintException.java new file mode 100644 index 00000000..14dfd4f7 --- /dev/null +++ b/src/java/org/apache/bcel/verifier/exc/CodeConstraintException.java @@ -0,0 +1,77 @@ +package org.apache.bcel.verifier.exc; + +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" and + * "Apache BCEL" must not be used to endorse or promote products + * derived from this software without prior written permission. For + * written permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * "Apache BCEL", nor may "Apache" appear in their name, without + * prior written permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ +/** + * Instances of this class are thrown by BCEL's class file verifier "JustIce" when + * a class file does not pass the verification pass 3. Note that the pass 3 used by + * "JustIce" involves verification that is usually delayed to pass 4. + * + * @version $Id$ + * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> + */ +public abstract class CodeConstraintException extends VerificationException{ + /** + * Constructs a new CodeConstraintException with null as its error message string. + */ + CodeConstraintException(){ + super(); + } + /** + * Constructs a new CodeConstraintException with the specified error message. + */ + CodeConstraintException(String message){ + super(message); + } +} diff --git a/src/java/org/apache/bcel/verifier/exc/InvalidMethodException.java b/src/java/org/apache/bcel/verifier/exc/InvalidMethodException.java new file mode 100644 index 00000000..5101b632 --- /dev/null +++ b/src/java/org/apache/bcel/verifier/exc/InvalidMethodException.java @@ -0,0 +1,71 @@ +package org.apache.bcel.verifier.exc; + +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" and + * "Apache BCEL" must not be used to endorse or promote products + * derived from this software without prior written permission. For + * written permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * "Apache BCEL", nor may "Apache" appear in their name, without + * prior written permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ +/** + * Instances of this class are thrown by BCEL's class file verifier "JustIce" + * when the verification of a method is requested that does not exist. + * + * @version $Id$ + * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> + */ +public class InvalidMethodException extends RuntimeException{ + /** Must not be no-args requested so there's always some error message. */ + private InvalidMethodException(){} + + /** Constructs an InvalidMethodException with the specified detail message. */ + public InvalidMethodException(String message){ + super(message); + } +} diff --git a/src/java/org/apache/bcel/verifier/exc/LinkingConstraintException.java b/src/java/org/apache/bcel/verifier/exc/LinkingConstraintException.java new file mode 100644 index 00000000..6ca913c4 --- /dev/null +++ b/src/java/org/apache/bcel/verifier/exc/LinkingConstraintException.java @@ -0,0 +1,74 @@ +package org.apache.bcel.verifier.exc; + +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" and + * "Apache BCEL" must not be used to endorse or promote products + * derived from this software without prior written permission. For + * written permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * "Apache BCEL", nor may "Apache" appear in their name, without + * prior written permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ +/** + * Instances of this class are thrown by BCEL's class file verifier "JustIce" when + * a class file to verify does not pass the verification pass 3 because of a violation + * of a constraint that is usually only verified at run-time (pass 4). + * The Java Virtual Machine Specification, 2nd edition, states that certain constraints + * are usually verified at run-time for performance reasons (the verification of those + * constraints requires loading in and recursively verifying referenced classes) that + * conceptually belong to pass 3; to be precise, that conceptually belong to the + * data flow analysis of pass 3 (called pass 3b in JustIce). + * These are the checks necessary for resolution: Compare pages 142-143 ("4.9.1 The + * Verification Process") and pages 50-51 ("2.17.3 Linking: Verification, Preparation, + * and Resolution") of the above mentioned book. + * <B>TODO: At this time, this class is not used in JustIce.</B> + * + * @version $Id$ + * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> + */ +public class LinkingConstraintException extends StructuralCodeConstraintException{ +} diff --git a/src/java/org/apache/bcel/verifier/exc/LoadingException.java b/src/java/org/apache/bcel/verifier/exc/LoadingException.java new file mode 100644 index 00000000..4e17e6cd --- /dev/null +++ b/src/java/org/apache/bcel/verifier/exc/LoadingException.java @@ -0,0 +1,82 @@ +package org.apache.bcel.verifier.exc; + +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" and + * "Apache BCEL" must not be used to endorse or promote products + * derived from this software without prior written permission. For + * written permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * "Apache BCEL", nor may "Apache" appear in their name, without + * prior written permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/** + * When loading a class file, BCEL will throw an instance of LoadingException if + * the class file is malformed; so it is not conforming to the "Pass 1" verification + * process as described in the Java Virtual Machine specification, 2nd. edition. + * @version $Id$ + * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> + */ +public class LoadingException extends VerifierConstraintViolatedException{ + /** The specified error message. */ + private String detailMessage; + + /** + * Constructs a new LoadingException with null as its error message string. + */ + public LoadingException(){ + super(); + } + + /** + * Constructs a new LoadingException with the specified error message. + */ + public LoadingException(String message){ + super (message); + detailMessage = message; + } +} diff --git a/src/java/org/apache/bcel/verifier/exc/LocalVariableInfoInconsistentException.java b/src/java/org/apache/bcel/verifier/exc/LocalVariableInfoInconsistentException.java new file mode 100644 index 00000000..2a52743d --- /dev/null +++ b/src/java/org/apache/bcel/verifier/exc/LocalVariableInfoInconsistentException.java @@ -0,0 +1,81 @@ +package org.apache.bcel.verifier.exc; + +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" and + * "Apache BCEL" must not be used to endorse or promote products + * derived from this software without prior written permission. For + * written permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * "Apache BCEL", nor may "Apache" appear in their name, without + * prior written permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/** + * A LocalVariableInfoInconsistentException instance is thrown by + * the LocalVariableInfo class when it detects that the information + * it holds is inconsistent; this is normally due to inconsistent + * LocalVariableTable entries in the Code attribute of a certain + * Method object. + * + * @version $Id$ + * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> + */ +public class LocalVariableInfoInconsistentException extends ClassConstraintException{ + /** + * Constructs a new LocalVariableInfoInconsistentException with null as its error message string. + */ + public LocalVariableInfoInconsistentException(){ + super(); + } + + /** + * Constructs a new LocalVariableInfoInconsistentException with the specified error message. + */ + public LocalVariableInfoInconsistentException(String message){ + super (message); + } +} diff --git a/src/java/org/apache/bcel/verifier/exc/StaticCodeConstraintException.java b/src/java/org/apache/bcel/verifier/exc/StaticCodeConstraintException.java new file mode 100644 index 00000000..86b0fd3b --- /dev/null +++ b/src/java/org/apache/bcel/verifier/exc/StaticCodeConstraintException.java @@ -0,0 +1,71 @@ +package org.apache.bcel.verifier.exc; + +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" and + * "Apache BCEL" must not be used to endorse or promote products + * derived from this software without prior written permission. For + * written permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * "Apache BCEL", nor may "Apache" appear in their name, without + * prior written permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/** + * Instances of this class are thrown by BCEL's class file verifier "JustIce" when + * a class file to verify does not pass the verification pass 3 because of a violation + * of a static constraint as described in the Java Virtual Machine Specification, + * 2nd edition, 4.8.1, pages 133-137. The static constraints checking part of pass 3 + * is called pass 3a in JustIce. + * + * @version $Id$ + * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> + */ +public abstract class StaticCodeConstraintException extends CodeConstraintException{ + public StaticCodeConstraintException(String message){ + super(message); + } +} diff --git a/src/java/org/apache/bcel/verifier/exc/StaticCodeInstructionConstraintException.java b/src/java/org/apache/bcel/verifier/exc/StaticCodeInstructionConstraintException.java new file mode 100644 index 00000000..43a8a3f7 --- /dev/null +++ b/src/java/org/apache/bcel/verifier/exc/StaticCodeInstructionConstraintException.java @@ -0,0 +1,74 @@ +package org.apache.bcel.verifier.exc; + +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" and + * "Apache BCEL" must not be used to endorse or promote products + * derived from this software without prior written permission. For + * written permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * "Apache BCEL", nor may "Apache" appear in their name, without + * prior written permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/** + * Instances of this class are thrown by BCEL's class file verifier "JustIce" when + * a class file to verify does not pass the verification pass 3 because of a violation + * of a static constraint as described in the Java Virtual Machine Specification, + * Second edition, 4.8.1, pages 133-137. The static constraints checking part of pass 3 + * is called pass 3a in JustIce. + * Static constraints on the instructions in the code array are checked early in + * pass 3a and are described on page 134 in the Java Virtual Machine Specification, + * Second Edition. + * + * @version $Id$ + * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> + */ +public class StaticCodeInstructionConstraintException extends StaticCodeConstraintException{ + public StaticCodeInstructionConstraintException(String message){ + super(message); + } +} diff --git a/src/java/org/apache/bcel/verifier/exc/StaticCodeInstructionOperandConstraintException.java b/src/java/org/apache/bcel/verifier/exc/StaticCodeInstructionOperandConstraintException.java new file mode 100644 index 00000000..3825a741 --- /dev/null +++ b/src/java/org/apache/bcel/verifier/exc/StaticCodeInstructionOperandConstraintException.java @@ -0,0 +1,74 @@ +package org.apache.bcel.verifier.exc; + +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" and + * "Apache BCEL" must not be used to endorse or promote products + * derived from this software without prior written permission. For + * written permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * "Apache BCEL", nor may "Apache" appear in their name, without + * prior written permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/** + * Instances of this class are thrown by BCEL's class file verifier "JustIce" when + * a class file to verify does not pass the verification pass 3 because of a violation + * of a static constraint as described in the Java Virtual Machine Specification, + * Second edition, 4.8.1, pages 133-137. The static constraints checking part of pass 3 + * is called pass 3a in JustIce. + * Static constraints on the operands of instructions in the code array are checked late in + * pass 3a and are described on page 134-137 in the Java Virtual Machine Specification, + * Second Edition. + * + * @version $Id$ + * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> + */ +public class StaticCodeInstructionOperandConstraintException extends StaticCodeConstraintException{ + public StaticCodeInstructionOperandConstraintException(String message){ + super(message); + } +} diff --git a/src/java/org/apache/bcel/verifier/exc/StructuralCodeConstraintException.java b/src/java/org/apache/bcel/verifier/exc/StructuralCodeConstraintException.java new file mode 100644 index 00000000..946f1044 --- /dev/null +++ b/src/java/org/apache/bcel/verifier/exc/StructuralCodeConstraintException.java @@ -0,0 +1,82 @@ +package org.apache.bcel.verifier.exc; + +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" and + * "Apache BCEL" must not be used to endorse or promote products + * derived from this software without prior written permission. For + * written permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * "Apache BCEL", nor may "Apache" appear in their name, without + * prior written permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ +/** + * Instances of this class are thrown by BCEL's class file verifier "JustIce" when + * a class file to verify does not pass the verification pass 3 because of a violation + * of a structural constraint as described in the Java Virtual Machine Specification, + * 2nd edition, 4.8.2, pages 137-139. + * Note that the notion of a "structural" constraint is somewhat misleading. Structural + * constraints are constraints on relationships between Java virtual machine instructions. + * These are the constraints where data-flow analysis is needed to verify if they hold. + * The data flow analysis of pass 3 is called pass 3b in JustIce. + * + * @version $Id$ + * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> + */ +public class StructuralCodeConstraintException extends CodeConstraintException{ + /** + * Constructs a new StructuralCodeConstraintException with the specified error message. + */ + public StructuralCodeConstraintException(String message){ + super(message); + } + /** + * Constructs a new StructuralCodeConstraintException with null as its error message string. + */ + public StructuralCodeConstraintException(){ + super(); + } +} diff --git a/src/java/org/apache/bcel/verifier/exc/Utility.java b/src/java/org/apache/bcel/verifier/exc/Utility.java new file mode 100644 index 00000000..01b80cea --- /dev/null +++ b/src/java/org/apache/bcel/verifier/exc/Utility.java @@ -0,0 +1,76 @@ +package org.apache.bcel.verifier.exc; + +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" and + * "Apache BCEL" must not be used to endorse or promote products + * derived from this software without prior written permission. For + * written permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * "Apache BCEL", nor may "Apache" appear in their name, without + * prior written permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +import java.io.*; + +/** + * A utility class providing convenience methods concerning Throwable instances. + * @version $Id$ + * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> + * @see java.lang.Throwable + */ +public final class Utility{ + /** This class is not instantiable. */ + private Utility(){} + + /** This method returns the stack trace of a Throwable instance as a String. */ + public static String getStackTrace(Throwable t){ + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + t.printStackTrace(pw); + return sw.toString(); + } +} diff --git a/src/java/org/apache/bcel/verifier/exc/VerificationException.java b/src/java/org/apache/bcel/verifier/exc/VerificationException.java new file mode 100644 index 00000000..d8d473fa --- /dev/null +++ b/src/java/org/apache/bcel/verifier/exc/VerificationException.java @@ -0,0 +1,82 @@ +package org.apache.bcel.verifier.exc; + +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" and + * "Apache BCEL" must not be used to endorse or promote products + * derived from this software without prior written permission. For + * written permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * "Apache BCEL", nor may "Apache" appear in their name, without + * prior written permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/** + * Instances of this class are thrown by BCEL's class file verifier "JustIce" when a + * class file to verify does not pass one of the verification passes 2 or 3. + * Note that the pass 3 used by "JustIce" involves verification that is usually + * delayed to pass 4. + * The name of this class is justified by the Java Virtual Machine Specification, 2nd + * edition, page 164, 5.4.1 where verification as a part of the linking process is + * defined to be the verification happening in passes 2 and 3. + * + * @version $Id$ + * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> + */ +public abstract class VerificationException extends VerifierConstraintViolatedException{ + /** + * Constructs a new VerificationException with null as its error message string. + */ + VerificationException(){ + super(); + } + /** + * Constructs a new VerificationException with the specified error message. + */ + VerificationException(String message){ + super(message); + } +} diff --git a/src/java/org/apache/bcel/verifier/exc/VerifierConstraintViolatedException.java b/src/java/org/apache/bcel/verifier/exc/VerifierConstraintViolatedException.java new file mode 100644 index 00000000..65dd1e96 --- /dev/null +++ b/src/java/org/apache/bcel/verifier/exc/VerifierConstraintViolatedException.java @@ -0,0 +1,107 @@ +package org.apache.bcel.verifier.exc; + +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" and + * "Apache BCEL" must not be used to endorse or promote products + * derived from this software without prior written permission. For + * written permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * "Apache BCEL", nor may "Apache" appear in their name, without + * prior written permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/** + * Instances of this class are thrown by BCEL's class file verifier "JustIce" + * whenever + * verification proves that some constraint of a class file (as stated in the + * Java Virtual Machine Specification, Edition 2) is violated. + * This is roughly equivalent to the VerifyError the JVM-internal verifiers + * throw. + * + * @version $Id$ + * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> + */ +public abstract class VerifierConstraintViolatedException extends RuntimeException{ + // /** The name of the offending class that did not pass the verifier. */ + // String name_of_offending_class; + + /** The specified error message. */ + private String detailMessage; + /** + * Constructs a new VerifierConstraintViolatedException with null as its error message string. + */ + VerifierConstraintViolatedException(){ + super(); + } + /** + * Constructs a new VerifierConstraintViolatedException with the specified error message. + */ + VerifierConstraintViolatedException(String message){ + super(message); // Not that important + detailMessage = message; + } + + + /** Extends the error message with a string before ("pre") and after ("post") the + 'old' error message. All of these three strings are allowed to be null, and null + is always replaced by the empty string (""). In particular, after invoking this + method, the error message of this object can no longer be null. + */ + public void extendMessage(String pre, String post){ + if (pre == null) pre=""; + if (detailMessage == null) detailMessage=""; + if (post == null) post=""; + detailMessage = pre+detailMessage+post; + } + /** + * Returns the error message string of this VerifierConstraintViolatedException object. + * @return the error message string of this VerifierConstraintViolatedException. + */ + public String getMessage(){ + return detailMessage; + } +} diff --git a/src/java/org/apache/bcel/verifier/exc/package.html b/src/java/org/apache/bcel/verifier/exc/package.html new file mode 100644 index 00000000..3d04b1b5 --- /dev/null +++ b/src/java/org/apache/bcel/verifier/exc/package.html @@ -0,0 +1,24 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> +<head> +<!-- +$Id$ +--> +</head> +<body bgcolor="white"> + +Exception classes used by JustIce, mostly used internally. You don't need to bother with them. + +<h2>Package Specification</h2> + +Contained in this package are Exception classes for use with the JustIce verifier. + +<h2>Related Documentation</h2> + +For a simple demonstration of JustIce working, please see: +<ul> + <li><a href="http://www.inf.fu-berlin.de/~ehaase/cgi-html/Verifier.html">A WWW front-end for JustIce.</a> +</ul> + +</body> +</html> |