示例#1
0
  /**
   * Return the class of this object. Similar to Reflection API. Note the naming inconsistency,
   * which avoids a clash with <code>java.lang.Object.getClass()</code>
   *
   * @return The bClass value
   * @throws ProjectNotOpenException if the project to which this object belongs has been closed by
   *     the user.
   * @throws ClassNotFoundException if the class has been deleted by the user.
   * @throws PackageNotFoundException if the Package has been deleted by the user.
   */
  public BClass getBClass()
      throws ProjectNotOpenException, PackageNotFoundException, ClassNotFoundException {
    // BClasses are retrieved from the BlueJ classTarget
    ClassTarget classTarget = wrapperId.getClassTarget();

    if (classTarget == null) {
      // Not a project class; exists in a library or the Java runtime
      wrapperId.getJavaClass(); // will throw ClassNotFoundException if not loadable
      return BClass.getBClass(wrapperId);
    }

    // There is only one instance of BClass for each ClassTarget
    return classTarget.getBClass();
  }