View Javadoc
1   package com.google.checkstyle.test.chapter6programpractice.rule64finalizers;
2   
3   /** Some javadoc. */
4   public class InputNoFinalizer {
5   
6     /** Some javadoc. */
7     public void finalize() { // violation 'Avoid using finalizer method.'
8       // It's not enough to check if the METHOD_DEF branch contains a PARAMETER_DEF, as that would
9       // treat this method as having a parameter.
10      Runnable runnable =
11          new Runnable() {
12  
13            public void run() {
14              reallyFinalize("hi");
15            }
16  
17            // generates a PARAMETER_DEF AST inside the METHOD_DEF of finalize()
18            private void reallyFinalize(String s) {}
19          };
20      runnable.run();
21    }
22  
23    /** should not be reported by NoFinalizer check. */
24    public void finalize(String x) {}
25  }