View Javadoc
1   package com.puppycrawl.tools.checkstyle.checks.coding.noclone;
2   public class InputNoClone
3   {/* class body */
4       public InputNoClone() throws CloneNotSupportedException
5       { //constructor body
6           super.equals(new String());
7           super.clone();
8       }
9       
10      public Object clone() throws CloneNotSupportedException
11      {
12          return super.clone();
13      }
14      
15      public void method() throws CloneNotSupportedException
16      {
17          super.clone();
18      }
19      
20      {
21          super.clone();
22      }
23  }
24  
25  class NoSuperClone
26  {
27      public Object clone()
28      {
29          return null;
30      }
31  }
32  
33  class InnerClone
34  {
35      public Object clone()
36      {
37          class Inner
38          {
39              public Object clone() throws CloneNotSupportedException
40              {
41                  return super.clone();
42              }
43          }
44          return null;
45      }
46  }
47  
48  // This could not pass as valid semantically but tests that
49  // type arguments are ignored when checking super calls
50  class CloneWithTypeArguments<T> extends CloneWithTypeArgumentsAndNoSuper<T>
51  {
52      public CloneWithTypeArguments<T> clone() throws CloneNotSupportedException
53      {
54          return (CloneWithTypeArguments<T>) super.<T>clone();
55      }
56  }
57  
58  class CloneWithTypeArgumentsAndNoSuper<T>
59  {
60      public CloneWithTypeArgumentsAndNoSuper<T> clone() throws CloneNotSupportedException
61      {
62          return null;
63      }
64  }
65  
66  //Check that super keword isn't snagged here
67  class MyClassWithGenericSuperMethod
68  {
69      void someMethod(java.util.List<? super java.util.Map<Object, Object>> l)
70      {
71  
72      }
73      
74      /**
75       * Not a valid clone override. Should not get flagged.
76       * @param o some object
77       * @return a cloned Object?
78       */
79      public static Object clone(Object o) {
80  	return null;
81      }
82  }
83  
84  class AnotherClass {
85      
86      /**
87       * Not a valid clone override. Should not get flagged.
88       * @param t some type
89       * @param <T> a type
90       * @return a cloned type?
91       */
92      public <T> T clone(T t) {
93  	return null;
94      }
95  }
96  
97  class NativeTest {
98      public native Object clone();
99  }