langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java
changeset 5216 b7f7018fa96a
parent 4076 319c19c1f28d
child 5520 86e4b9a9da40
equal deleted inserted replaced
5215:e8022d132fc8 5216:b7f7018fa96a
   223 
   223 
   224         AccessFlags flags = f.access_flags;
   224         AccessFlags flags = f.access_flags;
   225         writeModifiers(flags.getFieldModifiers());
   225         writeModifiers(flags.getFieldModifiers());
   226         Signature_attribute sigAttr = getSignature(f.attributes);
   226         Signature_attribute sigAttr = getSignature(f.attributes);
   227         if (sigAttr == null)
   227         if (sigAttr == null)
   228             print(getFieldType(f.descriptor));
   228             print(getJavaFieldType(f.descriptor));
   229         else {
   229         else {
   230             try {
   230             try {
   231                 Type t = sigAttr.getParsedSignature().getType(constant_pool);
   231                 Type t = sigAttr.getParsedSignature().getType(constant_pool);
   232                 print(t);
   232                 print(getJavaName(t.toString()));
   233             } catch (ConstantPoolException e) {
   233             } catch (ConstantPoolException e) {
   234                 // report error?
   234                 // report error?
   235                 // fall back on non-generic descriptor
   235                 // fall back on non-generic descriptor
   236                 print(getFieldType(f.descriptor));
   236                 print(getJavaFieldType(f.descriptor));
   237             }
   237             }
   238         }
   238         }
   239         print(" ");
   239         print(" ");
   240         print(getFieldName(f));
   240         print(getFieldName(f));
   241         if (options.showConstants && !options.compat) { // BUG 4111861 print static final field contents
   241         if (options.showConstants && !options.compat) { // BUG 4111861 print static final field contents
   312         if (methodType != null) {
   312         if (methodType != null) {
   313             writeListIfNotEmpty("<", methodType.typeParamTypes, "> ");
   313             writeListIfNotEmpty("<", methodType.typeParamTypes, "> ");
   314         }
   314         }
   315         if (getName(m).equals("<init>")) {
   315         if (getName(m).equals("<init>")) {
   316             print(getJavaName(classFile));
   316             print(getJavaName(classFile));
   317             print(getParameterTypes(d, flags));
   317             print(getJavaParameterTypes(d, flags));
   318         } else if (getName(m).equals("<clinit>")) {
   318         } else if (getName(m).equals("<clinit>")) {
   319             print("{}");
   319             print("{}");
   320         } else {
   320         } else {
   321             print(getReturnType(d));
   321             print(getJavaReturnType(d));
   322             print(" ");
   322             print(" ");
   323             print(getName(m));
   323             print(getName(m));
   324             print(getParameterTypes(d, flags));
   324             print(getJavaParameterTypes(d, flags));
   325         }
   325         }
   326 
   326 
   327         Attribute e_attr = m.attributes.get(Attribute.Exceptions);
   327         Attribute e_attr = m.attributes.get(Attribute.Exceptions);
   328         if (e_attr != null) { // if there are generic exceptions, there must be erased exceptions
   328         if (e_attr != null) { // if there are generic exceptions, there must be erased exceptions
   329             if (e_attr instanceof Exceptions_attribute) {
   329             if (e_attr instanceof Exceptions_attribute) {
   458         } catch (ConstantPoolException e) {
   458         } catch (ConstantPoolException e) {
   459             return report(e);
   459             return report(e);
   460         }
   460         }
   461     }
   461     }
   462 
   462 
   463     String getFieldType(Descriptor d) {
   463     String getJavaFieldType(Descriptor d) {
   464         try {
   464         try {
   465             return d.getFieldType(constant_pool);
   465             return getJavaName(d.getFieldType(constant_pool));
   466         } catch (ConstantPoolException e) {
   466         } catch (ConstantPoolException e) {
   467             return report(e);
   467             return report(e);
   468         } catch (DescriptorException e) {
   468         } catch (DescriptorException e) {
   469             return report(e);
   469             return report(e);
   470         }
   470         }
   471     }
   471     }
   472 
   472 
   473     String getReturnType(Descriptor d) {
   473     String getJavaReturnType(Descriptor d) {
   474         try {
   474         try {
   475             return d.getReturnType(constant_pool);
   475             return getJavaName(d.getReturnType(constant_pool));
   476         } catch (ConstantPoolException e) {
   476         } catch (ConstantPoolException e) {
   477             return report(e);
   477             return report(e);
   478         } catch (DescriptorException e) {
   478         } catch (DescriptorException e) {
   479             return report(e);
   479             return report(e);
   480         }
   480         }
   481     }
   481     }
   482 
   482 
   483     String getParameterTypes(Descriptor d, AccessFlags flags) {
   483     String getJavaParameterTypes(Descriptor d, AccessFlags flags) {
   484         try {
   484         try {
   485             return adjustVarargs(flags, d.getParameterTypes(constant_pool));
   485             return getJavaName(adjustVarargs(flags, d.getParameterTypes(constant_pool)));
   486         } catch (ConstantPoolException e) {
   486         } catch (ConstantPoolException e) {
   487             return report(e);
   487             return report(e);
   488         } catch (DescriptorException e) {
   488         } catch (DescriptorException e) {
   489             return report(e);
   489             return report(e);
   490         }
   490         }