/** * Obtains the name of this constructor. * It is the same as the simple name of the class declaring this * constructor. If this object represents a class initializer, * then this method returns <code>"<clinit>"</code>. */ public String getName() { if (methodInfo.isStaticInitializer()) return MethodInfo.nameClinit; else return declaringClass.getSimpleName(); }
/** * Obtains the name of this constructor. * It is the same as the simple name of the class declaring this * constructor. If this object represents a class initializer, * then this method returns <code>"<clinit>"</code>. */ @Override public String getName() { if (methodInfo.isStaticInitializer()) return MethodInfo.nameClinit; return declaringClass.getSimpleName(); }
private static RuntimeException barf( CtClass ct, CtField fld ) throws NotFoundException { return new RuntimeException(ct.getSimpleName()+"."+fld.getName()+" of type "+(fld.getType().getSimpleName())+": Serialization not implemented; does not extend Iced or DTask"); }
private static boolean isThrowsSqlException(CtMethod method) { try { for (CtClass clazz : method.getExceptionTypes()) { if (clazz.getSimpleName().equals("SQLException")) { return true; } } } catch (NotFoundException e) { // fall thru } return false; }
.copy(getCtConstructor(mCopyConstructors.get(code.substring(1))), mCtc, null)); } else { String[] sn = mCtc.getSimpleName().split("\\$+"); // inner class name include $. mCtc.addConstructor( CtNewConstructor.make(code.replaceFirst(SIMPLE_NAME_TAG, sn[sn.length - 1]), mCtc));
private CtClass createControlClass(CtClass modifiedClass) throws Exception { CtClass patchClass = classPool.get(NameManger.getInstance().getPatchName(modifiedClass.getName())); patchClass.defrost(); CtClass controlClass = classPool.getAndRename(Constants.PATCH_TEMPLATE_FULL_NAME, NameManger.getInstance().getPatchControlName(modifiedClass.getSimpleName())); StringBuilder getRealParameterMethodBody = new StringBuilder(); getRealParameterMethodBody.append("public Object getRealParameter(Object parameter) {"); getRealParameterMethodBody.append("if(parameter instanceof " + modifiedClass.getName() + "){"); getRealParameterMethodBody. append("return new " + patchClass.getName() + "(parameter);"); getRealParameterMethodBody.append("}"); getRealParameterMethodBody.append("return parameter;}"); controlClass.addMethod(CtMethod.make(getRealParameterMethodBody.toString(), controlClass)); controlClass.getDeclaredMethod("accessDispatch").insertBefore(getAccessDispatchMethodBody(patchClass, modifiedClass.getName())); controlClass.getDeclaredMethod("isSupport").insertBefore(getIsSupportMethodBody(patchClass, modifiedClass.getName())); controlClass.defrost(); return controlClass; }
.copy(getCtConstructor(mCopyConstructors.get(code.substring(1))), mCtc, null)); } else { String[] sn = mCtc.getSimpleName().split("\\$+"); // inner class name include $. mCtc.addConstructor( CtNewConstructor.make(code.replaceFirst(SIMPLE_NAME_TAG, sn[sn.length - 1]), mCtc));
private void ensureNullaryCtor(CtClass cc) throws NotFoundException, CannotCompileException { // Build a null-ary constructor if needed String clzname = cc.getSimpleName(); if( !hasExisting(clzname,"()V",cc.getDeclaredConstructors()) ) { String body = "public "+clzname+"() { }"; cc.addConstructor(CtNewConstructor.make(body,cc)); } else { CtConstructor ctor = cc.getConstructor("()V"); ctor.setModifiers(javassist.Modifier.setPublic(ctor.getModifiers())); } }
mCtc.addConstructor(CtNewConstructor.copy(getCtConstructor(mCopyConstructors.get(code.substring(1))), mCtc, null)); } else { String[] sn = mCtc.getSimpleName().split("\\$+"); // inner class name include $. mCtc.addConstructor(CtNewConstructor.make(code.replaceFirst(SIMPLE_NAME_TAG, sn[sn.length - 1]), mCtc));
@Override public String getName() { String[] nameElements = ctClass.getSimpleName().replace('$', '.').split("\\."); return nameElements[nameElements.length - 1]; }
@Override public String getName() { String[] nameElements = ctClass.getSimpleName().replace('$', '.').split("\\."); return nameElements[nameElements.length - 1]; }
/** * Obtains the name of this constructor. * It is the same as the simple name of the class declaring this * constructor. If this object represents a class initializer, * then this method returns <code>"<clinit>"</code>. */ public String getName() { if (methodInfo.isStaticInitializer()) return MethodInfo.nameClinit; else return declaringClass.getSimpleName(); }
/** * Obtains the name of this constructor. * It is the same as the simple name of the class declaring this * constructor. If this object represents a class initializer, * then this method returns <code>"<clinit>"</code>. */ public String getName() { if (methodInfo.isStaticInitializer()) return MethodInfo.nameClinit; else return declaringClass.getSimpleName(); }
/** * Returns simple description like '@AnAnnotation does not support "int".'. * @param ctBehavior {@link CtBehavior} * @param targetType * @param annotation * @return */ public static String createSimpleDescription(CtBehavior ctBehavior, CtClass targetType, Annotation annotation) { return "@" + getAnnotationSimpleName(ctBehavior, annotation) + " does not support \"" + targetType.getSimpleName() + "\"."; }
/** * Obtains the name of this constructor. * It is the same as the simple name of the class declaring this * constructor. If this object represents a class initializer, * then this method returns <code>"<clinit>"</code>. */ public String getName() { if (methodInfo.isStaticInitializer()) return MethodInfo.nameClinit; else return declaringClass.getSimpleName(); }
public static String advisorFieldRead(CtClass genadvisor, String fieldName) { return genadvisor.getSimpleName() + "$" + fieldRead(fieldName); }
public static String getSimpleName(ClassPool classPool, Annotation annotation) { if (classPool == null) throw new IllegalArgumentException("classPool is null."); if (annotation == null) throw new IllegalArgumentException("annotation is null."); return getCtClass(classPool, annotation.getTypeName()).getSimpleName(); }
private CtClass setupClass()throws NotFoundException, CannotCompileException { String className = getGeneratedJoinPointClassName(advisedClass.getSimpleName(), index); //Create inner joinpoint class in advised class, super class is jp jp = TransformerCommon.makeNestedClass(advisedClass, className, true, Modifier.PUBLIC | Modifier.STATIC, INVOCATION_CT_TYPE); addUntransformableInterface(instrumentor, jp); return jp; }
private void addJoinpoint(CtClass clazz, CtConstructor constructor, String ciname, int index)throws CannotCompileException, NotFoundException { CtClass joinpoint = createJoinpointClass(clazz, constructor, ciname, index); CtClass genadvisor = ((GeneratedAdvisorInstrumentor)getInstrumentor()).getGenadvisor(); CtField field = new CtField( joinpoint, ConstructorJoinPointGenerator.getGeneratedJoinPointFieldName(clazz.getSimpleName(), index), genadvisor); field.setModifiers(Modifier.PUBLIC); genadvisor.addField(field); }
private void addJoinpoint(CtConstructor constructor, String ciname, int index)throws CannotCompileException, NotFoundException { CtClass clazz = constructor.getDeclaringClass(); CtClass joinpoint = createJoinpointClass(clazz, constructor, ciname, index); CtClass genadvisor = ((GeneratedAdvisorInstrumentor)instrumentor).getGenadvisor(); CtField field = new CtField( joinpoint, ConstructionJoinPointGenerator.getGeneratedJoinPointFieldName(clazz.getSimpleName(), index), genadvisor); field.setModifiers(Modifier.PUBLIC); genadvisor.addField(field); }