KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > lang > instrument > ClassDefinition


1 /*
2  * @(#)ClassDefinition.java 1.4 04/05/05
3  *
4  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
5  */

6
7 package java.lang.instrument;
8
9 /*
10  * Copyright 2003 Wily Technology, Inc.
11  */

12
13 /**
14  * This class serves as a parameter block to the <code>Instrumentation.redefineClasses</code> method.
15  * Serves to bind the <code>Class</code> that needs redefining together with the new class file bytes.
16  *
17  * @see java.lang.instrument.Instrumentation#redefineClasses
18  * @since JDK1.5
19  */

20 public final class ClassDefinition {
21     /**
22      * The class to redefine
23      */

24     private final Class JavaDoc mClass;
25     
26     /**
27      * The replacement class file bytes
28      */

29     private final byte[] mClassFile;
30
31     /**
32      * Creates a new <code>ClassDefinition</code> binding using the supplied
33      * class and class file bytes. Does not copy the supplied buffer, just captures a reference to it.
34      *
35      * @param theClass the <code>Class</code> that needs redefining
36      * @param theClassFile the new class file bytes
37      *
38      * @throws java.lang.NullPointerException if the supplied class or array is <code>null</code>.
39      */

40     public
41     ClassDefinition( Class JavaDoc<?> theClass,
42                         byte[] theClassFile) {
43         if (theClass == null || theClassFile == null) {
44             throw new NullPointerException JavaDoc();
45         }
46         mClass = theClass;
47         mClassFile = theClassFile;
48     }
49
50     /**
51      * Returns the class.
52      *
53      * @return the <code>Class</code> object referred to.
54      */

55     public Class JavaDoc<?>
56     getDefinitionClass() {
57         return mClass;
58     }
59
60     /**
61      * Returns the array of bytes that contains the new class file.
62      *
63      * @return the class file bytes.
64      */

65     public byte[]
66     getDefinitionClassFile() {
67         return mClassFile;
68     }
69 }
70
Popular Tags