/**
  * Get CodeException object.<br>
  * This relies on that the instruction list has already been dumped to byte code or or that the
  * `setPositions' methods has been called for the instruction list.
  *
  * @param cp constant pool
  */
 public CodeException getCodeException(ConstantPoolGen cp) {
   return new CodeException(
       start_pc.getPosition(),
       end_pc.getPosition() + end_pc.getInstruction().getLength(),
       handler_pc.getPosition(),
       (catch_type == null) ? 0 : cp.addClass(catch_type));
 }
Beispiel #2
0
  public int[] getInterfaces() {
    int size = interface_vec.size();
    int[] interfaces = new int[size];

    for (int i = 0; i < size; i++) interfaces[i] = cp.addClass((String) interface_vec.get(i));

    return interfaces;
  }
Beispiel #3
0
  /**
   * Convenience constructor to set up some important values initially.
   *
   * @param class_name fully qualified class name
   * @param super_class_name fully qualified superclass name
   * @param file_name source file name
   * @param access_flags access qualifiers
   * @param interfaces implemented interfaces
   * @param cp constant pool to use
   */
  public ClassGen(
      String class_name,
      String super_class_name,
      String file_name,
      int access_flags,
      String[] interfaces,
      ConstantPoolGen cp) {
    this.class_name = class_name;
    this.super_class_name = super_class_name;
    this.file_name = file_name;
    this.access_flags = access_flags;
    this.cp = cp;

    // Put everything needed by default into the constant pool and the vectors
    if (file_name != null)
      addAttribute(
          new SourceFile(cp.addUtf8("SourceFile"), 2, cp.addUtf8(file_name), cp.getConstantPool()));

    class_name_index = cp.addClass(class_name);
    superclass_name_index = cp.addClass(super_class_name);

    if (interfaces != null) for (int i = 0; i < interfaces.length; i++) addInterface(interfaces[i]);
  }
Beispiel #4
0
 public void setSuperclassName(String name) {
   super_class_name = name.replace('/', '.');
   superclass_name_index = cp.addClass(name);
 }
Beispiel #5
0
 public void setClassName(String name) {
   class_name = name.replace('/', '.');
   class_name_index = cp.addClass(name);
 }