org.jboss.errai.codegen.meta.MetaClass.getDeclaredMethod()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(4.9k)|赞(0)|评价(0)|浏览(113)

本文整理了Java中org.jboss.errai.codegen.meta.MetaClass.getDeclaredMethod()方法的一些代码示例,展示了MetaClass.getDeclaredMethod()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MetaClass.getDeclaredMethod()方法的具体详情如下:
包路径:org.jboss.errai.codegen.meta.MetaClass
类名称:MetaClass
方法名:getDeclaredMethod

MetaClass.getDeclaredMethod介绍

暂无

代码示例

代码示例来源:origin: errai/errai

public static MetaMethod get(final Method method) {
 return get(method.getDeclaringClass()).getDeclaredMethod(method.getName(), method.getParameterTypes());
}

代码示例来源:origin: org.jboss.errai/errai-codegen

public static MetaMethod get(final Method method) {
 return get(method.getDeclaringClass()).getDeclaredMethod(method.getName(), method.getParameterTypes());
}

代码示例来源:origin: errai/errai

static MetaMethod getOverridenMethod(final MetaMethod specializingMethod) {
 final MetaClass[] producerParams = GraphUtil.getParameterTypes(specializingMethod);
 MetaClass enclosingType = specializingMethod.getDeclaringClass();
 MetaMethod specializedMethod = null;
 while (specializedMethod == null && enclosingType.getSuperClass() != null) {
  enclosingType = enclosingType.getSuperClass();
  specializedMethod = enclosingType.getDeclaredMethod(specializingMethod.getName(), producerParams);
 }
 return specializedMethod;
}

代码示例来源:origin: errai/errai

@Test
public void testFieldWithSingleUpperBoundedTypeVarParam() throws Exception {
 final MetaClass metaClass = getMetaClass(ClassWithGenericCollections.class);
 final MetaMethod field = metaClass.getDeclaredMethod("hasSingleBoundedTypeVarFromSelf", new Class[] {});
 assertNotNull(field);
 final MetaTypeVariable returnType = (MetaTypeVariable) field.getGenericReturnType();
 assertEquals("B", returnType.getName());
 assertEquals("Should have a single upper bound",
     Arrays.asList(getMetaClass(Serializable.class)),
     Arrays.asList(returnType.getBounds()));
}

代码示例来源:origin: errai/errai

@Test
public void testFieldWithTwoUpperBoundedTypeVarParam() throws Exception {
 final MetaClass metaClass = getMetaClass(ClassWithGenericCollections.class);
 final MetaMethod field = metaClass.getDeclaredMethod("hasDoubleBoundedTypeVarFromSelf", new Class[] {});
 assertNotNull(field);
 final MetaTypeVariable returnType = (MetaTypeVariable) field.getGenericReturnType();
 assertEquals("B", returnType.getName());
 assertEquals("Should have two upper bounds",
     Arrays.asList(getMetaClass(Collection.class), getMetaClass(Serializable.class)),
     Arrays.asList(returnType.getBounds()));
}

代码示例来源:origin: errai/errai

@Override
public void makeMethodAccessible(final ClassStructureBuilder<?> classBuilder,
                 final MetaMethod method,
                 final Modifier[] modifiers) {
 final MetaMethod erasedMethod = method.getDeclaringClass().getErased().getDeclaredMethod(method.getName(),
     getErasedParamterTypes(method));
 final List<Parameter> wrapperDefParms = new ArrayList<Parameter>();
 if (!erasedMethod.isStatic()) {
  wrapperDefParms.add(Parameter.of(erasedMethod.getDeclaringClass().getErased(), "instance"));
 }
 final List<Parameter> methodDefParms = DefParameters.from(erasedMethod).getParameters();
 wrapperDefParms.addAll(methodDefParms);
 Annotation[] annotations = NO_ANNOTATIONS;
 for (MetaParameter p : erasedMethod.getParameters()) {
  if (p.getType().getCanonicalName().equals("long")) {
   annotations = new Annotation[] { UNSAFE_NATIVE_LONG_ANNOTATION };
  }
 }
 if (erasedMethod.getReturnType().getCanonicalName().equals("long")) {
  annotations = new Annotation[] { UNSAFE_NATIVE_LONG_ANNOTATION };
 }
 classBuilder.publicMethod(erasedMethod.getReturnType(), PrivateAccessUtil.getPrivateMethodName(method))
     .annotatedWith(annotations)
     .parameters(DefParameters.fromParameters(wrapperDefParms))
     .modifiers(appendJsni(modifiers))
     .body()
     ._(StringStatement.of(JSNIUtil.methodAccess(erasedMethod)))
     .finish();
}

代码示例来源:origin: org.jboss.errai/errai-codegen-gwt

@Override
public void makeMethodAccessible(final ClassStructureBuilder<?> classBuilder,
                 final MetaMethod method,
                 final Modifier[] modifiers) {
 final MetaMethod erasedMethod = method.getDeclaringClass().getErased().getDeclaredMethod(method.getName(),
     getErasedParamterTypes(method));
 final List<Parameter> wrapperDefParms = new ArrayList<Parameter>();
 if (!erasedMethod.isStatic()) {
  wrapperDefParms.add(Parameter.of(erasedMethod.getDeclaringClass().getErased(), "instance"));
 }
 final List<Parameter> methodDefParms = DefParameters.from(erasedMethod).getParameters();
 wrapperDefParms.addAll(methodDefParms);
 Annotation[] annotations = NO_ANNOTATIONS;
 for (MetaParameter p : erasedMethod.getParameters()) {
  if (p.getType().getCanonicalName().equals("long")) {
   annotations = new Annotation[] { UNSAFE_NATIVE_LONG_ANNOTATION };
  }
 }
 if (erasedMethod.getReturnType().getCanonicalName().equals("long")) {
  annotations = new Annotation[] { UNSAFE_NATIVE_LONG_ANNOTATION };
 }
 classBuilder.publicMethod(erasedMethod.getReturnType(), PrivateAccessUtil.getPrivateMethodName(method))
     .annotatedWith(annotations)
     .parameters(DefParameters.fromParameters(wrapperDefParms))
     .modifiers(appendJsni(modifiers))
     .body()
     ._(StringStatement.of(JSNIUtil.methodAccess(erasedMethod)))
     .finish();
}

相关文章