src/share/classes/com/sun/tools/javac/jvm/ClassReader.java

changeset 795
7b99f98b3035
parent 784
4dd1c0176d81
child 798
4868a36f6fd8
child 804
3131e664558d
     1.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Mon Dec 13 14:08:01 2010 -0800
     1.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Mon Dec 13 15:11:00 2010 -0800
     1.3 @@ -105,10 +105,15 @@
     1.4       */
     1.5      boolean allowAnnotations;
     1.6  
     1.7 -    /** Lint option: warn about classfile issues
     1.8 +    /** Switch: allow simplified varargs.
     1.9 +     */
    1.10 +    boolean allowSimplifiedVarargs;
    1.11 +
    1.12 +   /** Lint option: warn about classfile issues
    1.13       */
    1.14      boolean lintClassfile;
    1.15  
    1.16 +
    1.17      /** Switch: preserve parameter names from the variable table.
    1.18       */
    1.19      public boolean saveParameterNames;
    1.20 @@ -279,6 +284,7 @@
    1.21          allowGenerics    = source.allowGenerics();
    1.22          allowVarargs     = source.allowVarargs();
    1.23          allowAnnotations = source.allowAnnotations();
    1.24 +        allowSimplifiedVarargs = source.allowSimplifiedVarargs();
    1.25          saveParameterNames = options.isSet("save-parameter-names");
    1.26          cacheCompletionFailure = options.isUnset("dev");
    1.27          preferSource = "source".equals(options.get("-Xprefer"));
    1.28 @@ -1883,7 +1889,7 @@
    1.29              // instance, however, there is no reliable way to tell so
    1.30              // we never strip this$n
    1.31              if (!currentOwner.name.isEmpty())
    1.32 -                type = new MethodType(type.getParameterTypes().tail,
    1.33 +                type = new MethodType(adjustMethodParams(flags, type.getParameterTypes()),
    1.34                                        type.getReturnType(),
    1.35                                        type.getThrownTypes(),
    1.36                                        syms.methodClass);
    1.37 @@ -1903,6 +1909,21 @@
    1.38          return m;
    1.39      }
    1.40  
    1.41 +    private List<Type> adjustMethodParams(long flags, List<Type> args) {
    1.42 +        boolean isVarargs = (flags & VARARGS) != 0;
    1.43 +        if (isVarargs) {
    1.44 +            Type varargsElem = args.last();
    1.45 +            ListBuffer<Type> adjustedArgs = ListBuffer.lb();
    1.46 +            for (Type t : args) {
    1.47 +                adjustedArgs.append(t != varargsElem ?
    1.48 +                    t :
    1.49 +                    ((ArrayType)t).makeVarargs());
    1.50 +            }
    1.51 +            args = adjustedArgs.toList();
    1.52 +        }
    1.53 +        return args.tail;
    1.54 +    }
    1.55 +
    1.56      /**
    1.57       * Init the parameter names array.
    1.58       * Parameter names are currently inferred from the names in the

mercurial