コード例 #1
0
ファイル: JavaProxy.java プロジェクト: goodwill/jruby
  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.getRuntime(), topModule.getName(), fieldMap.keySet().iterator().next());
    }
  }
コード例 #2
0
ファイル: Interpreter.java プロジェクト: phongnh/jruby
  public static IRubyObject INTERPRET_METHOD(
      ThreadContext context,
      CFG cfg,
      InterpreterContext interp,
      String name,
      RubyModule implClass,
      boolean isTraceable) {
    Ruby runtime = interp.getRuntime();
    boolean syntheticMethod = name == null || name.equals("");

    try {
      String className = implClass.getName();
      if (!syntheticMethod)
        ThreadContext.pushBacktrace(context, className, name, context.getFile(), context.getLine());
      if (isTraceable) methodPreTrace(runtime, context, name, implClass);
      return interpret(context, cfg, interp);
    } finally {
      if (isTraceable) {
        try {
          methodPostTrace(runtime, context, name, implClass);
        } finally {
          if (!syntheticMethod) ThreadContext.popBacktrace(context);
        }
      } else {
        if (!syntheticMethod) ThreadContext.popBacktrace(context);
      }
    }
  }
コード例 #3
0
ファイル: RubyIconv.java プロジェクト: qmx/jruby
    @JRubyMethod(name = "inspect")
    @Override
    public IRubyObject inspect() {
      RubyModule rubyClass = getMetaClass();
      StringBuilder buffer = new StringBuilder("#<");
      buffer.append(rubyClass.getName()).append(": ").append(success.inspect().toString());
      buffer.append(", ").append(failed.inspect().toString()).append(">");

      return getRuntime().newString(buffer.toString());
    }
コード例 #4
0
 @Override
 public String toString() {
   return super.toString()
       + "("
       + candidateObj
       + ", "
       + expectedVersion
       + "["
       + module.getName()
       + "], "
       + failurePathLabel
       + ")";
 }