< prev index next >

src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/BootstrapMethod.java

Print this page




  57      * Construct object from input stream.
  58      *
  59      * @param input Input stream
  60      * @throws IOException
  61      */
  62     BootstrapMethod(final DataInput input) throws IOException {
  63         this(input.readUnsignedShort(), input.readUnsignedShort());
  64 
  65         for (int i = 0; i < bootstrap_arguments.length; i++) {
  66             bootstrap_arguments[i] = input.readUnsignedShort();
  67         }
  68     }
  69 
  70     // helper method
  71     private BootstrapMethod(final int bootstrap_method_ref, final int num_bootstrap_arguments) {
  72         this(bootstrap_method_ref, new int[num_bootstrap_arguments]);
  73     }
  74 
  75     /**
  76      * @param bootstrap_method_ref int index into constant_pool of CONSTANT_MethodHandle
  77      * @param bootstrap_arguments int[] indices into constant_pool of CONSTANT_<type>_info
  78      */
  79     public BootstrapMethod(final int bootstrap_method_ref, final int[] bootstrap_arguments) {
  80         this.bootstrap_method_ref = bootstrap_method_ref;
  81         this.bootstrap_arguments = bootstrap_arguments;
  82     }
  83 
  84     /**
  85      * @return index into constant_pool of bootstrap_method
  86      */
  87     public int getBootstrapMethodRef() {
  88         return bootstrap_method_ref;
  89     }
  90 
  91     /**
  92      * @param bootstrap_method_ref int index into constant_pool of CONSTANT_MethodHandle
  93      */
  94     public void setBootstrapMethodRef(final int bootstrap_method_ref) {
  95         this.bootstrap_method_ref = bootstrap_method_ref;
  96     }
  97 
  98     /**
  99      * @return int[] of bootstrap_method indices into constant_pool of CONSTANT_<type>_info
 100      */
 101     public int[] getBootstrapArguments() {
 102         return bootstrap_arguments;
 103     }
 104 
 105     /**
 106      * @return count of number of boostrap arguments
 107      */
 108     public int getNumBootstrapArguments() {
 109         return bootstrap_arguments.length;
 110     }
 111 
 112     /**
 113      * @param bootstrap_arguments int[] indices into constant_pool of CONSTANT_<type>_info
 114      */
 115     public void setBootstrapArguments(final int[] bootstrap_arguments) {
 116         this.bootstrap_arguments = bootstrap_arguments;
 117     }
 118 
 119     /**
 120      * @return String representation.
 121      */
 122     @Override
 123     public final String toString() {
 124         return "BootstrapMethod(" + bootstrap_method_ref + ", " + bootstrap_arguments.length + ", "
 125                + Arrays.toString(bootstrap_arguments) + ")";
 126     }
 127 
 128     /**
 129      * @return Resolved string representation
 130      */
 131     public final String toString( final ConstantPool constant_pool ) {
 132         final StringBuilder buf = new StringBuilder();
 133         String bootstrap_method_name;
 134         bootstrap_method_name = constant_pool.constantToString(bootstrap_method_ref,
 135                 Const.CONSTANT_MethodHandle);
 136         buf.append(Utility.compactClassName(bootstrap_method_name));
 137         final int num_bootstrap_arguments = bootstrap_arguments.length;
 138         if (num_bootstrap_arguments > 0) {
 139             buf.append("\n     Method Arguments:");
 140             for (int i = 0; i < num_bootstrap_arguments; i++) {
 141                 buf.append("\n     ").append(i).append(": ");
 142                 buf.append(constant_pool.constantToString(constant_pool.getConstant(bootstrap_arguments[i])));
 143             }
 144         }
 145         return buf.toString();
 146     }
 147 
 148     /**
 149      * Dump object to file stream in binary format.
 150      *
 151      * @param file Output file stream
 152      * @throws IOException
 153      */
 154     public final void dump(final DataOutputStream file) throws IOException {
 155         file.writeShort(bootstrap_method_ref);
 156         file.writeShort(bootstrap_arguments.length);
 157         for (final int bootstrap_argument : bootstrap_arguments) {
 158             file.writeShort(bootstrap_argument);
 159         }


  57      * Construct object from input stream.
  58      *
  59      * @param input Input stream
  60      * @throws IOException
  61      */
  62     BootstrapMethod(final DataInput input) throws IOException {
  63         this(input.readUnsignedShort(), input.readUnsignedShort());
  64 
  65         for (int i = 0; i < bootstrap_arguments.length; i++) {
  66             bootstrap_arguments[i] = input.readUnsignedShort();
  67         }
  68     }
  69 
  70     // helper method
  71     private BootstrapMethod(final int bootstrap_method_ref, final int num_bootstrap_arguments) {
  72         this(bootstrap_method_ref, new int[num_bootstrap_arguments]);
  73     }
  74 
  75     /**
  76      * @param bootstrap_method_ref int index into constant_pool of CONSTANT_MethodHandle
  77      * @param bootstrap_arguments int[] indices into constant_pool of CONSTANT_[type]_info
  78      */
  79     public BootstrapMethod(final int bootstrap_method_ref, final int[] bootstrap_arguments) {
  80         this.bootstrap_method_ref = bootstrap_method_ref;
  81         this.bootstrap_arguments = bootstrap_arguments;
  82     }
  83 
  84     /**
  85      * @return index into constant_pool of bootstrap_method
  86      */
  87     public int getBootstrapMethodRef() {
  88         return bootstrap_method_ref;
  89     }
  90 
  91     /**
  92      * @param bootstrap_method_ref int index into constant_pool of CONSTANT_MethodHandle
  93      */
  94     public void setBootstrapMethodRef(final int bootstrap_method_ref) {
  95         this.bootstrap_method_ref = bootstrap_method_ref;
  96     }
  97 
  98     /**
  99      * @return int[] of bootstrap_method indices into constant_pool of CONSTANT_[type]_info
 100      */
 101     public int[] getBootstrapArguments() {
 102         return bootstrap_arguments;
 103     }
 104 
 105     /**
 106      * @return count of number of boostrap arguments
 107      */
 108     public int getNumBootstrapArguments() {
 109         return bootstrap_arguments.length;
 110     }
 111 
 112     /**
 113      * @param bootstrap_arguments int[] indices into constant_pool of CONSTANT_[type]_info
 114      */
 115     public void setBootstrapArguments(final int[] bootstrap_arguments) {
 116         this.bootstrap_arguments = bootstrap_arguments;
 117     }
 118 
 119     /**
 120      * @return String representation.
 121      */
 122     @Override
 123     public final String toString() {
 124         return "BootstrapMethod(" + bootstrap_method_ref + ", " + bootstrap_arguments.length + ", "
 125                + Arrays.toString(bootstrap_arguments) + ")";
 126     }
 127 
 128     /**
 129      * @return Resolved string representation
 130      */
 131     public final String toString( final ConstantPool constant_pool ) {
 132         final StringBuilder buf = new StringBuilder();
 133         String bootstrap_method_name;
 134         bootstrap_method_name = constant_pool.constantToString(bootstrap_method_ref,
 135                 Const.CONSTANT_MethodHandle);
 136         buf.append(Utility.compactClassName(bootstrap_method_name, false));
 137         final int num_bootstrap_arguments = bootstrap_arguments.length;
 138         if (num_bootstrap_arguments > 0) {
 139             buf.append("\nMethod Arguments:");
 140             for (int i = 0; i < num_bootstrap_arguments; i++) {
 141                 buf.append("\n  ").append(i).append(": ");
 142                 buf.append(constant_pool.constantToString(constant_pool.getConstant(bootstrap_arguments[i])));
 143             }
 144         }
 145         return buf.toString();
 146     }
 147 
 148     /**
 149      * Dump object to file stream in binary format.
 150      *
 151      * @param file Output file stream
 152      * @throws IOException
 153      */
 154     public final void dump(final DataOutputStream file) throws IOException {
 155         file.writeShort(bootstrap_method_ref);
 156         file.writeShort(bootstrap_arguments.length);
 157         for (final int bootstrap_argument : bootstrap_arguments) {
 158             file.writeShort(bootstrap_argument);
 159         }
< prev index next >