From d96924c601912c7df55e378806a126850a798eaa Mon Sep 17 00:00:00 2001 From: chiba Date: Mon, 4 Aug 2003 15:47:33 +0000 Subject: updated some javadoc comments. modified Loader so that getPackage() works. git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@32 30ef5769-5b8d-40dd-aea6-55b5d6557bb3 --- tutorial/tutorial2.html | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tutorial/tutorial2.html') diff --git a/tutorial/tutorial2.html b/tutorial/tutorial2.html index 31d75f0b..13574c96 100644 --- a/tutorial/tutorial2.html +++ b/tutorial/tutorial2.html @@ -23,6 +23,32 @@ the Java reflection API. CtClass provides definition. It allows to add a new field, constructor, and method. Instrumenting a method body is also possible. +

+Methods are represented by CtMethod objects. +CtMethod provides several methods for modifying +the definition of the method. Note that if a method is inherited +from a super class, then +the same CtMethod object +that represents the inherited method represents the method declared +in that super class. +A CtMethod object corresponds to every method declaration. + +

+For example, if class Point declares method move() +and a subclass ColorPoint of Point does +not override move(), the two move() methods +declared in Point and inherited in ColorPoint +are represented by the identical CtMethod object. +If the method definition represented by this +CtMethod object is modified, the modification is +reflected on both the methods. +If you want to modify only the move() method in +ColorPoint, you first have to add to ColorPoint +a copy of the CtMethod object representing move() +in Point. A copy of the the CtMethod object +can be obtained by CtNewMethod.copy(). + +