< prev index next >

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

Print this page

        

*** 647,656 **** --- 647,657 ---- } private void writeParamAnnotations(List<VarSymbol> params, RetentionPolicy retention) { + databuf.appendByte(params.length()); for (VarSymbol s : params) { ListBuffer<Attribute.Compound> buf = new ListBuffer<>(); for (Attribute.Compound a : s.getRawAttributes()) if (types.getRetention(a) == retention) buf.append(a);
*** 659,682 **** writeCompoundAttribute(a); } } - private void writeParamAnnotations(MethodSymbol m, - RetentionPolicy retention) { - databuf.appendByte(m.params.length()); - writeParamAnnotations(m.params, retention); - } - /** Write method parameter annotations; * return number of attributes written. */ ! int writeParameterAttrs(MethodSymbol m) { boolean hasVisible = false; boolean hasInvisible = false; ! if (m.params != null) { ! for (VarSymbol s : m.params) { for (Attribute.Compound a : s.getRawAttributes()) { switch (types.getRetention(a)) { case SOURCE: break; case CLASS: hasInvisible = true; break; case RUNTIME: hasVisible = true; break; --- 660,677 ---- writeCompoundAttribute(a); } } /** Write method parameter annotations; * return number of attributes written. */ ! int writeParameterAttrs(List<VarSymbol> vars) { boolean hasVisible = false; boolean hasInvisible = false; ! if (vars != null) { ! for (VarSymbol s : vars) { for (Attribute.Compound a : s.getRawAttributes()) { switch (types.getRetention(a)) { case SOURCE: break; case CLASS: hasInvisible = true; break; case RUNTIME: hasVisible = true; break;
*** 687,703 **** } int attrCount = 0; if (hasVisible) { int attrIndex = writeAttr(names.RuntimeVisibleParameterAnnotations); ! writeParamAnnotations(m, RetentionPolicy.RUNTIME); endAttr(attrIndex); attrCount++; } if (hasInvisible) { int attrIndex = writeAttr(names.RuntimeInvisibleParameterAnnotations); ! writeParamAnnotations(m, RetentionPolicy.CLASS); endAttr(attrIndex); attrCount++; } return attrCount; } --- 682,698 ---- } int attrCount = 0; if (hasVisible) { int attrIndex = writeAttr(names.RuntimeVisibleParameterAnnotations); ! writeParamAnnotations(vars, RetentionPolicy.RUNTIME); endAttr(attrIndex); attrCount++; } if (hasInvisible) { int attrIndex = writeAttr(names.RuntimeInvisibleParameterAnnotations); ! writeParamAnnotations(vars, RetentionPolicy.CLASS); endAttr(attrIndex); attrCount++; } return attrCount; }
*** 1105,1114 **** --- 1100,1137 ---- databuf.appendChar(flags); } endAttr(alenIdx); } + int writeRecordAttribute(ClassSymbol csym) { + int alenIdx = writeAttr(names.Record); + Scope s = csym.members(); + List<VarSymbol> vars = List.nil(); + int numParams = 0; + for (Symbol sym : s.getSymbols(NON_RECURSIVE)) { + if (sym.kind == VAR && sym.isRecord()) { + vars = vars.prepend((VarSymbol)sym); + numParams++; + } + } + databuf.appendChar(numParams); + for (VarSymbol v: vars) { + databuf.appendChar(pool.put(v.name)); + databuf.appendChar(adjustFlags(v.flags())); + // descriptor + databuf.appendChar(pool.put(typeSig(v.erasure(types)))); + // signature + databuf.appendChar(pool.put(typeSig(v.type))); + } + int acountIdx = beginAttrs(); + int acount = 0; + acount += writeParameterAttrs(vars); + endAttrs(acountIdx, acount); + endAttr(alenIdx); + return 1; + } + /** * Write NestMembers attribute (if needed) */ int writeNestMembersIfNeeded(ClassSymbol csym) { ListBuffer<Symbol> nested = new ListBuffer<>();
*** 1241,1251 **** if (!m.isLambdaMethod()) // Per JDK-8138729, do not emit parameters table for lambda bodies. acount += writeMethodParametersAttr(m); } acount += writeMemberAttrs(m); if (!m.isLambdaMethod()) ! acount += writeParameterAttrs(m); endAttrs(acountIdx, acount); } /** Write code attribute of method. */ --- 1264,1274 ---- if (!m.isLambdaMethod()) // Per JDK-8138729, do not emit parameters table for lambda bodies. acount += writeMethodParametersAttr(m); } acount += writeMemberAttrs(m); if (!m.isLambdaMethod()) ! acount += writeParameterAttrs(m.params); endAttrs(acountIdx, acount); } /** Write code attribute of method. */
*** 1891,1900 **** --- 1914,1927 ---- acount += writeNestMembersIfNeeded(c); acount += writeNestHostIfNeeded(c); } } + if (c.isRecord()) { + acount += writeRecordAttribute(c); + } + writePool(c.pool); if (innerClasses != null) { writeInnerClasses(); acount++;
< prev index next >