< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/PoolWriter.java

Print this page
*** 31,10 ***
--- 31,11 ---
  import com.sun.tools.javac.code.Symbol.DynamicMethodSymbol;
  import com.sun.tools.javac.code.Symbol.MethodHandleSymbol;
  import com.sun.tools.javac.code.Symbol.ModuleSymbol;
  import com.sun.tools.javac.code.Symbol.PackageSymbol;
  import com.sun.tools.javac.code.Type;
+ import com.sun.tools.javac.code.Type.ConstantPoolQType;
  import com.sun.tools.javac.code.Types;
  import com.sun.tools.javac.jvm.ClassWriter.PoolOverflow;
  import com.sun.tools.javac.jvm.ClassWriter.StringOverflow;
  import com.sun.tools.javac.jvm.PoolConstant.LoadableConstant;
  import com.sun.tools.javac.jvm.PoolConstant.LoadableConstant.BasicConstant;

*** 113,13 ***
--- 114,27 ---
      /**
       * Puts a type into the pool and return its index. The type could be either a class, a type variable
       * or an array type.
       */
      int putClass(Type t) {
+         /* Their is nothing to be gained by having the pair of class types Foo.ref and Foo.val
+            result in two different CONSTANT_Class_info strucures in the pool. These are
+            indistinguishable at the class file level. Hence we coalesce them here.
+         */
+         if (t.tsym.isPrimitiveClass())
+             t = t.asValueType();
          return pool.writeIfNeeded(types.erasure(t));
      }
  
+     /**
+      * Puts a type into the pool and return its index. The type could be either a class, a type variable
+      * or an array type.
+      */
+     int putClass(ConstantPoolQType t) {
+         return pool.writeIfNeeded(t);
+     }
+ 
      /**
       * Puts a member reference into the constant pool. Valid members are either field or method symbols.
       */
      int putMember(Symbol s) {
          return pool.writeIfNeeded(s);

*** 360,14 ***
  
          void writeConstant(PoolConstant c) {
              int tag = c.poolTag();
              switch (tag) {
                  case ClassFile.CONSTANT_Class: {
!                     Type ct = (Type)c;
                      Name name = ct.hasTag(ARRAY) ?
                              typeSig(ct) :
!                             names.fromUtf(externalize(ct.tsym.flatName()));
                      poolbuf.appendByte(tag);
                      poolbuf.appendChar(putName(name));
                      if (ct.hasTag(CLASS)) {
                          enterInner((ClassSymbol)ct.tsym);
                      }
--- 375,14 ---
  
          void writeConstant(PoolConstant c) {
              int tag = c.poolTag();
              switch (tag) {
                  case ClassFile.CONSTANT_Class: {
!                     Type ct = c instanceof ConstantPoolQType ? ((ConstantPoolQType)c).type : (Type)c;
                      Name name = ct.hasTag(ARRAY) ?
                              typeSig(ct) :
!                             c instanceof ConstantPoolQType ? names.fromString("Q" + new String(externalize(ct.tsym.flatName())) + ";") : names.fromUtf(externalize(ct.tsym.flatName()));
                      poolbuf.appendByte(tag);
                      poolbuf.appendChar(putName(name));
                      if (ct.hasTag(CLASS)) {
                          enterInner((ClassSymbol)ct.tsym);
                      }

*** 500,10 ***
--- 515,11 ---
              signatureGen.assembleParamsSig(typarams);
          }
          signatureGen.assembleSig(types.supertype(t));
          for (Type i : types.interfaces(t))
              signatureGen.assembleSig(i);
+ 
          return signatureGen.toName();
      }
  
      void reset() {
          innerClasses.clear();
< prev index next >