Codota Logo
MethodInfo
Code IndexAdd Codota to your IDE (free)

How to use
MethodInfo
in
jodd.proxetta

Best Java code snippets using jodd.proxetta.MethodInfo (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
BufferedReader b =
  • Codota IconInputStream in;new BufferedReader(new InputStreamReader(in))
  • Codota IconReader in;new BufferedReader(in)
  • Codota IconFile file;new BufferedReader(new FileReader(file))
  • Smart code suggestions by Codota
}
origin: oblac/jodd

/**
 * Returns {@link WrapperProxetta} used for building loggable prepared statements.
 * Initializes proxetta when called for the first time.
 */
protected BaseLoggableFactory(final Class<T> targetClass) {
  this.targetClass = targetClass;
  this.proxetta = Proxetta.wrapperProxetta().withAspect(ProxyAspect.of(LoggableAdvice.class, methodInfo -> {
    int argumentsCount = methodInfo.getArgumentsCount();
    char argumentType = 0;
    if (argumentsCount >= 1) {
      argumentType = methodInfo.getArgument(1).getOpcode();
    }
    return
      methodInfo.getReturnType().getOpcode() == 'V' &&			// void-returning method
        argumentType == 'I' &&									// first argument type
        methodInfo.isPublicMethod() &&
        methodInfo.getMethodName().startsWith("set") &&			// set*
        (argumentsCount == 2 || argumentsCount == 3);			// number of arguments
  }));
}
origin: oblac/jodd

/**
 * Visits replacement code for {@link ProxyTarget#targetMethodAnnotation(String, String)}.
 */
public static void targetMethodAnnotation(final MethodVisitor mv, final MethodInfo methodInfo, final String[] args) {
  AnnotationInfo[] anns = methodInfo.getAnnotations();
  if (anns != null) {
    targetAnnotation(mv, anns, args);
  }
}
origin: oblac/jodd

@Test
void testMethodSignature8() throws IOException {
  MethodInfo msv = getMethodSignatureForSingleMethod(M8.class);
  assertEquals(0, msv.getArgumentsCount());
  assertEquals(CLASS_SIGNATURE + "$M8", msv.getClassname());
  assertEquals("macka#()V", msv.getCleanSignature());
  assertEquals("()void", msv.getDeclaration());
  assertEquals(CLASS_SIGNATURE + "$M8", msv.getDeclaredClassName());
  assertEquals("()V", msv.getDescription());
  assertEquals("java/io/IOException,java/lang/NullPointerException", msv.getExceptionsAsString());
  assertEquals("macka", msv.getMethodName());
}
origin: oblac/jodd

  @Override
  public boolean apply(final MethodInfo methodInfo) {
    return
        methodInfo.isTopLevelMethod() &&
          methodInfo.isPublicMethod();
  }
}
origin: oblac/jodd

  @Override
  public boolean apply(final MethodInfo methodInfo) {
    return
        methodInfo.isPublicMethod()
        && methodInfo.matchMethodName("set*")
        && methodInfo.hasOneArgument()
        ;
  }
}
origin: oblac/jodd

  @Override
  public boolean apply(final MethodInfo methodInfo) {
    return
        methodInfo.isPublicMethod()
        && methodInfo.hasReturnValue()
        && (methodInfo.matchMethodName("get*") || (methodInfo.matchMethodName("is*")))
        && methodInfo.hasNoArguments()
        ;
  }
}
origin: oblac/jodd

@Test
void testMethodSignature9() throws IOException {
  MethodInfo msv = getMethodSignatureForSingleMethod(M9.class);
  assertEquals(1, msv.getArgumentsCount());
  assertEquals("java.lang.String[]", msv.getArgument(1).getType());
  assertEquals("[Ljava/lang/String;", msv.getArgument(1).getName());
  assertEquals("[Ljava/lang/String;", msv.getArgument(1).getRawName());
  assertEquals('[', msv.getArgument(1).getOpcode());
  assertEquals(CLASS_SIGNATURE + "$M9", msv.getClassname());
  assertEquals("main#([Ljava/lang/String;)V", msv.getCleanSignature());
  assertEquals("(java.lang.String[])void", msv.getDeclaration());
  assertEquals(CLASS_SIGNATURE + "$M9", msv.getDeclaredClassName());
  assertEquals("([Ljava/lang/String;)V", msv.getDescription());
  assertEquals("main", msv.getMethodName());
}
origin: oblac/jodd

    FooProxyAdvice.class,
    methodInfo -> {
      if (methodInfo.getMethodName().equals("p1")) {
        value.set(methodInfo);
        return true;
assertEquals("p1", mi.getMethodName());
assertEquals(Foo.class.getName().replace('.', '/'), mi.getClassname());
assertEquals("(java.lang.String)java.lang.String", mi.getDeclaration());
assertEquals("(Ljava/lang/String;)Ljava/lang/String;", mi.getDescription());
assertEquals("java.lang.String", mi.getReturnType().getType());
assertEquals("Ljava/lang/String;", mi.getReturnType().getName());
assertEquals("java.lang.String p1(java.lang.String)", mi.getSignature());
assertEquals(1, mi.getArgumentsCount());
assertEquals("Ljava/lang/String;", mi.getArgument(1).getName());
assertTrue(mi.isTopLevelMethod());
AnnotationInfo[] anns = mi.getArgument(1).getAnnotations();
origin: oblac/jodd

@Test
void testMethodSignature10() throws IOException {
  MethodInfo msv = getMethodSignatureForSingleMethod(M10.class);
  assertEquals(2, msv.getArgumentsCount());
  assertEquals(0, msv.getArgument(1).getAnnotations().length);
  assertEquals(1, msv.getArgument(2).getAnnotations().length);
  assertEquals("jodd.proxetta.fixtures.data.FooAnn", msv.getArgument(2).getAnnotations()[0].getAnnotationClassname());
  assertEquals("macka", msv.getMethodName());
  assertEquals(1, msv.getAnnotations().length);
  assertEquals("jodd.proxetta.fixtures.data.FooAnn", msv.getAnnotations()[0].getAnnotationClassname());
}
origin: oblac/jodd

/**
 * Returns <code>true</code> if method has no argument.
 */
default boolean hasNoArguments() {
  return getArgumentsCount() == 0;
}
origin: oblac/jodd

if (methodInfo.getMethodName().equals(INIT)) {
  if (
      (!firstSuperCtorInitCalled) &&
  throw new ProxettaException("Super call detected in class " + methodInfo.getClassname() + " method: " + methodInfo.getSignature() +
    "\nProxetta can't handle super calls due to VM limitations.");
    mv.visitInsn(POP);
    ProxyTargetReplacement.targetClassAnnotation(mv, methodInfo.getClassInfo(), args);
    wd.proxyApplied = true;
    return;
  super.visitLdcInsn(methodInfo.getMethodName());
  super.visitLdcInsn(methodInfo.getSignature());
origin: oblac/jodd

/**
 * Returns <code>true</code> if method has a return type.
 */
default boolean hasReturnValue() {
  return getReturnType().getOpcode() != AsmUtil.TYPE_VOID;
}
origin: oblac/jodd

public static void storeMethodArgumentFromObject(final MethodVisitor mv, final MethodInfo methodInfo, final int index) {
  int type = methodInfo.getArgument(index).getOpcode();
  int offset = methodInfo.getArgumentOffset(index);
  storeValue(mv, offset, type);
}
origin: org.jodd/jodd-wot

  public boolean apply(MethodInfo methodInfo) {
    int argumentsCount = methodInfo.getArgumentsCount();
    char argumentType = 0;
    if (argumentsCount >= 1) {
      argumentType = methodInfo.getArgumentOpcodeType(1);
    }
    return
        methodInfo.getReturnOpcodeType() == 'V' &&				// void-returning method
        argumentType == 'I' &&									// first argument type
        methodInfo.isTopLevelMethod() &&						// top-level
        methodInfo.getMethodName().startsWith("set") &&			// set*
        (argumentsCount == 2 || argumentsCount == 3);			// number of arguments
  }
}));
origin: oblac/jodd

if (firstTime.value) {
  firstTime.value = false;
  ClassInfo ci = mi.getClassInfo();
  assertEquals("BigFatJoe", ci.getClassname());
  assertEquals(BigFatJoe.class.getPackage().getName(), ci.getPackage());
if (mi.getMethodName().equals("publicMethod")) {
  AnnotationInfo[] anns = mi.getAnnotations();
  assertNotNull(anns);
  assertEquals(3, anns.length);
  assertSame(ai, mi.getAnnotation(Action.class));
  assertEquals(Action.class.getName(), ai.getAnnotationClassname());
  assertEquals("value", ai.getElement("value"));
  assertSame(ai, mi.getAnnotation(PetiteInject.class));
  assertEquals(PetiteInject.class.getName(), ai.getAnnotationClassname());
  assertEquals(0, ai.getElementNames().size());
  assertSame(ai, mi.getAnnotation(Transaction.class));
  assertEquals(Transaction.class.getName(), ai.getAnnotationClassname());
  assertEquals(2, ai.getElementNames().size());
if (mi.getMethodName().equals("superPublicMethod")) {
  AnnotationInfo[] anns = mi.getAnnotations();
  assertNotNull(anns);
  assertEquals(3, anns.length);
  assertSame(ai, mi.getAnnotation(Action.class));
origin: oblac/jodd

/**
 * Visits replacement code for {@link ProxyTarget#targetMethodName()}.
 */
public static void targetMethodName(final MethodVisitor mv, final MethodInfo methodInfo) {
  mv.visitLdcInsn(methodInfo.getMethodName());
}
origin: org.jodd/jodd-wot

if (methodInfo.getMethodName().equals(INIT)) {
  if (
      (firstSuperCtorInitCalled == false) &&
  throw new ProxettaException("Super call detected in class " + methodInfo.getClassname() + " method: " + methodInfo.getSignature() +
    "\nProxetta can't handle super calls due to VM limitations.");
  super.visitLdcInsn(methodInfo.getMethodName());
  super.visitLdcInsn(methodInfo.getSignature());
origin: oblac/jodd

WrapperProxetta proxetta = Proxetta.wrapperProxetta().withAspect(new ProxyAspect(StatCounterAdvice.class, methodInfo -> methodInfo.isPublicMethod() &&
    (methodInfo.getMethodName().equals("hello") || methodInfo.getMethodName().equals("ola"))));
origin: oblac/jodd

varOffset += methodInfo.getAllArgumentsSize();
switch (methodInfo.getReturnType().getOpcode()) {
  case 'V':
    mv.visitInsn(ACONST_NULL);
origin: oblac/jodd

Calc calc = new CalcImpl();
WrapperProxetta proxetta = Proxetta.wrapperProxetta().withAspects(new ProxyAspect(StatCounterAdvice.class, methodInfo -> !methodInfo.isRootMethod() && methodInfo.isPublicMethod()));
jodd.proxettaMethodInfo

Javadoc

Method info provides various information about a method. There are two types of information:
  • java-like, user-readable, that matches the java code, where, for example, packages in class names are separated with a dot;
  • bytecode-related, where information is more suitable for bytecodes, where, for example, packages in class names are separated with a slash.

Most used methods

  • getArgumentsCount
    Returns number of method arguments.
  • getMethodName
    Returns method name.
  • getReturnType
    Returns return TypeInfo.
  • getArgument
    Returns methods argument (1-indexed).
  • isPublicMethod
    Returns true if method is public.
  • getAnnotations
    Returns annotation infos, if there is any.
  • getClassname
    Returns bytecode-like class name.
  • getDeclaredClassName
    Returns declared class name for inner methods or #getClassname() for top-level methods.
  • getSignature
    Returns java-like method signature.
  • isTopLevelMethod
    Returns true if method is declared in top-level class.
  • getAccessFlags
    Returns methods access flags.
  • getClassInfo
    Returns target jodd.proxetta.ClassInfo.
  • getAccessFlags,
  • getClassInfo,
  • getDescription,
  • getExceptions,
  • getAllArgumentsSize,
  • getArgumentOffset,
  • hasAnnotation,
  • hasNoArguments,
  • hasOneArgument,
  • hasReturnValue

Popular in Java

  • Creating JSON documents from java classes using gson
  • startActivity (Activity)
  • setContentView (Activity)
  • requestLocationUpdates (LocationManager)
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registery of org.quartz
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now