Commit cf904d59 authored by Lionel Seinturier's avatar Lionel Seinturier

Use Class<?> instead of UClass in the proxy code generators.

parent a43ac0fd
......@@ -30,7 +30,6 @@ import org.objectweb.fractal.api.Component;
import org.objectweb.fractal.api.Type;
import org.objectweb.fractal.api.type.InterfaceType;
import org.objectweb.fractal.juliac.Juliac;
import org.objectweb.fractal.juliac.UClass;
import org.objectweb.fractal.juliac.desc.MembraneDesc;
import org.objectweb.fractal.juliac.proxy.AbstractProxyClassGenerator;
import org.objectweb.fractal.juliac.visit.BlockSourceCodeVisitor;
......@@ -95,7 +94,8 @@ extends AbstractProxyClassGenerator {
}
@Override
public void generateConstructors( ClassSourceCodeVisitor cv, UClass proxycl ) {
public void generateConstructors( ClassSourceCodeVisitor cv, Class<?> proxycl ) {
super.generateConstructors(cv, proxycl);
// public constructor()
......@@ -119,7 +119,7 @@ extends AbstractProxyClassGenerator {
@Override
public void generateProxyMethodBodyBeforeCode(
BlockSourceCodeVisitor mv, UClass proxycl, Method proxym ) {
BlockSourceCodeVisitor mv, Class<?> proxycl, Method proxym ) {
/*
* Regiqter the request context and get the content instance which
......@@ -137,7 +137,7 @@ extends AbstractProxyClassGenerator {
@Override
public void generateProxyMethodBodyAfterCode(
BlockSourceCodeVisitor mv, UClass proxycl, Method proxym ) {
BlockSourceCodeVisitor mv, Class<?> proxycl, Method proxym ) {
// End of the try block
mv.visitln(" }");
......@@ -157,7 +157,7 @@ extends AbstractProxyClassGenerator {
mv.visitln(" }");
}
public String getDelegatingInstance( UClass proxycl, Method proxym ) {
public String getDelegatingInstance( Class<?> proxycl, Method proxym ) {
return "impl";
}
}
......@@ -105,7 +105,7 @@ extends ServerInterfaceClassGenerator {
}
@Override
public void generateMethods( ClassSourceCodeVisitor cv, UClass proxycl ) {
public void generateMethods( ClassSourceCodeVisitor cv, Class<?> proxycl ) {
super.generateMethods(cv, proxycl);
......@@ -127,7 +127,7 @@ extends ServerInterfaceClassGenerator {
@Override
public void generateProxyMethod(
ClassSourceCodeVisitor cv, UClass proxycl, Method proxym ) {
ClassSourceCodeVisitor cv, Class<?> proxycl, Method proxym ) {
/*
* Indeed nothing.
* Proxy methods are inherited from the component server interface
......
......@@ -47,13 +47,13 @@ extends org.objectweb.fractal.juliac.proxy.InterceptorClassGenerator {
}
@Override
public String getDelegatingInstance( UClass proxycl, Method proxym ) {
public String getDelegatingInstance( Class<?> proxycl, Method proxym ) {
return "impl";
}
@Override
public void generateProxyMethodBodyDelegatingCode(
BlockSourceCodeVisitor mv, UClass proxycl, Method proxym ) {
BlockSourceCodeVisitor mv, Class<?> proxycl, Method proxym ) {
String rtypename = UClass.getGenericReturnType(proxym,proxycl);
......@@ -93,7 +93,7 @@ extends org.objectweb.fractal.juliac.proxy.InterceptorClassGenerator {
* @since 1.1.1
*/
@Override
public void generateFieldImpl( ClassSourceCodeVisitor cv, UClass proxycl ) {
public void generateFieldImpl( ClassSourceCodeVisitor cv, Class<?> proxycl ) {
/*
* The implementation of the impl field is inherited from
* TinfiComponentInterceptor.
......@@ -104,7 +104,7 @@ extends org.objectweb.fractal.juliac.proxy.InterceptorClassGenerator {
* @since 1.1.1
*/
@Override
public void generateMethodGetFcItfDelegate( ClassSourceCodeVisitor cv, UClass proxycl ) {
public void generateMethodGetFcItfDelegate( ClassSourceCodeVisitor cv, Class<?> proxycl ) {
/*
* The implementation of the getFcItfDelegate method is inherited from
* TinfiComponentInterceptor.
......@@ -115,7 +115,7 @@ extends org.objectweb.fractal.juliac.proxy.InterceptorClassGenerator {
* @since 1.1.1
*/
@Override
public void generateMethodSetFcItfDelegate( ClassSourceCodeVisitor cv, UClass proxycl ) {
public void generateMethodSetFcItfDelegate( ClassSourceCodeVisitor cv, Class<?> proxycl ) {
/*
* The implementation of the setFcItfDelegate method is inherited from
* TinfiComponentInterceptor.
......
......@@ -28,7 +28,6 @@ import java.lang.reflect.Method;
import org.objectweb.fractal.api.type.InterfaceType;
import org.objectweb.fractal.juliac.Juliac;
import org.objectweb.fractal.juliac.UClass;
import org.objectweb.fractal.juliac.desc.MembraneDesc;
import org.objectweb.fractal.juliac.helper.ClassHelper;
import org.objectweb.fractal.juliac.proxy.AbstractInterceptorSourceCodeGenerator;
......@@ -95,7 +94,7 @@ extends AbstractInterceptorSourceCodeGenerator {
@Override
public void generateProxyMethodBodyBeforeCode(
BlockSourceCodeVisitor mv, UClass proxycl, Method proxym ) {
BlockSourceCodeVisitor mv, Class<?> proxycl, Method proxym ) {
/*
* Regiqter the request context and get the content instance which
......@@ -103,7 +102,7 @@ extends AbstractInterceptorSourceCodeGenerator {
*/
mv.visit (" ");
mv.visit (it.getFcItfSignature());
String[] tpnames = ClassHelper.getTypeParameterNames(proxycl.cl);
String[] tpnames = ClassHelper.getTypeParameterNames(proxycl);
if( tpnames.length != 0 ) {
String s = ClassHelper.getTypeParameterNamesSignature(tpnames);
mv.visit(s);
......@@ -120,7 +119,7 @@ extends AbstractInterceptorSourceCodeGenerator {
@Override
public void generateProxyMethodBodyFinallyCode(
BlockSourceCodeVisitor mv, UClass proxycl, Method proxym ) {
BlockSourceCodeVisitor mv, Class<?> proxycl, Method proxym ) {
// End of the try block
mv.visitln(" }");
......
......@@ -89,13 +89,13 @@ extends AbstractInterceptorSourceCodeGenerator {
}
@Override
public void generateStaticParts( ClassSourceCodeVisitor cv, UClass proxycl ) {
public void generateStaticParts( ClassSourceCodeVisitor cv, Class<?> proxycl ) {
/*
* Initialize the METHODS field (declared below in method
* generateFields).
*/
Method[] proxymethods = proxycl.cl.getMethods();
Method[] proxymethods = proxycl.getMethods();
BlockSourceCodeVisitor bv = cv.visitStaticPart();
if( proxymethods.length > 0 ) {
bv.visitln(" try {");
......@@ -103,7 +103,8 @@ extends AbstractInterceptorSourceCodeGenerator {
bv.visitln(" METHODS = new java.lang.reflect.Method[]{");
// Iterate on methods
String proxyclname = proxycl.toString(proxycl.cl);
UClass uc = UClass.get(proxycl);
String proxyclname = uc.toString(proxycl);
for (int i = 0; i < proxymethods.length; i++) {
Method proxym = proxymethods[i];
......@@ -137,7 +138,7 @@ extends AbstractInterceptorSourceCodeGenerator {
}
@Override
public void generateFields( ClassSourceCodeVisitor cv, UClass proxycl ) {
public void generateFields( ClassSourceCodeVisitor cv, Class<?> proxycl ) {
/*
* Generate a METHODS field to store the array of component methods
......@@ -254,25 +255,25 @@ extends AbstractInterceptorSourceCodeGenerator {
}
@Override
public void generateMethodInitFcController( BlockSourceCodeVisitor mv, UClass proxycl ) {
public void generateMethodInitFcController( BlockSourceCodeVisitor mv, Class<?> proxycl ) {
mv.visitln(" initIntentHandlersMap(METHODS);");
}
@Override
public void generateMethodClone( BlockSourceCodeVisitor mv, UClass proxycl ) {
public void generateMethodClone( BlockSourceCodeVisitor mv, Class<?> proxycl ) {
mv.visitln(" clone.initIntentHandlersMap(METHODS);");
}
@Override
public void generateProxyMethodBodyBeforeCode(
BlockSourceCodeVisitor mv, UClass proxycl, Method proxym ) {
BlockSourceCodeVisitor mv, Class<?> proxycl, Method proxym ) {
/*
* Retrieve the index of proxym in the array of methods for proxycl.
*/
int idx = -1;
String proxymstring = proxym.toString();
Method[] ums = proxycl.cl.getMethods();
Method[] ums = proxycl.getMethods();
for (int i = 0; i < ums.length; i++) {
Method um = ums[i];
String umstring = um.toString();
......@@ -382,7 +383,7 @@ extends AbstractInterceptorSourceCodeGenerator {
@Override
public void generateProxyMethodBodyFinallyCode(
BlockSourceCodeVisitor mv, UClass proxycl, Method proxym ) {
BlockSourceCodeVisitor mv, Class<?> proxycl, Method proxym ) {
// End of else block
mv.visitln(" }");
......
......@@ -102,12 +102,12 @@ extends AbstractInterceptorSourceCodeGenerator {
}
@Override
public void generateMethodInitFcController( BlockSourceCodeVisitor mv, UClass proxycl ) {
public void generateMethodInitFcController( BlockSourceCodeVisitor mv, Class<?> proxycl ) {
mv.visitIns("super.initFcController(ic)");
}
@Override
public void generateMethodClone( BlockSourceCodeVisitor mv, UClass proxycl ) {
public void generateMethodClone( BlockSourceCodeVisitor mv, Class<?> proxycl ) {
mv.visitIns("initFcClone(clone)");
}
}
......@@ -83,7 +83,7 @@ extends InterfaceImplementationClassGenerator {
}
@Override
public void generateFieldImpl( ClassSourceCodeVisitor cv, UClass proxycl ) {
public void generateFieldImpl( ClassSourceCodeVisitor cv, Class<?> proxycl ) {
/*
* Indeed nothing.
* The field is managed by TinfiComponentInterface.
......@@ -91,7 +91,7 @@ extends InterfaceImplementationClassGenerator {
}
@Override
public void generateMethodGetFcItfImpl( ClassSourceCodeVisitor cv, UClass proxycl ) {
public void generateMethodGetFcItfImpl( ClassSourceCodeVisitor cv, Class<?> proxycl ) {
/*
* Indeed nothing.
* The method is inherited from TinfiComponentInterface.
......@@ -99,7 +99,7 @@ extends InterfaceImplementationClassGenerator {
}
@Override
public void generateMethodSetFcItfImpl( ClassSourceCodeVisitor cv, UClass proxycl ) {
public void generateMethodSetFcItfImpl( ClassSourceCodeVisitor cv, Class<?> proxycl ) {
/*
* Indeed nothing.
* The method is inherited from TinfiComponentInterface.
......
......@@ -134,7 +134,7 @@ extends AbstractProxyClassGenerator {
@Override
public void generateConstructors(
ClassSourceCodeVisitor cv, UClass proxycl ) {
ClassSourceCodeVisitor cv, Class<?> proxycl ) {
super.generateConstructors(cv,proxycl);
......@@ -143,7 +143,7 @@ extends AbstractProxyClassGenerator {
* if any.
*/
String signature = it.getFcItfSignature();
String[] tpnames = ClassHelper.getTypeParameterNames(proxycl.cl);
String[] tpnames = ClassHelper.getTypeParameterNames(proxycl);
if( tpnames.length != 0 ) {
String s = ClassHelper.getTypeParameterNamesSignature(tpnames);
signature += s;
......@@ -164,7 +164,7 @@ extends AbstractProxyClassGenerator {
* @since 1.4.1
*/
@Override
public void generateMethods( ClassSourceCodeVisitor cv, UClass proxycl ) {
public void generateMethods( ClassSourceCodeVisitor cv, Class<?> proxycl ) {
/*
* Override the getService method inherited from ServiceReferenceImpl.
* The idea is that in generated subclasses of ServiceReferenceImpl we
......@@ -184,11 +184,11 @@ extends AbstractProxyClassGenerator {
@Override
public void generateProxyMethodBodyBeforeCode(
BlockSourceCodeVisitor mv, UClass proxycl, Method proxym ) {
BlockSourceCodeVisitor mv, Class<?> proxycl, Method proxym ) {
super.generateProxyMethodBodyBeforeCode(mv,proxycl,proxym);
conversationalItf = proxycl.cl.getAnnotation(Conversational.class);
conversationalItf = proxycl.getAnnotation(Conversational.class);
oneWayMeth =
MethodHelper.getAnnotation(
proxym,
......@@ -198,7 +198,7 @@ extends AbstractProxyClassGenerator {
callbackClass = Void.class; // callback.value() defaults to Void
Annotation callback =
ClassHelper.getAnnotation(
proxycl.cl,
proxycl,
Callback.class.getName(),
"org.osoa.sca.annotations.Callback");
if( callback != null ) {
......@@ -209,9 +209,10 @@ extends AbstractProxyClassGenerator {
if( oneWayMeth != null ) {
Class<?> rtype = proxym.getReturnType();
if( ! rtype.getName().equals("void") ) {
UClass uc = UClass.get(proxycl);
final String msg =
"@OneWay annotated method "+proxym.toString()+" in "+
proxycl.toString(proxycl.cl)+" should return void";
uc.toString(proxycl)+" should return void";
throw new TinfiRuntimeException(msg);
}
mv.visitln(" new Thread() {");
......@@ -258,7 +259,7 @@ extends AbstractProxyClassGenerator {
@Override
public void generateProxyMethodBodyAfterCode(
BlockSourceCodeVisitor mv, UClass proxycl, Method proxym ) {
BlockSourceCodeVisitor mv, Class<?> proxycl, Method proxym ) {
super.generateProxyMethodBodyAfterCode(mv,proxycl,proxym);
......@@ -288,7 +289,7 @@ extends AbstractProxyClassGenerator {
}
}
public String getDelegatingInstance( UClass proxycl, Method proxym ) {
public String getDelegatingInstance( Class<?> proxycl, Method proxym ) {
return "service";
}
}
......@@ -71,17 +71,12 @@ extends org.ow2.frascati.tinfi.opt.oo.InitializerOOCtrlClassGenerator {
List<ControllerDesc> ctrlDescs = membraneDesc.getCtrlDescs();
UClass ucinitializable = jc.create(Initializable.class.getName());
UClass uccomponent = jc.create(Component.class.getName());
UClass ucscaecc =
jc.create(SCAExtendedContentController.class.getName());
mv.visitln(" Object ctrl = null;");
for (ControllerDesc ctrlDesc : ctrlDescs) {
String ctrlImplName = ctrlDesc.getImplName();
UClass uc = jc.create(ctrlImplName);
if( ucscaecc.cl.isAssignableFrom(uc.cl) ) {
if( SCAExtendedContentController.class.isAssignableFrom(uc.cl) ) {
// SCA Content Controller
String contentClassName = (String) contentDesc;
TypeGeneratorItf cg = null;
......@@ -94,7 +89,7 @@ extends org.ow2.frascati.tinfi.opt.oo.InitializerOOCtrlClassGenerator {
ctrlImplName = cg.getTargetTypeName();
}
mv.visitln(" ic.controllers.add(ctrl = new "+ctrlImplName+"());");
if( ucinitializable.cl.isAssignableFrom(uc.cl) ) {
if( Initializable.class.isAssignableFrom(uc.cl) ) {
Tree tree = ctrlDesc.getTree();
if( tree != null ) {
mv.visitln(" "+Tree.class.getName()+" tree = "+TreeHelper.javaify(tree)+';');
......@@ -106,7 +101,7 @@ extends org.ow2.frascati.tinfi.opt.oo.InitializerOOCtrlClassGenerator {
mv.visitln(" }");
}
}
if( uccomponent.cl.isAssignableFrom(uc.cl) ) {
if( Component.class.isAssignableFrom(uc.cl) ) {
mv.visitln(" "+Component.class.getName()+" compctrl = ("+Component.class.getName()+")ctrl;");
}
}
......
......@@ -25,7 +25,6 @@ package org.ow2.frascati.tinfi.opt.oo.light;
import java.lang.reflect.Method;
import org.objectweb.fractal.juliac.UClass;
import org.objectweb.fractal.juliac.visit.ClassSourceCodeVisitor;
/**
......@@ -42,7 +41,7 @@ extends org.objectweb.fractal.juliac.proxy.InterceptorClassGenerator {
public InterceptorNoIntentClassGenerator() {}
@Override
public void generateFieldImpl( ClassSourceCodeVisitor cv, UClass proxycl ) {
public void generateFieldImpl( ClassSourceCodeVisitor cv, Class<?> proxycl ) {
/*
* The implementation of the impl field is inherited from
* TinfiComponentInterceptor.
......@@ -50,7 +49,7 @@ extends org.objectweb.fractal.juliac.proxy.InterceptorClassGenerator {
}
@Override
public void generateMethodGetFcItfDelegate(ClassSourceCodeVisitor cv, UClass proxycl) {
public void generateMethodGetFcItfDelegate(ClassSourceCodeVisitor cv, Class<?> proxycl) {
/*
* The implementation of the getFcItfDelegate method is inherited from
* TinfiComponentInterceptor.
......@@ -58,7 +57,7 @@ extends org.objectweb.fractal.juliac.proxy.InterceptorClassGenerator {
}
@Override
public void generateMethodSetFcItfDelegate(ClassSourceCodeVisitor cv, UClass proxycl) {
public void generateMethodSetFcItfDelegate(ClassSourceCodeVisitor cv, Class<?> proxycl) {
/*
* The implementation of the setFcItfDelegate method is inherited from
* TinfiComponentInterceptor.
......@@ -66,7 +65,7 @@ extends org.objectweb.fractal.juliac.proxy.InterceptorClassGenerator {
}
@Override
public String getDelegatingInstance( UClass proxycl, Method proxym ) {
public String getDelegatingInstance( Class<?> proxycl, Method proxym ) {
return "impl";
}
}
......@@ -200,7 +200,6 @@ public class TinfiParserSupportImpl implements ADLParserSupportItf {
Map<String,Class<?>> refmap = new HashMap<String,Class<?>>();
Map<String,Boolean> refcontingencymap = new HashMap<String,Boolean>();
Map<String,Boolean> refcardinalitymap = new HashMap<String,Boolean>();
UClass uclist = jc.create(List.class.getName());
Field[] fields = ClassHelper.getAllFields(uc.cl);
fields = FieldHelper.removeOverriden(fields);
for (Field field : fields) {
......@@ -222,7 +221,7 @@ public class TinfiParserSupportImpl implements ADLParserSupportItf {
}
Class<?> fieldtype = field.getType();
boolean isMultiple = uclist.cl.isAssignableFrom(fieldtype);
boolean isMultiple = List.class.isAssignableFrom(fieldtype);
refcardinalitymap.put(name,isMultiple);
Class<?> reftype = null;
if(isMultiple) {
......
......@@ -133,12 +133,11 @@ public class SCAUltraMerge extends AbstractUltraMerge {
CtTypeReference<?> tref = ctfield.getType();
String qname = tref.getQualifiedName();
UClass umclass = jc.create(qname);
UClass umlist = jc.create(List.class.getName());
/*
* Fields of type List hold references for collection references.
*/
boolean b = !( umlist.cl.isAssignableFrom(umclass.cl) );
boolean b = !( List.class.isAssignableFrom(umclass.cl) );
return b;
}
......@@ -149,12 +148,11 @@ public class SCAUltraMerge extends AbstractUltraMerge {
CtTypeReference<?> tref = ctfield.getType();
String qname = tref.getQualifiedName();
UClass umclass = jc.create(qname);
UClass umlist = jc.create(List.class.getName());
/*
* Fields of type List hold references for collection references.
*/
boolean b = umlist.cl.isAssignableFrom(umclass.cl);
boolean b = List.class.isAssignableFrom(umclass.cl);
return b;
}
......
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