org.jruby.Ruby.getJavaSupport()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(182)

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

Ruby.getJavaSupport介绍

暂无

代码示例

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

@SuppressWarnings("deprecation")
public static RubyModule getProxyClass(final Ruby runtime, final Class<?> clazz) {
  RubyModule proxy = runtime.getJavaSupport().getUnfinishedProxy(clazz);
  if (proxy != null) return proxy;
  return runtime.getJavaSupport().getProxyClassFromCache(clazz);
}

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

public JavaConstructor(Ruby runtime, Constructor<?> constructor) {
  super(runtime, runtime.getJavaSupport().getJavaConstructorClass(), constructor.getParameterTypes());
  this.constructor = constructor;
  //this.objectConverter = JavaUtil.getJavaConverter(constructor.getDeclaringClass());
}

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

public JavaArray(Ruby runtime, Object array) {
  super(runtime, runtime.getJavaSupport().getJavaArrayClass(), array);
  assert array.getClass().isArray();
  javaConverter = JavaUtil.getJavaConverter(array.getClass().getComponentType());
}

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

public JavaArray(Ruby runtime, Object array) {
  super(runtime, runtime.getJavaSupport().getJavaArrayClass(), array);
  assert array.getClass().isArray();
  javaConverter = JavaUtil.getJavaConverter(array.getClass().getComponentType());
}

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

State(final Ruby runtime, final Class superClass) {
  if (superClass == null) {
    staticNames = new HashMap<>(8);
    instanceNames = new HashMap<>(26);
  } else {
    staticNames = new HashMap<>(runtime.getJavaSupport().getStaticAssignedNames().get(superClass));
    instanceNames = new HashMap<>(runtime.getJavaSupport().getInstanceAssignedNames().get(superClass));
  }
  staticNames.putAll(STATIC_RESERVED_NAMES);
  instanceNames.putAll(INSTANCE_RESERVED_NAMES);
}

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

private static RubyModule getPackageModule(final Ruby runtime, final String name) {
  final RubyModule javaModule = runtime.getJavaSupport().getJavaModule();
  final IRubyObject packageModule = javaModule.getConstantAt(name);
  if ( packageModule instanceof RubyModule ) return (RubyModule) packageModule;
  final String packageName;
  if ( "Default".equals(name) ) packageName = "";
  else {
    Matcher match = CAMEL_CASE_PACKAGE_SPLITTER.matcher(name);
    packageName = match.replaceAll("$1.$2").toLowerCase();
  }
  return createPackageModule(runtime, javaModule, name, packageName);
}

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

public JavaClass(Ruby runtime, Class<?> javaClass) {
  super(runtime, (RubyClass) runtime.getJavaSupport().getJavaClassClass(), javaClass);
  if (javaClass.isInterface()) {
    initializer = new InterfaceInitializer(javaClass);
  } else if (!(javaClass.isArray() || javaClass.isPrimitive())) {
    initializer = new ClassInitializer(javaClass);
  } else {
    initializer = DUMMY_INITIALIZER;
  }
}

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

public static JavaClass forNameQuiet(Ruby runtime, String className) {
  synchronized (JavaClass.class) {
    Class<?> klass = runtime.getJavaSupport().loadJavaClassQuiet(className);
    return JavaClass.get(runtime, klass);
  }
}

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

public static RubyClass createConcreteJavaProxy(final ThreadContext context) {
  final Ruby runtime = context.runtime;
  final RubyClass JavaProxy = runtime.getJavaSupport().getJavaProxyClass();
  RubyClass ConcreteJavaProxy = runtime.defineClass("ConcreteJavaProxy", JavaProxy, ALLOCATOR);
  initialize(ConcreteJavaProxy);
  return ConcreteJavaProxy;
}

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

public static RubyClass createMapJavaProxy(final Ruby runtime) {
  RubyClass MapJavaProxy = runtime.defineClass(
    "MapJavaProxy", runtime.getJavaSupport().getConcreteProxyClass(), ALLOCATOR
  );
  // this is done while proxy class is created.
  // See org.jruby.javasuppoer.java.createProxyClass()
  // MapJavaProxy.defineAnnotatedMethods(MapJavaProxy.class);
  ConcreteJavaProxy.initialize(MapJavaProxy);
  return MapJavaProxy;
}

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

@JRubyMethod(module = true)
public static IRubyObject java_to_ruby(ThreadContext context, IRubyObject recv, IRubyObject ary) {
  if (!(ary instanceof ArrayJavaProxy)) {
    throw context.runtime.newTypeError(ary, context.runtime.getJavaSupport().getArrayProxyClass());
  }
  return ((ArrayJavaProxy)ary).to_a(context);
}

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

@SuppressWarnings("unchecked")
@JRubyMethod(required = 1)
public IRubyObject annotation(final IRubyObject annoClass) {
  final Ruby runtime = getRuntime();
  if ( ! ( annoClass instanceof JavaClass ) ) {
    throw runtime.newTypeError(annoClass, runtime.getJavaSupport().getJavaClassClass());
  }
  final Class annotation = ((JavaClass) annoClass).javaClass();
  return Java.getInstance(runtime, javaClass().getAnnotation(annotation));
}

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

@SuppressWarnings("unchecked")
@JRubyMethod(name = "annotation_present?", required = 1)
public IRubyObject annotation_present_p(final IRubyObject annoClass) {
  final Ruby runtime = getRuntime();
  if ( ! ( annoClass instanceof JavaClass ) ) {
    throw runtime.newTypeError(annoClass, runtime.getJavaSupport().getJavaClassClass());
  }
  final Class annotation = ((JavaClass) annoClass).javaClass();
  return runtime.newBoolean( javaClass().isAnnotationPresent(annotation) );
}

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

private static IRubyObject invokeProxyClassInherited(final ThreadContext context,
  final IRubyObject clazz, final IRubyObject subclazz) {
  final JavaSupport javaSupport = context.runtime.getJavaSupport();
  RubyClass javaProxyClass = javaSupport.getJavaProxyClass().getMetaClass();
  Helpers.invokeAs(context, javaProxyClass, clazz, "inherited", subclazz, Block.NULL_BLOCK);
  if ( ! ( subclazz instanceof RubyClass ) ) {
    throw context.runtime.newTypeError(subclazz, context.runtime.getClassClass());
  }
  setupJavaSubclass(context, (RubyClass) subclazz);
  return context.nil;
}

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

public static RubyClass createInterfaceJavaProxy(ThreadContext context) {
  final Ruby runtime = context.runtime;
  RubyClass InterfaceJavaProxy = runtime.defineClass(
    "InterfaceJavaProxy", runtime.getJavaSupport().getJavaProxyClass(), ALLOCATOR
  );
  RubyClass JavaInterfaceExtended = runtime.defineClass(
    "JavaInterfaceExtender", runtime.getObject(), runtime.getObject().getAllocator()
  );
  JavaInterfaceExtended.defineAnnotatedMethods(JavaInterfaceExtender.class);
  return InterfaceJavaProxy;
}

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

public static RubyClass createArrayJavaProxy(ThreadContext context) {
  Ruby runtime = context.runtime;
  RubyClass arrayJavaProxy = runtime.defineClass("ArrayJavaProxy",
      runtime.getJavaSupport().getJavaProxyClass(),
      ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
  RubyClass singleton = arrayJavaProxy.getSingletonClass();
  singleton.addMethod("new", new ArrayNewMethod(singleton, Visibility.PUBLIC));
  arrayJavaProxy.defineAnnotatedMethods(ArrayJavaProxy.class);
  arrayJavaProxy.includeModule(runtime.getEnumerable());
  return arrayJavaProxy;
}

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

@SuppressWarnings("unchecked")
@JRubyMethod(name = "annotation_present?")
public IRubyObject annotation_present_p(final IRubyObject annoClass) {
  if ( ! ( annoClass instanceof JavaClass ) ) {
    throw getRuntime().newTypeError(annoClass, getRuntime().getJavaSupport().getJavaClassClass());
  }
  final Class annotation = ((JavaClass) annoClass).javaClass();
  return getRuntime().newBoolean( accessibleObject().isAnnotationPresent(annotation) );
}

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

@SuppressWarnings("unchecked")
@JRubyMethod
public IRubyObject annotation(final IRubyObject annoClass) {
  if ( ! ( annoClass instanceof JavaClass ) ) {
    throw getRuntime().newTypeError(annoClass, getRuntime().getJavaSupport().getJavaClassClass());
  }
  final Class annotation = ((JavaClass) annoClass).javaClass();
  return Java.getInstance(getRuntime(), accessibleObject().getAnnotation(annotation));
}

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

@SuppressWarnings("unchecked")
@JRubyMethod
public IRubyObject annotation(IRubyObject annoClass) {
  if (!(annoClass instanceof JavaClass)) {
    throw getRuntime().newTypeError(annoClass, getRuntime().getJavaSupport().getJavaClassClass());
  }
  return Java.getInstance(getRuntime(), accessibleObject().getAnnotation(((JavaClass) annoClass).javaClass()));
}

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

@JRubyMethod(name = "annotation_present?")
public IRubyObject annotation_present_p(IRubyObject annoClass) {
  if (!(annoClass instanceof JavaClass)) {
    throw getRuntime().newTypeError(annoClass, getRuntime().getJavaSupport().getJavaClassClass());
  }
  return getRuntime().newBoolean(this.accessibleObject().isAnnotationPresent(((JavaClass) annoClass).javaClass()));
}

相关文章

Ruby类方法