Beispiel #1
0
 public static void main(String[] args) {
   A p = g(0, 5);
   p.f();
   System.out.println("---");
   p = g(2, 1);
   p.f();
 }
Beispiel #2
0
 public static void main(String[] args) {
   A pa = g();
   try {
     pa.f();
   } catch (Exception1 e) {
   }
 }
Beispiel #3
0
 public void testF() {
   A instance = new A();
   instance.f();
   String[] temp = outContent.toString().split(System.getProperty("line.separator"));
   assertEquals("A", temp[1]);
   // TODO review the generated test code and remove the default call to fail.
   // fail("The test case is a prototype.");
 }
Beispiel #4
0
 public static void main(String[] x) {
   B b = new B();
   A a = b;
   b.x = 11;
   b.y = 22;
   System.out.println(a.f());
   System.out.println(a.g());
 }
Beispiel #5
0
 @IcecapCompileMe
 public static boolean test(A a) {
   a.f = true;
   if (a.f) {
     return false;
   } else {
     return true;
   }
 }
 public static void main(String[] args) throws Exception {
   A a = InnerA.makeA();
   a.f();
   System.out.println(a.getClass().getName());
   // Reflection still gets into the private class:
   HiddenImplementation.callHiddenMethod(a, "g");
   HiddenImplementation.callHiddenMethod(a, "u");
   HiddenImplementation.callHiddenMethod(a, "v");
   HiddenImplementation.callHiddenMethod(a, "w");
 }
Beispiel #7
0
  @Test
  public void getFinal() {
    final A a = new A();
    a.f = new F();

    LazyModel<F> model = model(from(a).getF());

    assertEquals(F.class, model.getObjectClass());
    assertEquals("f", model.getPath());

    assertEquals(a.f, model.getObject());
  }
Beispiel #8
0
  @Test
  public void getStringFromFinalFails() {
    final A a = new A();
    a.f = new F();
    a.f.string = "string";

    try {
      from(a).getF().getString();

      fail();
    } catch (NullPointerException expected) {
    }
  }
Beispiel #9
0
 public static void main(String[] args) {
   A a = new A();
   B b = new B();
   C c = new C();
   try {
     a.f(3);
     a.f(-3);
   } catch (MyException1 e) {
     System.out.println(e.getMessage());
   }
   try {
     b.f(8, 2);
     b.f(8, 0);
   } catch (MyException2 e) {
     System.out.println(e.getMessage());
   }
   try {
     c.f(3, 4, 5);
     c.f(-1, -4, 0);
   } catch (MyException3 e) {
     System.out.println(e.getMessage());
   }
 }
 public static void main(String[] args) throws Exception {
   A a = HiddenC.makeA();
   a.f();
   System.out.println(a.getClass().getName());
   // Compile error: cannot find symbol 'C':
   /* if(a instanceof C) {
     C c = (C)a;
     c.g();
   } */
   // Oops! Reflection still allows us to call g():
   callHiddenMethod(a, "g");
   // And even methods that are less accessible!
   callHiddenMethod(a, "u");
   callHiddenMethod(a, "v");
   callHiddenMethod(a, "w");
 }
Beispiel #11
0
 public static void main(String[] args) {
   B ref0 = new C();
   A ref1 = ref0;
   ref1.f();
   ref0.f();
 }
Beispiel #12
0
 void m() {
   a.f = 0; /*1*/
   b.f = 0; /*2*/
   ab.f = 0; /*3*/
 }