UMC.GCThe "UMC Unwanted method calls" group of errors relates to some methods, such as System.exit() and System.gc() that might be unwanted. Debug print, such as System.out.println() and System.err.println(), might be unwanted as well. A UMC.GC warning appears if there is a call to the System.gc() method. Vulnerability and riskThis method should only be used in performance-related testing procedure; otherwise the impact might be opposite of that expected. Example 110 String multiply(String x, int n) { 11 if (n <= 0) return ""; 12 StringBuffer buf = new StringBuffer(); 13 while (n-- > 0) { 14 buf.append(x); 15 } 16 return buf.toString(); 17 } 18 String multiplyGc(String x, int n) { 19 System.gc(); // see perfromance resutlts if run this test 20 return multiply(x, n); 21 } UMC.GC is reported for line 19: The System.gc() method call is unwanted |