]> source.dussan.org Git - javassist.git/commitdiff
changed line delimiters.
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Mon, 5 Apr 2004 09:57:57 +0000 (09:57 +0000)
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Mon, 5 Apr 2004 09:57:57 +0000 (09:57 +0000)
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@77 30ef5769-5b8d-40dd-aea6-55b5d6557bb3

sample/Test.java
sample/evolve/DemoLoader.java

index 07eeda98cbd6810ad5676c6d08356d8445c4c0d3..810b6b61a8a846f4c50b431259a4328832ede5c4 100644 (file)
@@ -1,44 +1,44 @@
-package sample;\r
-\r
-import javassist.*;\r
-\r
-/*\r
-   A very simple sample program\r
-\r
-   This program overwrites sample/Test.class (the class file of this\r
-   class itself) for adding a method g().  If the method g() is not\r
-   defined in class Test, then this program adds a copy of\r
-   f() to the class Test with name g().  Otherwise, this program does\r
-   not modify sample/Test.class at all.\r
-\r
-   To see the modified class definition, execute:\r
-\r
-   % javap sample.Test\r
-\r
-   after running this program.\r
-*/\r
-public class Test {\r
-    public int f(int i) {\r
-       return i + 1;\r
-    }\r
-\r
-    public static void main(String[] args) throws Exception {\r
-       ClassPool pool = ClassPool.getDefault();\r
-\r
-       CtClass cc = pool.get("sample.Test");\r
-       try {\r
-           cc.getDeclaredMethod("g");\r
-           System.out.println("g() is already defined in sample.Test.");\r
-       }\r
-       catch (NotFoundException e) {\r
-           /* getDeclaredMethod() throws an exception if g()\r
-            * is not defined in sample.Test.\r
-            */\r
-           CtMethod fMethod = cc.getDeclaredMethod("f");\r
-           CtMethod gMethod = CtNewMethod.copy(fMethod, "g", cc, null);\r
-           cc.addMethod(gMethod);\r
-           pool.writeFile("sample.Test");      // update the class file\r
-           System.out.println("g() was added.");\r
-       }\r
-    }\r
-}\r
+package sample;
+
+import javassist.*;
+
+/*
+   A very simple sample program
+
+   This program overwrites sample/Test.class (the class file of this
+   class itself) for adding a method g().  If the method g() is not
+   defined in class Test, then this program adds a copy of
+   f() to the class Test with name g().  Otherwise, this program does
+   not modify sample/Test.class at all.
+
+   To see the modified class definition, execute:
+
+   % javap sample.Test
+
+   after running this program.
+*/
+public class Test {
+    public int f(int i) {
+       return i + 1;
+    }
+
+    public static void main(String[] args) throws Exception {
+       ClassPool pool = ClassPool.getDefault();
+
+       CtClass cc = pool.get("sample.Test");
+       try {
+           cc.getDeclaredMethod("g");
+           System.out.println("g() is already defined in sample.Test.");
+       }
+       catch (NotFoundException e) {
+           /* getDeclaredMethod() throws an exception if g()
+            * is not defined in sample.Test.
+            */
+           CtMethod fMethod = cc.getDeclaredMethod("f");
+           CtMethod gMethod = CtNewMethod.copy(fMethod, "g", cc, null);
+           cc.addMethod(gMethod);
+           pool.writeFile("sample.Test");      // update the class file
+           System.out.println("g() was added.");
+       }
+    }
+}
index ecf45049c399befafb5eb51ac9786541e16d34d8..6c16c6dc5af1e78fe2eb7317cb66b0ee1e30d355 100644 (file)
@@ -1,41 +1,41 @@
-package sample.evolve;\r
-\r
-import javassist.*;\r
-import java.io.*;\r
-import java.util.Hashtable;\r
-\r
-/**\r
- * DemoLoader is a class loader for running a program including\r
- * an updatable class.  This simple loader allows only a single\r
- * class to be updatable.  (Extending it for supporting multiple\r
- * updatable classes is easy.)\r
- *\r
- * To run, type as follows:\r
- *\r
- * % java sample.evolve.DemoLoader <port number>\r
- *\r
- * Then DemoLoader launches sample.evolve.DemoServer with <port number>.\r
- * It also translates sample.evolve.WebPage, which sample.evolve.DemoServer\r
- * uses, so that it is an updable class.\r
- *\r
- * Note: JDK 1.2 or later only.\r
- */\r
-public class DemoLoader {\r
-    private static final int initialVersion = 0;\r
-    private String updatableClassName = null;\r
-    private CtClass updatableClass = null;\r
-\r
-    /* Creates a <code>DemoLoader</code> for making class WebPage\r
-     * updatable.  Then it runs main() in sample.evolve.DemoServer.\r
-     */\r
-    public static void main(String[] args) throws Throwable {\r
-        Evolution translator = new Evolution();\r
-        ClassPool cp = ClassPool.getDefault();\r
-        cp.insertTranslator(translator);\r
-        Loader cl = new Loader();\r
-        cl.setClassPool(cp);\r
-\r
-        translator.makeUpdatable("sample.evolve.WebPage");\r
-        cl.run("sample.evolve.DemoServer", args);\r
-    }\r
-}\r
+package sample.evolve;
+
+import javassist.*;
+import java.io.*;
+import java.util.Hashtable;
+
+/**
+ * DemoLoader is a class loader for running a program including
+ * an updatable class.  This simple loader allows only a single
+ * class to be updatable.  (Extending it for supporting multiple
+ * updatable classes is easy.)
+ *
+ * To run, type as follows:
+ *
+ * % java sample.evolve.DemoLoader <port number>
+ *
+ * Then DemoLoader launches sample.evolve.DemoServer with <port number>.
+ * It also translates sample.evolve.WebPage, which sample.evolve.DemoServer
+ * uses, so that it is an updable class.
+ *
+ * Note: JDK 1.2 or later only.
+ */
+public class DemoLoader {
+    private static final int initialVersion = 0;
+    private String updatableClassName = null;
+    private CtClass updatableClass = null;
+
+    /* Creates a <code>DemoLoader</code> for making class WebPage
+     * updatable.  Then it runs main() in sample.evolve.DemoServer.
+     */
+    public static void main(String[] args) throws Throwable {
+        Evolution translator = new Evolution();
+        ClassPool cp = ClassPool.getDefault();
+        cp.insertTranslator(translator);
+        Loader cl = new Loader();
+        cl.setClassPool(cp);
+
+        translator.makeUpdatable("sample.evolve.WebPage");
+        cl.run("sample.evolve.DemoServer", args);
+    }
+}