KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tctest > ReflectionFieldTestApp


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

5 package com.tctest;
6
7 import com.tc.object.bytecode.ClassAdapterBase;
8 import com.tc.object.bytecode.Manageable;
9 import com.tc.object.config.ConfigVisitor;
10 import com.tc.object.config.DSOClientConfigHelper;
11 import com.tc.object.tx.ReadOnlyException;
12 import com.tc.simulator.app.ApplicationConfig;
13 import com.tc.simulator.listener.ListenerProvider;
14 import com.tc.util.Assert;
15
16 import java.awt.Color JavaDoc;
17 import java.lang.reflect.Field JavaDoc;
18 import java.util.ArrayList JavaDoc;
19 import java.util.HashMap JavaDoc;
20 import java.util.List JavaDoc;
21 import java.util.Map JavaDoc;
22
23 public class ReflectionFieldTestApp extends GenericTestApp {
24   // This field is used by reflection.
25
private DataRoot reflectionRoot = null;
26   private Integer JavaDoc literalRoot; // used by reflection.
27
private int primitiveRoot; // used by reflection.
28

29   private DataRoot nonShared = new DataRoot();
30   private NonInstrumentedTestObject nonInstrumentedObject = new NonInstrumentedTestObject();
31
32   private NonInstrumented nonInstrumented = new NonInstrumented();
33
34   public ReflectionFieldTestApp(String JavaDoc appId, ApplicationConfig cfg, ListenerProvider listenerProvider) {
35     super(appId, cfg, listenerProvider, DataRoot.class);
36   }
37
38   protected Object JavaDoc getTestObject(String JavaDoc testName) {
39     DataRoot root = (DataRoot) sharedMap.get("root");
40     return root;
41   }
42
43   protected void setupTestObject(String JavaDoc testName) {
44     sharedMap.put("root", new DataRoot(Long.MIN_VALUE));
45   }
46
47   void testBasicModifyRoot(DataRoot root, boolean validate) {
48     if (validate) {
49       Assert.assertEquals(12, root.getLongValue());
50     } else {
51       synchronized (root) {
52         root.setLongValue(12);
53       }
54     }
55   }
56
57   void testModifyPhysicalInstrumentedObjectWithStaticManager(DataRoot root, boolean validate) throws Exception JavaDoc {
58     if (validate) {
59       Assert.assertEquals(12, root.getLongValue());
60     } else {
61       synchronized (root) {
62         Field JavaDoc longValueField = root.getClass().getDeclaredField("longValue");
63         longValueField.setAccessible(true);
64         longValueField.setLong(root, 12);
65       }
66     }
67   }
68
69   void testModifyPhysicalInstrumentedObjectWithNonStaticManager(DataRoot root, boolean validate) throws Exception JavaDoc {
70     if (validate) {
71       Assert.assertEquals(200, root.getColor().getRGB());
72     } else {
73       synchronized (root) {
74         Color JavaDoc color = root.getColor();
75         Field JavaDoc colorField = color.getClass().getDeclaredField("value");
76         colorField.setAccessible(true);
77         Assert.assertEquals(100, colorField.getInt(color));
78         colorField.setInt(color, 200);
79       }
80     }
81   }
82
83   void testModifyObjectReference(DataRoot root, boolean validate) throws Exception JavaDoc {
84     if (validate) {
85       Assert.assertEquals(200, root.getColor().getRGB());
86     } else {
87       synchronized (root) {
88         Field JavaDoc colorField = root.getClass().getDeclaredField("color");
89         colorField.setAccessible(true);
90         colorField.set(root, new Color JavaDoc(200, true));
91       }
92     }
93   }
94
95   void testModifyBoolean(DataRoot root, boolean validate) throws Exception JavaDoc {
96     if (validate) {
97       Assert.assertTrue(root.isBooleanValue());
98     } else {
99       synchronized (root) {
100         Field JavaDoc booleanField = root.getClass().getDeclaredField("booleanValue");
101         booleanField.setAccessible(true);
102         booleanField.setBoolean(root, true);
103       }
104     }
105   }
106
107   void testModifyByte(DataRoot root, boolean validate) throws Exception JavaDoc {
108     if (validate) {
109       Assert.assertEquals(Byte.MAX_VALUE, root.getByteValue());
110     } else {
111       synchronized (root) {
112         Field JavaDoc byteField = root.getClass().getDeclaredField("byteValue");
113         byteField.setAccessible(true);
114         byteField.setByte(root, Byte.MAX_VALUE);
115       }
116     }
117   }
118
119   void testModifyCharacter(DataRoot root, boolean validate) throws Exception JavaDoc {
120     if (validate) {
121       Assert.assertEquals(Character.MAX_VALUE, root.getCharValue());
122     } else {
123       synchronized (root) {
124
125         Field JavaDoc charField = root.getClass().getDeclaredField("charValue");
126         charField.setAccessible(true);
127         charField.setChar(root, Character.MAX_VALUE);
128
129       }
130     }
131   }
132
133   void testModifyDoubleWithFloatValue(DataRoot root, boolean validate) throws Exception JavaDoc {
134     if (validate) {
135       Assert.assertEquals(Float.MAX_VALUE, root.getDoubleValue());
136     } else {
137       synchronized (root) {
138
139         Field JavaDoc doubleField = root.getClass().getDeclaredField("doubleValue");
140         doubleField.setAccessible(true);
141         doubleField.setFloat(root, Float.MAX_VALUE);
142       }
143     }
144   }
145
146   void testModifyDoubleWithIntValue(DataRoot root, boolean validate) throws Exception JavaDoc {
147     if (validate) {
148       Assert.assertEquals(4, root.getDoubleValue());
149     } else {
150       synchronized (root) {
151
152         Field JavaDoc doubleField = root.getClass().getDeclaredField("doubleValue");
153         doubleField.setAccessible(true);
154         doubleField.setInt(root, 4);
155       }
156     }
157   }
158
159   void testModifyDoubleWithLongValue(DataRoot root, boolean validate) throws Exception JavaDoc {
160     if (validate) {
161       Assert.assertEquals(4L, root.getDoubleValue());
162     } else {
163       synchronized (root) {
164
165         Field JavaDoc doubleField = root.getClass().getDeclaredField("doubleValue");
166         doubleField.setAccessible(true);
167         doubleField.setLong(root, 4L);
168       }
169     }
170   }
171
172   void testModifyDouble(DataRoot root, boolean validate) throws Exception JavaDoc {
173     if (validate) {
174       Assert.assertEquals(Double.MAX_VALUE, root.getDoubleValue());
175     } else {
176       synchronized (root) {
177
178         Field JavaDoc doubleField = root.getClass().getDeclaredField("doubleValue");
179         doubleField.setAccessible(true);
180         doubleField.setDouble(root, Double.MAX_VALUE);
181       }
182     }
183   }
184
185   void testModifyFloat(DataRoot root, boolean validate) throws Exception JavaDoc {
186     if (validate) {
187       Assert.assertEquals(Float.MAX_VALUE, root.getFloatValue());
188     } else {
189       synchronized (root) {
190
191         Field JavaDoc floatField = root.getClass().getDeclaredField("floatValue");
192         floatField.setAccessible(true);
193         floatField.setFloat(root, Float.MAX_VALUE);
194       }
195     }
196   }
197
198   void testModifyShort(DataRoot root, boolean validate) throws Exception JavaDoc {
199     if (validate) {
200       Assert.assertEquals(Short.MAX_VALUE, root.getShortValue());
201     } else {
202       synchronized (root) {
203
204         Field JavaDoc shortField = root.getClass().getDeclaredField("shortValue");
205         shortField.setAccessible(true);
206         shortField.setShort(root, Short.MAX_VALUE);
207       }
208     }
209   }
210
211   void testModifyIntWithShortValue(DataRoot root, boolean validate) throws Exception JavaDoc {
212     if (validate) {
213       Assert.assertEquals(Short.MAX_VALUE, root.getIntValue());
214     } else {
215       synchronized (root) {
216
217         Field JavaDoc intField = root.getClass().getDeclaredField("intValue");
218         intField.setAccessible(true);
219         intField.setInt(root, Short.MAX_VALUE);
220       }
221     }
222   }
223
224   void testModifyIntWithByteValue(DataRoot root, boolean validate) throws Exception JavaDoc {
225     if (validate) {
226       Assert.assertEquals(Byte.MAX_VALUE, root.getIntValue());
227     } else {
228       synchronized (root) {
229
230         Field JavaDoc intField = root.getClass().getDeclaredField("intValue");
231         intField.setAccessible(true);
232         intField.setInt(root, Byte.MAX_VALUE);
233       }
234     }
235   }
236
237   void testModifyIntWithCharValue(DataRoot root, boolean validate) throws Exception JavaDoc {
238     if (validate) {
239       Assert.assertEquals(Character.MAX_VALUE, root.getIntValue());
240     } else {
241       synchronized (root) {
242
243         Field JavaDoc intField = root.getClass().getDeclaredField("intValue");
244         intField.setAccessible(true);
245         intField.setInt(root, Character.MAX_VALUE);
246       }
247     }
248   }
249
250   void testModifyInt(DataRoot root, boolean validate) throws Exception JavaDoc {
251     if (validate) {
252       Assert.assertEquals(Integer.MAX_VALUE, root.getIntValue());
253     } else {
254       synchronized (root) {
255
256         Field JavaDoc intField = root.getClass().getDeclaredField("intValue");
257         intField.setAccessible(true);
258         intField.setInt(root, Integer.MAX_VALUE);
259       }
260     }
261   }
262
263   void testModifyLongWithIntValue(DataRoot root, boolean validate) throws Exception JavaDoc {
264     if (validate) {
265       Assert.assertEquals(Integer.MAX_VALUE, root.getLongValue());
266     } else {
267       synchronized (root) {
268
269         Field JavaDoc longField = root.getClass().getDeclaredField("longValue");
270         longField.setAccessible(true);
271         longField.setInt(root, Integer.MAX_VALUE);
272       }
273     }
274   }
275
276   void testModifyLongWithShortValue(DataRoot root, boolean validate) throws Exception JavaDoc {
277     if (validate) {
278       Assert.assertEquals(Short.MAX_VALUE, root.getLongValue());
279     } else {
280       synchronized (root) {
281
282         Field JavaDoc longField = root.getClass().getDeclaredField("longValue");
283         longField.setAccessible(true);
284         longField.setShort(root, Short.MAX_VALUE);
285       }
286     }
287   }
288
289   void testModifyLongWithByteValue(DataRoot root, boolean validate) throws Exception JavaDoc {
290     if (validate) {
291       Assert.assertEquals(Byte.MAX_VALUE, root.getLongValue());
292     } else {
293       synchronized (root) {
294
295         Field JavaDoc longField = root.getClass().getDeclaredField("longValue");
296         longField.setAccessible(true);
297         longField.setByte(root, Byte.MAX_VALUE);
298       }
299     }
300   }
301
302   void testModifyLongWithCharValue(DataRoot root, boolean validate) throws Exception JavaDoc {
303     if (validate) {
304       Assert.assertEquals(Character.MAX_VALUE, root.getLongValue());
305     } else {
306       synchronized (root) {
307
308         Field JavaDoc longField = root.getClass().getDeclaredField("longValue");
309         longField.setAccessible(true);
310         longField.setChar(root, Character.MAX_VALUE);
311       }
312     }
313   }
314
315   void testModifyLongWithFloatValue(DataRoot root, boolean validate) throws Exception JavaDoc {
316     if (validate) {
317       Assert.assertEquals(Long.MIN_VALUE, root.getLongValue());
318     } else {
319       synchronized (root) {
320         try {
321           Field JavaDoc longField = root.getClass().getDeclaredField("longValue");
322           longField.setAccessible(true);
323           longField.setFloat(root, Float.MAX_VALUE);
324           throw new AssertionError JavaDoc("should have thrown an exception");
325         } catch (IllegalArgumentException JavaDoc re) {
326           // Expected.
327
}
328       }
329     }
330   }
331
332   void testModifyLongWithDoubleValue(DataRoot root, boolean validate) throws Exception JavaDoc {
333     if (validate) {
334       Assert.assertEquals(Long.MIN_VALUE, root.getLongValue());
335     } else {
336       synchronized (root) {
337         try {
338           Field JavaDoc longField = root.getClass().getDeclaredField("longValue");
339           longField.setAccessible(true);
340           longField.setDouble(root, Double.MAX_VALUE);
341           throw new AssertionError JavaDoc("should have thrown an exception");
342         } catch (IllegalArgumentException JavaDoc re) {
343           // Expected.
344
}
345       }
346     }
347   }
348
349   void testModifyLong(DataRoot root, boolean validate) throws Exception JavaDoc {
350     if (validate) {
351       Assert.assertEquals(Long.MAX_VALUE, root.getLongValue());
352     } else {
353       synchronized (root) {
354         Field JavaDoc longField = root.getClass().getDeclaredField("longValue");
355         longField.setAccessible(true);
356         longField.setLong(root, Long.MAX_VALUE);
357       }
358     }
359   }
360
361   void testModifyNonSharedTCManagedField(DataRoot root, boolean validate) throws Exception JavaDoc {
362     Field JavaDoc tcManaged = nonShared.getClass().getDeclaredField(ClassAdapterBase.MANAGED_FIELD_NAME);
363     tcManaged.setAccessible(true);
364     if (validate) {
365       Object JavaDoc tcManagedObject = tcManaged.get(nonShared);
366       Assert.assertNull(tcManagedObject);
367       Assert.assertNull(((Manageable) nonShared).__tc_managed());
368     } else {
369       Assert.assertNotNull(((Manageable) root).__tc_managed());
370       Assert.assertNull(((Manageable) nonShared).__tc_managed());
371       tcManaged.set(nonShared, ((Manageable) root).__tc_managed());
372       Assert.assertNull(((Manageable) nonShared).__tc_managed());
373     }
374   }
375
376   void testModifySharedTCManagedField(DataRoot root, boolean validate) throws Exception JavaDoc {
377     Field JavaDoc tcManaged = root.getClass().getDeclaredField(ClassAdapterBase.MANAGED_FIELD_NAME);
378     tcManaged.setAccessible(true);
379     if (validate) {
380       Object JavaDoc tcManagedObject = tcManaged.get(root);
381       Assert.assertNull(tcManagedObject);
382       Assert.assertNotNull(((Manageable) root).__tc_managed());
383     } else {
384       Assert.assertNotNull(((Manageable) root).__tc_managed());
385       tcManaged.set(root, null);
386       Assert.assertNotNull(((Manageable) root).__tc_managed());
387     }
388   }
389
390   void testModifyAndGetLiteralRoot(DataRoot root, boolean validate) throws Exception JavaDoc {
391     Field JavaDoc literalRootField = getClass().getDeclaredField("literalRoot");
392     literalRootField.setAccessible(true);
393
394     Field JavaDoc primitiveRootField = getClass().getDeclaredField("primitiveRoot");
395     primitiveRootField.setAccessible(true);
396
397     if (validate) {
398       Integer JavaDoc localLiteralRoot = (Integer JavaDoc) literalRootField.get(this);
399       Assert.assertNotNull(localLiteralRoot);
400       Assert.assertEquals(new Integer JavaDoc(100), localLiteralRoot);
401
402       Integer JavaDoc localPrimitiveRoot = (Integer JavaDoc) primitiveRootField.get(this);
403       Assert.assertNotNull(localPrimitiveRoot);
404       Assert.assertEquals(new Integer JavaDoc(200), localPrimitiveRoot);
405     } else {
406       Object JavaDoc value = literalRootField.get(this);
407       Assert.assertNull(value);
408
409       // don't need DSO lock to set roots
410
literalRootField.set(this, new Integer JavaDoc(100));
411
412       value = primitiveRootField.get(this);
413       Assert.assertEquals(new Integer JavaDoc(0), value);
414       primitiveRootField.set(this, new Integer JavaDoc(200));
415     }
416   }
417
418   void testModifyAndGetRoot(DataRoot root, boolean validate) throws Exception JavaDoc {
419     Field JavaDoc rootField = getClass().getDeclaredField("reflectionRoot");
420     rootField.setAccessible(true);
421
422     if (validate) {
423       DataRoot dataRoot = (DataRoot) rootField.get(this);
424       Assert.assertNotNull(dataRoot);
425       Assert.assertEquals(200, dataRoot.getLongValue());
426       Assert.assertEquals(200, reflectionRoot.getLongValue());
427     } else {
428       Object JavaDoc value = rootField.get(this);
429       Assert.assertNull(value);
430
431       // don't need DSO lock to set roots
432
rootField.set(this, new DataRoot(200));
433     }
434   }
435
436   void testModifyNonSharedObject(DataRoot root, boolean validate) throws Exception JavaDoc {
437     if (!validate) {
438       synchronized (nonShared) {
439
440         Field JavaDoc longValueField = nonShared.getClass().getDeclaredField("longValue");
441         longValueField.setAccessible(true);
442         longValueField.setLong(nonShared, Long.MAX_VALUE);
443       }
444       Assert.assertEquals(Long.MAX_VALUE, nonShared.getLongValue());
445     }
446   }
447
448   void testModifyNonInstrumentedObject(DataRoot root, boolean validate) throws Exception JavaDoc {
449     if (!validate) {
450       synchronized (nonInstrumentedObject) {
451         Field JavaDoc longValueField = nonInstrumentedObject.getClass().getDeclaredField("longValue");
452         longValueField.setAccessible(true);
453         longValueField.setLong(nonInstrumentedObject, Long.MAX_VALUE);
454       }
455       Assert.assertEquals(Long.MAX_VALUE, nonInstrumentedObject.getLongValue());
456     }
457   }
458
459   void testModifyLogicalInstrumentedObject(DataRoot root, boolean validate) throws Exception JavaDoc {
460     if (validate) {
461       Assert.assertEquals(0, root.getList().size());
462     } else {
463       synchronized (root) {
464         List JavaDoc list = root.getList();
465         try {
466           Field JavaDoc sizeField = list.getClass().getDeclaredField("size");
467           sizeField.setAccessible(true);
468           sizeField.setInt(list, 10);
469           throw new AssertionError JavaDoc("should have thrown an exception");
470         } catch (IllegalAccessException JavaDoc re) {
471           // Checking the exact text of the exception isn't great, but unless we want to create a unique
472
// expception type for this condition, this is how we differentiate between other potential
473
// IllegalAccessExceptions being thrown here
474
Assert.assertEquals("Field modification through reflection for non-physical shared object of type "
475                               + list.getClass().getName() + " is not supported!", re.getMessage());
476         }
477       }
478
479     }
480   }
481
482   void testModifyNonInstrumentedObjectRoot(DataRoot root, boolean validate) throws Exception JavaDoc {
483     Field JavaDoc nonInstrumentedRootField = nonInstrumented.getClass().getDeclaredField("nonInstrumentedRoot");
484     nonInstrumentedRootField.setAccessible(true);
485     if (validate) {
486       Assert.assertEquals(root, nonInstrumented.getNonInstrumentedRoot());
487
488       Object JavaDoc nonInstrumentedRoot = nonInstrumentedRootField.get(nonInstrumented);
489       Assert.assertEquals(root, nonInstrumentedRoot);
490     } else {
491       nonInstrumentedRootField.set(nonInstrumented, root);
492     }
493   }
494
495   void testGetObjectReference(DataRoot root, boolean validate) throws Exception JavaDoc {
496     if (validate) {
497       Field JavaDoc colorField = root.getClass().getDeclaredField("color");
498       colorField.setAccessible(true);
499       Object JavaDoc color = colorField.get(root);
500       Assert.assertNotNull(color);
501       Assert.assertEquals(new Color JavaDoc(100, true), color);
502     }
503   }
504
505   void testLogicalClasses(DataRoot root, boolean validate) throws Exception JavaDoc {
506     Map JavaDoc map = root.getMap();
507     Map JavaDoc subMap = root.getSubMap();
508
509     Field JavaDoc sizeField = HashMap JavaDoc.class.getDeclaredField("size");
510     Field JavaDoc iField = subMap.getClass().getDeclaredField("i");
511     sizeField.setAccessible(true);
512     iField.setAccessible(true);
513
514     if (validate) {
515       int size = sizeField.getInt(map);
516       Assert.assertEquals(1, size);
517       size = ((Integer JavaDoc) sizeField.get(subMap)).intValue();
518
519       int i = iField.getInt(subMap);
520       Assert.assertEquals(5, i);
521
522     } else {
523       int i = iField.getInt(subMap);
524       Assert.assertEquals(3, i);
525
526       synchronized (subMap) {
527         iField.setInt(subMap, 5);
528       }
529     }
530
531   }
532
533   /*
534    * A static field of a non-root shared object is not shared. This test case is to make sure that we could use the
535    * current reflection instrumentation to set a static field.
536    */

537   void testModifyNonRootStaticField(DataRoot root, boolean validate) throws Exception JavaDoc {
538     Field JavaDoc staticLongField = root.getClass().getDeclaredField("staticLong");
539     staticLongField.setAccessible(true);
540     if (!validate) {
541       staticLongField.set(null, new Long JavaDoc(33L));
542       Assert.assertEquals(new Long JavaDoc(33L), DataRoot.getStaticLong());
543
544       Object JavaDoc staticLongFieldValue = staticLongField.get(null);
545       Assert.assertEquals(new Long JavaDoc(33L), staticLongFieldValue);
546
547       staticLongField.set(null, new Long JavaDoc(50L));
548       Assert.assertEquals(new Long JavaDoc(50L), DataRoot.getStaticLong());
549
550       staticLongFieldValue = staticLongField.get(null);
551       Assert.assertEquals(new Long JavaDoc(50L), staticLongFieldValue);
552     }
553   }
554
555   void testModifyRootStaticField(DataRoot root, boolean validate) throws Exception JavaDoc {
556     Field JavaDoc nonInstrumentedStaticRootField = nonInstrumented.getClass().getDeclaredField("nonInstrumentedStaticRoot");
557     nonInstrumentedStaticRootField.setAccessible(true);
558     if (validate) {
559       Assert.assertEquals(root, NonInstrumented.getNonInstrumentedStaticRoot());
560
561       Object JavaDoc nonInstrumentedStaticRootValue = nonInstrumentedStaticRootField.get(null);
562       Assert.assertEquals(root, nonInstrumentedStaticRootValue);
563     } else {
564       nonInstrumentedStaticRootField.set(null, root);
565     }
566   }
567
568   // ReadOnly test.
569
void testReadOnlyModifyLong(DataRoot root, boolean validate) throws Exception JavaDoc {
570     if (validate) {
571       Assert.assertEquals(Long.MIN_VALUE, root.getLongValue());
572     } else {
573       synchronized (root) {
574         try {
575           Field JavaDoc longField = root.getClass().getDeclaredField("longValue");
576           longField.setAccessible(true);
577           longField.setLong(root, Long.MAX_VALUE);
578           throw new AssertionError JavaDoc("I should have thrown a ReadOnlyException.");
579         } catch (ReadOnlyException t) {
580           // expected
581
}
582       }
583     }
584   }
585
586   public static void visitL1DSOConfig(ConfigVisitor visitor, DSOClientConfigHelper config) {
587     String JavaDoc testClass = ReflectionFieldTestApp.class.getName();
588     config.getOrCreateSpec(testClass);
589
590     config.getOrCreateSpec(SubMap.class.getName());
591
592     String JavaDoc writeAllowedMethodExpression = "* " + testClass + "*.*(..)";
593     config.addWriteAutolock(writeAllowedMethodExpression);
594     String JavaDoc readOnlyMethodExpression = "* " + testClass + "*.*ReadOnly*(..)";
595     config.addReadAutolock(readOnlyMethodExpression);
596
597     config.addRoot(testClass, "reflectionRoot", "reflectionRoot", true);
598     config.addRoot(testClass, "literalRoot", "literalRoot", true);
599     config.addRoot(testClass, "primitiveRoot", "primitiveRoot", true);
600     config.addIncludePattern(DataRoot.class.getName());
601
602     config.addRoot(NonInstrumented.class.getName(), "nonInstrumentedRoot", "nonInstrumentedRoot", false);
603     config.addRoot(NonInstrumented.class.getName(), "nonInstrumentedStaticRoot", "nonInstrumentedStaticRoot", false);
604   }
605
606   protected void silenceCompilerWarnings() {
607     if (false && literalRoot != literalRoot && primitiveRoot != primitiveRoot) {
608       // silence eclipse warnings about not directly reading the root fields
609
throw new AssertionError JavaDoc("Don't call this method");
610     }
611   }
612
613   private static class NonInstrumented extends NonInstrumentedTestObject {
614     private static DataRoot nonInstrumentedStaticRoot;
615
616     private DataRoot nonInstrumentedRoot;
617
618     public NonInstrumented() {
619       super();
620     }
621
622     public static DataRoot getNonInstrumentedStaticRoot() {
623       return nonInstrumentedStaticRoot;
624     }
625
626     public static void setNonInstrumentedStaticRoot(DataRoot nonInstrumentedStaticRoot) {
627       NonInstrumented.nonInstrumentedStaticRoot = nonInstrumentedStaticRoot;
628     }
629
630     public DataRoot getNonInstrumentedRoot() {
631       return nonInstrumentedRoot;
632     }
633
634     public void setNonInstrumentedRoot(DataRoot nonInstrumentedRoot) {
635       this.nonInstrumentedRoot = nonInstrumentedRoot;
636     }
637   }
638
639   private static class SubMap extends HashMap JavaDoc {
640     private int i = 3;
641
642     public SubMap() {
643       put("key", "value");
644       if (i == 5) { // silence compiler warning
645
throw new RuntimeException JavaDoc();
646       }
647     }
648   }
649
650   private static class DataRoot {
651     private static Long JavaDoc staticLong;
652
653     private ArrayList JavaDoc list = new ArrayList JavaDoc();
654     private Color JavaDoc color = new Color JavaDoc(100, true);
655     private long longValue = Long.MIN_VALUE;
656     private int intValue = Integer.MIN_VALUE;
657     private short shortValue = Short.MIN_VALUE;
658     private boolean booleanValue = false;
659     private byte byteValue = Byte.MIN_VALUE;
660     private char charValue = Character.MIN_VALUE;
661     private double doubleValue = Double.MIN_VALUE;
662     private float floatValue = Float.MIN_VALUE;
663
664     private final Map JavaDoc map = new HashMap JavaDoc();
665     {
666       map.put("key", "value");
667     }
668
669     private final Map JavaDoc subMap = new SubMap();
670
671     public DataRoot(long longValue) {
672       this.longValue = longValue;
673     }
674
675     public DataRoot() {
676       //
677
}
678
679     public Map JavaDoc getSubMap() {
680       return subMap;
681     }
682
683     public Map JavaDoc getMap() {
684       return map;
685     }
686
687     public static Long JavaDoc getStaticLong() {
688       return staticLong;
689     }
690
691     public static void setStaticLong(Long JavaDoc staticLong) {
692       DataRoot.staticLong = staticLong;
693     }
694
695     protected ArrayList JavaDoc getList() {
696       return list;
697     }
698
699     protected void setList(ArrayList JavaDoc list) {
700       this.list = list;
701     }
702
703     protected Color JavaDoc getColor() {
704       return color;
705     }
706
707     protected void setColor(Color JavaDoc color) {
708       this.color = color;
709     }
710
711     protected long getLongValue() {
712       return longValue;
713     }
714
715     protected void setLongValue(long longValue) {
716       this.longValue = longValue;
717     }
718
719     protected int getIntValue() {
720       return intValue;
721     }
722
723     protected void setIntValue(int intValue) {
724       this.intValue = intValue;
725     }
726
727     protected boolean isBooleanValue() {
728       return booleanValue;
729     }
730
731     protected void setBooleanValue(boolean booleanValue) {
732       this.booleanValue = booleanValue;
733     }
734
735     protected byte getByteValue() {
736       return byteValue;
737     }
738
739     protected void setByteValue(byte byteValue) {
740       this.byteValue = byteValue;
741     }
742
743     protected char getCharValue() {
744       return charValue;
745     }
746
747     protected void setCharValue(char charValue) {
748       this.charValue = charValue;
749     }
750
751     protected double getDoubleValue() {
752       return doubleValue;
753     }
754
755     protected void setDoubleValue(double doubleValue) {
756       this.doubleValue = doubleValue;
757     }
758
759     protected float getFloatValue() {
760       return floatValue;
761     }
762
763     protected void setFloatValue(float floatValue) {
764       this.floatValue = floatValue;
765     }
766
767     protected short getShortValue() {
768       return shortValue;
769     }
770
771     protected void setShortValue(short shortValue) {
772       this.shortValue = shortValue;
773     }
774   }
775 }
776
Popular Tags