Пример #1
0
 /** @param name a qualified class name. e.g. java.lang.String */
 public CtField lookupField(String className, Symbol fieldName) throws CompileError {
   CtClass cc = lookupClass(className, false);
   try {
     return cc.getField(fieldName.get());
   } catch (NotFoundException e) {
   }
   throw new CompileError("no such field: " + fieldName.get());
 }
Пример #2
0
  /**
   * Only used by fieldAccess() in MemberCodeGen and TypeChecker.
   *
   * @param jvmClassName a JVM class name. e.g. java/lang/String
   */
  public CtField lookupFieldByJvmName2(String jvmClassName, Symbol fieldSym, ASTree expr)
      throws NoFieldException {
    String field = fieldSym.get();
    CtClass cc = null;
    try {
      cc = lookupClass(jvmToJavaName(jvmClassName), true);
    } catch (CompileError e) {
      // EXPR might be part of a qualified class name.
      throw new NoFieldException(jvmClassName + "/" + field, expr);
    }

    try {
      return cc.getField(field);
    } catch (NotFoundException e) {
      // maybe an inner class.
      jvmClassName = javaToJvmName(cc.getName());
      throw new NoFieldException(jvmClassName + "$" + field, expr);
    }
  }