本文整理了Java中org.jruby.anno.JRubyMethod.visibility()
方法的一些代码示例,展示了JRubyMethod.visibility()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JRubyMethod.visibility()
方法的具体详情如下:
包路径:org.jruby.anno.JRubyMethod
类名称:JRubyMethod
方法名:visibility
暂无
代码示例来源:origin: org.jruby/jruby-complete
@SuppressWarnings("deprecation")
public JavaMethod constructJavaMethod(RubyModule implementationClass, JavaMethodDescriptor desc, String name, Class c) throws InstantiationException, IllegalAccessException, java.lang.reflect.InvocationTargetException, NoSuchMethodException {
// In order to support older versions of generated JavaMethod invokers, we check for the Version
// annotation to be present and > 0. If absent, we use a thread local to allow the deprecated constructor
// to still provide a final method name.
DynamicMethod.Version version = (DynamicMethod.Version) c.getAnnotation(DynamicMethod.Version.class);
JavaMethod ic;
if (version == null) {
// Old constructor with no name, use thread-local to pass it.
JavaMethod.NAME_PASSER.set(name);
try {
ic = (JavaMethod) c.getConstructor(RubyModule_and_Visibility).newInstance(implementationClass, desc.anno.visibility());
} finally {
JavaMethod.NAME_PASSER.remove();
}
} else {
// New constructor with name.
ic = (JavaMethod) c.getConstructor(RubyModule_and_Visibility_and_Name).newInstance(implementationClass, desc.anno.visibility(), name);
}
return ic;
}
代码示例来源:origin: org.jruby/jruby-core
@SuppressWarnings("deprecation")
public JavaMethod constructJavaMethod(RubyModule implementationClass, JavaMethodDescriptor desc, String name, Class c) throws InstantiationException, IllegalAccessException, java.lang.reflect.InvocationTargetException, NoSuchMethodException {
// In order to support older versions of generated JavaMethod invokers, we check for the Version
// annotation to be present and > 0. If absent, we use a thread local to allow the deprecated constructor
// to still provide a final method name.
DynamicMethod.Version version = (DynamicMethod.Version) c.getAnnotation(DynamicMethod.Version.class);
JavaMethod ic;
if (version == null) {
// Old constructor with no name, use thread-local to pass it.
JavaMethod.NAME_PASSER.set(name);
try {
ic = (JavaMethod) c.getConstructor(RubyModule_and_Visibility).newInstance(implementationClass, desc.anno.visibility());
} finally {
JavaMethod.NAME_PASSER.remove();
}
} else {
// New constructor with name.
ic = (JavaMethod) c.getConstructor(RubyModule_and_Visibility_and_Name).newInstance(implementationClass, desc.anno.visibility(), name);
}
return ic;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public ReflectedJavaMultiMethod(
RubyModule implementationClass, List<Method> methods, List<JRubyMethod> annotations) {
super(implementationClass, annotations.get(1).visibility());
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public ReflectedJavaMultiMethod(
RubyModule implementationClass, List<Method> methods, List<JRubyMethod> annotations) {
super(implementationClass, annotations.get(1).visibility());
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
String implClass = anno.meta() ? "singletonClass" : "cls";
out.println(" javaMethod = new " + annotatedBindingName + "(" + implClass + ", Visibility." + anno.visibility() + ");");
out.println(" populateMethod(javaMethod, " +
"-1, \"" +
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
String implClass = anno.meta() ? "singletonClass" : "cls";
out.println(" javaMethod = new " + annotatedBindingName + "(" + implClass + ", Visibility." + anno.visibility() + ");");
out.println(" populateMethod(javaMethod, " +
"-1, \"" +
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
String implClass = anno.meta() ? "singletonClass" : "cls";
out.println(" javaMethod = new " + annotatedBindingName + "(" + implClass + ", Visibility." + anno.visibility() + ");");
out.println(" populateMethod(javaMethod, " +
+AnnotationHelper.getArityValue(anno, actualRequired) + ", \""
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
String implClass = anno.meta() ? "singletonClass" : "cls";
out.println(" javaMethod = new " + annotatedBindingName + "(" + implClass + ", Visibility." + anno.visibility() + ");");
out.println(" populateMethod(javaMethod, " +
+AnnotationHelper.getArityValue(anno, actualRequired) + ", \""
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public ReflectedJavaMethod(
RubyModule implementationClass, Method method, JRubyMethod annotation) {
super(implementationClass, annotation.visibility());
this.method = method;
Class<?>[] params = method.getParameterTypes();
this.needsBlock = params.length > 0 && params[params.length - 1] == Block.class;
this.isStatic = Modifier.isStatic(method.getModifiers());
Arity arity = Arity.fromAnnotation(annotation, params, this.isStatic);
setArity(arity);
this.required = arity.getValue() >= 0 ? arity.getValue() : Math.abs(arity.getValue())-1;
this.optional = annotation.optional();
this.rest = annotation.rest();
this.needsThreadContext = params.length > 0 && params[0] == ThreadContext.class;
this.argsAsIs = ! isStatic && optional == 0 && !rest && !needsBlock && !needsThreadContext;
if (rest) {
max = -1;
} else {
max = required + optional;
}
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public ReflectedJavaMethod(
RubyModule implementationClass, Method method, JRubyMethod annotation) {
super(implementationClass, annotation.visibility());
this.method = method;
Class<?>[] params = method.getParameterTypes();
this.needsBlock = params.length > 0 && params[params.length - 1] == Block.class;
this.isStatic = Modifier.isStatic(method.getModifiers());
Arity arity = Arity.fromAnnotation(annotation, params, this.isStatic);
setArity(arity);
this.required = arity.getValue() >= 0 ? arity.getValue() : Math.abs(arity.getValue())-1;
this.optional = annotation.optional();
this.rest = annotation.rest();
this.needsThreadContext = params.length > 0 && params[0] == ThreadContext.class;
this.argsAsIs = ! isStatic && optional == 0 && !rest && !needsBlock && !needsThreadContext;
if (rest) {
max = -1;
} else {
max = required + optional;
}
}
代码示例来源: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
out.println(" javaMethod = new " + annotatedBindingName + "(" + implClass + ", Visibility." + anno.visibility() + ", \"" + baseName + "\");");
out.println(" populateMethod(javaMethod, " +
join(-1,
代码示例来源:origin: org.jruby/jruby-core
out.println(" javaMethod = new " + annotatedBindingName + "(" + implClass + ", Visibility." + anno.visibility() + ", \"" + baseName + "\");");
out.println(" populateMethod(javaMethod, " +
join(-1,
代码示例来源:origin: org.jruby/jruby-complete
out.println(" javaMethod = new " + annotatedBindingName + "(" + implClass + ", Visibility." + anno.visibility() + ", \"" + baseName + "\");");
out.println(" populateMethod(javaMethod, " +
join(AnnotationHelper.getArityValue(anno, actualRequired),
代码示例来源:origin: org.jruby/jruby-core
out.println(" javaMethod = new " + annotatedBindingName + "(" + implClass + ", Visibility." + anno.visibility() + ", \"" + baseName + "\");");
out.println(" populateMethod(javaMethod, " +
join(AnnotationHelper.getArityValue(anno, actualRequired),
代码示例来源:origin: com.ning.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.kill-bill.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: org.kill-bill.billing/killbill-osgi-bundles-jruby
if (DEBUG) out.println(" min: " + info.getMin() + ", max: " + info.getMax());
JavaMethod ic = (JavaMethod)c.getConstructor(new Class[]{RubyModule.class, Visibility.class}).newInstance(new Object[]{implementationClass, desc1.anno.visibility()});
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
if (DEBUG) out.println(" min: " + info.getMin() + ", max: " + info.getMax());
JavaMethod ic = (JavaMethod)c.getConstructor(new Class[]{RubyModule.class, Visibility.class}).newInstance(new Object[]{implementationClass, desc1.anno.visibility()});
代码示例来源: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);
}
内容来源于网络,如有侵权,请联系作者删除!