You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Test.j 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. A sample program using sample.vector.VectorAssistant
  3. and the javassist.preproc package.
  4. This automatically produces the classes representing vectors of integer
  5. and vectors of java.lang.String.
  6. To compile and run this program, do as follows:
  7. % java javassist.tool.Compiler sample/vector/Test.j
  8. % javac sample/vector/Test.java
  9. % java sample.vector.Test
  10. The first line produces one source file (sample/Test.java) and
  11. two class files (sample/vector/intVector.class and
  12. sample/vector/StringVector.class).
  13. */
  14. package sample.vector;
  15. import java.util.Vector by sample.vector.VectorAssistant(java.lang.String);
  16. import java.util.Vector by sample.vector.VectorAssistant(int);
  17. public class Test {
  18. public static void main(String[] args) {
  19. intVector iv = new intVector();
  20. iv.add(3);
  21. iv.add(4);
  22. for (int i = 0; i < iv.size(); ++i)
  23. System.out.println(iv.at(i));
  24. StringVector sv = new StringVector();
  25. sv.add("foo");
  26. sv.add("bar");
  27. for (int i = 0; i < sv.size(); ++i)
  28. System.out.println(sv.at(i));
  29. }
  30. }