View Javadoc
1 package net.sf.cglib.transform.impl; 2 3 import net.sf.cglib.core.*; 4 import net.sf.cglib.transform.*; 5 import org.objectweb.asm.Attribute; 6 7 /*** 8 * A {@link GeneratorStrategy} suitable for use with {@link net.sf.cglib.Enhancer} which 9 * causes all undeclared exceptions thrown from within a proxied method to be wrapped 10 * in an alternative exception of your choice. 11 */ 12 public class UndeclaredThrowableStrategy extends DefaultGeneratorStrategy { 13 private ClassTransformer t; 14 15 /*** 16 * Create a new instance of this strategy. 17 * @param wrapper a class which extends either directly or 18 * indirectly from <code>Throwable</code> and which has at least one 19 * constructor that takes a single argument of type 20 * <code>Throwable</code>, for example 21 * <code>java.lang.reflect.UndeclaredThrowableException.class</code> 22 */ 23 public UndeclaredThrowableStrategy(Class wrapper) { 24 t = new UndeclaredThrowableTransformer(wrapper); 25 t = new MethodFilterTransformer(TRANSFORM_FILTER, t); 26 } 27 28 private static final MethodFilter TRANSFORM_FILTER = new MethodFilter() { 29 public boolean accept(int access, String name, String desc, String[] exceptions, Attribute attrs) { 30 return !TypeUtils.isPrivate(access) && name.indexOf('$') < 0; 31 } 32 }; 33 34 protected ClassGenerator transform(ClassGenerator cg) throws Exception { 35 return new TransformingClassGenerator(cg, t); 36 } 37 } 38

This page was automatically generated by Maven