@@ -85,49 +85,55 @@ public void visitMethod(Method obj) {
8585 return ;
8686 }
8787
88- if (Values .CONSTRUCTOR .equals (getMethodName ()) && javaClass .getClassName ().contains ("$" )) {
89- return ;
90- }
91-
92- List <String > types = SignatureUtils .getParameterSignatures (obj .getSignature ());
93- if ((types .isEmpty ()) || (types .size () > 2 )) {
94- return ;
95- }
88+ boolean isVarMethod = (obj .getAccessFlags () & Constants .ACC_VARARGS ) != 0 ;
9689
97- if ((obj .getAccessFlags () & Constants .ACC_VARARGS ) != 0 ) {
98- return ;
99- }
90+ boolean isConvertable = !isVarMethod && methodHasConvertableLastParam (obj );
10091
101- String lastParmSig = types .get (types .size () - 1 );
102- if (!lastParmSig .startsWith (Values .SIG_ARRAY_PREFIX )
103- || lastParmSig .startsWith (Values .SIG_ARRAY_OF_ARRAYS_PREFIX )) {
104- return ;
92+ super .visitMethod (obj );
93+
94+ if (isConvertable ) {
95+ bugReporter .reportBug (new BugInstance (this , BugType .UVA_USE_VAR_ARGS .name (), LOW_PRIORITY ).addClass (this )
96+ .addMethod (this ));
10597 }
10698
107- if (SignatureBuilder .SIG_BYTE_ARRAY .equals (lastParmSig )
108- || SignatureBuilder .SIG_CHAR_ARRAY .equals (lastParmSig )) {
109- return ;
110- }
99+ } catch (ClassNotFoundException cnfe ) {
100+ bugReporter .reportMissingClass (cnfe );
101+ }
102+ }
103+
104+ public boolean methodHasConvertableLastParam (Method method ) throws ClassNotFoundException {
105+ if (Values .CONSTRUCTOR .equals (getMethodName ()) && javaClass .getClassName ().contains ("$" )) {
106+ return false ;
107+ }
108+ List <String > types = SignatureUtils .getParameterSignatures (method .getSignature ());
109+ if ((types .isEmpty ()) || (types .size () > 2 )) {
110+ return false ;
111+ }
111112
112- if (hasSimilarParms (types )) {
113- return ;
114- }
113+ String lastParmSig = types .get (types .size () - 1 );
114+ if (!lastParmSig .startsWith (Values .SIG_ARRAY_PREFIX )
115+ || lastParmSig .startsWith (Values .SIG_ARRAY_OF_ARRAYS_PREFIX )) {
116+ return false ;
117+ }
115118
116- if (obj .isStatic () && "main" .equals (obj .getName ()) && SIG_STRING_ARRAY_TO_VOID .equals (obj .getSignature ())) {
117- return ;
118- }
119+ if (SignatureBuilder .SIG_BYTE_ARRAY .equals (lastParmSig )
120+ || SignatureBuilder .SIG_CHAR_ARRAY .equals (lastParmSig )) {
121+ return false ;
122+ }
119123
120- if (! obj . isPrivate () && ! obj . isStatic () && isInherited ( obj )) {
121- return ;
122- }
124+ if (hasSimilarParms ( types )) {
125+ return false ;
126+ }
123127
124- super . visitMethod ( obj );
125- bugReporter . reportBug ( new BugInstance ( this , BugType . UVA_USE_VAR_ARGS . name (), LOW_PRIORITY ). addClass ( this )
126- . addMethod ( this ));
128+ if ( method . isStatic () && "main" . equals ( method . getName ()) && SIG_STRING_ARRAY_TO_VOID . equals ( method . getSignature ())) {
129+ return false ;
130+ }
127131
128- } catch ( ClassNotFoundException cnfe ) {
129- bugReporter . reportMissingClass ( cnfe ) ;
132+ if (! method . isPrivate () && ! method . isStatic () && isInherited ( method ) ) {
133+ return false ;
130134 }
135+
136+ return true ;
131137 }
132138
133139 /**
0 commit comments