public synchronized void initialize() { if (hasRun) return; hasRun = true; InitializerState state = new InitializerState(getRuntime(), null); Field[] fields = getDeclaredFields(javaClass); for (int i = fields.length; --i >= 0; ) { Field field = fields[i]; if (javaClass != field.getDeclaringClass()) continue; if (ConstantField.isConstant(field)) state.constantFields.add(new ConstantField(field)); int modifiers = field.getModifiers(); if (Modifier.isStatic(modifiers)) addField(state.staticCallbacks, state.staticNames, field, Modifier.isFinal(modifiers), true); } // Add in any Scala singleton methods handleScalaSingletons(javaClass, state); // Now add all aliases for the static methods (fields) as appropriate for (Map.Entry<String, NamedInstaller> entry : state.staticCallbacks.entrySet()) { if (entry.getValue().type == NamedInstaller.STATIC_METHOD && entry.getValue().hasLocalMethod()) { assignAliases((MethodInstaller)entry.getValue(), state.staticNames); } } JavaClass.this.staticAssignedNames = Collections.unmodifiableMap(state.staticNames); JavaClass.this.staticInstallers = Collections.unmodifiableMap(state.staticCallbacks); JavaClass.this.constantFields = Collections.unmodifiableList(state.constantFields); } };
public synchronized void initialize() { if (hasRun) return; hasRun = true; InitializerState state = new InitializerState(getRuntime(), null); Field[] fields = getDeclaredFields(javaClass); for (int i = fields.length; --i >= 0; ) { Field field = fields[i]; if (javaClass != field.getDeclaringClass()) continue; if (ConstantField.isConstant(field)) state.constantFields.add(new ConstantField(field)); int modifiers = field.getModifiers(); if (Modifier.isStatic(modifiers)) addField(state.staticCallbacks, state.staticNames, field, Modifier.isFinal(modifiers), true); } // Add in any Scala singleton methods handleScalaSingletons(javaClass, state); // Now add all aliases for the static methods (fields) as appropriate for (Map.Entry<String, NamedInstaller> entry : state.staticCallbacks.entrySet()) { if (entry.getValue().type == NamedInstaller.STATIC_METHOD && entry.getValue().hasLocalMethod()) { assignAliases((MethodInstaller)entry.getValue(), state.staticNames); } } JavaClass.this.staticAssignedNames = Collections.unmodifiableMap(state.staticNames); JavaClass.this.staticInstallers = Collections.unmodifiableMap(state.staticCallbacks); JavaClass.this.constantFields = Collections.unmodifiableList(state.constantFields); } };
private static void findFields(ThreadContext context, RubyModule topModule, IRubyObject args[], boolean asReader, boolean asWriter) { Map<String, String> fieldMap = getFieldListFromArgs(args); for (RubyModule module = topModule; module != null; module = module.getSuperClass()) { Class<?> javaClass = getJavaClass(context, module); // Hit a non-java proxy class (included Modules can be a cause of this...skip) if (javaClass == null) continue; Field[] fields = JavaClass.getDeclaredFields(javaClass); for (int j = 0; j < fields.length; j++) { installField(context, fieldMap, fields[j], module, asReader, asWriter); } } // We could not find all of them print out first one (we could print them all?) if (!fieldMap.isEmpty()) { throw JavaClass.undefinedFieldError(context.runtime, topModule.getName(), fieldMap.keySet().iterator().next()); } }
private static void findFields(final ThreadContext context, final RubyModule topModule, final IRubyObject[] args, final boolean asReader, final boolean asWriter) { final Map<String, String> fieldMap = getFieldListFromArgs(context, args); for (RubyModule module = topModule; module != null; module = module.getSuperClass()) { final Class<?> javaClass = JavaClass.getJavaClassIfProxy(context, module); // Hit a non-java proxy class (included Modules can be a cause of this...skip) if ( javaClass == null ) continue; Field[] fields = JavaClass.getDeclaredFields(javaClass); for (int j = 0; j < fields.length; j++) { installField(context, fieldMap, fields[j], module, asReader, asWriter); } } // We could not find all of them print out first one (we could print them all?) if ( ! fieldMap.isEmpty() ) { throw JavaClass.undefinedFieldError(context.runtime, topModule.getName(), fieldMap.keySet().iterator().next()); } }
private static void findFields(ThreadContext context, RubyModule topModule, IRubyObject args[], boolean asReader, boolean asWriter) { Map<String, String> fieldMap = getFieldListFromArgs(args); for (RubyModule module = topModule; module != null; module = module.getSuperClass()) { Class<?> javaClass = getJavaClass(context, module); // Hit a non-java proxy class (included Modules can be a cause of this...skip) if (javaClass == null) continue; Field[] fields = JavaClass.getDeclaredFields(javaClass); for (int j = 0; j < fields.length; j++) { installField(context, fieldMap, fields[j], module, asReader, asWriter); } } // We could not find all of them print out first one (we could print them all?) if (!fieldMap.isEmpty()) { throw JavaClass.undefinedFieldError(context.runtime, topModule.getName(), fieldMap.keySet().iterator().next()); } }
private static void findFields(final ThreadContext context, final RubyModule topModule, final IRubyObject[] args, final boolean asReader, final boolean asWriter) { final Map<String, String> fieldMap = getFieldListFromArgs(context, args); for (RubyModule module = topModule; module != null; module = module.getSuperClass()) { final Class<?> javaClass = JavaClass.getJavaClassIfProxy(context, module); // Hit a non-java proxy class (included Modules can be a cause of this...skip) if ( javaClass == null ) continue; Field[] fields = JavaClass.getDeclaredFields(javaClass); for (int j = 0; j < fields.length; j++) { installField(context, fieldMap, fields[j], module, asReader, asWriter); } } // We could not find all of them print out first one (we could print them all?) if ( ! fieldMap.isEmpty() ) { throw JavaClass.undefinedFieldError(context.runtime, topModule.getName(), fieldMap.keySet().iterator().next()); } }
final State state = new State(runtime, null); Field[] fields = JavaClass.getDeclaredFields(javaClass);
final State state = new State(runtime, null); Field[] fields = JavaClass.getDeclaredFields(javaClass);