Пример #1
0
 /**
  * Gets the super class of this class.
  *
  * @return the super class of this class
  */
 public final ProxyType getSuperclass() throws IOException, SDWPException {
   Klass superClass = klass.getSuperclass();
   // the "-bytecode-" class actually inherits from INT, but don't tell jdwp that!
   if (superClass != null && !superClass.isPrimitive()) {
     return ptm.lookup(superClass, true);
   }
   return null;
 }
Пример #2
0
 @SuppressWarnings("unchecked")
 private void addFields(List list, boolean isStatic) {
   int count = klass.getFieldCount(isStatic);
   for (int i = 0; i != count; ++i) {
     Field field = klass.getField(i, isStatic);
     FieldID fid = new FieldID(JDWP.getTag(field.getType()), field.getOffset(), isStatic, getID());
     ProxyField proxyField = new ProxyField(fid, field);
     list.add(proxyField);
   }
 }
Пример #3
0
 @SuppressWarnings("unchecked")
 private void addMethods(List list, boolean isStatic) {
   int count = klass.getMethodCount(isStatic);
   for (int i = 0; i != count; ++i) {
     Method method = klass.getMethod(i, isStatic);
     if (!method.isHosted()) {
       MethodID mid = new MethodID(method.getOffset(), isStatic);
       ProxyMethod proxyMethod = new ProxyMethod(mid, method);
       list.add(proxyMethod);
     }
   }
 }
Пример #4
0
  /**
   * Gets the fully qualified name of this type. The returned name is formatted as it might appear
   * in a Java programming language declaration for objects of this type.
   *
   * <p>For primitive classes the returned name is the name of the corresponding primitive type; for
   * example, "int" is returned as the name of the class represented by {@link
   * java.lang.Integer#TYPE Integer.TYPE}.
   *
   * @return a string containing the type name.
   */
  public String getName() {
    String name = klass.getName();
    if (!klass.isArray()) {
      return name;
    }

    int dimensions = 0;
    while (name.charAt(dimensions) == '[') {
      ++dimensions;
    }

    name = name.substring(dimensions);
    char first = name.charAt(0);
    if (first == 'L') {
      name = name.substring(1, name.length() - 2).replace('/', '.');
    } else {
      switch (first) {
        case 'I':
          name = "int";
          break;
        case 'J':
          name = "long";
          break;
        case 'F':
          name = "float";
          break;
        case 'D':
          name = "double";
          break;
        case 'Z':
          name = "boolean";
          break;
        case 'C':
          name = "char";
          break;
        case 'S':
          name = "short";
          break;
        case 'B':
          name = "byte";
          break;
        case 'V':
          name = "void";
          break;
      }
    }
    while (dimensions-- != 0) {
      name += "[]";
    }
    return name;
  }
Пример #5
0
 /**
  * Returns interfaces directly implemented by this type.
  *
  * @return a List of the interfaces directly implemented by this type
  */
 @SuppressWarnings("unchecked")
 public List getInterfaces() throws IOException, SDWPException {
   Klass[] interfaces = klass.getInterfaces();
   List list = new ArrayList(interfaces.length);
   for (int i = 0; i != interfaces.length; ++i) {
     list.add(ptm.lookup(interfaces[i], true));
   }
   return list;
 }
Пример #6
0
 /**
  * Returns a list containing each {@link Method} declared directly in this type. Inherited methods
  * are not included. Constructors, the initialization method if any, and any synthetic methods
  * created by the compiler are included in the list.
  *
  * <p>For arrays and primitive classes, the returned list is always empty.
  *
  * @return a list {@link Method} objects; the list has length 0 if no methods exist.
  */
 public List getMethods() {
   if (methods == null) {
     if (klass.isArray()) {
       methods = Collections.EMPTY_LIST;
     } else {
       methods = new ArrayList();
       addMethods(methods, true);
       addMethods(methods, false);
     }
   }
   return methods;
 }
Пример #7
0
 /**
  * Gets an identifying name for the source corresponding to the declaration of this type.
  * Interpretation of this string is the responsibility of the source repository mechanism.
  *
  * <p>The returned name is dependent on VM's default stratum ({@link
  * VirtualMachine#getDefaultStratum()}). In the reference implementation, when using the base
  * stratum, the returned string is the unqualified name of the source file containing the
  * declaration of this type. In other strata the returned source name is the first source name for
  * that stratum. Since other languages may have more than one source name for a reference type,
  * the use of {@link Location#sourceName()} or {@link #sourceNames(String)} is preferred.
  *
  * <p>
  *
  * @return the string source file name or null if it is not known
  */
 public String getSourceName() {
   return klass.getSourceFileName();
 }
Пример #8
0
 /**
  * Returns the modifiers for the reference type. ACC_PUBLIC, ACC_FINAL, etc. Undefined for arrays
  * and primitive type.
  *
  * @return the class modifiers in JVM Spec format.
  */
 public int getModifiers() {
   return klass.getModifiers() & Modifier.getJVMClassModifiers();
 }