javap use internal class name when printing bound of type variable
Jonathan Gibbons
jonathan.gibbons at oracle.com
Fri Nov 16 07:55:06 PST 2012
Rémi,
Thank you. I have filed JDK-8003537 for this. I'll post a webrev for
review in due course.
-- Jon
On 11/16/2012 06:13 AM, Remi Forax wrote:
> Hi guys,
> I've noticed a small bug in javap, the declared type variables prints
> their bounds with '/' instead of '.'
>
> By example:
> public abstract <U extends java/lang/Object> U
> fold(java.util.functions.Factory<U>, java.util.functions.Combiner<U,
> T, U>, java.util.functions.BinaryOperator<U>);
>
> Here is the patch to use the type printer instead of toString() when
> printing
> the declaration of the type variable.
> It creates one JavaTypePrinter by methods because I haven't wanted to
> change the code too much,
> but maybe the same JavaTypePrinter should be used for all methods.
>
> cheers,
> Rémi
>
> diff -r bdcef2ef52d2
> src/share/classes/com/sun/tools/javap/ClassWriter.java
> --- a/src/share/classes/com/sun/tools/javap/ClassWriter.java Thu Nov
> 15 23:07:24 2012 -0800
> +++ b/src/share/classes/com/sun/tools/javap/ClassWriter.java Fri Nov
> 16 15:08:37 2012 +0100
> @@ -329,7 +329,7 @@
> sb.append(suffix);
> }
>
> - private void appendIfNotEmpty(StringBuilder sb, String
> prefix, List<? extends Type> list, String suffix) {
> + void appendIfNotEmpty(StringBuilder sb, String prefix,
> List<? extends Type> list, String suffix) {
> if (!isEmpty(list))
> append(sb, prefix, list, suffix);
> }
> @@ -438,7 +438,10 @@
>
> writeModifiers(flags.getMethodModifiers());
> if (methodType != null) {
> - writeListIfNotEmpty("<", methodType.typeParamTypes, "> ");
> + JavaTypePrinter printer = new JavaTypePrinter(false);
> + StringBuilder builder = new StringBuilder();
> + printer.appendIfNotEmpty(builder, "<",
> methodType.typeParamTypes, "> ");
> + print(builder);
> }
> if (getName(m).equals("<init>")) {
> print(getJavaName(classFile));
>
More information about the compiler-dev
mailing list