1. /*
  2. * @(#)ClassDefinition.java 1.4 04/05/05
  3. *
  4. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  5. */
  6. package java.lang.instrument;
  7. /*
  8. * Copyright 2003 Wily Technology, Inc.
  9. */
  10. /**
  11. * This class serves as a parameter block to the <code>Instrumentation.redefineClasses</code> method.
  12. * Serves to bind the <code>Class</code> that needs redefining together with the new class file bytes.
  13. *
  14. * @see java.lang.instrument.Instrumentation#redefineClasses
  15. * @since JDK1.5
  16. */
  17. public final class ClassDefinition {
  18. /**
  19. * The class to redefine
  20. */
  21. private final Class mClass;
  22. /**
  23. * The replacement class file bytes
  24. */
  25. private final byte[] mClassFile;
  26. /**
  27. * Creates a new <code>ClassDefinition</code> binding using the supplied
  28. * class and class file bytes. Does not copy the supplied buffer, just captures a reference to it.
  29. *
  30. * @param theClass the <code>Class</code> that needs redefining
  31. * @param theClassFile the new class file bytes
  32. *
  33. * @throws java.lang.NullPointerException if the supplied class or array is <code>null</code>.
  34. */
  35. public
  36. ClassDefinition( Class<?> theClass,
  37. byte[] theClassFile) {
  38. if (theClass == null || theClassFile == null) {
  39. throw new NullPointerException();
  40. }
  41. mClass = theClass;
  42. mClassFile = theClassFile;
  43. }
  44. /**
  45. * Returns the class.
  46. *
  47. * @return the <code>Class</code> object referred to.
  48. */
  49. public Class<?>
  50. getDefinitionClass() {
  51. return mClass;
  52. }
  53. /**
  54. * Returns the array of bytes that contains the new class file.
  55. *
  56. * @return the class file bytes.
  57. */
  58. public byte[]
  59. getDefinitionClassFile() {
  60. return mClassFile;
  61. }
  62. }