accessDispatchMethodBody.append(" if((\"" + methodNumber + "\").equals(methodNo)){\n"); if (Constants.isLogging) { accessDispatchMethodBody.append(" android.util.Log.d(\"robust\",\"invoke method is " + method.getLongName() + " \" );");
private void transformMethod(String normalizedClassName, CtMethod method, boolean enableDurationProfiling, List<Integer> argumentsForProfile) { if (method.isEmpty()) { logger.info("Ignored empty class method: " + method.getLongName()); return; logger.info("Transformed class method: " + method.getLongName() + ", durationProfiling: " + enableDurationProfiling + ", argumentProfiling: " + argumentsForProfile); } catch (Throwable ex) { ex.printStackTrace(); logger.warn("Failed to transform class method: " + method.getLongName(), ex);
if (!d1.equals(d2)) throw new CannotCompileException("signature mismatch: " + substMethod.getLongName()); != substMethod.getDeclaringClass().isInterface()) throw new CannotCompileException("invoke-type mismatch " + substMethod.getLongName());
if (!d1.equals(d2)) throw new CannotCompileException("signature mismatch: " + substMethod.getLongName()); != substMethod.getDeclaringClass().isInterface()) throw new CannotCompileException("invoke-type mismatch " + substMethod.getLongName());
/** * Creates an error message for return value constraint assertion error. * <p/> * ex.<br/> * - <code>Hoge.getName() is not supposed to return empty value.</code><br/> * * @param ctMethod * target method * @return an error message for return value constraint assertion error */ private String createReturnValueConstraintAssertionErrorMessage(CtMethod ctMethod) { return MessageFormat.format(RETURN_VALUE_CONSTRAINT_ASSERTION_ERROR_MESSAGE_PATTERN, ctMethod.getLongName()); }
/** * Creates an error message for return value constraint assertion error. * <p/> * ex.<br/> * - <code>Hoge.foo() is not supposed to return null.</code><br/> * * @param ctMethod * target method * @return an error message for return value constraint assertion error */ private String createReturnValueConstraintAssertionErrorMessage(CtMethod ctMethod) { return MessageFormat.format(RETURN_VALUE_CONSTRAINT_ASSERTION_ERROR_MESSAGE_PATTERN, ctMethod.getLongName()); }
private String createReturnValueConstraintAssertionErrorMessage(CtMethod ctMethod, double threshold) { return MessageFormat.format(ASSERTION_ERROR_MESSAGE_PATTERN, "return value", RETURN_VALUE_IDENTIFIER, ctMethod.getLongName(), comparativeOperatorDescription, "" + threshold); }
@Override public String toString() { return versions.lastEntry().getValue().getLongName(); } }
private boolean hasGetClassMethod(CtClass _c) { final CtMethod[] methods = _c.getMethods(); for(CtMethod m: methods) { if(m.getLongName().equals("java.lang.Object.getClass()")) return true; } return false; } }
@Override public void edit(MethodCall m) throws CannotCompileException { try { if (continuationMethods.contains(m.getMethod().getLongName())) { _needsContinuations[0] = true; } } catch (Exception e) { } } });
public static void disassemble(CtMethod method, PrintStream out) { out.println(method.getLongName()); new InstructionPrinter(out).print(method); out.println(""); }
public static String toString(Optional<CtMethod> method) { if(method == null ) { return OptionalHelper.N_A; } if(method.isPresent()) { return method.get().getLongName(); } return OptionalHelper.N_A; }
public static String toString(Optional<CtMethod> method) { if(method == null ) { return OptionalHelper.N_A; } if(method.isPresent()) { return method.get().getLongName(); } return OptionalHelper.N_A; }
public static void stopRecording() { currentDiagramBean.getRoot().methodReturned(); currentDiagramBean.setStopTime(System.currentTimeMillis()); records.add(currentDiagramBean); log.info("Recording stoped " + currentDiagramBean.getEntryPoint().getLongName()); try { writer.write(currentDiagramBean); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException(e); } currentDiagramBean=null; }
@Override public void transform(String className, CtClass ctclz) throws Exception { final CtMethod[] methods = ctclz.getDeclaredMethods(); for (final CtMethod m : methods) { final Time ann = (Time) m.getAnnotation(Time.class); if (ann != null) { String timerName = ann.identifier(); if (timerName == null || timerName.length() == 0) timerName = String.format("%s#%s", className, m.getLongName()); addTimingInterceptor(ctclz, m, timerName); } } }
@Override public void transform(String className, CtClass ctclz) throws Exception { final CtMethod[] methods = ctclz.getDeclaredMethods(); for (final CtMethod m : methods) { final Time ann = (Time) m.getAnnotation(Time.class); if (ann != null) { String timerName = ann.identifier(); if (timerName == null || timerName.length() == 0) timerName = String.format("%s#%s", className, m.getLongName()); addTimingInterceptor(ctclz, m, timerName); } } }
@Override public void edit(MethodCall called) { try { String calledMethodName = called.getMethod().getLongName(); if (targetNames.contains(called.getClassName())) { allMethods.add(getMethod(called.getClassName(), called.getMethod())); getCallTree(called.getClassName(), calledMethodName, targetNames, allMethods, ctClasses); } } catch (NotFoundException e) { throw new RuntimeException(e); } } });
private void profile(CtMethod ctMethod) throws CannotCompileException, ClassNotFoundException { final String START = "com.baidu.hugegraph.perf.PerfUtil.instance().start(\"%s\");"; final String END = "com.baidu.hugegraph.perf.PerfUtil.instance().end(\"%s\");"; Watched annotation = (Watched) ctMethod.getAnnotation(Watched.class); String name = annotation.value(); if (name.isEmpty()) { name = ctMethod.getName(); } if (!annotation.prefix().isEmpty()) { name = annotation.prefix() + "." + name; } ctMethod.insertBefore(String.format(START, name)); // Insert as a finally-statement ctMethod.insertAfter(String.format(END, name), true); LOG.debug("Profiled for: '{}' [{}]", name, ctMethod.getLongName()); }
private String describe(CtMethod ctMethod) throws NotFoundException { return Modifier.toString(ctMethod.getModifiers()) + " " + ctMethod.getReturnType().getSimpleName() + " " + ctMethod.getLongName(); }
@Override public void preProcessAnnotatedMethod(T annotation, MethodAnnotationContext context) throws NotFoundException { if (ignoreReturns || !isActive(context)) return; // TODO handle properly Ensure.that(!context.isVoid(), "Context must not be void: %s", context.getMethod().getLongName()); try { context.getMethod().insertAfter(ASSERT_FULLY_QUALIFIED_NAME + createMethodCheck(annotation, context) + ";"); } catch (CannotCompileException e) { logError(context, context.getMethod(), e); throw SoftException.soften(e); } }