01: /* Copyright (c) 2005 Per S Hustad. All rights reserved.
02: *
03: * Redistribution and use in source and binary forms, with or without
04: * modification, are permitted provided that the following conditions are met:
05: *
06: * o Redistributions of source code must retain the above copyright notice,
07: * this list of conditions and the following disclaimer.
08: *
09: * o Redistributions in binary form must reproduce the above copyright notice,
10: * this list of conditions and the following disclaimer in the documentation
11: * and/or other materials provided with the distribution.
12: *
13: * o Neither the name of surrogate.sourceforge.net nor the names of
14: * its contributors may be used to endorse or promote products derived
15: * from this software without specific prior written permission.
16: *
17: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
19: * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24: * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25: * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26: * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27: * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28: */
29: package net.sf.surrogate.core;
30:
31: /**
32: * Throws an exception without declaring it!.
33: * This class is just ment for testing purposes and used by the Surrogate AspectJ code.
34: * It is not used "in place" but decompiled using the BCEL JasminVisitor and
35: * re-assembled using Jasmin to remove the "throws" clause.
36: * <p>
37: * The reason why this class exists is that, when creating "mockPointcuts", the
38: * corresponding "around" advices would have to declare a "throw" clause
39: * for some pointcuts but not for others. This would break the generic appoach
40: * of the framwork.
41: * @see <a href=http://www.javaworld.com/javaworld/javaqa/2003-02/02-qa-0228-evilthrow.html> JavaWorld Article</a>
42: * @author Per S Hustad
43: */
44: public class ExceptionThrower {
45: /**
46: * Throws a throwable as an unchecked exception.
47: * I.e. the following call will have "foo" throwing
48: * an Exception
49: * <pre>
50: * ...
51: * public void foo() {
52: * ExceptionThrower.throwThrowable(new Exception());
53: * }
54: * </pre>
55: * @param throwable the throwable
56: * @throws Throwable the throwable given on input
57: */
58: // If re-jasminifying this class, uncomment the
59: // "throws Throwable" and "throw"
60: public static void throwThrowable(Throwable throwable)
61: /* throws Throwable */{
62: //throw throwable;
63: }
64: }
|