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.

InterTypeConstructors.java 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import junit.framework.Assert;
  2. public class InterTypeConstructors {
  3. public static void main(String[] args) {
  4. Target t = A.makeT();
  5. }
  6. }
  7. class Target implements I {
  8. private Target(String s) {
  9. System.err.println(s);
  10. }
  11. public Target() {
  12. this(10);
  13. }
  14. int f = 10;
  15. static int ss() { return 100; }
  16. String getS() { return "Target" + this.instS("Foo"); }
  17. private int instS(String s) { return 10; }
  18. public int mmmm() { System.err.println("noarg"); return 3;}
  19. }
  20. class C {
  21. class SubTarget extends Target {
  22. final String s;
  23. public SubTarget() {
  24. super(10);
  25. s = "hi";
  26. }
  27. }
  28. }
  29. //class SubTarget extends Target {
  30. // String getS() { return "SubTarget"; }
  31. // static int ss() { return 10; }
  32. //
  33. // public void foobar() {
  34. // mmmm(333);
  35. // }
  36. //
  37. // //public int mmmm(int x) { return x; }
  38. //}
  39. interface SuperI {}
  40. interface I extends SuperI { }
  41. privileged aspect A {
  42. public static Target makeT() {
  43. return new Target(10);
  44. }
  45. Target.new(int foo) {
  46. this("hi" + ++foo);
  47. this.f = mmmm() + foo;
  48. System.err.println(f == 14);
  49. }
  50. //C.SubTarget.new(String value) { // uncomment for an error
  51. //this.s = value;
  52. //}
  53. }