1.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Fri Dec 14 11:16:46 2012 +0000 1.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Sat Dec 15 13:54:51 2012 +0000 1.3 @@ -39,7 +39,12 @@ 1.4 import com.sun.tools.javac.code.Attribute.RetentionPolicy; 1.5 import com.sun.tools.javac.code.Symbol.*; 1.6 import com.sun.tools.javac.code.Type.*; 1.7 +import com.sun.tools.javac.code.Types.UniqueType; 1.8 import com.sun.tools.javac.file.BaseFileObject; 1.9 +import com.sun.tools.javac.jvm.Pool.DynamicMethod; 1.10 +import com.sun.tools.javac.jvm.Pool.Method; 1.11 +import com.sun.tools.javac.jvm.Pool.MethodHandle; 1.12 +import com.sun.tools.javac.jvm.Pool.Variable; 1.13 import com.sun.tools.javac.util.*; 1.14 1.15 import static com.sun.tools.javac.code.BoundKind.*; 1.16 @@ -142,7 +147,7 @@ 1.17 /** The bootstrap methods to be written in the corresponding class attribute 1.18 * (one for each invokedynamic) 1.19 */ 1.20 - Map<MethodSymbol, Pool.MethodHandle> bootstrapMethods; 1.21 + Map<DynamicMethod, MethodHandle> bootstrapMethods; 1.22 1.23 /** The log to use for verbose output. 1.24 */ 1.25 @@ -477,10 +482,10 @@ 1.26 while (i < pool.pp) { 1.27 Object value = pool.pool[i]; 1.28 Assert.checkNonNull(value); 1.29 - if (value instanceof Pool.Method) 1.30 - value = ((Pool.Method)value).m; 1.31 - else if (value instanceof Pool.Variable) 1.32 - value = ((Pool.Variable)value).v; 1.33 + if (value instanceof Method) 1.34 + value = ((Method)value).m; 1.35 + else if (value instanceof Variable) 1.36 + value = ((Variable)value).v; 1.37 1.38 if (value instanceof MethodSymbol) { 1.39 MethodSymbol m = (MethodSymbol)value; 1.40 @@ -493,8 +498,9 @@ 1.41 } else { 1.42 //invokedynamic 1.43 DynamicMethodSymbol dynSym = (DynamicMethodSymbol)m; 1.44 - Pool.MethodHandle handle = new Pool.MethodHandle(dynSym.bsmKind, dynSym.bsm); 1.45 - bootstrapMethods.put(dynSym, handle); 1.46 + MethodHandle handle = new MethodHandle(dynSym.bsmKind, dynSym.bsm, types); 1.47 + DynamicMethod dynMeth = new DynamicMethod(dynSym, types); 1.48 + bootstrapMethods.put(dynMeth, handle); 1.49 //init cp entries 1.50 pool.put(names.BootstrapMethods); 1.51 pool.put(handle); 1.52 @@ -531,7 +537,7 @@ 1.53 NameAndType nt = (NameAndType)value; 1.54 poolbuf.appendByte(CONSTANT_NameandType); 1.55 poolbuf.appendChar(pool.put(nt.name)); 1.56 - poolbuf.appendChar(pool.put(typeSig(nt.type))); 1.57 + poolbuf.appendChar(pool.put(typeSig(nt.uniqueType.type))); 1.58 } else if (value instanceof Integer) { 1.59 poolbuf.appendByte(CONSTANT_Integer); 1.60 poolbuf.appendInt(((Integer)value).intValue()); 1.61 @@ -549,17 +555,18 @@ 1.62 } else if (value instanceof String) { 1.63 poolbuf.appendByte(CONSTANT_String); 1.64 poolbuf.appendChar(pool.put(names.fromString((String)value))); 1.65 - } else if (value instanceof MethodType) { 1.66 - MethodType mtype = (MethodType)value; 1.67 - poolbuf.appendByte(CONSTANT_MethodType); 1.68 - poolbuf.appendChar(pool.put(typeSig(mtype))); 1.69 - } else if (value instanceof Type) { 1.70 - Type type = (Type)value; 1.71 - if (type.hasTag(CLASS)) enterInner((ClassSymbol)type.tsym); 1.72 - poolbuf.appendByte(CONSTANT_Class); 1.73 - poolbuf.appendChar(pool.put(xClassName(type))); 1.74 - } else if (value instanceof Pool.MethodHandle) { 1.75 - Pool.MethodHandle ref = (Pool.MethodHandle)value; 1.76 + } else if (value instanceof UniqueType) { 1.77 + Type type = ((UniqueType)value).type; 1.78 + if (type instanceof MethodType) { 1.79 + poolbuf.appendByte(CONSTANT_MethodType); 1.80 + poolbuf.appendChar(pool.put(typeSig((MethodType)type))); 1.81 + } else { 1.82 + if (type.hasTag(CLASS)) enterInner((ClassSymbol)type.tsym); 1.83 + poolbuf.appendByte(CONSTANT_Class); 1.84 + poolbuf.appendChar(pool.put(xClassName(type))); 1.85 + } 1.86 + } else if (value instanceof MethodHandle) { 1.87 + MethodHandle ref = (MethodHandle)value; 1.88 poolbuf.appendByte(CONSTANT_MethodHandle); 1.89 poolbuf.appendByte(ref.refKind); 1.90 poolbuf.appendChar(pool.put(ref.refSym)); 1.91 @@ -589,7 +596,7 @@ 1.92 return new NameAndType(fieldName(sym), 1.93 retrofit 1.94 ? sym.erasure(types) 1.95 - : sym.externalType(types)); 1.96 + : sym.externalType(types), types); 1.97 // if we retrofit, then the NameAndType has been read in as is 1.98 // and no change is necessary. If we compile normally, the 1.99 // NameAndType is generated from a symbol reference, and the 1.100 @@ -951,14 +958,16 @@ 1.101 void writeBootstrapMethods() { 1.102 int alenIdx = writeAttr(names.BootstrapMethods); 1.103 databuf.appendChar(bootstrapMethods.size()); 1.104 - for (Map.Entry<MethodSymbol, Pool.MethodHandle> entry : bootstrapMethods.entrySet()) { 1.105 - DynamicMethodSymbol dsym = (DynamicMethodSymbol)entry.getKey(); 1.106 + for (Map.Entry<DynamicMethod, MethodHandle> entry : bootstrapMethods.entrySet()) { 1.107 + DynamicMethod dmeth = entry.getKey(); 1.108 + DynamicMethodSymbol dsym = (DynamicMethodSymbol)dmeth.baseSymbol(); 1.109 //write BSM handle 1.110 databuf.appendChar(pool.get(entry.getValue())); 1.111 //write static args length 1.112 databuf.appendChar(dsym.staticArgs.length); 1.113 //write static args array 1.114 - for (Object o : dsym.staticArgs) { 1.115 + Object[] uniqueArgs = dmeth.uniqueStaticArgs; 1.116 + for (Object o : uniqueArgs) { 1.117 databuf.appendChar(pool.get(o)); 1.118 } 1.119 } 1.120 @@ -1534,7 +1543,7 @@ 1.121 pool = c.pool; 1.122 innerClasses = null; 1.123 innerClassesQueue = null; 1.124 - bootstrapMethods = new LinkedHashMap<MethodSymbol, Pool.MethodHandle>(); 1.125 + bootstrapMethods = new LinkedHashMap<DynamicMethod, MethodHandle>(); 1.126 1.127 Type supertype = types.supertype(c.type); 1.128 List<Type> interfaces = types.interfaces(c.type);