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