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.

AccessFlag.java 3.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * Javassist, a Java-bytecode translator toolkit.
  3. * Copyright (C) 1999-2003 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. /**
  17. * A support class providing static methods and constants
  18. * for access modifiers such as public, rivate, ...
  19. */
  20. public class AccessFlag {
  21. public static final int PUBLIC = 0x0001;
  22. public static final int PRIVATE = 0x0002;
  23. public static final int PROTECTED = 0x0004;
  24. public static final int STATIC = 0x0008;
  25. public static final int FINAL = 0x0010;
  26. public static final int SYNCHRONIZED = 0x0020;
  27. public static final int VOLATILE = 0x0040;
  28. public static final int TRANSIENT = 0x0080;
  29. public static final int NATIVE = 0x0100;
  30. public static final int INTERFACE = 0x0200;
  31. public static final int ABSTRACT = 0x0400;
  32. public static final int STRICT = 0x0800;
  33. public static final int SUPER = 0x0020;
  34. // Note: 0x0020 is assigned to both ACC_SUPER and ACC_SYNCHRONIZED
  35. // although java.lang.reflect.Modifier does not recognize ACC_SUPER.
  36. /**
  37. * Truns the public bit on. The protected and private bits are
  38. * cleared.
  39. */
  40. public static int setPublic(int accflags) {
  41. return (accflags & ~(PRIVATE | PROTECTED)) | PUBLIC;
  42. }
  43. /**
  44. * Truns the protected bit on. The protected and public bits are
  45. * cleared.
  46. */
  47. public static int setProtected(int accflags) {
  48. return (accflags & ~(PRIVATE | PUBLIC)) | PROTECTED;
  49. }
  50. /**
  51. * Truns the private bit on. The protected and private bits are
  52. * cleared.
  53. */
  54. public static int setPrivate(int accflags) {
  55. return (accflags & ~(PROTECTED | PUBLIC)) | PRIVATE;
  56. }
  57. /**
  58. * Clears the public, protected, and private bits.
  59. */
  60. public static int setPackage(int accflags) {
  61. return (accflags & ~(PROTECTED | PUBLIC | PRIVATE));
  62. }
  63. /**
  64. * Clears a specified bit in <code>accflags</code>.
  65. */
  66. public static int clear(int accflags, int clearBit) {
  67. return accflags & ~clearBit;
  68. }
  69. /**
  70. * Converts a javassist.Modifier into
  71. * a javassist.bytecode.AccessFlag.
  72. *
  73. * @param modifier javassist.Modifier
  74. */
  75. public static int of(int modifier) {
  76. return modifier;
  77. }
  78. /**
  79. * Converts a javassist.bytecode.AccessFlag
  80. * into a javassist.Modifier.
  81. *
  82. * @param accflags javassist.bytecode.Accessflag
  83. */
  84. public static int toModifier(int accflags) {
  85. return accflags;
  86. }
  87. }