@@ -236,14 +236,32 @@ public JVar varParam(Class<?> type, String name) {
236236 * method signature.
237237 */
238238 public JVar varParam (JType type , String name ) {
239- if (!hasVarArgs ()) {
239+ return varParam (JMod .NONE , type , name );
240+ }
240241
241- varParam =
242- new JVar (
243- JMods .forVar (JMod .NONE ),
244- type .array (),
245- name ,
246- null );
242+ /**
243+ * Add the specified variable argument to the list of parameters
244+ * for this method signature.
245+ *
246+ * @param mods
247+ * The modifiers for the variable.
248+ *
249+ * @param type
250+ * Type of the parameter being added.
251+ *
252+ * @param name
253+ * Name of the parameter being added
254+ *
255+ * @return the variable parameter
256+ *
257+ * @throws IllegalStateException
258+ * If this method is called twice.
259+ * varargs in J2SE 1.5 can appear only once in the
260+ * method signature.
261+ */
262+ public JVar varParam (int mods , JType type , String name ) {
263+ if (!hasVarArgs ()) {
264+ varParam = new JVar (JMods .forVar (mods ), type .array (), name , null );
247265 return varParam ;
248266 } else {
249267 throw new IllegalStateException (
@@ -425,23 +443,30 @@ public void declare(JFormatter f) {
425443 // declare the generics parameters
426444 super .declare (f );
427445
428- if (!isConstructor ())
446+ if (!isConstructor ()) {
429447 f .g (type );
448+ }
430449 f .id (name ).p ('(' ).i ();
450+
431451 // when parameters are printed in new lines, we want them to be indented.
432452 // there's a good chance no newlines happen, too, but just in case it does.
433453 boolean first = true ;
434454 for (JVar var : params ) {
435- if (!first )
455+ if (!first ) {
436456 f .p (',' );
437- if (var .isAnnotated ())
457+ }
458+ if (var .isAnnotated ()) {
438459 f .nl ();
460+ }
439461 f .b (var );
440462 first = false ;
441463 }
442464 if (hasVarArgs ()) {
443- if (!first )
465+ if (!first ) {
444466 f .p (',' );
467+ }
468+
469+ f .g (varParam .mods ());
445470 f .g (varParam .type ().elementType ());
446471 f .p ("... " );
447472 f .id (varParam .name ());
0 commit comments