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

changeset 781
e3df8d7a9752
parent 747
1dd813a529cf
child 798
4868a36f6fd8
     1.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Thu Dec 09 15:50:34 2010 +0000
     1.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Thu Dec 09 15:50:57 2010 +0000
     1.3 @@ -1168,7 +1168,7 @@
     1.4                  VarSymbol sym = var.sym;
     1.5                  databuf.appendChar(pool.put(sym.name));
     1.6                  Type vartype = sym.erasure(types);
     1.7 -                if (!types.isSameType(sym.type, vartype))
     1.8 +                if (needsLocalVariableTypeEntry(sym.type))
     1.9                      nGenericVars++;
    1.10                  databuf.appendChar(pool.put(typeSig(vartype)));
    1.11                  databuf.appendChar(var.reg);
    1.12 @@ -1185,7 +1185,7 @@
    1.13              for (int i=0; i<code.varBufferSize; i++) {
    1.14                  Code.LocalVar var = code.varBuffer[i];
    1.15                  VarSymbol sym = var.sym;
    1.16 -                if (types.isSameType(sym.type, sym.erasure(types)))
    1.17 +                if (!needsLocalVariableTypeEntry(sym.type))
    1.18                      continue;
    1.19                  count++;
    1.20                  // write variable info
    1.21 @@ -1209,6 +1209,14 @@
    1.22          }
    1.23          endAttrs(acountIdx, acount);
    1.24      }
    1.25 +    //where
    1.26 +    private boolean needsLocalVariableTypeEntry(Type t) {
    1.27 +        //a local variable needs a type-entry if its type T is generic
    1.28 +        //(i.e. |T| != T) and if it's not an intersection type (not supported
    1.29 +        //in signature attribute grammar)
    1.30 +        return (!types.isSameType(t, types.erasure(t)) &&
    1.31 +                !t.isCompound());
    1.32 +    }
    1.33  
    1.34      void writeStackMap(Code code) {
    1.35          int nframes = code.stackMapBufferSize;

mercurial