浏览代码

jfinal 4.1 release ^_^

James 6 年之前
父节点
当前提交
67cb5beabb

+ 26 - 1
src/main/java/com/jfinal/proxy/ProxyGenerator.java

@@ -65,7 +65,11 @@ public class ProxyGenerator {
 		clazz.set("pkg", proxyClass.getPkg());
 		clazz.set("pkg", proxyClass.getPkg());
 		clazz.set("name", proxyClass.getName());
 		clazz.set("name", proxyClass.getName());
 		clazz.set("targetName", getTargetName(target));
 		clazz.set("targetName", getTargetName(target));
-		clazz.set("classTypeVars", getTypeVars(target.getTypeParameters()));
+		
+		@SuppressWarnings("rawtypes")
+		TypeVariable[] tvs = target.getTypeParameters();
+		clazz.set("classTypeVars", getTypeVars(tvs));
+		clazz.set("targetTypeVars", getTargetTypeVars(tvs));
 		
 		
 		List<Class<?>> methodUpperInters = getMethodUpperInterceptors(proxyClass);
 		List<Class<?>> methodUpperInters = getMethodUpperInterceptors(proxyClass);
 		
 		
@@ -216,6 +220,27 @@ public class ProxyGenerator {
 	}
 	}
 	
 	
 	/**
 	/**
+	 * 相对于 getTypeVars(...) 取消了 TypeVariable.getBounds() 内容的生成,否则编译错误
+	 */
+	@SuppressWarnings("rawtypes")
+	protected String getTargetTypeVars(TypeVariable[] typeVars) {
+		if (typeVars == null|| typeVars.length == 0) {
+			return null;
+		}
+		
+		StringBuilder ret = new StringBuilder();
+		ret.append('<');
+		for (int i=0; i<typeVars.length; i++) {
+			TypeVariable tv = typeVars[i];
+			if (i > 0) {
+				ret.append(", ");
+			}
+			ret.append(tv.getName());
+		}
+		return ret.append('>').toString();
+	}
+	
+	/**
 	 * 跳过不能代理的方法
 	 * 跳过不能代理的方法
 	 * 1:非 public
 	 * 1:非 public
 	 * 2:final、static、abstract
 	 * 2:final、static、abstract

+ 1 - 1
src/main/java/com/jfinal/proxy/proxy_class_template.jf

@@ -24,7 +24,7 @@ public class Target$$EnhancerByJFinal extends Target {
 
 
 package #(pkg);
 package #(pkg);
 import com.jfinal.aop.Invocation;
 import com.jfinal.aop.Invocation;
-public class #(name)#(classTypeVars) extends #(targetName)#(classTypeVars) {
+public class #(name)#(classTypeVars) extends #(targetName)#(targetTypeVars) {
 #for(x : methodList)
 #for(x : methodList)
 	
 	
 	public #(x.methodTypeVars) #(x.returnType) #(x.name)(#for(y : x.paraTypes)#(y) p#(for.index)#(for.last ? "" : ", ")#end) {
 	public #(x.methodTypeVars) #(x.returnType) #(x.name)(#for(y : x.paraTypes)#(y) p#(for.index)#(for.last ? "" : ", ")#end) {