1. /*
  2. * @(#)ReflectAccess.java 1.7 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.lang.reflect;
  8. import sun.reflect.MethodAccessor;
  9. import sun.reflect.ConstructorAccessor;
  10. /** Package-private class implementing the
  11. sun.reflect.LangReflectAccess interface, allowing the java.lang
  12. package to instantiate objects in this package. */
  13. class ReflectAccess implements sun.reflect.LangReflectAccess {
  14. public Field newField(Class declaringClass,
  15. String name,
  16. Class type,
  17. int modifiers,
  18. int slot)
  19. {
  20. return new Field(declaringClass,
  21. name,
  22. type,
  23. modifiers,
  24. slot);
  25. }
  26. public Method newMethod(Class declaringClass,
  27. String name,
  28. Class[] parameterTypes,
  29. Class returnType,
  30. Class[] checkedExceptions,
  31. int modifiers,
  32. int slot)
  33. {
  34. return new Method(declaringClass,
  35. name,
  36. parameterTypes,
  37. returnType,
  38. checkedExceptions,
  39. modifiers,
  40. slot);
  41. }
  42. public Constructor newConstructor(Class declaringClass,
  43. Class[] parameterTypes,
  44. Class[] checkedExceptions,
  45. int modifiers,
  46. int slot)
  47. {
  48. return new Constructor(declaringClass,
  49. parameterTypes,
  50. checkedExceptions,
  51. modifiers,
  52. slot);
  53. }
  54. public MethodAccessor getMethodAccessor(Method m) {
  55. return m.getMethodAccessor();
  56. }
  57. public void setMethodAccessor(Method m, MethodAccessor accessor) {
  58. m.setMethodAccessor(accessor);
  59. }
  60. public ConstructorAccessor getConstructorAccessor(Constructor c) {
  61. return c.getConstructorAccessor();
  62. }
  63. public void setConstructorAccessor(Constructor c,
  64. ConstructorAccessor accessor)
  65. {
  66. c.setConstructorAccessor(accessor);
  67. }
  68. public int getConstructorSlot(Constructor c) {
  69. return c.getSlot();
  70. }
  71. //
  72. // Copying routines, needed to quickly fabricate new Field,
  73. // Method, and Constructor objects from templates
  74. //
  75. public Method copyMethod(Method arg) {
  76. return arg.copy();
  77. }
  78. public Field copyField(Field arg) {
  79. return arg.copy();
  80. }
  81. public Constructor copyConstructor(Constructor arg) {
  82. return arg.copy();
  83. }
  84. }