You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

NestHostAttribute.java 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Javassist, a Java-bytecode translator toolkit.
  3. * Copyright (C) 1999- 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. * or the Apache License Version 2.0.
  10. *
  11. * Software distributed under the License is distributed on an "AS IS" basis,
  12. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13. * for the specific language governing rights and limitations under the
  14. * License.
  15. */
  16. package javassist.bytecode;
  17. import java.io.DataInputStream;
  18. import java.io.IOException;
  19. import java.util.Map;
  20. /**
  21. * <code>NestHost_attribute</code>.
  22. * It was introduced by JEP-181. See JVMS 4.7.28 for the specification.
  23. *
  24. * @since 3.24
  25. */
  26. public class NestHostAttribute extends AttributeInfo {
  27. /**
  28. * The name of this attribute <code>"NestHost"</code>.
  29. */
  30. public static final String tag = "NestHost";
  31. NestHostAttribute(ConstPool cp, int n, DataInputStream in) throws IOException {
  32. super(cp, n, in);
  33. }
  34. private NestHostAttribute(ConstPool cp, int hostIndex) {
  35. super(cp, tag, new byte[2]);
  36. ByteArray.write16bit(hostIndex, get(), 0);
  37. }
  38. /**
  39. * Makes a copy. Class names are replaced according to the
  40. * given <code>Map</code> object.
  41. *
  42. * @param newCp the constant pool table used by the new copy.
  43. * @param classnames pairs of replaced and substituted
  44. * class names.
  45. */
  46. @Override
  47. public AttributeInfo copy(ConstPool newCp, Map<String, String> classnames) {
  48. int hostIndex = ByteArray.readU16bit(get(), 0);
  49. int newHostIndex = getConstPool().copy(hostIndex, newCp, classnames);
  50. return new NestHostAttribute(newCp, newHostIndex);
  51. }
  52. /**
  53. * Returns <code>host_class_index</code>. The constant pool entry
  54. * at this entry is a <code>CONSTANT_Class_info</code> structure.
  55. * @return the value of <code>host_class_index</code>.
  56. */
  57. public int hostClassIndex() {
  58. return ByteArray.readU16bit(info, 0);
  59. }
  60. }