mv = binfo.getMemberValue("isTransient");
boolean isTransient = (mv != null) ? ((BooleanMemberValue) mv).getValue() : true;//Note! this should be the same as the default in @Mixin
String name = cf.getName() + "." + minfo.getName(); //Name of the method defined on
InterfaceIntroduction intro = null;
String construction = name;
switch(Descriptor.numOfParameters(minfo.getDescriptor()))
{
case 0:
construction += "()";
intro = createIntroduction(name, target, typeExpression, null, null, null);//cf.getName(), minfo.getName());
break;
case 1:
construction += "(this)";
intro = createIntroduction(name, target, typeExpression, null, cf.getName(), minfo.getName());
String parameter = Descriptor.getParamDescriptor(minfo.getDescriptor());
if (parameter.charAt(1) != 'L')
{
String errorMessage = "Mixin creator method '" + name +
"' parameter is primitive type ";
char desc = parameter.charAt(1);
if (desc == ((CtPrimitiveType) CtClass.booleanType).getDescriptor())
{
errorMessage += "boolean";
}
else if (desc == ((CtPrimitiveType) CtClass.byteType).getDescriptor())
{
errorMessage += "byte";
}
else if (desc == ((CtPrimitiveType) CtClass.charType).getDescriptor())
{
errorMessage += "char";
}
else if (desc == ((CtPrimitiveType) CtClass.doubleType).getDescriptor())
{
errorMessage += "double";
}
else if (desc == ((CtPrimitiveType) CtClass.floatType).getDescriptor())
{
errorMessage += "float";
}
else if (desc == ((CtPrimitiveType) CtClass.intType).getDescriptor())
{
errorMessage += "int";
}
else if (desc == ((CtPrimitiveType) CtClass.longType).getDescriptor())
{
errorMessage += "long";
}
else if (desc == ((CtPrimitiveType) CtClass.shortType).getDescriptor())
{
errorMessage += "short";
}
else
{
break;
}
errorMessage += ".\n It should have the introduction target type as parameter, or have no parameter at all.";
throw new RuntimeException(errorMessage);
}
break;
default:
throw new RuntimeException("Mixin creator method '" + name +
"' should not have more than one parameter.");
}
if (!Modifier.isStatic(minfo.getAccessFlags()) ||
!Modifier.isPublic(minfo.getAccessFlags()))
{
throw new RuntimeException("Mixin creator method '" + name +
"' must be public and static.");
}
//Parse the descriptor to get the returntype of the method.
String classname = getReturnType(minfo);
intro.getMixins().add(new InterfaceIntroduction.Mixin(classname, interfaces, construction, isTransient));
manager.addInterfaceIntroduction(intro);
}
}