Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

SignatureAttribute.java 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Javassist, a Java-bytecode translator toolkit.
  3. * Copyright (C) 1999-2004 Shigeru Chiba. All Rights Reserved.
  4. *
  5. * The contents of this file are subject to the Mozilla Public License Version
  6. * 1.1 (the "License"); you may not use this file except in compliance with
  7. * the License. Alternatively, the contents of this file may be used under
  8. * the terms of the GNU Lesser General Public License Version 2.1 or later.
  9. *
  10. * Software distributed under the License is distributed on an "AS IS" basis,
  11. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. * for the specific language governing rights and limitations under the
  13. * License.
  14. */
  15. package javassist.bytecode;
  16. import java.io.DataInputStream;
  17. import java.io.IOException;
  18. import java.util.Map;
  19. /**
  20. * <code>Signature_attribute</code>.
  21. */
  22. public class SignatureAttribute extends AttributeInfo {
  23. /**
  24. * The name of this attribute <code>"Signature"</code>.
  25. */
  26. public static final String tag = "Signature";
  27. SignatureAttribute(ConstPool cp, int n, DataInputStream in)
  28. throws IOException
  29. {
  30. super(cp, n, in);
  31. }
  32. /**
  33. * Constructs a Signature attribute.
  34. *
  35. * @param cp a constant pool table.
  36. * @param signature the signature represented by this attribute.
  37. */
  38. public SignatureAttribute(ConstPool cp, String signature) {
  39. super(cp, tag);
  40. int index = cp.addUtf8Info(signature);
  41. byte[] bvalue = new byte[2];
  42. bvalue[0] = (byte)(index >>> 8);
  43. bvalue[1] = (byte)index;
  44. set(bvalue);
  45. }
  46. /**
  47. * Returns the signature indicated by <code>signature_index</code>.
  48. */
  49. public String getSignature() {
  50. return getConstPool().getUtf8Info(ByteArray.readU16bit(get(), 0));
  51. }
  52. /**
  53. * Makes a copy. Class names are replaced according to the
  54. * given <code>Map</code> object.
  55. *
  56. * @param newCp the constant pool table used by the new copy.
  57. * @param classnames pairs of replaced and substituted
  58. * class names.
  59. */
  60. public AttributeInfo copy(ConstPool newCp, Map classnames) {
  61. return new SignatureAttribute(newCp, getSignature());
  62. }
  63. }