[PATCH] 8036827: Incorrect printing of the generic method declaration
Jonathan Gibbons
jonathan.gibbons at oracle.com
Thu Jan 26 21:24:03 UTC 2017
Bernard,
I don't think this should be changed, and I will close out the JBS issue.
Without the -verbose flag, the "extends java.lang.Object" is not printed.
$ ./build/linux-x86_64-normal-server-release/images/jdk/bin/javap
play/src/JDK_8036827.class
Compiled from "JDK_8036827.java"
class JDK_8036827 {
JDK_8036827();
public <T> T m1(T);
}
When the -verbose flag is used, it does not seem unreasonable to print
out information which is explicitly present in the class file.
-- Jon
On 01/26/2017 02:39 AM, B. Blaser wrote:
> Hi,
>
> 2017-01-25 21:23 GMT+01:00 B. Blaser <bsrbnd at gmail.com>:
>> Next is a suggestion to remove javap's redundant printing of "extends
>> java.lang.Object" in the following example (according to JDK 8036827
>> description):
>>
>> class JDK_8036827 {
>> public <T> T m1(T a) {
>> return null;
>> }
>> }
>>
> I've also updated the existing related tests, below.
>
> Bernard
>
> diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/javap/ClassWriter.java
> b/src/jdk.jdeps/share/classes/com/sun/tools/javap/ClassWriter.java
> --- a/src/jdk.jdeps/share/classes/com/sun/tools/javap/ClassWriter.java
> +++ b/src/jdk.jdeps/share/classes/com/sun/tools/javap/ClassWriter.java
> @@ -344,8 +344,7 @@
> public StringBuilder visitTypeParamType(TypeParamType
> type, StringBuilder sb) {
> sb.append(type.name);
> String sep = " extends ";
> - if (type.classBound != null
> - && (options.verbose || !type.classBound.isObject())) {
> + if (type.classBound != null && !type.classBound.isObject()) {
> sb.append(sep);
> append(sb, type.classBound);
> sep = " & ";
> diff --git a/test/tools/javap/4870651/T4870651.java
> b/test/tools/javap/4870651/T4870651.java
> --- a/test/tools/javap/4870651/T4870651.java
> +++ b/test/tools/javap/4870651/T4870651.java
> @@ -40,7 +40,7 @@
>
> public void run() throws IOException {
> verify("Test",
> - "class Test<T extends java.lang.Object, " +
> + "class Test<T, " +
> "E extends java.lang.Exception &
> java.lang.Comparable<T>, " +
> "U extends java.lang.Comparable>",
> "v1(java.lang.String...)");
> diff --git a/test/tools/javap/BoundsTypeVariableTest.java
> b/test/tools/javap/BoundsTypeVariableTest.java
> --- a/test/tools/javap/BoundsTypeVariableTest.java
> +++ b/test/tools/javap/BoundsTypeVariableTest.java
> @@ -49,7 +49,7 @@
> srcDir.mkdirs();
> File classesDir = new File("classes");
> classesDir.mkdirs();
> - final String expect = "public abstract <U extends
> java.lang.Object> U doit();";
> + final String expect = "public abstract <U> U doit();";
> List<String> contents = new ArrayList<>();
> contents.add("abstract class X {");
> contents.add(expect);
More information about the compiler-dev
mailing list