1 package net.sf.cglib.transform.impl;
2
3 import net.sf.cglib.transform.*;
4 import java.lang.reflect.Method;
5 import java.lang.reflect.Modifier;
6 import net.sf.cglib.core.*;
7
8 /***
9 * @author Juozas Baliuka, Chris Nokleberg
10 */
11 public class AddStaticInitTransformer extends ClassEmitterTransformer {
12 private Method classInit;
13
14 public AddStaticInitTransformer(Method classInit) {
15 if (!Modifier.isStatic(classInit.getModifiers())) {
16 throw new IllegalArgumentException(classInit + " is not static");
17 }
18 Class[] types = classInit.getParameterTypes();
19 if (types.length != 1 ||
20 !types[0].equals(Class.class) ||
21 !classInit.getReturnType().equals(Void.TYPE)) {
22 throw new IllegalArgumentException(classInit + " illegal signature");
23 }
24 this.classInit = classInit;
25 }
26
27 protected void init() {
28 if (!TypeUtils.isInterface(getAccess())) {
29 CodeEmitter e = getStaticHook();
30 EmitUtils.load_class_this(e);
31 e.invoke(classInit);
32 }
33 }
34 }
This page was automatically generated by Maven