コード例 #1
0
  public OJField getCopy() {
    /*if (isAlterable())  return substance.getCopy();*/
    /** **************** */
    // return (FieldDeclaration) substance.clone () ;
    try {

      if (substance instanceof OJFieldByteCode) {
        java.lang.reflect.Field field = ((OJFieldByteCode) substance).getByteCode();
        OJField result = (OJField) this.clone();
        // On remplace du ByteCode par du SourceCode
        FieldDeclaration fd =
            new FieldDeclaration(
                new ModifierList(field.getModifiers()),
                TypeName.forOJClass(OJClass.forClass(field.getDeclaringClass())),
                field.getName(),
                null);
        Environment env = substance.getDeclaringClass().getEnvironment();
        result.substance = new OJFieldSourceCode(env, substance.getDeclaringClass(), fd);
        return result;
      } else if (substance instanceof OJFieldSourceCode) {
        OJField result = (OJField) this.clone();
        result.substance =
            new OJFieldSourceCode(
                ((OJFieldSourceCode) this.substance).getEnvironment(),
                this.substance.getDeclaringClass(),
                (FieldDeclaration) this.substance.getSourceCode().makeRecursiveCopy());
        return result;
      }
    } catch (Exception e) {
      System.err.println("Failed to copy " + this + ": " + e);
      e.printStackTrace();
    }
    return null;
  }
コード例 #2
0
 public OJClass getDeclaringClass() {
   return substance.getDeclaringClass();
 }