Commit 350400f6 authored by Lionel Seinturier's avatar Lionel Seinturier
Browse files

Fix bugs with generics when generating Tinfi proxies (interface and interceptor implementations.)

parent bc16b01b
......@@ -58,13 +58,13 @@
<isOptional>false</isOptional>
<isCollection>false</isCollection>
</interfaceType>
<!-- interfaceType>
<interfaceType>
<name>if</name>
<signature>example.proxyparameters.ImplementationFactory</signature>
<isClient>false</isClient>
<isOptional>false</isOptional>
<isCollection>false</isCollection>
</interfaceType -->
</interfaceType>
</interfaceTypes>
<controllerDesc>scaPrimitive</controllerDesc>
<contentDesc>example.proxyparameters.CImpl</contentDesc>
......
......@@ -120,9 +120,7 @@ extends ServerInterfaceClassGenerator {
String srclname = cg.getTargetClassName();
mv.visit (" return new ");
mv.visit (srclname);
mv.visit ("<");
mv.visit (it.getFcItfSignature());
mv.visit (">(");
mv.visit ("(");
mv.visit (it.getFcItfSignature());
mv.visitln(".class,this);");
mv.visitEnd();
......
......@@ -91,20 +91,29 @@ extends AbstractProxyClassGenerator {
}
}
@Override
public String[] getClassGenericTypeParameters() {
// TODO handle generation for generic interfaces (e.g. o.o.f.bf.BindingFactoryPlugin)
return new String[]{"B extends "+it.getFcItfSignature()};
}
@Override
public String getSuperClassName() {
return ServiceReferenceImpl.class.getName()+"<B>";
String superClassName =
ServiceReferenceImpl.class.getName()+"<"+it.getFcItfSignature()+">";
return superClassName;
}
@Override
public String[] getImplementedInterfaceNames() {
return new String[]{it.getFcItfSignature()};
String signature = it.getFcItfSignature();
/*
* Add type parameters if any.
*/
UnifiedClass proxycl = jc.create(signature);
String[] tpnames = proxycl.getTypeParameterNames();
if( tpnames.length != 0 ) {
String s = Utils.getTypeParameterNamesSignature(tpnames);
signature += s;
}
return new String[]{signature};
}
@Override
......@@ -113,9 +122,13 @@ extends AbstractProxyClassGenerator {
super.generateConstructors(cv,proxycl);
String signature = it.getFcItfSignature();
// public constructor(Class<B>,B)
String[] parameters =
new String[]{ "Class<B> businessInterface", "B service" };
new String[]{
"Class<"+signature+"> businessInterface",
signature+" service" };
MethodSourceCodeVisitor mv =
cv.visitConstructor(Modifier.PUBLIC,null,parameters,null);
mv.visitBegin();
......@@ -129,6 +142,7 @@ extends AbstractProxyClassGenerator {
super.generateProxyMethodBodyBeforeCode(mv,proxycl,proxym);
String signature = it.getFcItfSignature();
conversationalItf = proxycl.getAnnotation(Conversational.class);
oneWayMeth = proxym.getAnnotation(OneWay.class);
......@@ -139,8 +153,8 @@ extends AbstractProxyClassGenerator {
}
// Retrieve the delegate
mv.visitln(" final B impl = getService();");
mv.visitln(" final "+ServiceReference.class.getName()+"<B> sr = this;");
mv.visitln(" final "+signature+" impl = getService();");
mv.visitln(" final "+ServiceReference.class.getName()+"<"+signature+"> sr = this;");
// OneWay method
if( oneWayMeth != null ) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment