public static TypePopulator loadPopulatorFor(Class<?> type) { if (Options.DEBUG_FULLTRACE.load() || Options.REFLECTED_HANDLES.load()) { // we want non-generated invokers or need full traces, use default (slow) populator LOG.debug("trace mode, using default populator"); } else { try { String qualifiedName = "org.jruby.gen." + type.getCanonicalName().replace('.', '$'); String fullName = qualifiedName + AnnotationBinder.POPULATOR_SUFFIX; String fullPath = fullName.replace('.', '/') + ".class"; if (LOG.isDebugEnabled()) LOG.debug("looking for populator " + fullName); if (Ruby.getClassLoader().getResource(fullPath) == null) { LOG.debug("could not find it, using default populator"); } else { return (TypePopulator) Class.forName(fullName).newInstance(); } } catch (Throwable ex) { if (LOG.isDebugEnabled()) LOG.debug("could not find populator, using default (" + ex + ')'); } } return new TypePopulator.ReflectiveTypePopulator(type); }
public void populate(final RubyModule target, final Class clazz) { assert clazz == this.clazz : "populator for " + this.clazz + " used for " + clazz; // fallback on non-pregenerated logic // populate method index; this is done statically in generated code AnnotationHelper.populateMethodIndex(clumper.readGroups, MethodIndex::addMethodReadFieldsPacked); AnnotationHelper.populateMethodIndex(clumper.writeGroups, MethodIndex::addMethodWriteFieldsPacked); final Ruby runtime = target.getRuntime(); final MethodFactory methodFactory = MethodFactory.createFactory(runtime.getJRubyClassLoader()); for (Map.Entry<String, List<JavaMethodDescriptor>> entry : clumper.getStaticAnnotatedMethods().entrySet()) { final String name = entry.getKey(); final List<JavaMethodDescriptor> methods = entry.getValue(); target.defineAnnotatedMethod(name, methods, methodFactory); addBoundMethodsUnlessOmitted(runtime, name, methods); } for (Map.Entry<String, List<JavaMethodDescriptor>> entry : clumper.getAnnotatedMethods().entrySet()) { final String name = entry.getKey(); final List<JavaMethodDescriptor> methods = entry.getValue(); target.defineAnnotatedMethod(name, methods, methodFactory); addBoundMethodsUnlessOmitted(runtime, name, methods); } }
public void populate(final RubyModule target, final Class clazz) { assert clazz == this.clazz : "populator for " + this.clazz + " used for " + clazz; // fallback on non-pregenerated logic // populate method index; this is done statically in generated code AnnotationHelper.populateMethodIndex(clumper.readGroups, MethodIndex::addMethodReadFieldsPacked); AnnotationHelper.populateMethodIndex(clumper.writeGroups, MethodIndex::addMethodWriteFieldsPacked); final Ruby runtime = target.getRuntime(); final MethodFactory methodFactory = MethodFactory.createFactory(runtime.getJRubyClassLoader()); for (Map.Entry<String, List<JavaMethodDescriptor>> entry : clumper.getStaticAnnotatedMethods().entrySet()) { final String name = entry.getKey(); final List<JavaMethodDescriptor> methods = entry.getValue(); target.defineAnnotatedMethod(name, methods, methodFactory); addBoundMethodsUnlessOmitted(runtime, name, methods); } for (Map.Entry<String, List<JavaMethodDescriptor>> entry : clumper.getAnnotatedMethods().entrySet()) { final String name = entry.getKey(); final List<JavaMethodDescriptor> methods = entry.getValue(); target.defineAnnotatedMethod(name, methods, methodFactory); addBoundMethodsUnlessOmitted(runtime, name, methods); } }
public static TypePopulator loadPopulatorFor(Class<?> type) { if (Options.DEBUG_FULLTRACE.load() || Options.REFLECTED_HANDLES.load()) { // we want non-generated invokers or need full traces, use default (slow) populator LOG.debug("trace mode, using default populator"); } else { try { String qualifiedName = "org.jruby.gen." + type.getCanonicalName().replace('.', '$'); String fullName = qualifiedName + AnnotationBinder.POPULATOR_SUFFIX; String fullPath = fullName.replace('.', '/') + ".class"; if (LOG.isDebugEnabled()) LOG.debug("looking for populator " + fullName); if (Ruby.getClassLoader().getResource(fullPath) == null) { LOG.debug("could not find it, using default populator"); } else { return (TypePopulator) Class.forName(fullName).newInstance(); } } catch (Throwable ex) { if (LOG.isDebugEnabled()) LOG.debug("could not find populator, using default (" + ex + ')'); } } return new TypePopulator.ReflectiveTypePopulator(type); }
public void populate(RubyModule clsmod, Class clazz) { ReflectiveTypePopulator populator = new ReflectiveTypePopulator(clazz); populator.populate(clsmod, clazz); } }
public void populate(RubyModule clsmod, Class clazz) { ReflectiveTypePopulator populator = new ReflectiveTypePopulator(clazz); populator.populate(clsmod, clazz); } }