langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
changeset 32334 fd65e32e16b3
parent 29050 76df9080086c
child 32336 9e9acf7f26a4
equal deleted inserted replaced
32256:3966bd3b8167 32334:fd65e32e16b3
   136     ListBuffer<ClassSymbol> innerClassesQueue;
   136     ListBuffer<ClassSymbol> innerClassesQueue;
   137 
   137 
   138     /** The bootstrap methods to be written in the corresponding class attribute
   138     /** The bootstrap methods to be written in the corresponding class attribute
   139      *  (one for each invokedynamic)
   139      *  (one for each invokedynamic)
   140      */
   140      */
   141     Map<DynamicMethod, MethodHandle> bootstrapMethods;
   141     Map<DynamicMethod.BootstrapMethodsKey, MethodHandle> bootstrapMethods;
   142 
   142 
   143     /** The log to use for verbose output.
   143     /** The log to use for verbose output.
   144      */
   144      */
   145     private final Log log;
   145     private final Log log;
   146 
   146 
   399                     poolbuf.appendChar(pool.put(nameType(m)));
   399                     poolbuf.appendChar(pool.put(nameType(m)));
   400                 } else {
   400                 } else {
   401                     //invokedynamic
   401                     //invokedynamic
   402                     DynamicMethodSymbol dynSym = (DynamicMethodSymbol)m;
   402                     DynamicMethodSymbol dynSym = (DynamicMethodSymbol)m;
   403                     MethodHandle handle = new MethodHandle(dynSym.bsmKind, dynSym.bsm, types);
   403                     MethodHandle handle = new MethodHandle(dynSym.bsmKind, dynSym.bsm, types);
   404                     DynamicMethod dynMeth = new DynamicMethod(dynSym, types);
   404                     DynamicMethod.BootstrapMethodsKey key = new DynamicMethod.BootstrapMethodsKey(dynSym, types);
   405                     bootstrapMethods.put(dynMeth, handle);
   405                     bootstrapMethods.put(key, handle);
   406                     //init cp entries
   406                     //init cp entries
   407                     pool.put(names.BootstrapMethods);
   407                     pool.put(names.BootstrapMethods);
   408                     pool.put(handle);
   408                     pool.put(handle);
   409                     for (Object staticArg : dynSym.staticArgs) {
   409                     for (Object staticArg : dynSym.staticArgs) {
   410                         pool.put(staticArg);
   410                         pool.put(staticArg);
  1022     /** Write "bootstrapMethods" attribute.
  1022     /** Write "bootstrapMethods" attribute.
  1023      */
  1023      */
  1024     void writeBootstrapMethods() {
  1024     void writeBootstrapMethods() {
  1025         int alenIdx = writeAttr(names.BootstrapMethods);
  1025         int alenIdx = writeAttr(names.BootstrapMethods);
  1026         databuf.appendChar(bootstrapMethods.size());
  1026         databuf.appendChar(bootstrapMethods.size());
  1027         for (Map.Entry<DynamicMethod, MethodHandle> entry : bootstrapMethods.entrySet()) {
  1027         for (Map.Entry<DynamicMethod.BootstrapMethodsKey, MethodHandle> entry : bootstrapMethods.entrySet()) {
  1028             DynamicMethod dmeth = entry.getKey();
  1028             DynamicMethod.BootstrapMethodsKey bsmKey = entry.getKey();
  1029             DynamicMethodSymbol dsym = (DynamicMethodSymbol)dmeth.baseSymbol();
       
  1030             //write BSM handle
  1029             //write BSM handle
  1031             databuf.appendChar(pool.get(entry.getValue()));
  1030             databuf.appendChar(pool.get(entry.getValue()));
       
  1031             Object[] uniqueArgs = bsmKey.getUniqueArgs();
  1032             //write static args length
  1032             //write static args length
  1033             databuf.appendChar(dsym.staticArgs.length);
  1033             databuf.appendChar(uniqueArgs.length);
  1034             //write static args array
  1034             //write static args array
  1035             Object[] uniqueArgs = dmeth.uniqueStaticArgs;
       
  1036             for (Object o : uniqueArgs) {
  1035             for (Object o : uniqueArgs) {
  1037                 databuf.appendChar(pool.get(o));
  1036                 databuf.appendChar(pool.get(o));
  1038             }
  1037             }
  1039         }
  1038         }
  1040         endAttr(alenIdx);
  1039         endAttr(alenIdx);