|
|
|
|
|
|
|
*/ |
|
/* |
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
|
* contributor license agreements. See the NOTICE file distributed with |
|
* this work for additional information regarding copyright ownership. |
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
|
* (the "License"); you may not use this file except in compliance with |
|
* the License. You may obtain a copy of the License at |
|
* |
|
* http://www.apache.org/licenses/LICENSE-2.0 |
|
* |
|
* Unless required by applicable law or agreed to in writing, software |
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
* See the License for the specific language governing permissions and |
|
* limitations under the License. |
|
*/ |
|
|
|
package com.sun.org.apache.bcel.internal.classfile; |
|
|
|
import java.io.DataInput; |
|
import java.io.DataOutputStream; |
|
import java.io.IOException; |
|
import java.util.Arrays; |
|
|
|
import com.sun.org.apache.bcel.internal.Const; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public class BootstrapMethod implements Cloneable { |
|
|
|
|
|
private int bootstrap_method_ref; |
|
|
|
|
|
private int[] bootstrap_arguments; |
|
|
|
|
|
|
|
|
|
*/ |
|
public BootstrapMethod(final BootstrapMethod c) { |
|
this(c.getBootstrapMethodRef(), c.getBootstrapArguments()); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
BootstrapMethod(final DataInput input) throws IOException { |
|
this(input.readUnsignedShort(), input.readUnsignedShort()); |
|
|
|
for (int i = 0; i < bootstrap_arguments.length; i++) { |
|
bootstrap_arguments[i] = input.readUnsignedShort(); |
|
} |
|
} |
|
|
|
|
|
private BootstrapMethod(final int bootstrap_method_ref, final int num_bootstrap_arguments) { |
|
this(bootstrap_method_ref, new int[num_bootstrap_arguments]); |
|
} |
|
|
|
|
|
|
|
|
|
*/ |
|
public BootstrapMethod(final int bootstrap_method_ref, final int[] bootstrap_arguments) { |
|
this.bootstrap_method_ref = bootstrap_method_ref; |
|
this.bootstrap_arguments = bootstrap_arguments; |
|
} |
|
|
|
|
|
|
|
*/ |
|
public int getBootstrapMethodRef() { |
|
return bootstrap_method_ref; |
|
} |
|
|
|
|
|
|
|
*/ |
|
public void setBootstrapMethodRef(final int bootstrap_method_ref) { |
|
this.bootstrap_method_ref = bootstrap_method_ref; |
|
} |
|
|
|
|
|
|
|
*/ |
|
public int[] getBootstrapArguments() { |
|
return bootstrap_arguments; |
|
} |
|
|
|
|
|
|
|
*/ |
|
public int getNumBootstrapArguments() { |
|
return bootstrap_arguments.length; |
|
} |
|
|
|
|
|
|
|
*/ |
|
public void setBootstrapArguments(final int[] bootstrap_arguments) { |
|
this.bootstrap_arguments = bootstrap_arguments; |
|
} |
|
|
|
|
|
|
|
*/ |
|
@Override |
|
public final String toString() { |
|
return "BootstrapMethod(" + bootstrap_method_ref + ", " + bootstrap_arguments.length + ", " |
|
+ Arrays.toString(bootstrap_arguments) + ")"; |
|
} |
|
|
|
|
|
|
|
*/ |
|
public final String toString( final ConstantPool constant_pool ) { |
|
final StringBuilder buf = new StringBuilder(); |
|
String bootstrap_method_name; |
|
bootstrap_method_name = constant_pool.constantToString(bootstrap_method_ref, |
|
Const.CONSTANT_MethodHandle); |
|
buf.append(Utility.compactClassName(bootstrap_method_name)); |
|
final int num_bootstrap_arguments = bootstrap_arguments.length; |
|
if (num_bootstrap_arguments > 0) { |
|
buf.append("\n Method Arguments:"); |
|
for (int i = 0; i < num_bootstrap_arguments; i++) { |
|
buf.append("\n ").append(i).append(": "); |
|
buf.append(constant_pool.constantToString(constant_pool.getConstant(bootstrap_arguments[i]))); |
|
} |
|
} |
|
return buf.toString(); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public final void dump(final DataOutputStream file) throws IOException { |
|
file.writeShort(bootstrap_method_ref); |
|
file.writeShort(bootstrap_arguments.length); |
|
for (final int bootstrap_argument : bootstrap_arguments) { |
|
file.writeShort(bootstrap_argument); |
|
} |
|
} |
|
|
|
|
|
|
|
*/ |
|
public BootstrapMethod copy() { |
|
try { |
|
return (BootstrapMethod) clone(); |
|
} catch (final CloneNotSupportedException e) { |
|
// TODO should this throw? |
|
} |
|
return null; |
|
} |
|
} |