org.jruby.anno.JRubyMethod类的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(11.5k)|赞(0)|评价(0)|浏览(65)

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

JRubyMethod介绍

暂无

代码示例

代码示例来源:origin: bazelbuild/bazel

@JRubyMethod
public IRubyObject clear(ThreadContext context) {
  this.storage.clear();
  return this.storage;
}

代码示例来源:origin: org.jruby/jruby-complete

int actualRequired = calculateActualRequired(method, method.getParameters().size(), anno.optional(), anno.rest(), isStatic, info.hasContext, info.hasBlock);
    isStatic,
    actualRequired,
    anno.optional(),
    true,
    anno.frame());
String implClass = anno.meta() ? "singletonClass" : "cls";
String baseName = getBaseName(anno.name(), method);
out.println("        javaMethod = new " + annotatedBindingName + "(" + implClass + ", Visibility." + anno.visibility() + ", \"" + baseName + "\");");
out.println("        populateMethod(javaMethod, " +
      join(-1,
          quote(method.getSimpleName()),
          isStatic,
          anno.notImplemented(),
          ((TypeElement) method.getEnclosingElement()).getQualifiedName() + ".class",
          quote(method.getSimpleName()),

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

hasMeta |= anno.meta();
hasModule |= anno.module();
hasCompat |= anno.compat() != CompatVersion.BOTH;
CharSequence name = anno.name().length == 0 ? method.getSimpleName() : anno.name()[0];
  if (anno.compat() == CompatVersion.RUBY1_8) {
    methodsHash = staticAnnotatedMethods1_8;
  } else if (anno.compat() == CompatVersion.RUBY1_9) {
    methodsHash = staticAnnotatedMethods1_9;
  } else if (anno.compat() == CompatVersion.RUBY2_0) {
    methodsHash = staticAnnotatedMethods2_0;
  } else {
  if (anno.compat() == CompatVersion.RUBY1_8) {
    methodsHash = annotatedMethods1_8;
  } else if (anno.compat() == CompatVersion.RUBY1_9) {
    methodsHash = annotatedMethods1_9;
  } else if (anno.compat() == CompatVersion.RUBY2_0) {
    methodsHash = annotatedMethods2_0;
  } else {
if (anno.frame()) {
  if (DEBUG)
    System.out.println("Method has frame = true: " + methodDescs.get(0).getEnclosingElement() + ":" + methodDescs);
  frame = true;
if (anno.scope()) {
  if (DEBUG)

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

if (jrubyMethod.frame()) {
  frame = true;
if (jrubyMethod.scope()) {
  scope = true;
for (FrameField field : jrubyMethod.reads()) {
  frame |= field.needsFrame();
  scope |= field.needsScope();
for (FrameField field : jrubyMethod.writes()) {
  frame |= field.needsFrame();
  scope |= field.needsScope();
if (jrubyMethod.meta()) {
  singletonClass = module.getSingletonClass();
  dynamicMethod.setImplementationClass(singletonClass);
  if (jrubyMethod.name().length == 0) {
    baseName = desc.name;
    singletonClass.addMethod(baseName, dynamicMethod);
  } else {
    baseName = jrubyMethod.name()[0];
    for (String name : jrubyMethod.name()) {
      singletonClass.addMethod(name, dynamicMethod);
  if (jrubyMethod.alias().length > 0) {
    for (String alias : jrubyMethod.alias()) {
      singletonClass.defineAlias(alias, baseName);

代码示例来源:origin: org.jruby/jruby-complete

hasMeta |= anno.meta();
hasModule |= anno.module();
if (anno.compat() == org.jruby.CompatVersion.RUBY1_8) continue;
CharSequence name = anno.name().length == 0 ? method.getSimpleName() : anno.name()[0];
JRubyMethod anno = decl.getAnnotation(JRubyMethod.class);
if (anno.omit()) continue;
JRubyMethod anno = decl.getAnnotation(JRubyMethod.class);
if (anno.omit()) continue;
if (decl.getSimpleName().equals(rubyName) && decl.getAnnotation(JRubyMethod.class).name().length <= 1) {
  simpleNames.add(decl);
  continue;

代码示例来源:origin: org.jruby/jruby-complete

false);
    int handleOffset = calculateHandleOffset(method.getParameters().size(), anno.required(), anno.optional(), anno.rest(), isStatic, hasContext, hasBlock);
    meta |= anno.meta();
mv.getstatic(p(Visibility.class), anno.visibility().name(), ci(Visibility.class));
mv.ldc(AnnotationBinder.getBaseName(anno.name(), methods.get(0)));
mv.ldc(encodeSignature(0, 0, 0, 0, 0, true, false));
mv.ldc(true);
mv.ldc(anno.notImplemented());

代码示例来源:origin: org.jruby/jruby-complete

public void generateMethodAddCalls(ExecutableElement md, JRubyMethod anno) {
  generateMethodAddCalls(md, anno.meta(), anno.module(), anno.name(), anno.alias());
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

if (anno.frame() || (anno.reads() != null && anno.reads().length >= 1) || (anno.writes() != null && anno.writes().length >= 1)) {
    ASTInspector.addFrameAwareMethods(anno.name());
clsmod.defineAnnotatedMethod(entry.getKey(), entry.getValue(), methodFactory);
for (JavaMethodDescriptor desc : entry.getValue()) {
  if (!desc.anno.omit()) runtime.addBoundMethod(desc.declaringClassName, desc.name, entry.getKey());
clsmod.defineAnnotatedMethod(entry.getKey(), entry.getValue(), methodFactory);
for (JavaMethodDescriptor desc : entry.getValue()) {
  if (!desc.anno.omit()) runtime.addBoundMethod(desc.declaringClassName, desc.name, entry.getKey());
clsmod.defineAnnotatedMethod(entry.getKey(), entry.getValue(), methodFactory);
for (JavaMethodDescriptor desc : entry.getValue()) {
  if (!desc.anno.omit()) runtime.addBoundMethod(desc.declaringClassName, desc.name, entry.getKey());
clsmod.defineAnnotatedMethod(entry.getKey(), entry.getValue(), methodFactory);
for (JavaMethodDescriptor desc : entry.getValue()) {
  if (!desc.anno.omit()) runtime.addBoundMethod(desc.declaringClassName, desc.name, entry.getKey());
clsmod.defineAnnotatedMethod(entry.getKey(), entry.getValue(), methodFactory);
for (JavaMethodDescriptor desc : entry.getValue()) {
  if (!desc.anno.omit()) runtime.addBoundMethod(desc.declaringClassName, desc.name, entry.getKey());
clsmod.defineAnnotatedMethod(entry.getKey(), entry.getValue(), methodFactory);
for (JavaMethodDescriptor desc : entry.getValue()) {
  if (!desc.anno.omit()) runtime.addBoundMethod(desc.declaringClassName, desc.name, entry.getKey());
clsmod.defineAnnotatedMethod(entry.getKey(), entry.getValue(), methodFactory);

代码示例来源:origin: org.jruby/jruby-complete

if (anno.compat() == org.jruby.CompatVersion.RUBY1_8) continue;
final String[] names = anno.name();
String name = names.length == 0 ? method.getName() : names[0];
if (anno.reads().length > 0 && readGroups == Collections.EMPTY_MAP) readGroups = new HashMap<>();
if (anno.writes().length > 0 && writeGroups == Collections.EMPTY_MAP) writeGroups = new HashMap<>();

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

public static void addMethodNamesToSet(Set<String> set, JRubyMethod jrubyMethod, String simpleName) {
  if (jrubyMethod.name().length == 0) {
    set.add(simpleName);
  } else {
    set.addAll(Arrays.asList(jrubyMethod.name()));
  }

  if (jrubyMethod.alias().length > 0) {
    set.addAll(Arrays.asList(jrubyMethod.alias()));
  }
}

代码示例来源:origin: org.jruby/jruby-complete

public static void groupFrameFields(Map<Set<FrameField>, List<String>> readGroups, Map<Set<FrameField>, List<String>> writeGroups, JRubyMethod anno, String simpleName) {
  if (anno.reads().length > 0) {
    Set<FrameField> reads = new HashSet<>(Arrays.asList(anno.reads()));
    List<String> nameList = readGroups.get(reads);
    if (nameList == null) readGroups.put(reads, nameList = new ArrayList<>());
    if (anno.name().length == 0) {
      nameList.add(simpleName);
    } else {
      nameList.addAll(Arrays.asList(anno.name()));
    }
  }
  if (anno.writes().length > 0) {
    Set<FrameField> writes = new HashSet<>(Arrays.asList(anno.writes()));
    List<String> nameList = writeGroups.get(writes);
    if (nameList == null) writeGroups.put(writes, nameList = new ArrayList<>());
    if (anno.name().length == 0) {
      nameList.add(simpleName);
    } else {
      nameList.addAll(Arrays.asList(anno.name()));
    }
  }
}

代码示例来源:origin: org.jruby/jruby-complete

DescriptorInfo info = new DescriptorInfo(desc1);
if (desc1.anno.frame()) {
  notImplemented = notImplemented || desc.anno.notImplemented();
    desc1.anno.visibility(),
    desc1.name,
    (min == max) ?

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

/**
 * Use code generation to provide a method handle based on an annotated Java
 * method.
 * 
 * @see org.jruby.runtime.MethodFactory#getAnnotatedMethod
 */
public DynamicMethod getAnnotatedMethod(RubyModule implementationClass, JavaMethodDescriptor desc) {
  String javaMethodName = desc.name;
  try {
    Class c = getAnnotatedMethodClass(Arrays.asList(desc));
    JavaMethod ic = (JavaMethod)c.getConstructor(new Class[]{RubyModule.class, Visibility.class}).newInstance(new Object[]{implementationClass, desc.anno.visibility()});
    TypePopulator.populateMethod(
        ic,
        Arity.fromAnnotation(desc.anno, desc.actualRequired).getValue(),
        javaMethodName,
        desc.isStatic,
        CallConfiguration.getCallConfigByAnno(desc.anno),
        desc.anno.notImplemented(),
        desc.getDeclaringClass(),
        desc.name,
        desc.getReturnClass(),
        desc.getParameterClasses());
    return ic;
  } catch(Exception e) {
    e.printStackTrace();
    throw implementationClass.getRuntime().newLoadError(e.getMessage());
  }
}

代码示例来源:origin: org.jruby/jruby-complete

/**
 * Produce a CallConfiguration name that represents what must be prepared around calls to
 * the method with this annotation.
 */
public static CallConfiguration getCallConfigByAnno(JRubyMethod anno) {
  return getCallConfig(anno.frame());
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

public static String getCallConfigNameByAnno(JRubyMethod anno) {
  return getCallConfigName(anno.frame(), anno.scope());
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

public void generateMethodAddCalls(ExecutableElement md, JRubyMethod jrubyMethod) {
  if (jrubyMethod.meta()) {
    defineMethodOnClass("javaMethod", "singletonClass", jrubyMethod, md);
  } else {
    defineMethodOnClass("javaMethod", "cls", jrubyMethod, md);
    if (jrubyMethod.module()) {
      out.println("        moduleMethod = populateModuleMethod(cls, javaMethod);");
      defineMethodOnClass("moduleMethod", "singletonClass", jrubyMethod, md);
    }
  }
  //                }
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

@Override
public DynamicMethod getAnnotatedMethod(RubyModule implementationClass, List<JavaMethodDescriptor> descs) {
  JavaMethodDescriptor desc1 = descs.get(0);
  
  if (desc1.anno.frame()) {
    // super logic does not work yet because we need to take impl class
    // and method name from the DynamicMethod#call call, so punt to
    // generated class for now
    return super.getAnnotatedMethod(implementationClass, descs);
  }
  if (!Modifier.isPublic(desc1.getDeclaringClass().getModifiers())) {
    LOG.warn("warning: binding non-public class {}; reflected handles won't work", desc1.declaringClassName);
  }
  DescriptorInfo info = new DescriptorInfo(descs);
  MethodHandle[] targets = buildAnnotatedMethodHandles(implementationClass.getRuntime(), descs, implementationClass);
  
  return new HandleMethod(implementationClass, desc1.anno.visibility(), CallConfiguration.getCallConfig(info.isFrame(), info.isScope()), targets, null);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

Modifier.isStatic(method0.getModifiers()),
      CallConfiguration.getCallConfigByAnno(anno0),
      anno0.notImplemented());
  return ic;
} catch (Exception e) {

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

String name = anno.name().length == 0 ? method.getName() : anno.name()[0];
  if (anno.compat() == RUBY1_8) {
    methodsHash = staticAnnotatedMethods1_8;
  } else if (anno.compat() == RUBY1_9) {
    methodsHash = staticAnnotatedMethods1_9;
  } else if (anno.compat() == RUBY2_0) {
    methodsHash = staticAnnotatedMethods2_0;
  } else {
  if (anno.compat() == RUBY1_8) {
    methodsHash = annotatedMethods1_8;
  } else if (anno.compat() == RUBY1_9) {
    methodsHash = annotatedMethods1_9;
  } else if (anno.compat() == RUBY2_0) {
    methodsHash = annotatedMethods2_0;
  } else {

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

public boolean defineAnnotatedMethod(Method method, MethodFactory methodFactory) { 
  JRubyMethod jrubyMethod = method.getAnnotation(JRubyMethod.class);
  if (jrubyMethod == null) return false;
  CompatVersion compatVersion = getRuntime().getInstanceConfig().getCompatVersion();
  if (shouldBindMethod(compatVersion, jrubyMethod.compat())) {
    JavaMethodDescriptor desc = new JavaMethodDescriptor(method);
    DynamicMethod dynamicMethod = methodFactory.getAnnotatedMethod(this, desc);
    define(this, desc, method.getName(), dynamicMethod);
    return true;
  }
  return false;
}

相关文章