org.jruby.RubyClass.getReifiedClass()方法的使用及代码示例

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

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

RubyClass.getReifiedClass介绍

暂无

代码示例

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

@Override
public Class toJavaClass(RubyModule clazz) {
  if (clazz instanceof RubyClass) {
    RubyClass rc = (RubyClass) clazz;
    Class c = rc.getReifiedClass();
    if (c!=null)    return c;   // is this right?
  }
  return RubyObject.class;
}

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

public static Class<? extends IRubyObject> nearestReifiedClass(final RubyClass klass) {
  RubyClass current = klass;
  do {
    Class<? extends IRubyObject> reified = current.getReifiedClass();
    if ( reified != null ) return reified;
    current = current.getSuperClass();
  }
  while ( current != null );
  return null;
}

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

public static Class<? extends IRubyObject> nearestReifiedClass(final RubyClass klass) {
  RubyClass current = klass;
  do {
    Class<? extends IRubyObject> reified = current.getReifiedClass();
    if ( reified != null ) return reified;
    current = current.getSuperClass();
  }
  while ( current != null );
  return null;
}

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

public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
    // if we haven't been here before, reify the class
    Class reifiedClass = klazz.getReifiedClass();
    if (proxyConstructor == null || proxyConstructor.getDeclaringClass() != reifiedClass) {
      if (reifiedClass == null) {
        reifiedClass = Java.generateRealClass(klazz);
      }
      proxyConstructor = Java.getRealClassConstructor(runtime, reifiedClass);
    }
    IRubyObject newObj = Java.constructProxy(runtime, proxyConstructor, klazz);
    return newObj;
  }
});

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

public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
    // if we haven't been here before, reify the class
    Class reifiedClass = klazz.getReifiedClass();
    if (proxyConstructor == null || proxyConstructor.getDeclaringClass() != reifiedClass) {
      if (reifiedClass == null) {
        reifiedClass = Java.generateRealClass(klazz);
      }
      proxyConstructor = Java.getRealClassConstructor(runtime, reifiedClass);
    }
    IRubyObject newObj = Java.constructProxy(runtime, proxyConstructor, klazz);
    return newObj;
  }
});

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

public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
    // if we haven't been here before, reify the class
    Class reifiedClass = klazz.getReifiedClass();
    if (proxyConstructor == null || proxyConstructor.getDeclaringClass() != reifiedClass) {
      if (reifiedClass == null) {
        reifiedClass = Java.generateRealClass(klazz);
      }
      proxyConstructor = Java.getRealClassConstructor(runtime, reifiedClass);
    }
    IRubyObject newObj = Java.constructProxy(runtime, proxyConstructor, klazz);
    return newObj;
  }
});

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

public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
    // if we haven't been here before, reify the class
    Class reifiedClass = klazz.getReifiedClass();
    if (proxyConstructor == null || proxyConstructor.getDeclaringClass() != reifiedClass) {
      if (reifiedClass == null) {
        reifiedClass = Java.generateRealClass(klazz);
      }
      proxyConstructor = Java.getRealClassConstructor(runtime, reifiedClass);
    }
    IRubyObject newObj = Java.constructProxy(runtime, proxyConstructor, klazz);
    return newObj;
  }
});

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

private static void reifyWithAncestors(RubyClass klazz) {
    
    RubyClass realSuper = klazz.getSuperClass().getRealClass();

    if (realSuper.getReifiedClass() == null) reifyWithAncestors(realSuper);
    synchronized (klazz) {
      klazz.reify();
      klazz.setAllocator(new ReifyingAllocator(klazz.getReifiedClass()));
    }
  }
}

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

private static IRubyObject becomeJava(final ThreadContext context, final RubyClass klass,
  final String dumpDir, final boolean useChildLoader) {
  klass.reifyWithAncestors(dumpDir, useChildLoader);
  final Class<?> reifiedClass = klass.getReifiedClass();
  generateFieldAccessors(context, klass, reifiedClass);
  return asJavaClass(context.runtime, reifiedClass);
}

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

private static IRubyObject becomeJava(final ThreadContext context, final RubyClass klass,
  final String dumpDir, final boolean useChildLoader) {
  klass.reifyWithAncestors(dumpDir, useChildLoader);
  final Class<?> reifiedClass = klass.getReifiedClass();
  generateFieldAccessors(context, klass, reifiedClass);
  return asJavaClass(context.runtime, reifiedClass);
}

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

private static void reifyWithAncestors(RubyClass klazz) {
    
    RubyClass realSuper = klazz.getSuperClass().getRealClass();

    if (realSuper.getReifiedClass() == null) reifyWithAncestors(realSuper);
    synchronized (klazz) {
      klazz.reify();
      klazz.setAllocator(new ReifyingAllocator(klazz.getReifiedClass()));
    }
  }
}

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

private static void reifyWithAncestors(RubyClass klazz) {
    
    RubyClass realSuper = klazz.getSuperClass().getRealClass();

    if (realSuper.getReifiedClass() == null) reifyWithAncestors(realSuper);
    synchronized (klazz) {
      klazz.reify();
      klazz.setAllocator(new ReifyingAllocator(klazz.getReifiedClass()));
    }
  }
}

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

private static void reifyWithAncestors(RubyClass klazz) {
    
    RubyClass realSuper = klazz.getSuperClass().getRealClass();

    if (realSuper.getReifiedClass() == null) reifyWithAncestors(realSuper);
    synchronized (klazz) {
      klazz.reify();
      klazz.setAllocator(new ReifyingAllocator(klazz.getReifiedClass()));
    }
  }
}

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

public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
  try {
    if (klazz.getReifiedClass() == this.klass) {
      return (IRubyObject) cons.newInstance(runtime, klazz);
    }
    reifyWithAncestors(klazz);
    return klazz.getAllocator().allocate(runtime, klazz);
  } catch (InstantiationException ie) {
    throw runtime.newTypeError("could not allocate " + this.klass + " with default constructor:\n" + ie);
  } catch (IllegalAccessException iae) {
    throw runtime.newSecurityError("could not allocate " + this.klass + " due to inaccessible default constructor:\n" + iae);
  } catch (InvocationTargetException ite) {
    throw runtime.newSecurityError("could not allocate " + this.klass + " due to inaccessible default constructor:\n" + ite);
  }
}

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

public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
  try {
    if (klazz.getReifiedClass() == this.klass) {
      return (IRubyObject) cons.newInstance(runtime, klazz);
    }
    reifyWithAncestors(klazz);
    return klazz.getAllocator().allocate(runtime, klazz);
  } catch (InstantiationException ie) {
    throw runtime.newTypeError("could not allocate " + this.klass + " with default constructor:\n" + ie);
  } catch (IllegalAccessException iae) {
    throw runtime.newSecurityError("could not allocate " + this.klass + " due to inaccessible default constructor:\n" + iae);
  } catch (InvocationTargetException ite) {
    throw runtime.newSecurityError("could not allocate " + this.klass + " due to inaccessible default constructor:\n" + ite);
  }
}

代码示例来源:origin: asciidoctor/asciidoctorj

@Override
public Class<?> resolve(String backend) {
  RubyClass rubyClass = (RubyClass) getConverterFactory()
    .callMethod("resolve", rubyRuntime.newString(backend));
  Class<?> clazz = rubyClass.getReifiedClass();
  if (clazz != null) {
    return clazz;
  } else if (rubyClass.getAllocator() instanceof ConverterProxy.Allocator) {
    ConverterProxy.Allocator allocator = (ConverterProxy.Allocator) rubyClass.getAllocator();
    return allocator.getConverterClass();
  }
  return null;
}

代码示例来源:origin: org.asciidoctor/asciidoctorj

@Override
public Class<?> resolve(String backend) {
  RubyClass rubyClass = (RubyClass) getConverterFactory()
    .callMethod("resolve", rubyRuntime.newString(backend));
  Class<?> clazz = rubyClass.getReifiedClass();
  if (clazz != null) {
    return clazz;
  } else if (rubyClass.getAllocator() instanceof ConverterProxy.Allocator) {
    ConverterProxy.Allocator allocator = (ConverterProxy.Allocator) rubyClass.getAllocator();
    return allocator.getConverterClass();
  }
  return null;
}

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

private static void checkAlreadyReified(final RubyClass clazz, Ruby runtime) throws RaiseException {
  // not allowed for original (non-generated) Java classes
  // note: not allowing for any previously created class right now;
  // this restriction might be loosened later for generated classes
  if ( ( Java.NEW_STYLE_EXTENSION && clazz.getReifiedClass() != null )
      ||
      ( clazz.hasInstanceVariable("@java_class")
        && clazz.getInstanceVariable("@java_class").isTrue()
        && !clazz.getSingletonClass().isMethodBound("java_proxy_class", false) )
      ||
      ( clazz.hasInstanceVariable("@java_proxy_class")
        && clazz.getInstanceVariable("@java_proxy_class").isTrue() ) ) {
    throw runtime.newArgumentError("can not add Java interface to existing Java class");
  }
}

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

private static void checkAlreadyReified(final RubyClass clazz, Ruby runtime) throws RaiseException {
  // not allowed for original (non-generated) Java classes
  // note: not allowing for any previously created class right now;
  // this restriction might be loosened later for generated classes
  if ((Java.NEW_STYLE_EXTENSION && clazz.getReifiedClass() != null)
      ||
      (clazz.hasInstanceVariable("@java_class")
        && clazz.getInstanceVariable("@java_class").isTrue()
        && !clazz.getSingletonClass().isMethodBound("java_proxy_class", false))
      ||
      (clazz.hasInstanceVariable("@java_proxy_class")
        && clazz.getInstanceVariable("@java_proxy_class").isTrue())) {
    throw runtime.newArgumentError("can not add Java interface to existing Java class");
  }
}

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

private static void checkAlreadyReified(final RubyClass clazz, Ruby runtime) throws RaiseException {
  // not allowed for original (non-generated) Java classes
  // note: not allowing for any previously created class right now;
  // this restriction might be loosened later for generated classes
  if ((Java.NEW_STYLE_EXTENSION && clazz.getReifiedClass() != null)
      ||
      (clazz.hasInstanceVariable("@java_class")
        && clazz.getInstanceVariable("@java_class").isTrue()
        && !clazz.getSingletonClass().isMethodBound("java_proxy_class", false))
      ||
      (clazz.hasInstanceVariable("@java_proxy_class")
        && clazz.getInstanceVariable("@java_proxy_class").isTrue())) {
    throw runtime.newArgumentError("can not add Java interface to existing Java class");
  }
}

相关文章

微信公众号

最新文章

更多

RubyClass类方法