KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tctest > transparency > SubClassC


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tctest.transparency;
5
6 public class SubClassC extends SubClassB {
7
8   int j = 9;
9   
10   public synchronized void method1() {
11     i = 20;
12     super.method1();
13   }
14   
15   public SubClassB getCopy() {
16     return super.getCopy();
17   }
18   
19   public Object JavaDoc clone() {
20     try {
21       // This is insane, but this is test code so ...
22
SubClassC c = (SubClassC) super.clone();
23       c.i++;
24       c.j--;
25       return c;
26     } catch (CloneNotSupportedException JavaDoc e) {
27       throw new RuntimeException JavaDoc(e);
28     }
29   }
30   
31   public synchronized void checkedUnCheckedSetsAndGets() {
32     //this should be unchecked
33
int newj = j + 100;
34     int newi = i + 1000;
35     j = newj;
36     i = newi;
37     
38     // This should be checked
39
SubClassD d = new SubClassD();
40     d.d = d.d ++;
41   }
42
43   public String JavaDoc toString() {
44     return "SubClassC::" + super.toString();
45   }
46   
47   public boolean equals(Object JavaDoc o) {
48     if (this == o) return true;
49     if (o instanceof SubClassC) { return j == ((SubClassC)o).j && super.equals(o); }
50     return false;
51   }
52 }
53
Popular Tags